Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4802430rdb; Fri, 15 Sep 2023 12:43:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEMeVuZ4GigEN9llz0O0t3CzSS3D6py3mDm0IJMOJsXhsB3shs4F/rcrjVDZX1RQhFsJqd X-Received: by 2002:a05:6a00:2da2:b0:690:38b6:b2da with SMTP id fb34-20020a056a002da200b0069038b6b2damr3104298pfb.2.1694807011490; Fri, 15 Sep 2023 12:43:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694807011; cv=none; d=google.com; s=arc-20160816; b=btrAcug+Vcyr9UxGsO6fvUD0jL8kx+UmBZvCy2I3w5MYN/T/eAg5KoDMVaaMQ1nM6P jsEZx3UO1iozM5F+bZrW5wkO30kXTqO4ypeydsGo/IhmsOkmw/UP2fVdVcnbj29eswQF UKzLQha4euYvmij4diPOqSvvEflTRh/3gjZZUTyrl6rbvM2oD4L0VPOUzn0bH1e4riD8 rZ12kwK9wn48Fks2Ly0FxBs0g6vMUhEImeo3mh3Zqg1CyuElXrLV8k8I+AvaX9DSZ17O AgYgemqlW4R1kUFXydjhjQn9+xvmY/bbjTqtFq8NKFb/tQ50+G6vjb0VeQx1y3O6D30M BCaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SlByD57EXAWo3wBYWh+1jomz9iI/v3Qz7x+/AUImBzs=; fh=kl+S4GAUWD1kOeoqBopscteh2mu3DZslcHc01dOJ6TI=; b=vbGkY/IvVtGG8SbXkjrf/qfwc3lcBboAXJ72/+35u7yqsRdOixghYjvDHuqIpI3Jo3 JDbh75UUC+MVwMMr0BrimZbb/IBghzkCbomjWhQBfWdmVedZMeYOhh2PJOaYOOFUQMhd 63rga4KvzkhUR+btQk+wUqlyHw82fBNQnq6XkEDq68+KUEmnZqPPaZWL6lR7ukpvO/d2 QGpAdgPuzwPpqDRldT2/NsS+iDc8Sk8Hhdv/KsAasBIcxVim8ykjDorc4sWQ/el+gDr2 Bh4/0JOxWGRvCd9mdCFNKtjR7V1TAkqwNezOP1OzlZ53dXDKYWFvHIGAIfkuzy6fXvB2 1fFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=nuY8POIA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id u2-20020a654c02000000b0057768a32896si3688440pgq.365.2023.09.15.12.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 12:43:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=nuY8POIA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 9246480320E7; Fri, 15 Sep 2023 11:44:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236852AbjIOSnk (ORCPT + 99 others); Fri, 15 Sep 2023 14:43:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237089AbjIOSnD (ORCPT ); Fri, 15 Sep 2023 14:43:03 -0400 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA8A135BF; Fri, 15 Sep 2023 11:40:01 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit 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 (pete.vger.email [0.0.0.0]); Fri, 15 Sep 2023 11:44:23 -0700 (PDT) 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 pete.vger.email 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; -- 2.40.1