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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE203D1AD53 for ; Wed, 16 Oct 2024 13:06:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 442536B0082; Wed, 16 Oct 2024 09:06:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F3436B0083; Wed, 16 Oct 2024 09:06:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E03E6B0088; Wed, 16 Oct 2024 09:06:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0FF206B0082 for ; Wed, 16 Oct 2024 09:06:25 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4C0531C5465 for ; Wed, 16 Oct 2024 13:06:13 +0000 (UTC) X-FDA: 82679488794.06.2EDFE6F Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by imf25.hostedemail.com (Postfix) with ESMTP id 0F207A0004 for ; Wed, 16 Oct 2024 13:06:15 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=huMirWV9; spf=pass (imf25.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729083838; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JCi90PWGZerW7sJN/H2MblCN/ThnlTZy4Lel3S1pN6s=; b=TO5AwDx6qXhPblis5zlooAIR9EyTFgzIef+nCPcx2uiO8oWX6RBnEqRsGz+9unCbE8KUVp 32q24M0OquVy+QxMUEoB7UGz3U8yVcYXAPEJJM+2asbbke8I74nF5PW7Gmz0vZTF4n4vPv 8fevjx7/TMyYrQQhfnU6LEPF0GnEuds= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729083838; a=rsa-sha256; cv=none; b=VkWsPNpOe8uRCu+g21FT9N5Ntd2fr2WgKiLsZJNJyNTjvJIbhqrGqFwr/Ew3aYjd/oaUUi bevn6S+qkTXBT+eVL+hKtERXXFbuPHGvJlzMwGR356bumZNPrAu+e7s52QA0Ly0G2CfCIX 3AF38xeUKfur10UyLHdU0DCgi0z0aEk= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=huMirWV9; spf=pass (imf25.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com 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 X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4XTB6w6qgFz9sRx; Wed, 16 Oct 2024 15:06:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1729083977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JCi90PWGZerW7sJN/H2MblCN/ThnlTZy4Lel3S1pN6s=; b=huMirWV9AVz/JD6v7UbrVon5zhbh8lKKFaIu3W20e91cQx0rWWjrILRFyY+Yxy/2vP6+zU gnwSo/uv5jSSuZwbBP9rzGbh4Ea4LqMk84x6vAFRcztfoxlTcHN/ZvaNmtqPgK/t10/6Nc hrbVDaZd5Hb1HO+0TGverW2iVUTHvRzMGv0NEf5TUXEiHiF1D/9d78IBG9RMlEm0Cq6Y91 RJc11YmGKp4fePwfiLF1UKeiDwVm0ZU6rS4ngLe91G06ZIRSXwDwdzNvPiHT2WAv+UCOjU eZBlqWOe6KCQjSr+JliKMvQ8Z2XVAxSh8kFUWAh8zvsDCHLX/s7VrAxcJ705Ig== Date: Wed, 16 Oct 2024 18:36:04 +0530 From: "Pankaj Raghav (Samsung)" To: Matthew Wilcox Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, mcgrof@kernel.org, gost.dev@samsung.com, Pankaj Raghav Subject: Re: Re: Re: [PATCH v14] mm: don't set readahead flag on a folio when lookahead_size > nr_to_read Message-ID: References: <20241015164106.465253-1-kernel@pankajraghav.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: 1pxuxnyq8q14riaonn4qicn7aezpnfcz X-Rspamd-Queue-Id: 0F207A0004 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729083975-799686 X-HE-Meta: U2FsdGVkX1/QqNNZTEICB+lqDTVN64HFB508d77syqK1Nwpa6iTS+326lfNCaG931RbD/g42YyK+BZPiUZmzo4i92yDKeN3fthU3A4YamjF9CkXxu9UGxQnFF+bHhw+1cE0ERldonzMlJb8drS2Tk2AAr9T2img6OhVVzUfKKvrp6TuyfMEAfq/2deAhzx3MMnw6R3q8IPglTRambDUsKr2jVtqIzMpM8EH7qJSvbH2ULS+wCG2t/YspmeHKyPys5Nc8/ASBE4ykDcCMOsN/sW1OEGbEqb9dUXJkKyfxbMMDuQiFt11eyEnYa3tkgq/jRWGV4A2/AdaFroXsNEEQrEUC2A6w5Pm3y9o6srDq7xv2H+jyfSr3iIwY4Qr8D+qtieDeua7ww/LMO/BBADC0ANnb/MMYcdbQa9gfcmxRk0YPqPA8Wqyn6Wp4QXj6vzLsWIeUITmUnztdkgihsVtqleakWDUrlQoEMH8f69QwK2GjTSdLyOYwDrcJ9jAGV0x7IQKrxYeeBt/b0lTizLmiKkwMuc+z6TzNcvEgYoh7cj4A7lGyR/I+obfzdyhTZ3UtK2LSTyXaXXC845xMHKRnY5gcnKXH7oqE46Ad19g71akH+l1pMYbYX7NbF1jU8IPQlEA22ebqJDCca+53aX2KtlaDG8wyZx/eXyDn/vDeONG+K+Jw1Bic/VU+XQ0iMu++ftlbPoIK3iCs+fxl05W5XM1SHWrjtdBv8Qee5NV2r4/DoWuFdEQw30xW0+WBwwhFicTtTtjWmuk4GCPn12PrDTAU0+eNkISua6N2pjMgtg8SNtEggJgudD591E5PR7/U2IZPf0DS6Uh8OF6GHIOFpfgKwzE3bDNq7A0LMnJA4Cfo1JGLyTGq/bFW2mxnNemBcU3swvBn1GTV4l99gWJxhFo5Bc1kgz56tbi5CL7l7FLRgetVZFxKKdarwt4FSfJiQG0I2nKR2RiacX+Dzum NmdwM+YT xJQuNNp6yLFZX4f8PFltQiqp4wvYa24RlDvyiT2X281tWWbOxy/7iMPxwOrQq18Oqtj7z/HBtnPZHSjrw85rINwwxS7iyUvFm8e5XlFZ7PzM3RRmW6CsdlyoIIwej423xxLfNdEvb6my5z6vmygSI/8N+yLZuOzDWUlgMGX85+Ln6X5hYBNCeQBUXc9rXjzzdHhrXrYWLRovsrYWCY4qkT7/6F4mnoHVtYH3pim2ltAZrb1GoWEpE9T54IvcwtphoSusl3weRvvce+Tz1uBLkiHJKH2KdiEyGfN/NyfjSEnonLpA= 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: List-Subscribe: List-Unsubscribe: On Wed, Oct 16, 2024 at 12:57:44PM +0100, Matthew Wilcox wrote: > On Wed, Oct 16, 2024 at 03:35:27PM +0530, Pankaj Raghav (Samsung) wrote: > > > > - The current calculation for `mark` with mapping_min_order > 0 gives > > > > incorrect results when lookahead_size > nr_to_read due to rounding > > > > up operation. > > > > > > > > Explicitly initialize `mark` to be ULONG_MAX and only calculate it > > > > when lookahead_size is within the readahead window. > > > > > > You haven't really spelled out the consequences of this properly. > > > Perhaps a worked example would help. > > > > Got it. I saw this while running generic/476 on XFS with 64k block size. > > > > Let's assume the following values: > > index = 128 > > nr_to_read = 16 > > lookahead_size = 28 > > mapping_min_order = 4 (16 pages) > > > > The lookahead_size is actually lying outside the current readahead > > window. The calculation without this patch will result in incorrect mark > > as follows: > > > > ra_folio_index = round_up(128 + 16 - 28, 16) = 128; > > mark = 128 - 128 = 0; > > > > So we will be marking the folio on 0th index with RA flag, even though Oops. I shouldn't have said 0th index. I meant at offset 0 from the index. > > we shouldn't have. Does that make sense? > > But we don't go back and find the folio for index 0. We only consider > the folios we're actually reading for marking. So if 'mark' lies > outside the readahead window, we simply won't mark any of them. So I `mark` is the offset from index. So we compare `mark` with the iterator `i`, which starts at 0. So we will set the RA flag on index 128 in this example, which is not correct. if (i == mark) folio_set_readahead(folio); With this patch, mark will be ULONG_MAX and not 0. > don't think your patch changes anything. Or did I miss something? Does that make sense?