mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Christoph Hellwig <hch@lst.de>,
	"Vlastimil Babka (SUSE)" <vbabka@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	Brendan Jackman <jackmanb@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	linux-nfs@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: revisiting alloc_pages_bulks semantics?
Date: Wed, 27 May 2026 09:58:11 -0400	[thread overview]
Message-ID: <276835c4-78d4-411d-8097-93cdfb000648@oracle.com> (raw)
In-Reply-To: <20260527121920.GB6079@lst.de>

On 5/27/26 8:19 AM, Christoph Hellwig wrote:
> On Wed, May 27, 2026 at 12:06:08PM +0200, Vlastimil Babka (SUSE) wrote:
>>> alloc_pages_bulks can do partial allocations for some reasons, and
>>> users usually have a fallback by either looping and calling it again
>>> or falling back to single page allocations.  This sucks!  Why can't
>>> we get our usual try as hard as you can semantics, requiring
>>> GFP_NORETRY or similar to relax it?
>>
>> If we do that, do we keep the possibility of partial success, i.e. return
>> how many were allocated? Seems wasteful to suceed N-1 and then throw all
>> away, if the caller can use a fallback only for the last one.
>> Do some callers need all-or-nothing semantics? Should a flag indicate which
>> one to use?
> 
> A lot of callers (but not all) need all or nothing semantics.  But
> freeing already allocated pages is the not a major problem - the caller
> just has to add a release_pages call if it didn't already have one
> for cleaning up later failures.

What the svc/nfsd thread is trying to avoid is sleeping uninterruptibly
waiting for memory resources. That stalls server shutdown, among other
things.

Guaranteeing forward progress is the bottom line.


>>> There is one single user (svc_fill_pages in sunrpc) that relies on it.
>>> For everyone else it creates extra burden and is very error prone
>>> (speaking from experience).
>>
>> Sounds good to me. Will sunrpc be easy to convert, or should it be another
>> flag to opt-in to the current behavior, that it would use?
> 
> I've added Chuck to the Cc list, but from memory sunrpc actually does
> make use of this feature and he objected to previous attempts to
> change it.  So a first step would be to have a lower-level helper
> that works as-is and a wrapper that zeroes the array, even if that
> doesn't feel as efficient as it could be.
If sunrpc is the only user, it might be sensible to hoist the "zero
fill" capability into sunrpc.ko.

The impact of walking the whole array, for this check, is measurable,
and I've got a patch in 7.1 to mitigate that:

commit d7f3efd9ff474867b04e1ea784690f02450a245b
(refs/patches/nfsd-fixes/sunrpc-optimize-rq_respages-allocation-in-svc_alloc_arg)
Author:     Chuck Lever <chuck.lever@oracle.com>
AuthorDate: Thu Feb 26 09:47:39 2026 -0500
Commit:     Chuck Lever <chuck.lever@oracle.com>
CommitDate: Sun Mar 29 21:25:09 2026 -0400

    SUNRPC: Optimize rq_respages allocation in svc_alloc_arg

    svc_alloc_arg() invokes alloc_pages_bulk() with the full rq_maxpages
    count (~259 for 1MB messages) for the rq_respages array, causing a
    full-array scan despite most slots holding valid pages.

    svc_rqst_release_pages() NULLs only the range

      [rq_respages, rq_next_page)

    after each RPC, so only that range contains NULL entries. Limit the
    rq_respages fill in svc_alloc_arg() to that range instead of
    scanning the full array.

    svc_init_buffer() initializes rq_next_page to span the entire
    rq_respages array, so the first svc_alloc_arg() call fills all
    slots.

    Reviewed-by: Jeff Layton <jlayton@kernel.org>
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>


-- 
Chuck Lever

  parent reply	other threads:[~2026-05-27 13:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27  7:18 Christoph Hellwig
2026-05-27  7:53 ` Zi Yan
2026-05-27  8:00   ` Christoph Hellwig
2026-05-27  8:31     ` Zi Yan
2026-05-27 12:15       ` Christoph Hellwig
2026-05-27 10:06 ` Vlastimil Babka (SUSE)
2026-05-27 12:19   ` Christoph Hellwig
2026-05-27 13:23     ` Matthew Wilcox
2026-05-27 13:58     ` Chuck Lever [this message]
2026-05-28  9:00       ` Christoph Hellwig
2026-05-28 13:16         ` Chuck Lever

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=276835c4-78d4-411d-8097-93cdfb000648@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=hch@lst.de \
    --cc=jackmanb@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mhocko@suse.com \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.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

all inboxes | Powered by JetHome®