From: Ananda Badmaev <a.badmaev@clicknet.pro>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-mm@kvack.org, vitaly.wool@konsulko.com, vbabka@suse.cz,
akpm@linux-foundation.org
Subject: Re: [PATCH v3] mm: add ztree - new allocator for use via zpool API
Date: Tue, 08 Mar 2022 20:10:45 +0300 [thread overview]
Message-ID: <fc7b85bc5d7e4115f3f3887845ba718cdbdea5a5.camel@clicknet.pro> (raw)
In-Reply-To: <Yid48GpeeNhsYqxI@casper.infradead.org>
В Вт, 08/03/2022 в 15:40 +0000, Matthew Wilcox пишет:
> On Tue, Mar 08, 2022 at 06:16:35PM +0300, Ananda Badmaev wrote:
> > > Hm. So 368 bytes on 64-bit, but 372 bytes on 32-bit? Is that
> > > intentional? Why 11?
> > >
> > Yes, 'slot_size' and 'slots_per_block' values are chosen so that in
> > general the range from 0 to PAGE_SIZE is split more or less evenly
> > and
> > the size of the block is as close as possible to the power of 2.
> > Also
> > 'slot_size' values are aligned to the size of long.
>
> Is it intrinsic to the design that the blocks are aligned to
> sizeof(long)?
slot_size values must be aligned so that the slot addresses in blocks
are also algined to avoid potential problems with unalinged access. I
guess 4/8 byte alignment is enough for 32/64 bit systems respectively.
> > >
> > > You have some very strange indentation (throughout).
> > >
> > I was trying to limit the length of lines.
>
> But you didn't achieve that. The _start_ of the line containing
> block_type and gfp was _more indented_ than the end of the previous
> line. Do you have unusual tab settings?
>
Maybe it's because I have tab size 4 in my editor.
> > > thinking
> > > about it". What if you have two threads that execute this path
> > > concurrently? Looks to me like you leak the memory allocated by
> > > the
> > > first thread.
> > >
> > Probably I should pass GFP_ATOMIC flag to alloc_block() and execute
> > this entire section of code under single spinlock.
>
> I think that's a bad approach. Better would be:
>
> spin_lock();
> if (free_slot_block)
> goto found;
> spin_unlock();
> block = alloc_block();
> spin_lock();
> if (free_slot_block) {
> free_block(block);
> block = free_slot_block;
> } else {
> free_slot_block = block;
> }
> found:
> ...
> spin_unlock();
Yes, seems really better to do like this. Solution with GFP_ATOMIC
probably will improve the worst time of ztree_alloc(), which was not
big issue in the tests, but most likely general efficiency will be
degraded.
next prev parent reply other threads:[~2022-03-08 17:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 14:27 Ananda
2022-03-07 15:08 ` Matthew Wilcox
[not found] ` <719621646713798@mail.yandex.ru>
2022-03-08 13:13 ` Matthew Wilcox
2022-03-08 15:16 ` Ananda Badmaev
2022-03-08 15:40 ` Matthew Wilcox
2022-03-08 17:10 ` Ananda Badmaev [this message]
2022-03-10 10:27 ` Mike Rapoport
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=fc7b85bc5d7e4115f3f3887845ba718cdbdea5a5.camel@clicknet.pro \
--to=a.badmaev@clicknet.pro \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=vbabka@suse.cz \
--cc=vitaly.wool@konsulko.com \
--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