From patchwork Tue Dec 6 16:18:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13066178 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 32E18C352A1 for ; Tue, 6 Dec 2022 17:19:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB1018E0003; Tue, 6 Dec 2022 12:19:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A3A618E0001; Tue, 6 Dec 2022 12:19:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DB278E0003; Tue, 6 Dec 2022 12:19:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7AD558E0001 for ; Tue, 6 Dec 2022 12:19:46 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 43808120D92 for ; Tue, 6 Dec 2022 17:19:46 +0000 (UTC) X-FDA: 80212543572.26.A849D7D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id EBCCD40018 for ; Tue, 6 Dec 2022 17:19:44 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PHn2Q33M; spf=pass (imf17.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670347185; 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:in-reply-to: references:references:dkim-signature; bh=AOGSNl4F+a3U3QMjdXFvMaoAelsGXf+7OuteK4kgbOQ=; b=081iwsLQq41N62axlPl46PD7hGayfG8WEOORTwzUfJPvFuK1m7hLwxkRm7RpeQpetO3OwP t6oIpIWZzPCsrw1be2XgwWb9a633AriDR+FqiXr8KmqmvGjm+aU8A+YHiS6dhswbHpY5qM suSk2jAMn0SQ96f5XZc+hp7bw4YVs+w= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PHn2Q33M; spf=pass (imf17.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670347185; a=rsa-sha256; cv=none; b=V2Dkgdam6nvOuNSkAzxvtEgArxzZnduNO4g8a2lT7qJPLpRuI6Jr6iv29dkFlm4GUZe0/B xx+3e27XyvZe5dAEogjxEs6oPMLrKgjJ+pSsNZmq6eVVvOVoaac78kcov0KhnX6kgP7NNq shC5NrY8Hdajy2X2wGRghBD/fQzJeKE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670347184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=AOGSNl4F+a3U3QMjdXFvMaoAelsGXf+7OuteK4kgbOQ=; b=PHn2Q33MixFuqdDyGUWyJl4aMrtgpgw72dywPcLzl0p8Op/onbaNr55DUpG0X4uAr4/HL2 vpVoOofRSXLHJFZTQB0soQblnfg5pufCalF3Z9Xfwi650HcWeIXVVJx1vmzgtsPSxeUZpX r+0fui7qlGUNEsMRRmr5n0DWiOvBBJw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-77-72YglCZgPLy4WsvxS_4UwQ-1; Tue, 06 Dec 2022 12:19:43 -0500 X-MC-Unique: 72YglCZgPLy4WsvxS_4UwQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0959D886469; Tue, 6 Dec 2022 17:19:42 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7885149BB60; Tue, 6 Dec 2022 17:19:41 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id C26B1409005D6; Tue, 6 Dec 2022 13:31:40 -0300 (-03) Message-ID: <20221206162416.404740300@redhat.com> User-Agent: quilt/0.66 Date: Tue, 06 Dec 2022 13:18:27 -0300 From: Marcelo Tosatti To: atomlin@redhat.com, frederic@kernel.org Cc: cl@linux.com, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, pauld@redhat.com, neelx@redhat.com, oleksandr@natalenko.name, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v9 1/5] mm/vmstat: Add CPU-specific variable to track a vmstat discrepancy References: <20221206161826.698593151@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EBCCD40018 X-Rspam-User: X-Stat-Signature: kycje7u8mhkcp8eguy97exdit5jmbgjq X-Spamd-Result: default: False [-6.84 / 9.00]; BAYES_HAM(-5.94)[99.88%]; DMARC_POLICY_ALLOW(-0.50)[redhat.com,none]; R_DKIM_ALLOW(-0.20)[redhat.com:s=mimecast20190719]; R_SPF_ALLOW(-0.20)[+ip4:170.10.129.0/24]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_SEVEN(0.00)[11]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[redhat.com:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; ARC_SIGNED(0.00)[hostedemail.com:s=arc-20220608:i=1]; RCVD_COUNT_FIVE(0.00)[5]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_NONE(0.00)[]; ARC_NA(0.00)[] X-HE-Tag: 1670347184-623317 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: From: Aaron Tomlin Introduce a CPU-specific variable namely vmstat_dirty to indicate if a vmstat imbalance is present for a given CPU. Therefore, at the appropriate time, we can fold all the remaining differentials. This patch also provides trivial helpers for modification and testing. Signed-off-by: Aaron Tomlin --- mm/vmstat.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) Index: linux-2.6/mm/vmstat.c =================================================================== --- linux-2.6.orig/mm/vmstat.c +++ linux-2.6/mm/vmstat.c @@ -194,6 +194,22 @@ void fold_vm_numa_events(void) #endif #ifdef CONFIG_SMP +static DEFINE_PER_CPU_ALIGNED(bool, vmstat_dirty); + +static inline void vmstat_mark_dirty(void) +{ + this_cpu_write(vmstat_dirty, true); +} + +static inline void vmstat_clear_dirty(void) +{ + this_cpu_write(vmstat_dirty, false); +} + +static inline bool is_vmstat_dirty(void) +{ + return this_cpu_read(vmstat_dirty); +} int calculate_pressure_threshold(struct zone *zone) {