Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17194952rwd; Mon, 26 Jun 2023 22:48:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62PhEXzx4ZCpF4APQTVc11hDF6dEFVfJxg4ROHmOHAU2WEygEyldmRgn1tMTUQmpeKayLG X-Received: by 2002:a05:6a00:1988:b0:675:8f71:28f1 with SMTP id d8-20020a056a00198800b006758f7128f1mr4780602pfl.30.1687844900344; Mon, 26 Jun 2023 22:48:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687844900; cv=none; d=google.com; s=arc-20160816; b=bUj3IYHy+MVfdipvEOiojScBsxzYOL8q9ZuBJeTKvPzB26LU8qknqkkQsQBrALgn70 Lf52tXWJKRbY2v34Dq00FXE1lSd6c7HJ/O2CI85YO2c8amfCgT7VObjcbaDowhKq6U8d sSKl3QA6611pkNrEvOQ/dwx6Kg8qDy+6ujiL3ZzfF8mg8qJCpnzWtHutW0Hd2Y2UK0lQ 3NdZeB/oplxKbt03vrib+aGxkZoXfriYbS8JsSdJkXgvu6VU3TJxr7UCLv/tJ5mvmgNw cQ8LlGwZYgHuyneNGdOhplwPO4IYfldlV4Sdt2BCA6VJCEXIn5Em6rnLyRNQUbuZ2b7k Zhbg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=FhTRP0e1hlPeVc/1zTc9kB113BtqpEKosEn7G/IlGwM=; fh=PwBF7hBSv2FZQRhAC1oEqH0GemCN4v5UxluKCc2vgIA=; b=Tnc3xeGb7NOQ4sxZzkUyT7tMtUo/GSmmDJrQjyFTgdHbHOZDXLhqSr888X6TgnrDtU gVKl2L/pCjw4yD7Mx4aQCBkjNNg2fL9AxEgXc3uM+QFKTZDtdhxjaKiUSkUHCfdL62sx wUG4YAwQZAtuNfUx+vnjL4e0lElMxV7D9Vf84D13Q4gZKG6InAV7ZmaMShj3gCEDon8K jeJmaiRjaEHObKbCFZ8QNamTfXE1RO7j/Gp+mNBXfIozlml75knkteS3KIpcv5TdVje4 B/LejHubK/ip3VM3IEeFfSzdkkS/LZZbjvlcn7ELVXGM/H7830O5JjXl6+5CPj/26rXw ramg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lveK8XWX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a056a0010c400b00662a8b9b730si6539064pfu.200.2023.06.26.22.48.09; Mon, 26 Jun 2023 22:48:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lveK8XWX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229790AbjF0FHO (ORCPT + 99 others); Tue, 27 Jun 2023 01:07:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229584AbjF0FHN (ORCPT ); Tue, 27 Jun 2023 01:07:13 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C13038F; Mon, 26 Jun 2023 22:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687842430; x=1719378430; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ud+CunnfVYp9ThBCLHD+sITFdVXD+yTRAxxIAbdMevk=; b=lveK8XWXhPV2If6FcupEmwVUHikLFv1soxx5L6he8VMxcdb8E7GQRP/r whLYJUrp4wCPEFopYVBwhpkIlWsOYRuwTZzmqppjpBID4gXLO3G30+88Q F2dhD6eP0QZWxbSclCvI5m1666Tp84Ub5ZXgRaIczqNWqN2q9bMPvsF/R 89MqM2LqQqwLJkHQkCfZphyYDKnF7ANBgaMYOh4qlggzDVFE619yxYYf5 cO6SEzTsyDzJrqXhLjMVriuHJySt6YgIZUJYZ1b3/NlBs4IktyifEjirk LXQLpU8i3FOf58F4LE2VkddFsTkd0y713Ds6c9sxi2M71B4xK31GRA00M w==; X-IronPort-AV: E=McAfee;i="6600,9927,10753"; a="341816754" X-IronPort-AV: E=Sophos;i="6.01,161,1684825200"; d="scan'208";a="341816754" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 22:07:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10753"; a="806315435" X-IronPort-AV: E=Sophos;i="6.01,161,1684825200"; d="scan'208";a="806315435" Received: from fyin-dev.sh.intel.com ([10.239.159.32]) by FMSMGA003.fm.intel.com with ESMTP; 26 Jun 2023 22:07:08 -0700 From: Yin Fengwei To: akpm@linux-foundation.org, mike.kravetz@oracle.com, willy@infradead.org, ackerleytng@google.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: fengwei.yin@intel.com, kernel test robot Subject: [PATCH] readahead: Correct the start and size in ondemand_readahead() Date: Tue, 27 Jun 2023 13:07:02 +0800 Message-Id: <20230627050702.823033-1-fengwei.yin@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The commit 9425c591e06a ("page cache: fix page_cache_next/prev_miss off by one") updated the page_cache_next_miss() to return the index beyond range. But it breaks the start/size of ra in ondemand_readahead() because the offset by one is accumulated to readahead_index. As a consequence, not best readahead order is picked. Tracing of the order parameter of filemap_alloc_folio() showed: page order : count distribution 0 : 892073 | | 1 : 0 | | 2 : 65120457 |****************************************| 3 : 32914005 |******************** | 4 : 33020991 |******************** | with 9425c591e06a9. With parent commit: page order : count distribution 0 : 3417288 |**** | 1 : 0 | | 2 : 877012 |* | 3 : 288 | | 4 : 5607522 |******* | 5 : 29974228 |****************************************| Fix the issue by set correct start/size of ra in ondemand_readahead(). Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202306211346.1e9ff03e-oliver.sang@intel.com Fixes: 9425c591e06a ("page cache: fix page_cache_next/prev_miss off by one") Signed-off-by: Yin Fengwei --- mm/readahead.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 47afbca1d122e..a1b8c628851a9 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -614,11 +614,11 @@ static void ondemand_readahead(struct readahead_control *ractl, max_pages); rcu_read_unlock(); - if (!start || start - index > max_pages) + if (!start || start - index - 1 > max_pages) return; - ra->start = start; - ra->size = start - index; /* old async_size */ + ra->start = start - 1; + ra->size = start - index - 1; /* old async_size */ ra->size += req_size; ra->size = get_next_ra_size(ra, max_pages); ra->async_size = ra->size; -- 2.39.2