[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a72a4e3a-3af9-7a36-4583-6181f3579cfb@suse.cz>
Date: Tue, 11 Jan 2022 16:41:29 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Roman Gushchin <guro@...com>,
Muchun Song <songmuchun@...edance.com>
Cc: Matthew Wilcox <willy@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
Vladimir Davydov <vdavydov.dev@...il.com>,
Shakeel Butt <shakeelb@...gle.com>,
Yang Shi <shy828301@...il.com>, Alex Shi <alexs@...nel.org>,
Wei Yang <richard.weiyang@...il.com>,
Dave Chinner <david@...morbit.com>,
trond.myklebust@...merspace.com, anna.schumaker@...app.com,
jaegeuk@...nel.org, chao@...nel.org,
Kari Argillander <kari.argillander@...il.com>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Linux Memory Management List <linux-mm@...ck.org>,
linux-nfs@...r.kernel.org, Qi Zheng <zhengqi.arch@...edance.com>,
Xiongchun duan <duanxiongchun@...edance.com>,
Fam Zheng <fam.zheng@...edance.com>,
Muchun Song <smuchun@...il.com>,
Christoph Lameter <cl@...ux.com>,
Pekka Enberg <penberg@...nel.org>,
David Rientjes <rientjes@...gle.com>
Subject: Re: [PATCH v5 02/16] mm: introduce kmem_cache_alloc_lru
On 1/10/22 19:47, Roman Gushchin wrote:
> On Sun, Jan 09, 2022 at 02:21:22PM +0800, Muchun Song wrote:
>> On Fri, Jan 7, 2022 at 11:05 AM Roman Gushchin <guro@...com> wrote:
>> >
>> [...]
>> > > /*
>> > > * struct kmem_cache related prototypes
>> > > @@ -425,6 +426,8 @@ static __always_inline unsigned int __kmalloc_index(size_t size,
>> > >
>> > > void *__kmalloc(size_t size, gfp_t flags) __assume_kmalloc_alignment __alloc_size(1);
>> > > void *kmem_cache_alloc(struct kmem_cache *s, gfp_t flags) __assume_slab_alignment __malloc;
>> > > +void *kmem_cache_alloc_lru(struct kmem_cache *s, struct list_lru *lru,
>> > > + gfp_t gfpflags) __assume_slab_alignment __malloc;
>> >
>> > I'm not a big fan of this patch: I don't see why preparing the lru
>> > infrastructure has to be integrated that deep into the slab code.
>> >
>> > Why can't kmem_cache_alloc_lru() be a simple wrapper like (pseudo-code):
>> > void *kmem_cache_alloc_lru(struct kmem_cache *s, struct list_lru *lru,
>> > gfp_t gfpflags) {
>> > if (necessarily)
>> > prepare_lru_infra();
>> > return kmem_cache_alloc();
>> > }
>>
>> Hi Roman,
>>
>> Actually, it can. But there is going to be some redundant code similar
>> like memcg_slab_pre_alloc_hook() does to detect the necessity of
>> prepare_lru_infra() in the new scheme of kmem_cache_alloc_lru().
>> I just want to reduce the redundant overhead.
>
> Is this about getting a memcg pointer?
> I doubt it's a good reason to make changes all over the slab code.
> Another option to consider adding a new gfp flag.
I'm not sure how a flag would help as it seems we really need to pass a
specific list_lru pointer and work with that. I was thinking if there was
only one list_lru per class of object it could be part of struct kmem_cache,
but investigating kmem_cache_alloc_lru() callers I see lru parameters:
- &nfs4_xattr_cache_lru - this is fixed
- xas->xa_lru potentially not fixed, although the only caller of
xas_set_lru() passes &shadow_nodes so effectively fixed
- &sb->s_dentry_lru - dynamic, boo
> Vlastimil, what do you think?
Memcg code is already quite intertwined with slab code, for better or worse,
so I guess the extra lru parameter in a bunch of inline functions won't
change much. I don't immediately see a better solution.
> Thanks!
>
Powered by blists - more mailing lists