Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2955804rwd; Fri, 2 Jun 2023 18:11:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4YT9/U5IRHi8xQ4f0sS6T4Hxs7I9KVySiTf2G0ZWBty2RI8DrLTZnnz7A3sfnmtWSxBMSQ X-Received: by 2002:a17:903:41c3:b0:1b1:ac87:b47a with SMTP id u3-20020a17090341c300b001b1ac87b47amr1809011ple.65.1685754699622; Fri, 02 Jun 2023 18:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685754699; cv=none; d=google.com; s=arc-20160816; b=0eGzZIV0iTtsJ/mK4u11V6l8yVhBsNPWcE93+zT0t9VQWFMthNtVd0rx2cLbWA/Y0f uZIHQrhDI5cQFS7ULFPQLRWG1/2x7ONl4W4dFihxcajsOwhg+oIKuEeZK4snMi5zK7gn /ZZoZVcxB9r5Rwe8wHV2ExKLw5E42L2/xWjutxw/xIiHeN6k71MguKeV/p/8I3CCBDQD +/R7zl3Usv9bipN/ZAp8RanS4yxZZYutu0OlgAeLGwcxsmpgHTBOHEawVA2FvIMeHo1g Mo6CqNcLioquEETmGBH+BaNmA8TYFZr0WfRRZpP2+w2OB1a28dGxY+T5qHpXgcjCPWgN TUSQ== 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:subject:cc:to:from:date :dkim-signature; bh=xa2Xjr1w7jLjjOB8f3fTZ7/SI3kTkRZC6GL9sqMYTmQ=; b=jvBBE7X8EDBFr6KZjeE5KAh/Zreau3DXE61lZ9RxTmNp4aXE0XgulKDx6HxV7/Vj/4 axM1DoUwgxPW1XI5vXahoeqLD4zoQ+2cEHoCRWutaFg2D3sn+RU4g7okSEVc1bv5DxX/ cnBvKphXmvR3j7YYyYjpmlvxLuErbDSXp5sbujf+wEwDl22KFPJDyRemsItdDUdUCWS9 lEldEZOMfy481dgp886IAiuH5ESpwt6WOqfU4WiBKMbovIO8j+gPdDfaeU+2Zae61nAm VC6g+u7Q/SbDt+y7tQesJGYBfq9OeHUXszevqwKWfWMYTxFQVA9exkYF8t74GdI4jKHE RYzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=Ckdb5p4P; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iz15-20020a170902ef8f00b001b02bd00c73si1720599plb.253.2023.06.02.18.11.28; Fri, 02 Jun 2023 18:11:39 -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=@linux-foundation.org header.s=korg header.b=Ckdb5p4P; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237030AbjFCAz5 (ORCPT + 99 others); Fri, 2 Jun 2023 20:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237011AbjFCAzz (ORCPT ); Fri, 2 Jun 2023 20:55:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0852E62; Fri, 2 Jun 2023 17:55:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2030C60FC6; Sat, 3 Jun 2023 00:55:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 246A0C433D2; Sat, 3 Jun 2023 00:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1685753748; bh=Xubkvl6o/dMjh0W2gs6rjN5eA+h0WSm7E9vZ1z6roSE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Ckdb5p4PjYQ2h0tguVeop9ZOh+CNCjMk4ZQS8TtIbeq1ACOe7Hp9tfmWK3rgzPfgd u/08F1YFM4P9P9YNGu9hXZBBpraG979oH2iY8h9V0WowMpD5+x8ChFXswpJBhMdHhw eWk+w9/CsGr7KZWGWop98gLyPrQgbPKWXY0FTPxI= Date: Fri, 2 Jun 2023 17:55:47 -0700 From: Andrew Morton To: Mike Kravetz Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Matthew Wilcox , Ackerley Tng , Sidhartha Kumar , Muchun Song , vannapurve@google.com, erdemaktas@google.com, stable , Greg Kroah-Hartman Subject: Re: [PATCH 0/1] RESEND fix page_cache_next/prev_miss off by one error Message-Id: <20230602175547.dba09bb3ef7eb0bc508b3a5a@linux-foundation.org> In-Reply-To: <20230602225747.103865-1-mike.kravetz@oracle.com> References: <20230602225747.103865-1-mike.kravetz@oracle.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 On Fri, 2 Jun 2023 15:57:46 -0700 Mike Kravetz wrote: > In commits d0ce0e47b323 and 91a2fb956ad99, hugetlb code was changed to > use page_cache_next_miss to determine if a page was present in the page > cache. However, the current implementation of page_cache_next_miss will > always return the passed index if max_scan is 1 as in the hugetlb code. > As a result, hugetlb code will always thing a page is present in the > cache, even if that is not the case. > > The patch which follows addresses the issue by changing the implementation > of page_cache_next_miss and for consistency page_cache_prev_miss. Since > such a patch also impacts the readahead code, I would suggest using the > patch by Sidhartha Kumar [1] to fix the issue in 6.3 and this patch moving > forward. Well this is tricky. This patch applies cleanly to 6.3, so if we add cc:stable to this patch, it will get backported, against your suggestion. Sidhartha's patch [1] (which you recommend for -stable) is quite different from this patch. And Sidhartha's patch has no route to being tested in linux-next nor to being merged by Linus. So problems. The preferable approach is to just backport this patch into -stable in the usual fashion. What are the risks in doing this? > If we would rather not modify page_cache_next/prev_miss, then a new > interface as suggested by Ackerley Tng [2] could also be used. > > Comments on the best way to fix moving forward would be appreciated. > > [1] https://lore.kernel.org/linux-mm/20230505185301.534259-1-sidhartha.kumar@oracle.com/ > [2] https://lore.kernel.org/linux-mm/98624c2f481966492b4eb8272aef747790229b73.1683069252.git.ackerleytng@google.com/ > > Mike Kravetz (1): > page cache: fix page_cache_next/prev_miss off by one > > mm/filemap.c | 26 ++++++++++++++++---------- > 1 file changed, 16 insertions(+), 10 deletions(-) >