[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6f4017dc-2b3d-4b1a-b819-423acb42d999@suse.com>
Date: Tue, 4 Mar 2025 19:47:34 +1030
From: Qu Wenruo <wqu@...e.com>
To: Yunsheng Lin <linyunsheng@...wei.com>, Yishai Hadas <yishaih@...dia.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Shameer Kolothum <shameerali.kolothum.thodi@...wei.com>,
Kevin Tian <kevin.tian@...el.com>,
Alex Williamson <alex.williamson@...hat.com>, Chris Mason <clm@...com>,
Josef Bacik <josef@...icpanda.com>, David Sterba <dsterba@...e.com>,
Gao Xiang <xiang@...nel.org>, Chao Yu <chao@...nel.org>,
Yue Hu <zbestahu@...il.com>, Jeffle Xu <jefflexu@...ux.alibaba.com>,
Sandeep Dhavale <dhavale@...gle.com>, Carlos Maiolino <cem@...nel.org>,
"Darrick J. Wong" <djwong@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Jesper Dangaard Brouer <hawk@...nel.org>,
Ilias Apalodimas <ilias.apalodimas@...aro.org>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>, Trond Myklebust <trondmy@...nel.org>,
Anna Schumaker <anna@...nel.org>, Chuck Lever <chuck.lever@...cle.com>,
Jeff Layton <jlayton@...nel.org>, Neil Brown <neilb@...e.de>,
Olga Kornievskaia <okorniev@...hat.com>, Dai Ngo <Dai.Ngo@...cle.com>,
Tom Talpey <tom@...pey.com>
Cc: Luiz Capitulino <luizcap@...hat.com>,
Mel Gorman <mgorman@...hsingularity.net>, Dave Chinner
<david@...morbit.com>, kvm@...r.kernel.org, virtualization@...ts.linux.dev,
linux-kernel@...r.kernel.org, linux-btrfs@...r.kernel.org,
linux-erofs@...ts.ozlabs.org, linux-xfs@...r.kernel.org, linux-mm@...ck.org,
netdev@...r.kernel.org, linux-nfs@...r.kernel.org
Subject: Re: [PATCH v2] mm: alloc_pages_bulk: remove assumption of populating
only NULL elements
在 2025/2/28 20:14, Yunsheng Lin 写道:
> As mentioned in [1], it seems odd to check NULL elements in
> the middle of page bulk allocating, and it seems caller can
> do a better job of bulk allocating pages into a whole array
> sequentially without checking NULL elements first before
> doing the page bulk allocation for most of existing users.
>
> Through analyzing of bulk allocation API used in fs, it
> seems that the callers are depending on the assumption of
> populating only NULL elements in fs/btrfs/extent_io.c and
> net/sunrpc/svc_xprt.c while erofs and btrfs don't, see:
> commit 91d6ac1d62c3 ("btrfs: allocate page arrays using bulk page allocator")
If you want to change the btrfs part, please run full fstests with
SCRATCH_DEV_POOL populated at least.
[...]
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index f0a1da40d641..ef52cedd9873 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -623,13 +623,26 @@ int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array,
> bool nofail)
> {
> const gfp_t gfp = nofail ? (GFP_NOFS | __GFP_NOFAIL) : GFP_NOFS;
> - unsigned int allocated;
> + unsigned int allocated, ret;
>
> - for (allocated = 0; allocated < nr_pages;) {
> - unsigned int last = allocated;
> + /* Defragment page_array so pages can be bulk allocated into remaining
> + * NULL elements sequentially.
> + */
> + for (allocated = 0, ret = 0; ret < nr_pages; ret++) {
> + if (page_array[ret]) {
You just prove how bad the design is.
All the callers have their page array members to initialized to NULL, or
do not care and just want alloc_pages_bulk() to overwrite the
uninitialized values.
The best example here is btrfs_encoded_read_regular().
Now your code will just crash encoded read.
Read the context before doing stupid things.
I find it unacceptable that you just change the code, without any
testing, nor even just check all the involved callers.
> + page_array[allocated] = page_array[ret];
> + if (ret != allocated)
> + page_array[ret] = NULL;
> +
> + allocated++;
> + }
> + }
>
> - allocated = alloc_pages_bulk(gfp, nr_pages, page_array);
> - if (unlikely(allocated == last)) {
> + while (allocated < nr_pages) {
> + ret = alloc_pages_bulk(gfp, nr_pages - allocated,
> + page_array + allocated);
I see the new interface way worse than the existing one.
All btrfs usage only wants a simple retry-until-all-fulfilled behavior.
NACK for btrfs part, and I find you very unresponsible not even bother
running any testsuit and just submit such a mess.
Just stop this, no one will ever take you serious anymore.
Thanks,
Qu
Powered by blists - more mailing lists