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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9EAA3C3ABC9 for ; Tue, 13 May 2025 06:21:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1wx+llxcYiTSb+k7jLA5/IQwwqFutgwerpX/Ddsqp0I=; b=QgDFGZ6HhCv+VW7t8Dzd8eQLAE PBgG8cURYCN8XlqR+PhoycjfGaN/uBZYhPLg5boiXhRRYSKduekhT23OhAPlqqJEPxo7JWtqz3R7+ wkjro3yhRBdtO38lMKsnaAP6VqzSjOQd0dHP+GoRZVUTNoPgXi7wJ5eS+k/Xm+lT9RhDqb09iN8i7 VAMN9TpQJhRqFIbH0uWI21jDCdJmCWzDqIivLe7XqwParzbyyh5oYPYl2iFf8OCXKZyOe6d2E+Z9W YzNZIUt/JPh1j97BIQKA6T/PAc82gQB4LtCVUI9zha0kaBHPfxFaO+kOXtjYa/cohrSrQukQ/EXAN RUEl7cxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uEj1S-0000000BUWR-0eko; Tue, 13 May 2025 06:21:50 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uEizS-0000000BULu-1wHk for linux-arm-kernel@lists.infradead.org; Tue, 13 May 2025 06:19:48 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 06F68150C; Mon, 12 May 2025 23:19:32 -0700 (PDT) Received: from [10.174.37.63] (unknown [10.174.37.63]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 87D583F5A1; Mon, 12 May 2025 23:19:37 -0700 (PDT) Message-ID: <30799c1f-eaa1-4c32-b22d-4c7505304d69@arm.com> Date: Tue, 13 May 2025 11:49:33 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v4 1/5] mm/readahead: Honour new_order in page_cache_ra_order() To: Ryan Roberts , Andrew Morton , "Matthew Wilcox (Oracle)" , Alexander Viro , Christian Brauner , Jan Kara , David Hildenbrand , Dave Chinner , Catalin Marinas , Will Deacon , Kalesh Singh , Zi Yan Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org References: <20250430145920.3748738-1-ryan.roberts@arm.com> <20250430145920.3748738-2-ryan.roberts@arm.com> Content-Language: en-GB From: Chaitanya S Prakash In-Reply-To: <20250430145920.3748738-2-ryan.roberts@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250512_231946_593261_F681586C X-CRM114-Status: GOOD ( 23.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 30/04/25 20:29, Ryan Roberts wrote: > page_cache_ra_order() takes a parameter called new_order, which is > intended to express the preferred order of the folios that will be > allocated for the readahead operation. Most callers indeed call this > with their preferred new order. But page_cache_async_ra() calls it with > the preferred order of the previous readahead request (actually the > order of the folio that had the readahead marker, which may be smaller > when alignment comes into play). > > And despite the parameter name, page_cache_ra_order() always treats it > at the old order, adding 2 to it on entry. As a result, a cold readahead > always starts with order-2 folios. > > Let's fix this behaviour by always passing in the *new* order. > > Worked example: > > Prior to the change, mmaping an 8MB file and touching each page > sequentially, resulted in the following, where we start with order-2 > folios for the first 128K then ramp up to order-4 for the next 128K, > then get clamped to order-5 for the rest of the file because pa_pages is > limited to 128K: > > TYPE STARTOFFS ENDOFFS SIZE STARTPG ENDPG NRPG ORDER > ----- ---------- ---------- --------- ------- ------- ----- ----- > FOLIO 0x00000000 0x00004000 16384 0 4 4 2 > FOLIO 0x00004000 0x00008000 16384 4 8 4 2 > FOLIO 0x00008000 0x0000c000 16384 8 12 4 2 > FOLIO 0x0000c000 0x00010000 16384 12 16 4 2 > FOLIO 0x00010000 0x00014000 16384 16 20 4 2 > FOLIO 0x00014000 0x00018000 16384 20 24 4 2 > FOLIO 0x00018000 0x0001c000 16384 24 28 4 2 > FOLIO 0x0001c000 0x00020000 16384 28 32 4 2 > FOLIO 0x00020000 0x00030000 65536 32 48 16 4 > FOLIO 0x00030000 0x00040000 65536 48 64 16 4 > FOLIO 0x00040000 0x00060000 131072 64 96 32 5 > FOLIO 0x00060000 0x00080000 131072 96 128 32 5 > FOLIO 0x00080000 0x000a0000 131072 128 160 32 5 > FOLIO 0x000a0000 0x000c0000 131072 160 192 32 5 > ... > > After the change, the same operation results in the first 128K being > order-0, then we start ramping up to order-2, -4, and finally get > clamped at order-5: > > TYPE STARTOFFS ENDOFFS SIZE STARTPG ENDPG NRPG ORDER > ----- ---------- ---------- --------- ------- ------- ----- ----- > FOLIO 0x00000000 0x00001000 4096 0 1 1 0 > FOLIO 0x00001000 0x00002000 4096 1 2 1 0 > FOLIO 0x00002000 0x00003000 4096 2 3 1 0 > FOLIO 0x00003000 0x00004000 4096 3 4 1 0 > FOLIO 0x00004000 0x00005000 4096 4 5 1 0 > FOLIO 0x00005000 0x00006000 4096 5 6 1 0 > FOLIO 0x00006000 0x00007000 4096 6 7 1 0 > FOLIO 0x00007000 0x00008000 4096 7 8 1 0 > FOLIO 0x00008000 0x00009000 4096 8 9 1 0 > FOLIO 0x00009000 0x0000a000 4096 9 10 1 0 > FOLIO 0x0000a000 0x0000b000 4096 10 11 1 0 > FOLIO 0x0000b000 0x0000c000 4096 11 12 1 0 > FOLIO 0x0000c000 0x0000d000 4096 12 13 1 0 > FOLIO 0x0000d000 0x0000e000 4096 13 14 1 0 > FOLIO 0x0000e000 0x0000f000 4096 14 15 1 0 > FOLIO 0x0000f000 0x00010000 4096 15 16 1 0 > FOLIO 0x00010000 0x00011000 4096 16 17 1 0 > FOLIO 0x00011000 0x00012000 4096 17 18 1 0 > FOLIO 0x00012000 0x00013000 4096 18 19 1 0 > FOLIO 0x00013000 0x00014000 4096 19 20 1 0 > FOLIO 0x00014000 0x00015000 4096 20 21 1 0 > FOLIO 0x00015000 0x00016000 4096 21 22 1 0 > FOLIO 0x00016000 0x00017000 4096 22 23 1 0 > FOLIO 0x00017000 0x00018000 4096 23 24 1 0 > FOLIO 0x00018000 0x00019000 4096 24 25 1 0 > FOLIO 0x00019000 0x0001a000 4096 25 26 1 0 > FOLIO 0x0001a000 0x0001b000 4096 26 27 1 0 > FOLIO 0x0001b000 0x0001c000 4096 27 28 1 0 > FOLIO 0x0001c000 0x0001d000 4096 28 29 1 0 > FOLIO 0x0001d000 0x0001e000 4096 29 30 1 0 > FOLIO 0x0001e000 0x0001f000 4096 30 31 1 0 > FOLIO 0x0001f000 0x00020000 4096 31 32 1 0 > FOLIO 0x00020000 0x00024000 16384 32 36 4 2 > FOLIO 0x00024000 0x00028000 16384 36 40 4 2 > FOLIO 0x00028000 0x0002c000 16384 40 44 4 2 > FOLIO 0x0002c000 0x00030000 16384 44 48 4 2 > FOLIO 0x00030000 0x00034000 16384 48 52 4 2 > FOLIO 0x00034000 0x00038000 16384 52 56 4 2 > FOLIO 0x00038000 0x0003c000 16384 56 60 4 2 > FOLIO 0x0003c000 0x00040000 16384 60 64 4 2 > FOLIO 0x00040000 0x00050000 65536 64 80 16 4 > FOLIO 0x00050000 0x00060000 65536 80 96 16 4 > FOLIO 0x00060000 0x00080000 131072 96 128 32 5 > FOLIO 0x00080000 0x000a0000 131072 128 160 32 5 > FOLIO 0x000a0000 0x000c0000 131072 160 192 32 5 > FOLIO 0x000c0000 0x000e0000 131072 192 224 32 5 > ... > > Signed-off-by: Ryan Roberts This looks good to me. Tested-by: Chaitanya S Prakash > --- > mm/readahead.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/mm/readahead.c b/mm/readahead.c > index 6a4e96b69702..8bb316f5a842 100644 > --- a/mm/readahead.c > +++ b/mm/readahead.c > @@ -479,9 +479,6 @@ void page_cache_ra_order(struct readahead_control *ractl, > > limit = min(limit, index + ra->size - 1); > > - if (new_order < mapping_max_folio_order(mapping)) > - new_order += 2; > - > new_order = min(mapping_max_folio_order(mapping), new_order); > new_order = min_t(unsigned int, new_order, ilog2(ra->size)); > new_order = max(new_order, min_order); > @@ -683,6 +680,7 @@ void page_cache_async_ra(struct readahead_control *ractl, > ra->size = get_next_ra_size(ra, max_pages); > ra->async_size = ra->size; > readit: > + order += 2; > ractl->_index = ra->start; > page_cache_ra_order(ractl, ra, order); > }