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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BB69C433FE for ; Fri, 4 Nov 2022 11:46:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231621AbiKDLqI (ORCPT ); Fri, 4 Nov 2022 07:46:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231302AbiKDLqF (ORCPT ); Fri, 4 Nov 2022 07:46:05 -0400 Received: from outbound-smtp30.blacknight.com (outbound-smtp30.blacknight.com [81.17.249.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DAAD2CDE6 for ; Fri, 4 Nov 2022 04:46:02 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp30.blacknight.com (Postfix) with ESMTPS id C1347BAC93 for ; Fri, 4 Nov 2022 11:46:00 +0000 (GMT) Received: (qmail 3010 invoked from network); 4 Nov 2022 11:46:00 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 4 Nov 2022 11:46:00 -0000 Date: Fri, 4 Nov 2022 11:45:59 +0000 From: Mel Gorman To: Andrew Morton Cc: NARIBAYASHI Akira , vbabka@suse.cz, rientjes@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] mm, compaction: fix fast_isolate_around() to stay within boundaries Message-ID: <20221104114559.k3gwykhqgfaxv7yf@techsingularity.net> References: <20221026112438.236336-1-a.naribayashi@fujitsu.com> <20221027132557.5f724149bd5753036f41512a@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20221027132557.5f724149bd5753036f41512a@linux-foundation.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 27, 2022 at 01:25:57PM -0700, Andrew Morton wrote: > On Wed, 26 Oct 2022 20:24:38 +0900 NARIBAYASHI Akira wrote: > > > Depending on the memory configuration, isolate_freepages_block() may > > scan pages out of the target range and causes panic. > > > > The problem is that pfn as argument of fast_isolate_around() could > > be out of the target range. Therefore we should consider the case > > where pfn < start_pfn, and also the case where end_pfn < pfn. > > > > This problem should have been addressd by the commit 6e2b7044c199 > > ("mm, compaction: make fast_isolate_freepages() stay within zone") > > but there was an oversight. > > > > Case1: pfn < start_pfn > > > > > > | node X's zone | node Y's zone > > +-----------------+------------------------------... > > pageblock ^ ^ ^ > > +-----------+-----------+-----------+-----------+... > > ^ ^ ^ > > ^ ^ end_pfn > > ^ start_pfn = cc->zone->zone_start_pfn > > pfn > > <---------> scanned range by "Scan After" > > > > Case2: end_pfn < pfn > > > > > > | node X's zone | node Y's zone > > +-----------------+------------------------------... > > pageblock ^ ^ ^ > > +-----------+-----------+-----------+-----------+... > > ^ ^ ^ > > ^ ^ pfn > > ^ end_pfn > > start_pfn > > <---------> scanned range by "Scan Before" > > > > It seems that there is no good reason to skip nr_isolated pages > > just after given pfn. So let perform simple scan from start to end > > instead of dividing the scan into "Before" and "After". > > Under what circumstances will this panic occur? I'd also like to see a warning or oops report combined with the /proc/zoneinfo file of the machine affected. This is to confirm it's an actual bug and not a suspicion based on code inspection and a simplification of the code. The answer determines whether this is a -stable candidate or not. Both Case 1 and 2 require that the initial pfn started outside the zone which is unexpected. The clamping on zone boundary in fast_isolate_aropund() is happening due to pageblock alignment as there is no guarantee that zones are aligned on a hugepage boundary. pfn itself should have been fine as it is the PFN of a page that was recently isolated. The Scan After logic should also be ok. In the context it's called, nr_isolated is the number of pages that were just isolated so pfn + nr_isolated is the end of the free page that was just isolated. The patch itself should be functionally fine but it rescans a region that has already been isolated which is a little wasteful but it is straight-forward and the overhead is probably negligible. -- Mel Gorman SUSE Labs