Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4844pxb; Mon, 31 Jan 2022 03:52:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNjK2G9mlYCWP6yKDiVgZvly8hn4BpT6024781Jg/oo/s3uYeqAs0TIsRkrru+FVfHIkKf X-Received: by 2002:a17:902:ec86:: with SMTP id x6mr20731511plg.96.1643629961105; Mon, 31 Jan 2022 03:52:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643629961; cv=none; d=google.com; s=arc-20160816; b=sPs1gf+WZMkLAztpcgY/5hVEMIHwFM6HwwMyWIf7Zv6dVKCUYaxkrnPZQjgituW66D O/EX3LFe2r06N/n64GhII7ANKcPcy6srIhSfDexsMLUfTDe6LN3mAH0tDyMOF9LRLJH7 iWrka4ebTkIivt0+kV/2HGpklWRcIpKcMoz06MmXW7T4H5tc4YmxG9UNmguOvSq4OHcf eZ6j39qnr9rnKe5B7iKkgI0gVCocPpvmU8j619Yvi8+a8XR11QOsDbGaWAk3Y0+Jq5Q/ ycl2nxe87sdM+xqY7SZ4HnnvyY5OmvcKPYnzfNug+6TAFxbNi/CFfkh5kNgHMFFzPw+0 aswA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=DzlKGdu63oR5Np89nKMxqPFykzScyAGBA+0JycwAsUY=; b=zhldv3dXFSvK++kYA5JcPyaldXf9ULsylNzp9K6o39CdqG3NJv8k2dKIu1teMpVTSR dhBsx96lt4XVx4jDCuL+HXQJIkO2j7YQIBMNWx1PDDjnJ/5NHqjynTkDsu7E7j/FmIHi k4ZiHZ+StJrZsebuAzofNmO4LRlI5V4niV2vo96UGo/GRT/2HiP3auZNmU7xCJ/x+wyw VTfF5v4PcFcozD3QhLPEYaxEgKII2GQxb9EZaJagLmIfbDz3VPbNgh0Ls67zmfLVfsWR k+CGtk/nFNRZnaD1a15pqX++ohVoWtKee7O1kZnY2KyInWL8m7Z7Urd0NWyprrGIv1up TqXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=e5pWhHvh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v27si13803645pga.21.2022.01.31.03.52.29; Mon, 31 Jan 2022 03:52:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=e5pWhHvh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235594AbiA2A1m (ORCPT + 99 others); Fri, 28 Jan 2022 19:27:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344709AbiA2A1l (ORCPT ); Fri, 28 Jan 2022 19:27:41 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E733DC061714 for ; Fri, 28 Jan 2022 16:27:40 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id u24so13058122eds.11 for ; Fri, 28 Jan 2022 16:27:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=DzlKGdu63oR5Np89nKMxqPFykzScyAGBA+0JycwAsUY=; b=e5pWhHvhSjsub44oqXp71+F6yp3o0iasEVgUl3tMiNyMhFZh6PPZur6H+E8xPpVXPu xvPloJ6qhhQWB0QuSpGR4JogJcMY7a/MT3ex3V1O5weKwVwhP3a1hQ9yXAo1suVQJksR Jv4kvfYKBAQTe2Z5kK37ecw3EbiwRdxIUefJ/WTcOrQ+XqTmvXDxZU7v9NSa50UPAGTU n3P9Cmm0EwPJbeVFH6St8toBJetsFQaF+QR3N4DuKu3jZhhXgcV2nGDNzR0LWMieQHSF 9IewkQcVt0WV3WTwo39GvtxwoNdNxfp/o1JYpoi4BTzxFYjJagBBN6c0uU9FWOTF5Fq6 L02A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=DzlKGdu63oR5Np89nKMxqPFykzScyAGBA+0JycwAsUY=; b=gLUeIVZG3oKvXG2P31jhklQ14gyi8DA1cjOMi/6CXaKKC/1Vi0Sj6aRENXz4lHk1mv Agb+PbzXqNZZCH+loL1Yu13e6OQDnmSEt5R43qUdEK/0dw+KkXb7FnD0e9C14W1XsVY9 GxmeHESYR18XDqwg8xLypgvzAuic1oiemBRvAR4DfzoY2tEy1Fuo9bPMD8V6l61tPDhF RMbzkD5DN2uF5WFxW0Cn9/pMpneeYV50aAJvszfZWNKjpOUvgdrCmv1ody2FRFdIU6s1 Y1C0aKSoav8dIy3QnKBx7cETbKeRRiEObza7+ldZtGEqy2YoUvXZHtzr/aQ+ZmozMuWJ es2g== X-Gm-Message-State: AOAM532u8hMj2LuhzQhPFQPFMJDRXUGlJb4nn49NFFTPSSLScO96hZFM AqYLjBP6m8gsU5Bn6G2mqrA= X-Received: by 2002:a05:6402:1ac5:: with SMTP id ba5mr10591620edb.337.1643416059486; Fri, 28 Jan 2022 16:27:39 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id d16sm10385885ejy.135.2022.01.28.16.27.39 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jan 2022 16:27:39 -0800 (PST) Date: Sat, 29 Jan 2022 00:27:38 +0000 From: Wei Yang To: David Hildenbrand Cc: Wei Yang , akpm@linux-foundation.org, mgorman@techsingularity.net, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/memory_hotplug: build zonelist for managed_zone Message-ID: <20220129002738.ofoewhgb4mwfwqfj@master> Reply-To: Wei Yang References: <20220127012023.18095-1-richard.weiyang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 27, 2022 at 09:39:56AM +0100, David Hildenbrand wrote: >On 27.01.22 02:20, Wei Yang wrote: >> During memory hotplug, when online/offline a zone, we need to rebuild >> the zonelist for all node. There are two checks to decide whether a zone >> would be added to zonelist: >> >> * one in online_pages/offline_pages to decide necessity >> * one in build_zonerefs_node to do real add >> >> Currently we use different criteria at these two places, which is >> different from the original behavior. >> >> Originally during memory hotplug, zonelist is re-built when zone hasn't >> been populated. This in introduced in 'commit 6811378e7d8b ("[PATCH] >> wait_table and zonelist initializing for memory hotadd: update zonelists")'. >> And at that moment, build_zonelists_node() also use populated_zone() to >> decide whether the zone should be added to zonelist. >> >> While in 'commit 6aa303defb74 ("mm, vmscan: only allocate and reclaim >> from zones with pages managed by the buddy allocator")', >> build_zonelists_node() changed to use managed_zone() to add zonelist. >> But we still use populated_zone() to decide the necessity. >> >> This patch restore the original behavior by using the same criteria to >> add a zone in zonelist during memory hotplug. >> >> Signed-off-by: Wei Yang >> Fixes: 6aa303defb74 ("mm, vmscan: only allocate and reclaim from zones with pages managed by the buddy allocator") >> CC: Mel Gorman >> --- >> mm/memory_hotplug.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c >> index 2a9627dc784c..8f1906b33937 100644 >> --- a/mm/memory_hotplug.c >> +++ b/mm/memory_hotplug.c >> @@ -1102,11 +1102,11 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, >> spin_unlock_irqrestore(&zone->lock, flags); >> >> /* >> - * If this zone is not populated, then it is not in zonelist. >> + * If this zone is not managed, then it is not in zonelist. >> * This means the page allocator ignores this zone. >> * So, zonelist must be updated after online. >> */ >> - if (!populated_zone(zone)) { >> + if (!managed_zone(zone)) { >> need_zonelists_rebuild = 1; >> setup_zone_pageset(zone); >> } >> @@ -1985,7 +1985,7 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages, >> /* reinitialise watermarks and update pcp limits */ >> init_per_zone_wmark_min(); >> >> - if (!populated_zone(zone)) { >> + if (!managed_zone(zone)) { >> zone_pcp_reset(zone); >> build_all_zonelists(NULL); >> } > >A note that managed_zone() is a moving target w.r.t. memory ballooning. >In extreme cases, we can have whole zones (temporarily) be completely >!managed for that reason. > >IMHO memory hot(un)plug is usually the wrong place to check for >managed_zone(), it cares about populated_zone(). > So we need to check populated_zone when building zonelist? >-- >Thanks, > >David / dhildenb -- Wei Yang Help you, Help me