Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1486481rbb; Mon, 26 Feb 2024 10:42:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUDXwdoNkaDdDWhKNJk2aoyvS/ScedjHiaZie5wGtbNC2SuWil/O/Jwoq67Sd8vB9yeKhOt2fugB0mPCccxCi0x5mW1U+owKc/At1dpEg== X-Google-Smtp-Source: AGHT+IEhRwHCFBYiVtUIumEhlwtaaP2a0oFij+DKA+h/0FI/b26f1vc1GFpPJwJDVYVy1KLnv6vr X-Received: by 2002:a05:6a20:c990:b0:1a0:fd1c:c7d4 with SMTP id gy16-20020a056a20c99000b001a0fd1cc7d4mr3755099pzb.44.1708972942577; Mon, 26 Feb 2024 10:42:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708972942; cv=pass; d=google.com; s=arc-20160816; b=SGR2VfDf5PS/7yiWKPuEwVJdQXYC6vbSPJ0p90kQtgN0lspz3g8QVhmhkySOyGYsSw cnWFG7JR5UBaatI/4LuK8TpHH9QLtN6bXxsMJMDMpX2+Dy953woYTZ1UNIbjNI86YIvz DKwXmlNLEztiL/cu8bQfH8oIAV8kAFeNuKWH9r8rZ3/i0Pu6QQAUDWhIXPM1MEwK0I/k eAtSekBw6pDzIlXi7x+6VoXRbJvVu5ZYuK66Zum4tR58etuhbTsrYZW6Aiycxhvjc/p0 I2vWJH36SYEUZkMLY7WjiQVyLk88J8KX04KN+HP46o6c7mTnoumzPRCbaME3eEBK9irM iafA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gauGe8/AuKWwXE/zVAiOKHD6lBDudnyYUkAdQbw+0Q0=; fh=IrswWLQdr8RUReWLOUl6bTv3Gs7y0bSQu4ieH1tZUiQ=; b=O4thuDIkhp+/3evn3ufzxL5V8uFo/e0DO++3vPhZcSCfmAJw6+40Gk7tvxO7EZzWo/ lMGXPgE0RfWJ7pMjsCS51DJGShe45yIGl5G2PT/+8t0qTdkPiJqxiehVIeeRAs7qrVT0 EJoFPQtac+TUcH0whqJ6FFtV64+b9Dqwc0KHpynVCviYfLvRTDidIRZZddx+sZKjSmFu ZdmCQnL2nprmzbHoyp7DtYHedgyfXwlw6fv4OVQS8PhDk+JlcDqk/CVQBhsixcOEu1gb +wxalxAFY8Qkxkc5FP1Fy7SLfqrY70gh+COhvNrcHRjMcs5mzgPARWkiuCjs5E9JtG5W +B1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EZCVljQj; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-81724-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81724-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e10-20020a17090a804a00b00299bceb07e2si5882008pjw.11.2024.02.26.10.42.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 10:42:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81724-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EZCVljQj; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-81724-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81724-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id DE60EB2F74E for ; Mon, 26 Feb 2024 15:04:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7390E130AEA; Mon, 26 Feb 2024 14:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="EZCVljQj" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C275C128379; Mon, 26 Feb 2024 14:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708958448; cv=none; b=DeK0RbUonks/NN1d1CjSmaT24Dfc4DxLMn9P0R6TsKDbEAxYzwuN4mdT5CPMQLg2r7v0y5s1QaTU7zzUTh8YxhW6dYfBfC/ZdZ52YYvZXMbaRMGBQ19fA08Ydi30ZEzg61pDFcSg5p3M5qYLXLq1nOdLDtuF6OVgxOIWxxJBoNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708958448; c=relaxed/simple; bh=SKSApeOruZLSq1n9l0Dfe1EJrrxjXRO2Y+aMmgRnG+Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Px5lWHJ2Oelt3ueLAS8mjkpOJu8YF166iT6FqgDgswqrFSG/XwoOKRgZaNeaEdk0v+c9+rENNKJyAFodQ1qdqsRzAeQk+BXygSN4raQNyYRnO1cGgaJC6ov7fVTKMKrQkCLYa7ktBZ0MpeRyBJznd7eLofHo4Uu2/FoGmKoDlPA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=EZCVljQj; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org 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=gauGe8/AuKWwXE/zVAiOKHD6lBDudnyYUkAdQbw+0Q0=; b=EZCVljQjaZUEOkxlB+8PNfeRt1 NQviA1U1m56nvCuj1UZ3e4AkjgDnJFn5grtISYLOThlXZv6PlZaXJpjNypivPEdhPh0mVxz25+8Ay opXth4lNOhcTliN3vGJm+HTt8x5Y4NWs0WCYjUVeLzUKY/9vMQnLZt9CPMREiWiuo0PbjUnxdU3gA WvwTOKGtNsMpFEQOVpxCRG+9m2rDsPqcKCq89jMOkBTMMTlR794MeF10UDwtGhwZzUaIisCKzdxRy yTcksGLDQC+gAMQw/TX7Y2Qn3BRd1rIbv607lZ+3BhHITyihcI/MXS5izrfwSc67yA0OcaWulzIhF 3gWCr3Mw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rec9q-0000000HPeI-0VQI; Mon, 26 Feb 2024 14:40:42 +0000 Date: Mon, 26 Feb 2024 14:40:42 +0000 From: Matthew Wilcox To: "Pankaj Raghav (Samsung)" Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org, mcgrof@kernel.org, ziy@nvidia.com, hare@suse.de, djwong@kernel.org, gost.dev@samsung.com, linux-mm@kvack.org, Pankaj Raghav Subject: Re: [PATCH 03/13] filemap: align the index to mapping_min_order in the page cache Message-ID: References: <20240226094936.2677493-1-kernel@pankajraghav.com> <20240226094936.2677493-4-kernel@pankajraghav.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240226094936.2677493-4-kernel@pankajraghav.com> On Mon, Feb 26, 2024 at 10:49:26AM +0100, Pankaj Raghav (Samsung) wrote: > From: Luis Chamberlain > > Supporting mapping_min_order implies that we guarantee each folio in the > page cache has at least an order of mapping_min_order. So when adding new > folios to the page cache we must ensure the index used is aligned to the > mapping_min_order as the page cache requires the index to be aligned to > the order of the folio. This seems like a remarkably complicated way of achieving: diff --git a/mm/filemap.c b/mm/filemap.c index 5603ced05fb7..36105dad4440 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2427,9 +2427,11 @@ static int filemap_update_page(struct kiocb *iocb, } static int filemap_create_folio(struct file *file, - struct address_space *mapping, pgoff_t index, + struct address_space *mapping, loff_t pos, struct folio_batch *fbatch) { + pgoff_t index; + unsigned int min_order; struct folio *folio; int error; @@ -2451,6 +2453,8 @@ static int filemap_create_folio(struct file *file, * well to keep locking rules simple. */ filemap_invalidate_lock_shared(mapping); + min_order = mapping_min_folio_order(mapping); + index = (pos >> (min_order + PAGE_SHIFT)) << min_order; error = filemap_add_folio(mapping, folio, index, mapping_gfp_constraint(mapping, GFP_KERNEL)); if (error == -EEXIST) @@ -2511,8 +2515,7 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, if (!folio_batch_count(fbatch)) { if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) return -EAGAIN; - err = filemap_create_folio(filp, mapping, - iocb->ki_pos >> PAGE_SHIFT, fbatch); + err = filemap_create_folio(filp, mapping, iocb->ki_pos, fbatch); if (err == AOP_TRUNCATED_PAGE) goto retry; return err;