From: Charan Teja Kalla <quic_charante@quicinc.com>
To: Matthew Wilcox <willy@infradead.org>, Vlastimil Babka <vbabka@suse.cz>
Cc: <Liam.Howlett@oracle.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: Purpose of maple_node objects to be its size aligned
Date: Tue, 23 Jan 2024 20:10:07 +0530 [thread overview]
Message-ID: <81b61c42-3c2b-bce3-d667-b45478d5fccd@quicinc.com> (raw)
In-Reply-To: <Za--f_sJ8cbgqn80@casper.infradead.org>
Thanks Matthew!!
On 1/23/2024 6:56 PM, Matthew Wilcox wrote:
>> I am just curious about the purpose of maple node slab objects to be its
>> size aligned, but I can understand why they need to be cache aligned.
> Because we encode various information in the bottom few bits of the
> maple node pointer.
>
> /*
> * The Maple Tree squeezes various bits in at various points which aren't
> * necessarily obvious. Usually, this is done by observing that pointers are
> * N-byte aligned and thus the bottom log_2(N) bits are available for use. We
> * don't use the high bits of pointers to store additional information because
> * we don't know what bits are unused on any given architecture.
> *
> * Nodes are 256 bytes in size and are also aligned to 256 bytes, giving us 8
> * low bits for our own purposes. Nodes are currently of 4 types:
> * 1. Single pointer (Range is 0-0)
> * 2. Non-leaf Allocation Range nodes
> * 3. Non-leaf Range nodes
> * 4. Leaf Range nodes All nodes consist of a number of node slots,
> * pivots, and a parent pointer.
> */
>
I got it. Looks like I need to revisit the maple tree documentation
before asking such questions.
> That seems like a very badly implemented patch. Rather than make all
> objects left & right redzone, we should simply insert a redzone at
> the beginning of the slab. ie
>
> 0 redzone
> 256 node
> 512 redzone
> 768 node
> 1024 redzone
> 1280 node
> [...]
> 3072 redzone
> 3382 node
> 3584 redzone
> 3840 wasted space
>
This seems to work when only redzone is enabled?
I think it will again 768b aligned if any other debug option enabled,
say U. It is:
(size aligned red zone + maple node + right red zone (size of (void*))
+ alloc/free track).
My understanding to have both left and right red zone is:
/*
* Add some empty padding so that __we can catch
* overwrites from earlier objects rather than let
* tracking information or the free pointer be
* corrupted if a user writes before the start
* of the object__.
*/
When all the debug options enabled, the slab object will roughly look
like below:
Left red zone | object | right red zone | free pointer | alloc/free
track | padding
> Instead of getting only five nodes per 4kB page, we'd get seven; about
> a 30% reduction in memory usage.
>
> Slab redzoning is not a feature people turn on often, so I'm not
> surprised nobody's noticed before now.
+Vlastimil. The patch in discussion is d86bd1bece6f ("mm/slub: support
left redzone").
Thanks,
Charan
prev parent reply other threads:[~2024-01-23 14:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 11:03 Charan Teja Kalla
2024-01-23 13:26 ` Matthew Wilcox
2024-01-23 14:40 ` Charan Teja Kalla [this message]
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=81b61c42-3c2b-bce3-d667-b45478d5fccd@quicinc.com \
--to=quic_charante@quicinc.com \
--cc=Liam.Howlett@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vbabka@suse.cz \
--cc=willy@infradead.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
all inboxes | Powered by JetHome®