From: Hyeonggon Yoo <42.hyeyoo@gmail.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Matthew Wilcox <willy@infradead.org>,
Christoph Lameter <cl@linux.com>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Jens Axboe <axboe@kernel.dk>
Subject: Re: [RFC PATCH] Introducing lockless cache built on top of slab allocator
Date: Mon, 20 Sep 2021 11:55:36 +0000 [thread overview]
Message-ID: <20210920115536.GA3117@kvm.asia-northeast3-a.c.our-ratio-313919.internal> (raw)
In-Reply-To: <432da236-4d8c-1013-cd57-42c352281862@suse.cz>
On Mon, Sep 20, 2021 at 11:07:36AM +0200, Vlastimil Babka wrote:
> On 9/20/21 03:53, Matthew Wilcox wrote:
> > On Mon, Sep 20, 2021 at 01:09:38AM +0000, Hyeonggon Yoo wrote:
> >> Hello Matthew, Thanks to give me a comment! I appreciate it.
> >> Yeah, we can implement lockless cache using kmem_cache_alloc_{bulk, free}
> >> but kmem_cache_alloc_{free,bulk} is not enough.
> >>
> >> > I'd rather see this be part of the slab allocator than a separate API.
> >>
> >> And I disagree on this. for because most of situation, we cannot
> >> allocate without lock, it is special case for IO polling.
> >>
> >> To make it as part of slab allocator, we need to modify existing data
> >> structure. But making it part of slab allocator will be waste of memory
> >> because most of them are not using this.
> >
> > Oh, it would have to be an option. Maybe as a new slab_flags_t flag.
> > Or maybe a kmem_cache_alloc_percpu_lockless().
>
> I've recently found out that similar attempts (introduce queueing to SLUB)
> have been done around 2010. See e.g. [1] but there will be other threads to
> search at lore too. Haven't checked yet while it wasn't ultimately merged,
> I guess Christoph and David could remember (this was before my time).
There was attempt on SLUB with queueing as you said.
I searched a bit and found [2] and [3].
- SLUB with queueing (V2) beats SLAB netperf TCP_RR, 2010-07
[2] https://lore.kernel.org/lkml/alpine.DEB.2.00.1007121010420.14328@router.home/T/#m5a31c7caa28b93a00de3af6d547b79273449f5ba
- The Unified slab allocator (V4), 2010-10
[3] https://linux-mm.kvack.narkive.com/e595iCuz/unifiedv4-00-16-the-unified-slab-allocator-v4#post47
Looking at [3], There was still some regression comparing "SLUB with queueing"
with SLAB. And I couldn't find patch series after [3] yet. I'll add link
if I find.
> I guess making it opt-in only for caches where performance improvement was
> measured would make it easier to add, as for some caches it would mean no
> improvement, but increased memory usage. But of course it makes the API more
> harder to use.
Do you mean "lockless cache" it should be separate from slab because some caches
doesn't benefit at all?
> I'd be careful about the name "lockless", as that's ambiguous. Is it "mostly
> lockless" therefore fast, but if the cache is empty, it will still take
> locks as part of refill?
It is actually "mostly lockless" so it is ambiguous.
Can you suggest a name? like try_lockless or anything?
> Or is it lockless always, therefore useful in
> contexts that can take no locks, but then the caller has to have fallbacks
> in case the cache is empty and nothing is allocated?
>
> [1] https://lore.kernel.org/linux-mm/20100804024531.914852850@linux.com/T/#u
next prev parent reply other threads:[~2021-09-20 11:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-19 16:42 Hyeonggon Yoo
2021-09-19 19:17 ` Matthew Wilcox
2021-09-20 1:09 ` Hyeonggon Yoo
2021-09-20 1:53 ` Matthew Wilcox
2021-09-20 2:54 ` Hyeonggon Yoo
2021-09-20 9:07 ` Vlastimil Babka
2021-09-20 11:55 ` Hyeonggon Yoo [this message]
2021-09-20 12:02 ` Vlastimil Babka
2021-09-20 15:55 ` Hyeonggon Yoo
2021-09-20 14:41 ` John Garry
2021-09-20 15:50 ` Hyeonggon Yoo
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=20210920115536.GA3117@kvm.asia-northeast3-a.c.our-ratio-313919.internal \
--to=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--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