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 867AEC433EF for ; Tue, 12 Apr 2022 22:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbiDLWbw (ORCPT ); Tue, 12 Apr 2022 18:31:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiDLWb3 (ORCPT ); Tue, 12 Apr 2022 18:31:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E6B935857 for ; Tue, 12 Apr 2022 14:16:51 -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 80C6A61C58 for ; Tue, 12 Apr 2022 20:59:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E136C385A5; Tue, 12 Apr 2022 20:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1649797153; bh=uOj1EWKfp5MbqFPddwn3qYnZPGLBfwLvKU5JMyCXO24=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=q+3BNwbhWqkqibwxCe3UjkkhP7AbmEqGgm29CifeVvXrVG7BAh9jboSLyIgroSuct Tj3ohffGqKfpaPBXU44v99VxIDg2vogFB8CvqaFWbe4TNwaxUiiQzkIpr5t68Ie8fc 2P41Y2YwstHn2Gd+tHNJ8nbrnIidz2n7We0HT7FM= Date: Tue, 12 Apr 2022 13:59:12 -0700 From: Andrew Morton To: Sudarshan Rajagopalan Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport , Anshuman Khandual , Suren Baghdasaryan Subject: Re: [PATCH] mm, page_alloc: check pfn is valid before moving to freelist Message-Id: <20220412135912.93175db2ab4e83f4bb060dbf@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Apr 2022 13:16:23 -0700 Sudarshan Rajagopalan wrote: > Check if pfn is valid before or not before moving it to freelist. > > There are possible scenario where a pageblock can have partial physical > hole and partial part of System RAM. This happens when base address in RAM > partition table is not aligned to pageblock size. > > ... > > > Signed-off-by: Sudarshan Rajagopalan > Fixes: 4c7b9896621be ("mm: remove pfn_valid_within() and CONFIG_HOLES_IN_ZONE") I made that 859a85ddf90e714092dea71a0e54c7b9896621be and added cc:stable. I'll await reviewer input before proceeding further. > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -2521,6 +2521,11 @@ static int move_freepages(struct zone *zone, > int pages_moved = 0; > > for (pfn = start_pfn; pfn <= end_pfn;) { > + if (!pfn_valid(pfn)) { Readers will wonder how we can encounter an invalid pfn here. A small comment might help clue them in. > + pfn++; > + continue; > + } > + > page = pfn_to_page(pfn); > if (!PageBuddy(page)) { > /*