xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Jan Beulich <jbeulich@suse.com>
Cc: George Dunlap <george.dunlap@citrix.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Volodymyr Babchuk <volodymyr_babchuk@epam.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 11/11] Arm/optee: don't open-code xzalloc_flex_struct()
Date: Thu, 15 Apr 2021 11:26:11 +0100	[thread overview]
Message-ID: <7945a56e-337d-3c84-ecfd-2be759adda4a@xen.org> (raw)
In-Reply-To: <1c9229ac-5491-313e-f053-bc5bee01c3de@suse.com>

Hi Jan,

On 14/04/2021 08:03, Jan Beulich wrote:
> On 13.04.2021 20:19, Julien Grall wrote:
>> On 08/04/2021 13:23, Jan Beulich wrote:
>>> There is a difference in generated code: xzalloc_bytes() forces
>>> SMP_CACHE_BYTES alignment. I think we not only don't need this here, but
>>> actually don't want it.
>>
>> So I think moving to xmalloc_flex_struct() is a pretty good move. But I
>> am actually a bit confused with the argument used.
>>
>> Could you provide some details why you think forcing the array to be
>> aligned to the maximum cache line supported (128 bytes on Arm) is wrong?
> 
> It is not "wrong" in that sense, but if this is intended it shouldn't
> be arranged via use of xmalloc_bytes().

This is not very clear from the commit message (or even the cover 
letter). How about:

"
The current use xzalloc_bytes() in optee is nearly an open-coded version 
of xzalloc_flex_struct() which was introduced after the driver was merged.

The main difference is xzalloc_bytes() will also force the allocation to 
be SMP_CACHE_BYTES aligned and therefore avoid sharing the cache line.

While sharing the cache line can have an impact on the performance, this 
is also true for most of the other users of  x*alloc_flex_struct(). So 
if we want to prevent sharing a cache line, it should be part of 
x*alloc_flex_struct().

In this case, we don't need stricter alignment than what the allocator 
does. So the call to xzalloc_bytes() is now replaced with a call 
xzalloc_flex_Struct().
"

Ideally, we want the same sort of the commit message in the other patches.

> As also pointed out in a
> similar discussion on another sub-thread, imo xmalloc_bytes(), being
> type-unsafe, should go away altogether mid-term.

And I will support dropping xmalloc_bytes().

> If individual callers
> have specific alignment requirements (which ought to be the exception),
> they should explicitly request the needed alignment. If architectures
> would prefer all allocations to have certain minimum alignment (e.g.
> to avoid cacheline sharing, which was Andrew's argument) or other
> "arrangement" (alignment by itself may not be that interesting due to
> the bhdr placed ahead of the allocation), it should be the allocator
> itself that provides for this, not individual callers.

And I agree that the allocator should do the alignment if this benefits 
every allocation.

Cheers,

-- 
Julien Grall


  reply	other threads:[~2021-04-15 10:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08 12:13 [PATCH 00/11] assorted replacement of x[mz]alloc_bytes() Jan Beulich
2021-04-08 12:16 ` [PATCH 01/11] x86/HVM: avoid effectively open-coding xzalloc_flex_struct() Jan Beulich
2021-04-08 12:20   ` Andrew Cooper
2021-04-08 12:17 ` [PATCH 02/11] x86/vPMU: " Jan Beulich
2021-04-08 12:25   ` Andrew Cooper
2021-04-08 12:29     ` Jan Beulich
2021-04-08 12:17 ` [PATCH 03/11] x86/MCE: avoid effectively open-coding xmalloc_array() Jan Beulich
2021-04-08 12:18 ` [PATCH 04/11] x86/HVM: " Jan Beulich
2021-04-08 12:19 ` [PATCH 05/11] x86/oprofile: " Jan Beulich
2021-04-08 12:20 ` [PATCH 06/11] x86/IRQ: avoid over-alignment in alloc_pirq_struct() Jan Beulich
2021-04-08 12:20 ` [PATCH 07/11] EFI/runtime: avoid effectively open-coding xmalloc_array() Jan Beulich
2021-04-08 12:21 ` [PATCH 08/11] hypfs: avoid effectively open-coding xzalloc_array() Jan Beulich
2021-04-08 14:28   ` Juergen Gross
2021-04-08 12:21 ` [PATCH 09/11] kexec: avoid effectively open-coding xzalloc_flex_struct() Jan Beulich
2021-04-09 12:54   ` Andrew Cooper
2021-04-09 13:23     ` Jan Beulich
2021-04-08 12:22 ` [PATCH 10/11] video/lfb: avoid effectively open-coding xzalloc_array() Jan Beulich
2021-04-08 12:23 ` [PATCH 11/11] Arm/optee: don't open-code xzalloc_flex_struct() Jan Beulich
2021-04-13 18:19   ` Julien Grall
2021-04-14  7:03     ` Jan Beulich
2021-04-15 10:26       ` Julien Grall [this message]
2021-04-15 11:02         ` Jan Beulich
2021-04-15 11:31           ` Julien Grall
2021-04-08 12:57 ` [PATCH 00/11] assorted replacement of x[mz]alloc_bytes() Andrew Cooper
2021-04-08 14:12   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7945a56e-337d-3c84-ecfd-2be759adda4a@xen.org \
    --to=julien@xen.org \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=sstabellini@kernel.org \
    --cc=volodymyr_babchuk@epam.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).