Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp282238pxj; Fri, 28 May 2021 04:00:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWCM3LHtiIXReBqf7jaO3hptobiDHNWMhZkl+zkbws8NJbJLz+1liSfOyTVPTzRGRyuSky X-Received: by 2002:a05:6602:2407:: with SMTP id s7mr6802889ioa.170.1622199652252; Fri, 28 May 2021 04:00:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622199652; cv=none; d=google.com; s=arc-20160816; b=Z/qP0OH/DxJNMkSVpBjG/SHHTCn58QZUzbi1TL23koQU4t2YE49YdlGWYEpV+mFyiz HaRrnRy0Fs/DSrZPsmtQgWc5Ji3lZMztBkSHTgCwkQjeI8SztC0tuLJvKmsdaRdyK278 iymPIV7DPTBifaiCadkkxA0UurVbAul3aQO4IYGl0Y654RubaHsEe4UjloE5/0UsWHMj M8Zz2ykyd1/fLR9A1eUtA10eSrMhbfr0GCDifUOZ1QNbjsS/rS6Axy4GJoUhl/zWqYvv 0EvDEfteUBd6H5QnlEjVBojtvG61g+3yWekvw+NfS8hvcHq2pRj3SmMFnhGoL2rOTrFS XzeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date; bh=axF5KRhBf9vffaq3QZ5n0fzS5OeTuMuMKwgTo3ZYeCo=; b=pr4A4nyEnJ7IWZQ97y45ekbPNinvrFZhfx2nvPQT2cPNJ4E+q9Xaazu2A95CtSfPM4 bPuthcP2lBHL8Ywu51JSpUHqGjXy69AphNeDmRzsSEvVRDM6x7ifuP7sDLgT9nS72nGQ /Qlf1vP0gun9+vhq2OG9aFBAzDNjOcedg8H5Zm2KYR/SDEEUI8NWJqSV9lsl3pL8OvGw bfnjlf2ro9JJijTA4mC11r975PcPAuBv78gLkBFe5cGlMQ8NGKJ5MzR7uKS0YN+vDi8l cVXF4d/NuqXnyMFgeS+RQnCfqUUaRM5PS2oO4KaPQ3b1BGXJ5WP/FmJxTTBEqhCnIFIb zIRw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si5626482jar.93.2021.05.28.04.00.36; Fri, 28 May 2021 04:00:52 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236611AbhE1LBN (ORCPT + 99 others); Fri, 28 May 2021 07:01:13 -0400 Received: from outbound-smtp31.blacknight.com ([81.17.249.62]:60647 "EHLO outbound-smtp31.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236170AbhE1LBD (ORCPT ); Fri, 28 May 2021 07:01:03 -0400 Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp31.blacknight.com (Postfix) with ESMTPS id 831DAC0B7C for ; Fri, 28 May 2021 11:59:26 +0100 (IST) Received: (qmail 11325 invoked from network); 28 May 2021 10:59:26 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.23.168]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 28 May 2021 10:59:26 -0000 Date: Fri, 28 May 2021 11:59:25 +0100 From: Mel Gorman To: Andrew Morton Cc: Vlastimil Babka , Hillf Danton , Dave Hansen , Michal Hocko , LKML , Linux-MM Subject: [PATCH] mm/page_alloc: Disassociate the pcp->high from pcp->batch -fix Message-ID: <20210528105925.GN30378@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Vlastimil Babka noted that __setup_per_zone_wmarks updating pcp->high did not protect watermark-related sysctl handlers from a parallel memory hotplug operations. This patch moves the PCP update to setup_per_zone_wmarks and updates the PCP high value while protected by the pcp_batch_high_lock mutex. As a side-effect, the zone_pcp_update calls during memory hotplug operations becomes redundant and can be removed. This is a fix to the mmotm patch mm-page_alloc-disassociate-the-pcp-high-from-pcp-batch.patch. It'll cause a conflict with mm-page_alloc-adjust-pcp-high-after-cpu-hotplug-events.patch but the resolution is simple as the zone_pcp_update callers in setup_per_zone_wmarks no longer exist. Signed-off-by: Mel Gorman Acked-by: Vlastimil Babka --- mm/memory_hotplug.c | 6 +++--- mm/page_alloc.c | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 70620d0dd923..974a565797d8 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -961,7 +961,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, struct zone *z node_states_set_node(nid, &arg); if (need_zonelists_rebuild) build_all_zonelists(NULL); - zone_pcp_update(zone); /* Basic onlining is complete, allow allocation of onlined pages. */ undo_isolate_page_range(pfn, pfn + nr_pages, MIGRATE_MOVABLE); @@ -974,6 +973,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, struct zone *z */ shuffle_zone(zone); + /* reinitialise watermarks and update pcp limits */ init_per_zone_wmark_min(); kswapd_run(nid); @@ -1829,13 +1829,13 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages) adjust_managed_page_count(pfn_to_page(start_pfn), -nr_pages); adjust_present_page_count(zone, -nr_pages); + /* reinitialise watermarks and update pcp limits */ init_per_zone_wmark_min(); if (!populated_zone(zone)) { zone_pcp_reset(zone); build_all_zonelists(NULL); - } else - zone_pcp_update(zone); + } node_states_clear_node(node, &arg); if (arg.status_change_nid >= 0) { diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c0536e5d088a..b686344e3889 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8188,12 +8188,6 @@ static void __setup_per_zone_wmarks(void) zone->_watermark[WMARK_LOW] = min_wmark_pages(zone) + tmp; zone->_watermark[WMARK_HIGH] = min_wmark_pages(zone) + tmp * 2; - /* - * The watermark size have changed so update the pcpu batch - * and high limits or the limits may be inappropriate. - */ - zone_set_pageset_high_and_batch(zone); - spin_unlock_irqrestore(&zone->lock, flags); } @@ -8210,11 +8204,19 @@ static void __setup_per_zone_wmarks(void) */ void setup_per_zone_wmarks(void) { + struct zone *zone; static DEFINE_SPINLOCK(lock); spin_lock(&lock); __setup_per_zone_wmarks(); spin_unlock(&lock); + + /* + * The watermark size have changed so update the pcpu batch + * and high limits or the limits may be inappropriate. + */ + for_each_zone(zone) + zone_pcp_update(zone); } /* -- Mel Gorman SUSE Labs