From patchwork Tue Dec 27 12:11:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13082274 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 34A29C4167B for ; Tue, 27 Dec 2022 12:36:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C50B8E0001; Tue, 27 Dec 2022 07:36:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 444FC8E0006; Tue, 27 Dec 2022 07:36:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 136418E0001; Tue, 27 Dec 2022 07:36:38 -0500 (EST) 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 EDC708E0003 for ; Tue, 27 Dec 2022 07:36:37 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C3CA140BAF for ; Tue, 27 Dec 2022 12:36:37 +0000 (UTC) X-FDA: 80288034834.09.8F96FE3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 3FF161C0006 for ; Tue, 27 Dec 2022 12:36:36 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P1lucjZq; spf=pass (imf18.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.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=1672144596; 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=A8ptA+mtJpfx4WDFilLLKvFD1fvtEmfC0YGkopBqCFA=; b=hzmUsXXXU+ZXZgqGgDkSUHFsv9wBgV9HyxfbwFvVtmndvnk6Lj0MNUq0JGIj/X4Bh2As9W besFKMLuM4bH1t1SShNq+KNX2YFz3zymvBy7Yx2Cyw1wON4fedAvcIa/AE1Yckh2xTjiVR rYrsxUJaoOYjSIrbZquOvc/Se2OSt8E= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P1lucjZq; spf=pass (imf18.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.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=1672144596; a=rsa-sha256; cv=none; b=fXsm/mMV7BkMu0DlT2TR/FOB+hJ5Ne3Hc/0BfhuMkCo000MApofMWoc6vIaQ4IKVlUHkEr VXTay+47pO3XHanipcpszZd7pw8hQKQzVxQyHe+kwdDyXjGAgOkBuRf/5052DFDchb+f6M aCkHtbzA2KWdqsenYp73bnYFLxfe3nU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672144595; 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=A8ptA+mtJpfx4WDFilLLKvFD1fvtEmfC0YGkopBqCFA=; b=P1lucjZqSHng4BMKDHfWovm2puO7XSK2+wHkKHb4502oxWDmLCL+VnWZD3V+KNJRUScVrn WQpYfAwUzRuwquLpTpp4smql/R5LCu/A48vblaeUCB1wZ6j/EsmOCPXAOpNg3dpcz98/Uh o2ggPNwrR063i3WAdt3KMRAs99K5DKc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-434-dM8Hsox4PtyMTRv7NbIZzw-1; Tue, 27 Dec 2022 07:36:32 -0500 X-MC-Unique: dM8Hsox4PtyMTRv7NbIZzw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED6432803D61; Tue, 27 Dec 2022 12:36:31 +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 7AA29111F3BB; Tue, 27 Dec 2022 12:36:31 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id B6A704052AA30; Tue, 27 Dec 2022 09:14:52 -0300 (-03) Message-ID: <20221227121341.940831921@redhat.com> User-Agent: quilt/0.66 Date: Tue, 27 Dec 2022 09:11:38 -0300 From: Marcelo Tosatti To: atomlin@atomlin.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, Marcelo Tosatti Subject: [PATCH v12 1/6] mm/vmstat: Add CPU-specific variable to track a vmstat discrepancy References: <20221227121137.102497574@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: 3FF161C0006 X-Stat-Signature: c1erzmscasxp1q1euo665p1wserujanm X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1672144596-358980 X-HE-Meta: U2FsdGVkX1/LE7Zcx8ZZnzS1OCyuxG1ZHVV7lxAYPbBQG/xuKe6vdDrsiACvvUiiT5Qlj+ufGN5MzZK/+Q+FXidnQZefeuq9klT1p9Ej5yzj9QrTTbkzI/nV/KEUdTMMa3x8Oftmr/kn/OL0EGFhVIUQnA9B3e/VvOLQtA8ThnhaXPSIXvSzFxTMqwRWXgIZRvF4qmn/yYSHkLiHSx6kJXMUAwibBCqVttAVC4j8KBQE0Y5pIKE4fsW/dGl7xkdoEMdpBskrIsrQTX/8AS91qKRFV7muBCLf4j6qEzFrnqSmS0ulkSmHuaWujXnBNoYBk1bWmm9uJ44Fggoq9EgJchh2fsH5rfJNmb9q/icsZPithlEuBbaSCYdgG2yjqXBRJJjpoup062eVH9eQL+6HIc/eD4w4vaMIImTjxn1iG98Bn6wOGzMBy3k3I/cQ0FpYEpnFoz/FgNSPZyh9Zonqu3GHdRixVPgZY1TVkq4/V8zq+ZwaGlJK0S1RusSRoWOc8ex+fobivmB9CotrpzR7JdQB6HCpa60AEn8HVk4IeTYHqkOlvFxoi6nx3delwNjGl7U83Pl9mn6mW44RNqGZcl0sCBynJWrUJLJyK5AwywkI1MrzeUznddhLJgIG7ev4tx8vgF8MuiUi0hZOD+E1I0YcVX8jFUA0mUm+lIMU6Rw9yDnl0blEhqYUUSsgwBiM3UwqAVx1ZwWrbrMACT3UdZQCxouPAiQUOziIfNsuB946dYz9wfjJ+lR4byzjTIgt8iMCrn0gFie4c4DGoZ0waxfvAL2heNc/Kq3FMxhLd1Mu2YpAG4OspulByzNOEug0drX9Fh8En5s4zMdJ1w364w6Ky6nFAhwxwa0vARo+ltQ7e2UjF+5SwZaFkYobnOBc 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 Signed-off-by: Marcelo Tosatti --- 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) {