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 1CC65C3271E for ; Fri, 5 Jul 2024 20:59:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A24446B009B; Fri, 5 Jul 2024 16:59:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AD6D6B009E; Fri, 5 Jul 2024 16:59:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84DDC6B009F; Fri, 5 Jul 2024 16:59:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 64CEC6B009B for ; Fri, 5 Jul 2024 16:59:19 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CD778C0382 for ; Fri, 5 Jul 2024 20:59:18 +0000 (UTC) X-FDA: 82306914396.18.10D5A64 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf04.hostedemail.com (Postfix) with ESMTP id 9FDC84000C for ; Fri, 5 Jul 2024 20:59:16 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=cX2laUmq; dmarc=none; spf=pass (imf04.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720213137; a=rsa-sha256; cv=none; b=w7Mw+4FD2UtwBETZs+rRz3pk9Izhdn07oz4UOo18pzRJkI/M6ZARppHH/oaMAh5DApQOy6 2oyVWjLmUQ5hHwyWI96nK/RtF1qjG1Qe83fo0Bq1c8A6Hy3N9NHmS9IUP8Ah6mrZdoQac0 oDn//u6CBzWnSdvzz9i9ubrrsC++utQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=cX2laUmq; dmarc=none; spf=pass (imf04.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720213137; h=from:from:sender: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:dkim-signature; bh=aKOkIMu2iOAUQl0lNfZhaedcxQj1RUeteRotvbVoSI4=; b=wERJPZcMHuo6bjkRo0LXxIzTvnmRY8cTrD7b1CAX0DFbvSA3WvqdodDQ4mgWx9TSTbLzEi O+7q6bkvuF4t0Ndn6+1JfsUgP1fJcNqp5rsshtN18SiqRTapWeX62BMwNnG3fdktRJArQy laWKM84ifn+ZGIoZrktR+ML0niIitvg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 27C1ACE3F30; Fri, 5 Jul 2024 20:59:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44B7FC116B1; Fri, 5 Jul 2024 20:59:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1720213152; bh=0grfUY/O+w2jvNUQdMGCDfoJk9yIgsZwGnLPHBTNo3Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cX2laUmqC9LHOCBPtEyNj+HX7bYu9jugElfXAppLd8JVmdk9bnrIIVsQIi/sKN32g 9VFOSfJX+DytaVJXmh8pK5NLkd1By7T9S8WIYcQti69H/CiMmXlnVBcCfRHMP0PEXr ldxLBs2iqAKZWN2pdN16McvfYSONf4lHtoEubv5Q= Date: Fri, 5 Jul 2024 13:59:11 -0700 From: Andrew Morton To: Saurabh Sengar Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, ssengar@microsoft.com, wei.liu@kernel.org Subject: Re: [PATCH] mm/vmstat: Defer the refresh_zone_stat_thresholds after all CPUs bringup Message-Id: <20240705135911.4a6e38379ae95c3fc6bbe7e2@linux-foundation.org> In-Reply-To: <1720169301-21002-1-git-send-email-ssengar@linux.microsoft.com> References: <1720169301-21002-1-git-send-email-ssengar@linux.microsoft.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 9FDC84000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: xe5x519pi333p3wykdfkas6ojzcxkzcb X-HE-Tag: 1720213156-298032 X-HE-Meta: U2FsdGVkX1/bhFlYH17ke5V5iwxSXBfaEeWS2eAYeImL/g2FpMYsxKH2+79+yby4yoBJTMUro1RAMhjC50ucoGeE9HjSB9HcEkht5bKLqQEKrQ8QTxfjHOPBgM2Ardi43Ly0v6Bnr61mTltnQ3o/kHrCgDrqxRUsf2tgUh3k5ks+F/mvRiT5ZiLclj4FBJNzpX4GtNZxMcKfHCdUrZ7tUM7EJYZ5mGOU1OtyiC0momJ5uOdP6ldoFYbArNF/CEbp0FGRWs0H4tPKVPhOCASlkKpTHwNjZ36OeVEUmEbZmqERgyTlvzLcIFtPF3tSIFW87yabj6rH7NYH7KwgezzzaFPembv2UXNXRtUUo81ukTXzvkmI+TDSZgVs8eYFwXQRmm9CUw5HbRssLinZ8MC+cjw1wR/3oevUGdS+xlAC+mRzuNMB5dFf4M8sB8MfdAvUrVNlGwbk28Fn5tvI5hp+uZ6la2RbGUVy9Gg7tkPz4MIea0Dfb8dgBjOtr/f2qX/GgaTnPRjxYlVv5umwBQXPnpL5Jt1HTG12JYk100IkAZYBJe0rRN4g/v6onhK1LS+jMtMBeTbEV5byqLzaM1o9j3EXsBFqI0lscqny7vgDZT1xqssgGBRKhHRoraoBPChW1phDvA7Vk+fotDQspKRVeDyXXtLRyP96x0Wc9rUpYEoU/Bosy9VcpxcwYNBszI1CueR3/JgvKcxD+0HsW4lJewxZO91ya4O0tco3dbY9mjy75oSQRnDldVYv/W+gXpvLbbH8gMbBaaCvVBYKY8JB1KUWCAIjXzv13HGjw5VxOU724SOC/5A+MdBo7W46rNj04wroPBr6Opl4e/7Wg1nb+XJYwzXVhmZjoPpIJaOiom4GWK41+enrbeswSDO72mL7KQ6pEIVIHdqBB4MkUqTkyAI6duGQxngXW6wFRHrUaxxrEhrnsJ0bqBoVGqqIGNAVI/7PTMJsKCcF0Vz6FG8 esiSixsZ X6eAZwOjfIkmERxHO+n1oWHowuDyuWqPcfoR9oHnrOA5591oie6vVeJFZIVXP7jiMm9KjXQeG1G0bAUPfaIHjjl7iU0KOHJhccOdrBqhh0m90/L/56Haz/lC7VUzamoDgSpgxlXijA9/KFhD7NLT8HFgUrUk0BAEpws2hOjRnYKHriTANP6fjzLkxtDI7dwSw1I2zAByx8NxJ6+tRdl96uiFsY6WVzjFu1Y0ePGkbzJy+B1V+3Y6EjeL3tP34uLK331aPRSl6yvFBwLrfDPCDVEFIbgdvFvpyUbjd X-Bogosity: Ham, tests=bogofilter, spamicity=0.000010, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, 5 Jul 2024 01:48:21 -0700 Saurabh Sengar wrote: > refresh_zone_stat_thresholds function has two loops which is expensive for > higher number of CPUs and NUMA nodes. > > Below is the rough estimation of total iterations done by these loops > based on number of NUMA and CPUs. > > Total number of iterations: nCPU * 2 * Numa * mCPU > Where: > nCPU = total number of CPUs > Numa = total number of NUMA nodes > mCPU = mean value of total CPUs (e.g., 512 for 1024 total CPUs) > > For the system under test with 16 NUMA nodes and 1024 CPUs, this > results in a substantial increase in the number of loop iterations > during boot-up when NUMA is enabled: > > No NUMA = 1024*2*1*512 = 1,048,576 : Here refresh_zone_stat_thresholds > takes around 224 ms total for all the CPUs in the system under test. > 16 NUMA = 1024*2*16*512 = 16,777,216 : Here refresh_zone_stat_thresholds > takes around 4.5 seconds total for all the CPUs in the system under test. Did you measure the overall before-and-after times? IOW, how much of that 4.5s do we reclaim? > Calling this for each CPU is expensive when there are large number > of CPUs along with multiple NUMAs. Fix this by deferring > refresh_zone_stat_thresholds to be called later at once when all the > secondary CPUs are up. Also, register the DYN hooks to keep the > existing hotplug functionality intact. > Seems risky - we'll now have online CPUs which have unintialized data, yes? What assurance do we have that this data won't be accessed? Another approach might be to make the code a bit smarter - instead of calculating thresholds for the whole world, we make incremental changes to the existing thresholds on behalf of the new resource which just became available?