From: Uladzislau Rezki <urezki@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Uladzislau Rezki <urezki@gmail.com>,
Manfred Spraul <manfred@colorfullife.com>,
LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Vasily Averin <vvs@virtuozzo.com>,
cgel.zte@gmail.com, shakeelb@google.com, rdunlap@infradead.org,
dbueso@suse.de, unixbhaskar@gmail.com, chi.minghao@zte.com.cn,
arnd@arndb.de, Zeal Robot <zealci@zte.com.cn>,
linux-mm@kvack.org, 1vier1@web.de, stable@vger.kernel.org
Subject: Re: [PATCH] mm/util.c: Make kvfree() safe for calling while holding spinlocks
Date: Sun, 26 Dec 2021 18:57:16 +0100 [thread overview]
Message-ID: <Ycis/J1U2DB6Zx7j@pc638.lan> (raw)
In-Reply-To: <YceiFXyoGcgPaLeJ@casper.infradead.org>
On Sat, Dec 25, 2021 at 10:58:29PM +0000, Matthew Wilcox wrote:
> On Sat, Dec 25, 2021 at 07:54:12PM +0100, Uladzislau Rezki wrote:
> > +static void drain_vmap_area(struct work_struct *work)
> > +{
> > + if (mutex_trylock(&vmap_purge_lock)) {
> > + __purge_vmap_area_lazy(ULONG_MAX, 0);
> > + mutex_unlock(&vmap_purge_lock);
> > + }
> > +}
> > +
> > +static DECLARE_WORK(drain_vmap_area_work, drain_vmap_area);
>
> Presuambly if the worker fails to get the mutex, it should reschedule
> itself? And should it even trylock or just always lock?
>
mutex_trylock() has no sense here. It should just always get the lock.
Otherwise we can miss the point to purge. Agree with your opinion.
>
> This kind of ties into something I've been wondering about -- we have
> a number of places in the kernel which cache 'freed' vmalloc allocations
> in order to speed up future allocations of the same size. Kind of like
> slab. Would we be better off trying to cache frequent allocations
> inside vmalloc instead of always purging them?
>
Hm... Some sort of caching would be good. Though it will require some
time to think over all details and design itself. We can cache VAs
instead of purging them until some point or threshold. So basically
we can keep it in our data structures, associate it with some cache,
based on size and reuse it later in the alloc_vmap_area().
All that is related to "vmap_area" caching. Another option is to cache
the "vm_struct". It includes "vmap_area" + pages to drive the mapping.
It is a higher level of caching and i am not sure if an implementation
would be so straightforward.
--
Vlad Rezki
next prev parent reply other threads:[~2021-12-26 17:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-22 19:48 Manfred Spraul
2021-12-23 3:40 ` Davidlohr Bueso
2021-12-23 7:21 ` Vasily Averin
2021-12-23 11:52 ` Manfred Spraul
2021-12-23 12:34 ` Vasily Averin
2021-12-25 18:54 ` Uladzislau Rezki
2021-12-25 22:58 ` Matthew Wilcox
2021-12-26 17:57 ` Uladzislau Rezki [this message]
2021-12-28 19:45 ` Uladzislau Rezki
2021-12-28 20:04 ` Manfred Spraul
2021-12-28 20:26 ` Uladzislau Rezki
2022-01-27 2:53 ` Andrew Morton
2022-01-27 5:59 ` Manfred Spraul
2022-01-27 8:25 ` Michal Hocko
2022-01-27 15:54 ` Uladzislau Rezki
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=Ycis/J1U2DB6Zx7j@pc638.lan \
--to=urezki@gmail.com \
--cc=1vier1@web.de \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=cgel.zte@gmail.com \
--cc=chi.minghao@zte.com.cn \
--cc=dbueso@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=manfred@colorfullife.com \
--cc=rdunlap@infradead.org \
--cc=shakeelb@google.com \
--cc=stable@vger.kernel.org \
--cc=unixbhaskar@gmail.com \
--cc=vvs@virtuozzo.com \
--cc=willy@infradead.org \
--cc=zealci@zte.com.cn \
/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