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 X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5163FC04FF3 for ; Fri, 21 May 2021 21:52:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E71E613EE for ; Fri, 21 May 2021 21:52:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbhEUVyF (ORCPT ); Fri, 21 May 2021 17:54:05 -0400 Received: from mga11.intel.com ([192.55.52.93]:38663 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbhEUVyE (ORCPT ); Fri, 21 May 2021 17:54:04 -0400 IronPort-SDR: Uztdzq2D/SPLu2rXXqyMVzgEfnlAP4Qm5wjEcGO10lDYFMsdWrwsvFk9a2Ix5c5eDg1DOGOTtr Pmmr3X90o21g== X-IronPort-AV: E=McAfee;i="6200,9189,9991"; a="198497400" X-IronPort-AV: E=Sophos;i="5.82,319,1613462400"; d="scan'208";a="198497400" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2021 14:52:40 -0700 IronPort-SDR: bgdQcUbvfsZiNpIBGMqZy6pcr0L3WBePzqj/o9s1GB0guGiI3/nF7oE3dgH5IYOmnJxwAeMFnI CX/LNDq0qwRA== X-IronPort-AV: E=Sophos;i="5.82,319,1613462400"; d="scan'208";a="613395099" Received: from pburton-mobl.amr.corp.intel.com (HELO [10.209.36.169]) ([10.209.36.169]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2021 14:52:39 -0700 Subject: Re: [PATCH 2/6] mm/page_alloc: Disassociate the pcp->high from pcp->batch To: Mel Gorman , Linux-MM Cc: Dave Hansen , Matthew Wilcox , Vlastimil Babka , Michal Hocko , Nicholas Piggin , LKML References: <20210521102826.28552-1-mgorman@techsingularity.net> <20210521102826.28552-3-mgorman@techsingularity.net> From: Dave Hansen Autocrypt: addr=dave.hansen@intel.com; keydata= xsFNBE6HMP0BEADIMA3XYkQfF3dwHlj58Yjsc4E5y5G67cfbt8dvaUq2fx1lR0K9h1bOI6fC oAiUXvGAOxPDsB/P6UEOISPpLl5IuYsSwAeZGkdQ5g6m1xq7AlDJQZddhr/1DC/nMVa/2BoY 2UnKuZuSBu7lgOE193+7Uks3416N2hTkyKUSNkduyoZ9F5twiBhxPJwPtn/wnch6n5RsoXsb ygOEDxLEsSk/7eyFycjE+btUtAWZtx+HseyaGfqkZK0Z9bT1lsaHecmB203xShwCPT49Blxz VOab8668QpaEOdLGhtvrVYVK7x4skyT3nGWcgDCl5/Vp3TWA4K+IofwvXzX2ON/Mj7aQwf5W iC+3nWC7q0uxKwwsddJ0Nu+dpA/UORQWa1NiAftEoSpk5+nUUi0WE+5DRm0H+TXKBWMGNCFn c6+EKg5zQaa8KqymHcOrSXNPmzJuXvDQ8uj2J8XuzCZfK4uy1+YdIr0yyEMI7mdh4KX50LO1 pmowEqDh7dLShTOif/7UtQYrzYq9cPnjU2ZW4qd5Qz2joSGTG9eCXLz5PRe5SqHxv6ljk8mb ApNuY7bOXO/A7T2j5RwXIlcmssqIjBcxsRRoIbpCwWWGjkYjzYCjgsNFL6rt4OL11OUF37wL QcTl7fbCGv53KfKPdYD5hcbguLKi/aCccJK18ZwNjFhqr4MliQARAQABzShEY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qUn3yFj8rwTAU1tluRUYyeLy0ayUlKBH ybj0N71vWO936MqP6haFERzuPAIpxj2ezwu0xb1GjTk4ynna6h5GjnKgdfOWoRtoWndMZxbA z5cecg== Message-ID: <83ddf311-cdfb-34cf-d08f-70590420beff@intel.com> Date: Fri, 21 May 2021 14:52:39 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210521102826.28552-3-mgorman@techsingularity.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/21/21 3:28 AM, Mel Gorman wrote: > Note that in this patch the pcp->high values are adjusted after memory > hotplug events, min_free_kbytes adjustments and watermark scale factor > adjustments but not CPU hotplug events. Not that it was a long wait to figure it out, but I'd probably say: "CPU hotplug events are handled later in the series". instead of just saying they're not handled. > Before grep -E "high:|batch" /proc/zoneinfo | tail -2 > high: 378 > batch: 63 > > After grep -E "high:|batch" /proc/zoneinfo | tail -2 > high: 649 > batch: 63 You noted the relationship between pcp->high and zone lock contention. Larger ->high values mean less contention. It's probably also worth noting the trend of having more logical CPUs per NUMA node. I have the feeling when this was put in place it wasn't uncommon to have somewhere between 1 and 8 CPUs in a node pounding on a zone. Today, having ~60 is common. I've occasionally resorted to recommending that folks enable hardware features like Sub-NUMA-Clustering [1] since it increases the number of zones and decreases the number of CPUs pounding on each zone lock. 1. https://software.intel.com/content/www/us/en/develop/articles/intel-xeon-processor-scalable-family-technical-overview.html > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index a48f305f0381..bf5cdc466e6c 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -2163,14 +2163,6 @@ void __init page_alloc_init_late(void) > /* Block until all are initialised */ > wait_for_completion(&pgdat_init_all_done_comp); > > - /* > - * The number of managed pages has changed due to the initialisation > - * so the pcpu batch and high limits needs to be updated or the limits > - * will be artificially small. > - */ > - for_each_populated_zone(zone) > - zone_pcp_update(zone); > - > /* > * We initialized the rest of the deferred pages. Permanently disable > * on-demand struct page initialization. > @@ -6594,13 +6586,12 @@ static int zone_batchsize(struct zone *zone) > int batch; > > /* > - * The per-cpu-pages pools are set to around 1000th of the > - * size of the zone. > + * The number of pages to batch allocate is either 0.1% Probably worth making that "~0.1%" just in case someone goes looking for the /1000 and can't find it. > + * of the zone or 1MB, whichever is smaller. The batch > + * size is striking a balance between allocation latency > + * and zone lock contention. > */ > - batch = zone_managed_pages(zone) / 1024; > - /* But no more than a meg. */ > - if (batch * PAGE_SIZE > 1024 * 1024) > - batch = (1024 * 1024) / PAGE_SIZE; > + batch = min(zone_managed_pages(zone) >> 10, (1024 * 1024) / PAGE_SIZE); > batch /= 4; /* We effectively *= 4 below */ > if (batch < 1) > batch = 1; > @@ -6637,6 +6628,27 @@ static int zone_batchsize(struct zone *zone) > #endif > } > > +static int zone_highsize(struct zone *zone) > +{ > +#ifdef CONFIG_MMU > + int high; > + int nr_local_cpus; > + > + /* > + * The high value of the pcp is based on the zone low watermark > + * when reclaim is potentially active spread across the online > + * CPUs local to a zone. Note that early in boot that CPUs may > + * not be online yet. > + */ FWIW, I like the way the changelog talked about this a bit better, with the goal of avoiding background reclaim even in the face of a bunch of full pcp's. > + nr_local_cpus = max(1U, cpumask_weight(cpumask_of_node(zone_to_nid(zone)))); > + high = low_wmark_pages(zone) / nr_local_cpus; I'm a little concerned that this might get out of hand on really big nodes with no CPUs. For persistent memory (which we *do* toss into the page allocator for volatile use), we can have multi-terabyte zones with no CPUs in the node. Also, while the CPUs which are on the node are the ones *most* likely to be hitting the ->high limit, we do *keep* a pcp for each possible CPU. So, the amount of memory which can actually be sequestered is num_online_cpus()*high. Right? *That* might really get out of hand if we have nr_local_cpus=1. We might want some overall cap on 'high', or even to scale it differently for the zone-local cpus' pcps versus remote.