From patchwork Fri Apr 12 12:30:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13627691 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 2690CC4345F for ; Fri, 12 Apr 2024 12:30:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97CFA6B0088; Fri, 12 Apr 2024 08:30:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92C7C6B0089; Fri, 12 Apr 2024 08:30:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CF316B008A; Fri, 12 Apr 2024 08:30:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5E2646B0088 for ; Fri, 12 Apr 2024 08:30:55 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1940940E6B for ; Fri, 12 Apr 2024 12:30:55 +0000 (UTC) X-FDA: 82000814070.10.4C952DF Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf28.hostedemail.com (Postfix) with ESMTP id 47660C0020 for ; Fri, 12 Apr 2024 12:30:53 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=C16OCKrh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712925053; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=UBp2pQhn2lVJ6DLLpM94qL9WNtmqnM/dHEgV5vi8MEs=; b=3wKwhonvv1bezjdKZAp9U94ySByBAtudpbcnZLjJPJHD1FHR/HxBjG7/gaAFACNe2rpZ7s q/iOB1cdMXMBxDKGg8/3ai1uw7PwpS19PcelZHf3wcKiuuIvj6Z6wfX0AfI/qRDGTVe2ay 9pHA7e+3CFAFaIPwleLaIxbBNSXvzU8= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=C16OCKrh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712925053; a=rsa-sha256; cv=none; b=A2jBrSOBvZFHNCz3PYZEFDwAEvJitzN9c0s/VWBI0q9JuRawjWeglF2rNY6PJYZhfBDEiY +1Q4hYzBgqaAevZrskY/mFMcjuSt64y+ZKyKuOal8SQ6XKtYpgQN0XHt2J24iQcLHl6/jF BPXagsCqz06CPaFeyy+0lHAJazb1dZE= Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6ed691fb83eso755750b3a.1 for ; Fri, 12 Apr 2024 05:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712925052; x=1713529852; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UBp2pQhn2lVJ6DLLpM94qL9WNtmqnM/dHEgV5vi8MEs=; b=C16OCKrhJEpwC3OSP6+KCyqx5RMcZtDypXJn1MRhzkrqlWqA45vtiseeWbUnGmlDJw d4JBR4/I37aFlOq+mR2NoMhDUXZAgxhirU1qWCI58dYdtA6UdJOtjOGy+i6V+gcqIk2h P7NHegRc6nZJBnD5UkR1BI9h5C+jYAoqLqK52BBXmNDaBDpdrJaDfhkMV8aGfgIlNRk6 yTfQNoJUcjaMBxVecLRlyIf9Mb2Id0J1EOBejtpyOJHKtfVE9oiUZ5j35J6WjcA0lXu7 1g4PIE93484nSnjfJOQrUb0fcyaMfR8MISdQNCxbNKNRr+gtvnJHVi5JnQvFD47MRxUe BqAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712925052; x=1713529852; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UBp2pQhn2lVJ6DLLpM94qL9WNtmqnM/dHEgV5vi8MEs=; b=hXe02zNUvo36gCLgSp9bfxypsn3Ai2X2gA/sbkJUDJhgTwzKwxl6aUbT5YuWk8jsoe iR4wKVIEEs5Tl/Oq3YRkNO9hNJ9ZOwkGK+TQZ9whMyhYaaMDhWAWe1nIa9ZBgdn+2rXP 0ZdINnDFLsTWVy4kyeIOMcv/vlrPYXOUQ8q0cvzsj5P4qsvQcogm2eXrfLsXBXMBUXLh fs+b7BUCZaLFuNEmbN7Oc8rysYB7TKh7PKA/vbiFGQzbzwNPnGcrLJoKvym0dAwde1i8 cpCPFYm22X2JJj7lI7XZVzHWeuUPwu6iRft+XIATvGCv9PndX0sZ9T+dtvd0u+9hyUEN MgaA== X-Forwarded-Encrypted: i=1; AJvYcCUSuqQQu8YoTxY+nP1T9k9vL5wEDQ0LTKZPcVNzjyzG1YVnvIywJzawaAOqi4HEQuELEhUIyqnqasoNGyxkKZXeQSY= X-Gm-Message-State: AOJu0Yw50KpVzyRNZ1/CVBjgXEVGjky+0njV4bo86zxxoi9vpt27qDid YwfrY4C/dGHK0m7tBWptuJXlq0hC6iEcObnsqhxoVyhLg0dv9NM2 X-Google-Smtp-Source: AGHT+IFIUprURx2SnyjUhwDxV4Bh2nvA3DyQ8qZ4jt626IUF0nOKgdRgq8pciGun9s1GWuqw1O8L/g== X-Received: by 2002:a05:6a20:4309:b0:1a9:9e0f:142b with SMTP id h9-20020a056a20430900b001a99e0f142bmr2619543pzk.39.1712925052106; Fri, 12 Apr 2024 05:30:52 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id g6-20020a1709026b4600b001e520495f51sm2864065plt.124.2024.04.12.05.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 05:30:51 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, willy@infradead.org, vbabka@suse.cz, hannes@cmpxchg.org, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Barry Song , Ryan Roberts Subject: [RFC PATCH] mm/vmstat: sum up all possible CPUs instead of using vm_events_fold_cpu Date: Sat, 13 Apr 2024 00:30:39 +1200 Message-Id: <20240412123039.442743-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 47660C0020 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: q5j4w4q1dkeq93c8oce9ngmadct5ica7 X-HE-Tag: 1712925053-983795 X-HE-Meta: U2FsdGVkX1+sBmaXFvqVW1vtP8SjtKG4M9HZZ4/5BUHMz5/S7KKJHB4094h0PXets2kujL1UqEYTy9oDn1mqPAHkbsQm3scpeepvIkhBNcg/jRh9FWl0ADG4+9qpH8IKvYSjXpTL/s0ncWg82PoQwyrYNW3kJIOII66TQOs7sol4qk8HTsDrp3I9xXdt8OGPjpLCmcJtnMgn/PmhF29qM2O1kmlZzUfsItZo8aEWqgHB+7bVh5aq00cIJj2PEpV1vvb2+jiR2uo4hzxx0o10yCx0JJpKPLovxIy3saIMPcI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iRJt5Htr13ufAT0PtXWlLO7vDlG96dyClFQyX0USarjErvM7i4wHhVsj/X0q1AgjA8NrAGo5UNcJUihHCfGRpmIkqPoE1JyJpQZN/2jhpIn/8NpZJmDj3ZqASjI5CwV4Q6D75bicSXI0rgV0Txr/xOZitWvhdfMCj4hD2un6Qo3PKtPNCU8//Qge7xMOH7kZTE7vO/we3mf6ojknr33EI30TL1D+MTA/922ZUBSGbWIjOUo5kOpNeadZjTEJX4I65BFMX0NS0pi7lYYnCwKwiw== 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: List-Subscribe: List-Unsubscribe: From: Barry Song When unplugging a CPU, the current code merges its vm_events with an online CPU. Because, during summation, it only considers online CPUs, which is a crude workaround. By transitioning to summing up all possible CPUs, we can eliminate the need for vm_events_fold_cpu. Suggested-by: Ryan Roberts Signed-off-by: Barry Song --- -v1: originally suggested by Ryan while he reviewed mTHP counters patchset[1]; I am also applying this suggestion to vm_events [1] https://lore.kernel.org/linux-mm/ca73cbf1-8304-4790-a721-3c3a42f9d293@arm.com/ include/linux/vmstat.h | 5 ----- mm/page_alloc.c | 8 -------- mm/vmstat.c | 19 +------------------ 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 735eae6e272c..f7eaeb8bfa47 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -83,8 +83,6 @@ static inline void count_vm_events(enum vm_event_item item, long delta) extern void all_vm_events(unsigned long *); -extern void vm_events_fold_cpu(int cpu); - #else /* Disable counters */ @@ -103,9 +101,6 @@ static inline void __count_vm_events(enum vm_event_item item, long delta) static inline void all_vm_events(unsigned long *ret) { } -static inline void vm_events_fold_cpu(int cpu) -{ -} #endif /* CONFIG_VM_EVENT_COUNTERS */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b51becf03d1e..640d5752e400 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5832,14 +5832,6 @@ static int page_alloc_cpu_dead(unsigned int cpu) mlock_drain_remote(cpu); drain_pages(cpu); - /* - * Spill the event counters of the dead processor - * into the current processors event counters. - * This artificially elevates the count of the current - * processor. - */ - vm_events_fold_cpu(cpu); - /* * Zero the differential counters of the dead processor * so that the vm statistics are consistent. diff --git a/mm/vmstat.c b/mm/vmstat.c index db79935e4a54..bae6ff476870 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -114,7 +114,7 @@ static void sum_vm_events(unsigned long *ret) memset(ret, 0, NR_VM_EVENT_ITEMS * sizeof(unsigned long)); - for_each_online_cpu(cpu) { + for_each_possible_cpu(cpu) { struct vm_event_state *this = &per_cpu(vm_event_states, cpu); for (i = 0; i < NR_VM_EVENT_ITEMS; i++) @@ -135,23 +135,6 @@ void all_vm_events(unsigned long *ret) } EXPORT_SYMBOL_GPL(all_vm_events); -/* - * Fold the foreign cpu events into our own. - * - * This is adding to the events on one processor - * but keeps the global counts constant. - */ -void vm_events_fold_cpu(int cpu) -{ - struct vm_event_state *fold_state = &per_cpu(vm_event_states, cpu); - int i; - - for (i = 0; i < NR_VM_EVENT_ITEMS; i++) { - count_vm_events(i, fold_state->event[i]); - fold_state->event[i] = 0; - } -} - #endif /* CONFIG_VM_EVENT_COUNTERS */ /*