From patchwork Thu Feb 3 02:00:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12733754 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 B1529C433F5 for ; Thu, 3 Feb 2022 02:00:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C468D8D0119; Wed, 2 Feb 2022 21:00:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF5636B0393; Wed, 2 Feb 2022 21:00:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABD2B8D0119; Wed, 2 Feb 2022 21:00:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 9AB326B0392 for ; Wed, 2 Feb 2022 21:00:32 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 607ED120CB1 for ; Thu, 3 Feb 2022 02:00:32 +0000 (UTC) X-FDA: 79099814304.03.1D59790 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by imf25.hostedemail.com (Postfix) with ESMTP id 2C007A0002 for ; Thu, 3 Feb 2022 02:00:32 +0000 (UTC) Received: by mail-ej1-f44.google.com with SMTP id a8so3234778ejc.8 for ; Wed, 02 Feb 2022 18:00:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=lxWBwGKgTWaFZT5siy9MmYF0wpXs3bDIfO+VSmkVhOs=; b=VrvDepaPiHZBFur4A33iJd7uY8YvKRz8K13whFn26G2dh3BG1TB1GYdcf4fivbkGM+ FhAZ9/s8ZI3gSAug+BEPoRid87hyp1BFgDfwqFASb80T9nG180nndYiQ/JsQ8f7ThMlf 2EOuSaRUI1q/wqV5PFXKWQnyt9NfSRvM8YuSzzgM/xrXsAi4WQqWmUxHXrmmsHBqimJ9 GzGQfT7B4m1bfBCuXYu9Q4VApQ7mRu5gXgbwvKEjT7X4CXLavN0xx7f1LKqYaWaFtWGz KpSiNQKz2MoVBo9+81J5QxFkLHOnPvKMHZL5hoh336V5VfvFwt2cEPdKBspMsQ9fVhux XYDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lxWBwGKgTWaFZT5siy9MmYF0wpXs3bDIfO+VSmkVhOs=; b=hBNOFuQv/SDUfE5TLXPlMaf9NsK/BWu0L05PIzte/H+9DgE7Y4uHfyOGFkf1jxtOJj U02TK1kt6k+ZLXxoR7huGL00/vXYzpQWkZcJWRj6Uxgag2z9DmxUvOFo/FDPlw14t6S8 9Z5ri8Qv2Yu6AbkEImeINVyBYdFVDP4k99ZGBew2P/xXsuLA+g7V4DZE2bOJNCTltFGJ 9CqPeDUv6qiCYm+oULVdQIS4Rrl34nFjG5s+HqN6ib6fKHQnBcqAMRUPeoeGZnWnXBb2 bp7e/QfNcUghf9VrUhsKzO2a5IeroIiNWrYNAVg7sC+3j1y4Bfw0iKYuUaG2pimPW/Mw 79/Q== X-Gm-Message-State: AOAM5335kJ+jMH63ZV3NmmsxpH156JI+g6iGPolQnHkUS3eMXBg+dn+Y Vqadnyv+kO0UlD9rgIltCPU= X-Google-Smtp-Source: ABdhPJzvG6IRe7QL1vHJcF2neabtJs69d92CVoL8a7zGs/RBvP33L1IALDJyeVmzuBgEl4AeTKEn+Q== X-Received: by 2002:a17:907:c20:: with SMTP id ga32mr27273669ejc.638.1643853630831; Wed, 02 Feb 2022 18:00:30 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id rv28sm15884487ejb.71.2022.02.02.18.00.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 Feb 2022 18:00:30 -0800 (PST) From: Wei Yang To: akpm@linux-foundation.org, mhocko@suse.com, mgorman@techsingularity.net Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang , David Hildenbrand Subject: [PATCH] mm/page_alloc: add zone to zonelist if populated Date: Thu, 3 Feb 2022 02:00:22 +0000 Message-Id: <20220203020022.3044-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Stat-Signature: 3zennwdrqruypjf8tdb3eonbjwxxywbp X-Rspam-User: nil Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=VrvDepaP; spf=pass (imf25.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.44 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2C007A0002 X-HE-Tag: 1643853632-415950 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: During memory hotplug, when online/offline a zone, we need to rebuild the zonelist for all nodes. Current behavior would lose a valid zone in zonelist since only pick up managed_zone. There are two cases for a zone with memory but still !managed. * all pages were allocated via memblock * all pages were taken by ballooning / virtio-mem This state maybe temporary, since both of them may release some memory. Then it end up with a managed zone not in zonelist. This is introduced in 'commit 6aa303defb74 ("mm, vmscan: only allocate and reclaim from zones with pages managed by the buddy allocator")'. This patch restore the behavior. Signed-off-by: Wei Yang CC: Mel Gorman CC: David Hildenbrand Fixes: 6aa303defb74 ("mm, vmscan: only allocate and reclaim from zones with pages managed by the buddy allocator") --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index de15021a2887..b433a57ee76f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6092,7 +6092,7 @@ static int build_zonerefs_node(pg_data_t *pgdat, struct zoneref *zonerefs) do { zone_type--; zone = pgdat->node_zones + zone_type; - if (managed_zone(zone)) { + if (populated_zone(zone)) { zoneref_set_zone(zone, &zonerefs[nr_zones++]); check_highest_zone(zone_type); }