From patchwork Fri Sep 15 18:38:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13387472 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 89EB0EED61E for ; Fri, 15 Sep 2023 18:39:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 954566B03C3; Fri, 15 Sep 2023 14:39:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 900826B03C4; Fri, 15 Sep 2023 14:39:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77B086B03C5; Fri, 15 Sep 2023 14:39:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5E6336B03C3 for ; Fri, 15 Sep 2023 14:39:28 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 03D4E80775 for ; Fri, 15 Sep 2023 18:39:27 +0000 (UTC) X-FDA: 81239694816.18.6BE3DFA Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by imf15.hostedemail.com (Postfix) with ESMTP id 403E8A000B for ; Fri, 15 Sep 2023 18:39:26 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=nuY8POIA; spf=pass (imf15.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803166; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SlByD57EXAWo3wBYWh+1jomz9iI/v3Qz7x+/AUImBzs=; b=WYp0N3OnYJc45UbzwubDF3UPqQNV2VJEk/3gZsObvNK69LKK53gp4GK4lVFdh3dpCLiiRh ELAdP33QOIYrJP8fBQWbks8bhGSJ1ftPsdkCX5/qhuWLYhMYhtBfVXfApJ+cGvMVbBrGxx bTtxZ/D9frUpCe8SSlxEcvnCzSnDNDA= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=nuY8POIA; spf=pass (imf15.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803166; a=rsa-sha256; cv=none; b=7j+KNwr4cfdMNB9DBNE696xH8wwsJDiEjRpGQlbECpxX0+MwS3V07x0+uWqMkIWHByY3+o DG+rhGqmxdKxju44Nk+gfEysFKHlW6AEXDi0IRK4yoK5DF/2w71KardBUZlcAwqN/2Jv4f k5lxhV95RgAAT5QVA5YN26AHVRHDj0I= Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4RnNJW0zkCz9sZG; Fri, 15 Sep 2023 20:39:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803163; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SlByD57EXAWo3wBYWh+1jomz9iI/v3Qz7x+/AUImBzs=; b=nuY8POIALXl0in4GfMc25TJC8coBeQG43+Ouex9LRzUcKwK8I5c7EEHIH+My1vP7A91IWR JpL8fg2KOkRRAcvKGXz+vA5/mbGmclH2WEI7vYKQZvUUY4PW+gydMVf/nU+wSdB/tEf3iD 7fIcfZwKxubSL8Be38uKFiNVIgOf5DyDHV87W0Y8X7Qk+tOJCtgkLZ61qi2KNIDwl4i7WX csxEGgzn3f5nPGSOcT7rO7zljDx1HiVZ9pDcU5CfZ4XyxCcK3iXZVxeySqazerokuxygMm 51rE3zIIvycA/2oxNMkX9/yceDwSbawy5u9l3xIe2eEB7PyD2gY58zVvZs2hxA== From: Pankaj Raghav To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: p.raghav@samsung.com, david@fromorbit.com, da.gomez@samsung.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, willy@infradead.org, djwong@kernel.org, linux-mm@kvack.org, chandan.babu@oracle.com, mcgrof@kernel.org, gost.dev@samsung.com Subject: [RFC 11/23] filemap: align the index to mapping_min_order in do_[a]sync_mmap_readahead Date: Fri, 15 Sep 2023 20:38:36 +0200 Message-Id: <20230915183848.1018717-12-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 403E8A000B X-Rspam-User: X-Stat-Signature: k89a4gobcphfmb4wm6rj6mp16kh78675 X-Rspamd-Server: rspam01 X-HE-Tag: 1694803166-294250 X-HE-Meta: U2FsdGVkX1+NMWW35Z1lJ7jwoDavWlGnkn5+Q3WJVMGlrfmF5/K/I1tHIpL7J5oJ+Q/8k0rOZKXxz7i2m8Hd0AVbxq1BdTDnotDiMXXKHyz0CAj1x4oe91zaMKuAb7yJ0qBGVHrQZLtm2epDu05kFU26PxVo6cglSj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RustPeeQ89obZfp2iovM7M99xvshkBFojE6r3EhVqtYr136vpo/DJbRpBZyQhIpqprqpMrMkxJibQAwsuaedGvB8qNEvaY9Pnog2t0ICQ5y 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: From: Pankaj Raghav Align the index to the mapping_min_order number of pages in do_[a]sync_mmap_readahead(). Signed-off-by: Pankaj Raghav --- mm/filemap.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 8a4bbddcf575..3853df90f9cf 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3164,7 +3164,10 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf) struct file *file = vmf->vma->vm_file; struct file_ra_state *ra = &file->f_ra; struct address_space *mapping = file->f_mapping; - DEFINE_READAHEAD(ractl, file, ra, mapping, vmf->pgoff); + int order = mapping_min_folio_order(mapping); + unsigned int nrpages = 1U << order; + pgoff_t index = round_down(vmf->pgoff, nrpages); + DEFINE_READAHEAD(ractl, file, ra, mapping, index); struct file *fpin = NULL; unsigned long vm_flags = vmf->vma->vm_flags; unsigned int mmap_miss; @@ -3216,10 +3219,11 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf) */ fpin = maybe_unlock_mmap_for_io(vmf, fpin); ra->start = max_t(long, 0, vmf->pgoff - ra->ra_pages / 2); + ra->start = round_down(ra->start, nrpages); ra->size = ra->ra_pages; ra->async_size = ra->ra_pages / 4; ractl._index = ra->start; - page_cache_ra_order(&ractl, ra, 0); + page_cache_ra_order(&ractl, ra, order); return fpin; } @@ -3233,7 +3237,10 @@ static struct file *do_async_mmap_readahead(struct vm_fault *vmf, { struct file *file = vmf->vma->vm_file; struct file_ra_state *ra = &file->f_ra; - DEFINE_READAHEAD(ractl, file, ra, file->f_mapping, vmf->pgoff); + int order = mapping_min_folio_order(file->f_mapping); + unsigned int nrpages = 1U << order; + pgoff_t index = round_down(vmf->pgoff, nrpages); + DEFINE_READAHEAD(ractl, file, ra, file->f_mapping, index); struct file *fpin = NULL; unsigned int mmap_miss;