From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A708C5478C for ; Tue, 27 Feb 2024 16:22:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 035CE28001D; Tue, 27 Feb 2024 11:22:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F27EA6B00AC; Tue, 27 Feb 2024 11:22:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF1B628001D; Tue, 27 Feb 2024 11:22:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CE93E6B00AA for ; Tue, 27 Feb 2024 11:22:34 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A76CB1C0EF0 for ; Tue, 27 Feb 2024 16:22:34 +0000 (UTC) X-FDA: 81838101828.23.9D0D568 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) by imf30.hostedemail.com (Postfix) with ESMTP id CF10180008 for ; Tue, 27 Feb 2024 16:22:32 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=bwO859o9; spf=pass (imf30.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.188 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709050953; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZpwdoTPDbBoPf3QYWjOhHZc19Xb5Er/Lboo1nmZhqcA=; b=8faIuZ/l9Nxviexg67ppMQfpPUvaRkAytZ3ZkCCTfCoxCUARFKnMpOwRWbCOEILGr3qiLG A3jvW1LvbADDGTVjFVjJ3N4Pk8KEJ5IzUoi6wOOKnbVj3TyEhgk5Ybn6qu2vOQTH8gNfYY o7ZLXm86y6P9uzlCm2Bd3qtYCf5ePpg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709050953; a=rsa-sha256; cv=none; b=2cXJl7OvOIg6Q3roJnbjQTYQEhE1I7NRNPhRVsJu7WBg2wGptAviq4jD9Y8AlRddQzN/Oy 7R1l29K2UFl3NsBnQaL9hVum32May/0Me4xO/6CkypuKOW9HrYGNJZxBEWZq+WwQfmhnOL B0dL4YdOyh4h5l/p8sARG7Mgx7QHY0U= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=bwO859o9; spf=pass (imf30.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.188 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Tue, 27 Feb 2024 11:22:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1709050950; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZpwdoTPDbBoPf3QYWjOhHZc19Xb5Er/Lboo1nmZhqcA=; b=bwO859o9nXk2p9RatAo3p5C1/sszAl7urqmVyqYIj76c/O++eLQ2fFVcxbPxk+/xgYiBF1 d/ZtnwEjP6Tl3Ey6WYdXoJAHfQ682oQonvYCCwO5IXX8NTU2/eiI2L2EhFkFB+aWXpZbUi pNflFYXlz5yMYfcD+4N3ENtkARdq5p4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: "Pankaj Raghav (Samsung)" Cc: Matthew Wilcox , 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> <37kubwweih4zwvxzvjbhnhxunrafawdqaqggzcw6xayd6vtrfl@dllnk6n53akf> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <37kubwweih4zwvxzvjbhnhxunrafawdqaqggzcw6xayd6vtrfl@dllnk6n53akf> X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: CF10180008 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ys1ip4p9gfepw7ebziksqe96sortpzr1 X-HE-Tag: 1709050952-818469 X-HE-Meta: U2FsdGVkX1/QVk37u1esIbbKeD/3V9PJE3+9E4oTFhhbueN5q++VaN5j5B5mPtV4BiMlINaYOW1KbHis0PINU1PG2JSsOSfOF31NQeLDckkqVKlJT4w/E1I9XmOyWtlwT4Jtt0kq6m4FyB4oUYdEyLFKvMdXKe/+/OENZoETGnf2jC7zzAPuY0ITqrowrRjPCu7M2DHdqClvH7GQsAp6Ida5WhnJDeW3L3TIbggDeCI3XY9rcOG73rDPJsr7YdhtlwOALvybBdoOT/m0ZlzmiRyNjS+eTTvh5XCJCht9Zs7T86BeQqOc1skz6u5uPKZE+BSZ9RppOYUxSgmIvlXVzX/e829SzuKFGwS47cKpfV0fyOFh50JFdjvd5PZkbHg8cQJHxly1mWxNkh8oqdPrpSy4edIadfSwtxIh0OKWOiEoWt4vhMtSpU7JViUbiojwq5bIxJxe1vOKBSn/yMosbLg0vWxPC4n3ysxGP3k5kyf71WQqMtGq1Ibi6MZ5TU4tTHga8WorX8Buetqc1OTSMh5T4A9jCjRa0a6wahBzo/mZE6dPuPQ/x738TWEqoLBBNbfN8qKFF7X2CaPY+ivyN4qgL6UxgZAKRv/2lW8QSy2NKd0hrr2qVgUuGwhwJc8hWN9LclzqWexQ8n34WoezkNNMJdV8C+SgWCllryfnHpcmHjXiFNLKflOE22yCTQY9leB1CVqGiCQdN8DkzWiYIKywEkfFrjhBJXgQ7tBdqsy9sl/DiGF9keJej2FOKnfeqj+T5ely9g+Mf72umfAyQaqWg4gPWxYbRA2FFz3/FIEPCkg0qk0sSv92hHiEn6cuMvwHrz7g87yyOEPczoYaAU29LSwhXDql X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Feb 27, 2024 at 11:06:37AM +0100, Pankaj Raghav (Samsung) wrote: > On Mon, Feb 26, 2024 at 02:40:42PM +0000, Matthew Wilcox wrote: > > 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; > > That is some cool mathfu. I will add a comment here as it might not be > that obvious to some people (i.e me). you guys are both wrong, just use rounddown()