Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2570570rdh; Mon, 30 Oct 2023 00:42:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhXghrVqOK0M7PEwSfkiyIVYMNntP21PiVDqp80qsJcRdEn62UVy638A8xkRoWTSMq/rhu X-Received: by 2002:a17:902:c94a:b0:1c4:fae:bf28 with SMTP id i10-20020a170902c94a00b001c40faebf28mr7863740pla.32.1698651734044; Mon, 30 Oct 2023 00:42:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698651734; cv=pass; d=google.com; s=arc-20160816; b=cZ++03Hc4Y58Wf9sUQ8JpH/9a6TireZZTXUEobIkTvAlnQuT3zKT5s8oMOG+uP73C+ Oo2fFhj5k61gdU11u206prKQN0LgOTukhC4FLfKqKG3XxPxPHmFuoeYjjFfv1qgUMO/V TA6ZzN71l031Z5EuBVEu5qzkNthsnuNxxwTcUEcG/kgwP6p3BCyGe2Z0s5OZ44bEUAhU mavUzzfQwTLBmriNH3WHBNXlW4b+l5qqhR1cn23pPOpJQlgs6DcMb65ebqf+sM3XZ3Rv P4CD+vFJ6KzjKdK+kUHlqgy4tESC4csHrHpSoWikzxZuyCWVyfSpkC/Zoql6qga0PQqm JwxQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=vvfMIPrRaI9nRJnjmTglFevwrok4cT1bM4EX4WtXQHA=; fh=g3rd4XEdLycQFGGZrFG/L/rM1r2y18a0OWGRAOM7EvQ=; b=Ff5NUYyzqz3pn7WvG/e/5BdFk05v0/n1cywOGu7aWRr6T482/lBHqBTprUn9Wik5Q0 lRA+rfyNfs912px61F6nZLnz/hv9umhWUHeBG8eI0eoVH4CgClwRiKubCQn2woVA527n y5O5FA6KHu1bEEHokrVYhi+NaYjzRMBspcGkER7rOaNMjqWrBbJOoFRcrsmVkRnEfajw uMrEDeifMuMCyKPF8uKvEmi6YG5iS9i600dtq2wV8DhVMnWRXcYB3qGGBfs6gpFnIGMj NY6Ykb9wREa97xrvz3wuliyJVw1MhUsc/WurHMvQBvbb4Uiv4TtUHteHoSXDTBInXL7Y A2dQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=UEi0XaOD; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id p3-20020a170902f08300b001c88fc3c593si4611810pla.560.2023.10.30.00.42.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 00:42:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=UEi0XaOD; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9126B8098481; Mon, 30 Oct 2023 00:42:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231752AbjJ3Hl5 (ORCPT + 99 others); Mon, 30 Oct 2023 03:41:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232155AbjJ3Hly (ORCPT ); Mon, 30 Oct 2023 03:41:54 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11olkn2101.outbound.protection.outlook.com [40.92.18.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2087A2; Mon, 30 Oct 2023 00:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XkbY8sPxiBcmFZD06LJh06cCCz2RS1jC4RISjUujG3oDxp6IzqECAnBuo+CYJwUGVuZG5vImuJjjBWLNOFrgzhTcHTcteb1EqZDleGznc+7kwym1o+u05/r9riyHI8twdNHd6iOlyVB95yfcWE/htVfx715qG/znsknHL31EfB3bsMddAP+cHDT1xM4WvjXiXMUO0Wvdd7B+/vISTUGbwJ8Hba6WxdghUWfwdKgadIlbs30eWZJgfNOJTNUz4KFTVH16KpEMEq8HZV7F/pPQqxv9uU52RXn9t/XiDjdRFHM3C5ZgNdfLjCz9mvTHZc1QFBHyUxK3EaC+fWa8s/KOUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vvfMIPrRaI9nRJnjmTglFevwrok4cT1bM4EX4WtXQHA=; b=fsHLB++339BJEDuVYmdLNna6YFxKid6ke6IWptSyPh4CrEgTrdFCsKwd04P91Uq1IPl5BpBDn2cpp0jhoRjDnKZOr0Pa5XXGCXJgsvO7/Cv3EfIb8G4RZ4TysV5BoAcNnGBZl7i673KbKyVSPDotznDmFqT++W3+hliAc+783kr2lO2kLz6tX8yzN5Fp1W1MOPxpX4ixA6qxT/wthb3AeGswVgYPlrK39iyHDRVkLDI8OKGnuizZt+Eir0ITVFLmxI+rwNufBA6IK1tK+iQYtVjbtbU5niz5OSqzXKKk3E4CICVuFA6X2Vm1SK5NTuJkwQC9v+RQoHRpzLRJtiPP5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vvfMIPrRaI9nRJnjmTglFevwrok4cT1bM4EX4WtXQHA=; b=UEi0XaOD1sUK4qd3B84//x+mnwZUX3oE3RW1fVtC6yaZrblGW3yFOQV66kh5v5plclLhJJCfUl5mof+3SsfG9fO3WVSe7esVDmLtHCNr9+eRT2V/2geG+Qk7V4AZR59gW8S30ltwCHAN1X2Nc/9Iw83oXHZxIQGwz67tkaaAiyQlC0iUlInmiQmZktj9yVoKdMUq0B1Z0srCvLDu+sf+rPOoT+yiKXo675GrHdkaQ6TOOC9WgNMo7PUzHLpZ1MIvyr9dPf24EFHRtdupZ61xV6np24qftxcU7TojAfoR1n7pDRmMLGNcNKflhhxNOXm4B7UqhJL1mi+Mz0sXVevE1Q== Received: from MW4PR84MB3145.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:303:1e1::10) by DM3PR84MB3692.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:0:1e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.29; Mon, 30 Oct 2023 07:41:49 +0000 Received: from MW4PR84MB3145.NAMPRD84.PROD.OUTLOOK.COM ([fe80::6761:2623:329a:27d6]) by MW4PR84MB3145.NAMPRD84.PROD.OUTLOOK.COM ([fe80::6761:2623:329a:27d6%3]) with mapi id 15.20.6933.027; Mon, 30 Oct 2023 07:41:48 +0000 From: Youling Tang To: Matthew Wilcox , Andrew Morton Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, tangyouling@kylinos.cn, youling.tang@outlook.com Subject: [PATCH] readahead: Update the file_ra_state.ra_pages with each readahead operation Date: Mon, 30 Oct 2023 15:41:30 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TMN: [K4EcORULqWqsEe8xctEACmQSjMROm7kF] X-ClientProxiedBy: TYCPR01CA0067.jpnprd01.prod.outlook.com (2603:1096:405:2::31) To MW4PR84MB3145.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:303:1e1::10) X-Microsoft-Original-Message-ID: <20231030074130.1538968-1-youling.tang@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR84MB3145:EE_|DM3PR84MB3692:EE_ X-MS-Office365-Filtering-Correlation-Id: d886a587-3402-4e42-7b94-08dbd91bac6d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L5FiTsJSjQeJUpb+UeqnlN3BftMKa25dQOgqUBAeOCVGqhi53n94pl0WnEuT6JuxUV91RbU7G0Luk8OKAa5CWZpxE4t9LxScyGpKhsv4wuB1VUWd7g8N4TqSZ05b2Ps052QL1M12uwgj/Ns/g/fO/R1TM60+c6DB09Lujmp6mHQrLEFtyeAivvVcnVTDFXJmK0j8MEEqzaHClZ5ZO+R+oVuQ3PO4ilhNK7ytB39KDA6rmaGqkzmPwvIiN3k2cjzpREVUoMEvrzKVMcsvQFcMbD1Qex9Dm2CHV1MRTleJoxGO3lEM4e/rg0McL+duDiSKFUTWzk1CVUlg2UmCfa5Vg2R8SONaUFNajrTdXD9cQfrLvOFtXQsedg1WsXjnPOiTlYiiZINYBQRh1FI1GwYzhurQY6rH0qUuVLDg13V8PlKlGQYPaksIksGq99wpcrt9vURL9h9reMwhP2rLdgAoANPLXQwrFbSQCQ6jcVGyWDvPKCpOvfO1vxxIo1K9O/P1lXjOM4dQQvYm2gWg9C9CJrKSMOMJaXmATHRJxf2BwBeLettTxR4NroovE8DmIX0/FKKDoPL3nqepaIaLR0N5RvP+8M2dWq5kQBoLXnrFfrU4nlWj/F+KSz5HfpipiAh6 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?jELSgBrRdf9KhZxmrIdeF1y+qCWQfRZT9zPsst3RikPAqYSVtSJtxwbTJcS6?= =?us-ascii?Q?wkEiBA60uLrV3JTPPMdaApoIVuUGDadiNhWtYGQEXn2xlhpR8WpgPWYP03Uf?= =?us-ascii?Q?ra8J2dIqPxx04KzUnEZdBI4TcUkI/ZL14pfUDqPqk9enbibXB5FNxgOBPNjY?= =?us-ascii?Q?9g7DxQxcDY9wU9rkzNXQVXmLHC2YpaprEKJVZTIqkBPIN9I+ucc8gRi7VsJ+?= =?us-ascii?Q?5ICn5AV6Dv7/DQt5c/353Cr//jwYGplJnFgahmJRSXSa/AKbX1/PryWeS0q+?= =?us-ascii?Q?8kja9ruAa3XD+Bl45lF7NEBEhR74JzScz82z0je2+ukj7+gqw7HWVfHA6U2X?= =?us-ascii?Q?wp6qzVrqR3Fdpe5ttW7YOjYqPU40vQPv67dQSFBUzCRVKfSps1+LJNaQ9Dak?= =?us-ascii?Q?pf4aQqP/qy59MGZOyE1YcP9GGG1auw4OiWjkOsuG+7Qc5wA8eXsxoDMPZ+Dk?= =?us-ascii?Q?myt5gpMGhQbjDjatecmLyn3gYGbr3u0LfEY27tk6NvR0Sv2r89QiXgSgorr5?= =?us-ascii?Q?lTsoX0Yz8G+GCGGCjUXy933RI06qKULacsMCZSj5o+YRAQrUNAsAuMbwOacQ?= =?us-ascii?Q?oGFla1NSD2/uxEHZA6mpBZaVC3sFk/TVphFsyx+Jj3RYdsqdZSZ5kWIHyqvQ?= =?us-ascii?Q?15Ni11RqHPfJ+pRSleMGzfp0dTsneSAL7ZAZC4kKoBEeLNi4KCkH05ojQuwi?= =?us-ascii?Q?/Zl1/L5jUsmvXQmCDUK7ykjWhupV7zqS4IagKAyObFNRQsjYn3iiwuHoG1Cx?= =?us-ascii?Q?OyP1CV4JQcEhzSuaBIbuMzZ3+ahl7GoQgjQpnRhrauzaL4erygNkHkOQlJgt?= =?us-ascii?Q?vfDbkRkjZUk8XhcnOi02Oo37LQRR3ks9ptEwRfN6NIbSN4ahgv1MtVpQmp1o?= =?us-ascii?Q?MMzmJpzmcCWgqIeUn27Fs6nLlY7rlwyc+D9G8+pwm2OQCeP4RtLnQkJ+qCQz?= =?us-ascii?Q?gp2yAT7ygEuEyEa+ZDJseDqbWXLJ1NkYYF9CeTSRHd0vJVbHYadLAVDLuYB6?= =?us-ascii?Q?NOthIS84kKh3qLV/w1lk9xZMDYupIgX6FjFcH3M7vdRJ1lKBEOpjSxl9Xpe7?= =?us-ascii?Q?QTWS2VtwxwU5rayjNZIVLZC6tYRUM0z2kyEp+AhpB8oxAxLmyKDSy6pTbG3p?= =?us-ascii?Q?BlCPM4Xrz83G1YK6TBGHQlAAu2/5652onWICz2hatHexf5elbuWXbTemulIx?= =?us-ascii?Q?bzAnq8V4pW1tIEAB81M0ukee8/ZP3Us8EA9QRDzr60LDnTYW3g31ElkCd1Q?= =?us-ascii?Q?=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d886a587-3402-4e42-7b94-08dbd91bac6d X-MS-Exchange-CrossTenant-AuthSource: MW4PR84MB3145.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 07:41:48.5400 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR84MB3692 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 groat.vger.email 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 (groat.vger.email [0.0.0.0]); Mon, 30 Oct 2023 00:42:11 -0700 (PDT) From: Youling Tang Changing the read_ahead_kb value midway through a sequential read of a large file found that the ra->ra_pages value remained unchanged (new ra_pages can only be detected the next time the file is opened). Because file_ra_state_init() is only called once in do_dentry_open() in most cases. In ondemand_readahead(), update bdi->ra_pages to ra->ra_pages to ensure that the maximum pages that can be allocated by the readahead algorithm are the same as (read_ahead_kb * 1024) / PAGE_SIZE after read_ahead_kb is modified. Signed-off-by: Youling Tang --- mm/readahead.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/readahead.c b/mm/readahead.c index e815c114de21..3dbabf819187 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -554,12 +554,14 @@ static void ondemand_readahead(struct readahead_control *ractl, { struct backing_dev_info *bdi = inode_to_bdi(ractl->mapping->host); struct file_ra_state *ra = ractl->ra; - unsigned long max_pages = ra->ra_pages; + unsigned long max_pages; unsigned long add_pages; pgoff_t index = readahead_index(ractl); pgoff_t expected, prev_index; unsigned int order = folio ? folio_order(folio) : 0; + max_pages = ra->ra_pages = bdi->ra_pages; + /* * If the request exceeds the readahead window, allow the read to * be up to the optimal hardware IO size -- 2.25.1