From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
Seth Jennings <sjenning@redhat.com>,
Dan Streetman <ddstreet@ieee.org>,
Vitaly Wool <vitaly.wool@konsulko.com>,
Nhat Pham <nphamcs@gmail.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Minchan Kim <minchan@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] zswap: do not allocate from atomic pool
Date: Tue, 22 Nov 2022 11:43:32 +0900 [thread overview]
Message-ID: <Y3w3VKm6CBzucSWg@google.com> (raw)
In-Reply-To: <20221121175619.f38259bac177de86bd9eb558@linux-foundation.org>
On (22/11/21 17:56), Andrew Morton wrote:
> > zswap_frontswap_load() should be called from preemptible
> > context (we even call mutex_lock() there) and it does not
> > look like we need to do GFP_ATOMIC allocaion for temp
> > buffer there. Use GFP_KERNEL instead.
> >
> > ...
> >
> > --- a/mm/zswap.c
> > +++ b/mm/zswap.c
> > @@ -1314,7 +1314,7 @@ static int zswap_frontswap_load(unsigned type, pgoff_t offset,
> > }
> >
> > if (!zpool_can_sleep_mapped(entry->pool->zpool)) {
> > - tmp = kmalloc(entry->length, GFP_ATOMIC);
> > + tmp = kmalloc(entry->length, GFP_KERNEL);
> > if (!tmp) {
> > ret = -ENOMEM;
> > goto freeentry;
>
> It seems strange to do
It does indeed.
> if (! can sleep)
> do something which can sleep
Some allocators enter the non-preemptible context in ->map callback and
exit that context in ->unmap. zswap uses async compression and needs to
wait for crypto to finish decompression of the mapped object, which it
cannot do when allocator disables preemption in ->map. So for allocators
that do this zswap allocates a temp buffer, then maps the object, copies
it to that temp buffer and unmaps the objects. So now it can wait for
async crypto because we are in preemptible context and we use the temp
copy of the object.
> or am I misreading the intent of zpool_driver.sleep_mapped? If so,
> perhaps some explanatory code comments will help.
I can add one. I assume at mm/zpool.c zpool_can_sleep_mapped() would be
the right place.
next prev parent reply other threads:[~2022-11-22 2:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 1:33 Sergey Senozhatsky
2022-11-22 1:56 ` Andrew Morton
2022-11-22 2:43 ` Sergey Senozhatsky [this message]
2022-11-22 3:16 ` Johannes Weiner
2022-11-22 3:30 ` Sergey Senozhatsky
2022-11-24 3:32 ` Sergey Senozhatsky
2022-11-24 3:42 ` Andrew Morton
2022-11-24 3:55 ` Nhat Pham
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=Y3w3VKm6CBzucSWg@google.com \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=ddstreet@ieee.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=nphamcs@gmail.com \
--cc=sjenning@redhat.com \
--cc=vitaly.wool@konsulko.com \
/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