Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5055504rdb; Sat, 16 Sep 2023 00:37:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAl1LRhG1gskoad2uo3pk8SICgvIzssW2PRK315lENThSMAJGjI+Ebr3yYflMvB09vZuNt X-Received: by 2002:a05:6a20:a120:b0:158:1e6d:23c8 with SMTP id q32-20020a056a20a12000b001581e6d23c8mr8670849pzk.3.1694849827969; Sat, 16 Sep 2023 00:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694849827; cv=none; d=google.com; s=arc-20160816; b=xdUKaccyG12B3tJg9UwHlVuMJ5SS6qv874dOf4mWWaKK8beJzdf1sAwfOqZXv3I5UY 4CIQP5M5tU2a+xr8h6RQZw8icuQgzJG8YTayRykhdwkqwJVR4gI3LrG8gXeHsjEUOmFg a9w1VVBghNfvEuhTMpInlQ48fI82t0m1aNWNhgqr89XVXq1E8OIcVAS0kk0blo8w7r2V ZF4qDP7MyN8YnIRm0UK8Z3Om4M/4gZbZaUKsgOgmmdIdP1YeBgSfjibAgcNBai9S7qt+ 7lv1UVXRLulWLZZ7xTjChUzVSb86pNJPCKYfuqn2KGxcQ6tAPRXamsFqp/vG+yBhbwnh 6rzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Yb0aXGGdlsQgU/B8FX1uy5m2GcMPKzwXuAhrykJSyg0=; fh=W11qpygqhVl+bKjrif44rQ6UzYM3D5CrbTfnG3zvQNY=; b=GndhIG06gMcMVAV8wtfi2H1bYnWyKIf6nTnuYzYYUfXArBCyaALN97bpAAw/1gm0tA tAssead0F0IUEOp1DYzMOFl0nG/okLrxCaAU4D/ehsMNJ1H9HfyBgQcVCvERBZ3qvxSW z9yKz1bXHDzUwRzj1MFQu26kSUQKjA3/Z9USG1qTbXMWIr1N8c30CzOFWYog4zF+211X AqJ9mxgXf3spfmtaWrbWeIbE34p3U8e03OGQyqeobCc6e0MVndMheizhZf2fn/vVJZPn 81btlKYeQoV4kmm9t5bPcnwKdiHzLVtFYggIPPi0mk9lFovzwYT4CiRdgcW8FJd2wlxX DPmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=T5Bw5jLf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bk13-20020a056a02028d00b005780001d4d3si3816425pgb.663.2023.09.16.00.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 00:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=T5Bw5jLf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id F282F80BE3FE; Fri, 15 Sep 2023 12:54:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236369AbjIOTyR (ORCPT + 99 others); Fri, 15 Sep 2023 15:54:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231969AbjIOTyP (ORCPT ); Fri, 15 Sep 2023 15:54:15 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63567C7; Fri, 15 Sep 2023 12:54:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Yb0aXGGdlsQgU/B8FX1uy5m2GcMPKzwXuAhrykJSyg0=; b=T5Bw5jLf+rV8lN51oBY/eYf7vW 4tVlsQ1NaKbz7asS3ljwbDo3W5nrMMKRr8bNPLdR1/fWWAi0BWpXgJeEowhVaJmqlX4BMJB3w9nkm 6hP+2/dTfCEc5h87HFBqbPje020S4imv4jMOAs8vNP+UjzGGXlPeC1fbe1hh8p3pvxhAYVMf29HeC ehtemRFVopME8CgLhmZFeWsRnfESAWaW9SZe3WlzTsQgdmaDOTU4GM7PeNFpKBlBMk2POlni1Z28I 8//nYNO8rWCG3R5JHP68kXv0kOnIQB42fxbSS1S3dDFkJkDJP1Fi+J5dipw95Xa4po122Jmk+Ybo9 sjlUu0iQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qhEtD-00Bip8-8T; Fri, 15 Sep 2023 19:54:07 +0000 Date: Fri, 15 Sep 2023 20:54:07 +0100 From: Matthew Wilcox To: Pankaj Raghav Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, p.raghav@samsung.com, david@fromorbit.com, da.gomez@samsung.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, djwong@kernel.org, linux-mm@kvack.org, chandan.babu@oracle.com, mcgrof@kernel.org, gost.dev@samsung.com Subject: Re: [RFC 09/23] filemap: use mapping_min_order while allocating folios Message-ID: References: <20230915183848.1018717-1-kernel@pankajraghav.com> <20230915183848.1018717-10-kernel@pankajraghav.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230915183848.1018717-10-kernel@pankajraghav.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 15 Sep 2023 12:54:50 -0700 (PDT) On Fri, Sep 15, 2023 at 08:38:34PM +0200, Pankaj Raghav wrote: > From: Pankaj Raghav > > Allocate al teast mapping_min_order when creating new folio for the > filemap in filemap_create_folio() and do_read_cache_folio(). This patch is where you should be doing: index &= ~(folio_nr_pages(folio) - 1UL); (or similar) > Signed-off-by: Pankaj Raghav > --- > mm/filemap.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/mm/filemap.c b/mm/filemap.c > index 21e1341526ab..e4d46f79e95d 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -2502,7 +2502,8 @@ static int filemap_create_folio(struct file *file, > struct folio *folio; > int error; > > - folio = filemap_alloc_folio(mapping_gfp_mask(mapping), 0); > + folio = filemap_alloc_folio(mapping_gfp_mask(mapping), > + mapping_min_folio_order(mapping)); > if (!folio) > return -ENOMEM; > > @@ -3696,7 +3697,8 @@ static struct folio *do_read_cache_folio(struct address_space *mapping, > repeat: > folio = filemap_get_folio(mapping, index); > if (IS_ERR(folio)) { > - folio = filemap_alloc_folio(gfp, 0); > + folio = filemap_alloc_folio(gfp, > + mapping_min_folio_order(mapping)); > if (!folio) > return ERR_PTR(-ENOMEM); > err = filemap_add_folio(mapping, folio, index, gfp); > -- > 2.40.1 >