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 B2786C433EF for ; Mon, 31 Jan 2022 10:53:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E4756B0071; Mon, 31 Jan 2022 05:53:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 393D86B0073; Mon, 31 Jan 2022 05:53:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25BEA6B0074; Mon, 31 Jan 2022 05:53:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay029.a.hostedemail.com [64.99.140.29]) by kanga.kvack.org (Postfix) with ESMTP id 11E226B0071 for ; Mon, 31 Jan 2022 05:53:44 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C5D9760F41 for ; Mon, 31 Jan 2022 10:53:43 +0000 (UTC) X-FDA: 79090271526.01.AD22B3D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 44F0C20009 for ; Mon, 31 Jan 2022 10:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643626422; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZJSmtJHqRe6UWSawn0lfqQ7m14tlGuxizEluP0CLcAc=; b=M2B4KmxwAHsZkRgFxSvODpm/J9oz1GSbJnsOZL4BTsLjFwee0pH+IDvth3h3WpClf5l9vz lUZp1QgdkzkcGItOT9/YdMuxP73IaVscCm9X7bCVWu1qPF5EiL2hXVOlC/3JOcRvehmgza inuR+CVW2nXr288UeekImWkZaldeZtg= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-672-Za_e7gDxPPONgcAC5EX2hA-1; Mon, 31 Jan 2022 05:53:38 -0500 X-MC-Unique: Za_e7gDxPPONgcAC5EX2hA-1 Received: by mail-ed1-f69.google.com with SMTP id i22-20020a0564020f1600b00407b56326a2so6759524eda.18 for ; Mon, 31 Jan 2022 02:53:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=ZJSmtJHqRe6UWSawn0lfqQ7m14tlGuxizEluP0CLcAc=; b=xBIq5Lp8j88+QN3qelmU+HjqSNXD3A5/Gz8GEJPb2JNWYYFOJcL1kZsLcPefP39dFC /qW/Lm2TeW4Ahc46Ym2jFeJrPGRmQ6gT4D7v4vJHm7NYxBncHv36MJ8Ut6uVVKSqoCCY vFtmgnz159cHTlHwwpVjboxq/+HsM4zzh6wbebTWZn/FMRy2JSKhUjFCARO+8mC9D5sL SKO3p50k9GbGoyNMJEgD7oUfi+y6b1R1lEPzS/wUpL4Ysp9va86OrHidnhNeYil4+5IV 1cExO3ln/kknyZ+u2lp9866jd0QMZ/kP2fDycC6bpuvgf+R6NfkHaXqefsb6tGbv3qP5 aIOg== X-Gm-Message-State: AOAM531+EBjqJQzEQEMvgQF6ibRe4fDbplTbBwtXWvidbgh1JM7uCoMH 72o3iOYa5HhfqAtDfc0idq3zs8zj6u8M8ud7E6l1T3r7rz8ecNfZ93FKb8HtcGXPGaxmS2nxkkV x8ki42r3lXS4= X-Received: by 2002:a17:907:168b:: with SMTP id hc11mr16922493ejc.676.1643626417423; Mon, 31 Jan 2022 02:53:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwiuoBf/CdDeAJ2fRaf8To9VDeqG7nGDfM2XYzvI4L7KxNtIpltzTcQIVY2KEhypriRTptmLg== X-Received: by 2002:a17:907:168b:: with SMTP id hc11mr16922467ejc.676.1643626417146; Mon, 31 Jan 2022 02:53:37 -0800 (PST) Received: from ?IPV6:2003:cb:c709:b200:f007:5a26:32e7:8ef5? (p200300cbc709b200f0075a2632e78ef5.dip0.t-ipconnect.de. [2003:cb:c709:b200:f007:5a26:32e7:8ef5]) by smtp.gmail.com with ESMTPSA id w22sm5646209ejc.137.2022.01.31.02.53.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Jan 2022 02:53:36 -0800 (PST) Message-ID: Date: Mon, 31 Jan 2022 11:53:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH] mm/memory_hotplug: build zonelist for managed_zone To: Wei Yang Cc: akpm@linux-foundation.org, mgorman@techsingularity.net, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220127012023.18095-1-richard.weiyang@gmail.com> <20220129002738.ofoewhgb4mwfwqfj@master> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220129002738.ofoewhgb4mwfwqfj@master> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 44F0C20009 X-Stat-Signature: s45eetr7psr83m1mhco36ig3m465e4qd Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M2B4Kmxw; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf03.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-Rspam-User: nil X-HE-Tag: 1643626423-260142 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: On 29.01.22 01:27, Wei Yang wrote: > 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? I think the issue is that a) We can have zones without any managed pages put present page during boot, for example, if all pages in the zone were allocated via memblock. b) We can have zones without any managed pages temporarily -- extreme cases of memory ballooning / virtio-mem. I tend to think that populated_zone() might actually be the right check whenever building a zonelist. Because even in case of a) we might end up freeing a memblock allocation later, suddenly having free pages in such a zone, but the zone not in any zonelist. -- Thanks, David / dhildenb