From patchwork Thu Jan 5 12:52:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13089802 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 5CDEFC3DA7A for ; Thu, 5 Jan 2023 12:56:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DECC8E0002; Thu, 5 Jan 2023 07:56:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 790538E0001; Thu, 5 Jan 2023 07:56:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 656F18E0002; Thu, 5 Jan 2023 07:56:45 -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 5676E8E0001 for ; Thu, 5 Jan 2023 07:56:45 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 17CA0120289 for ; Thu, 5 Jan 2023 12:56:45 +0000 (UTC) X-FDA: 80320744770.18.8BD72E2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 0F99FC0007 for ; Thu, 5 Jan 2023 12:56:42 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QO9hWfDO; spf=pass (imf22.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=1672923403; 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=O+BWm0WbUsJFc+hBlgUceZ9iy6IScpknBXtrIDAHI/11Ci8yAvTr/Sa+OfKo/XfrmjavLm zMXqDOASD+Wq0O2F3ZD1g05yToqYl6JqIRQ1W7I8lSQqDPgLoSA+3PLUXORFOnUIeb7W7Z AvC69gzOTcZ1CjpfWdBOJWkMCyb6lGU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QO9hWfDO; spf=pass (imf22.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=1672923403; a=rsa-sha256; cv=none; b=RaLl1tFGWIm31jVo3c3qT1W8kWZDfYBmNKxSMVYPryp1WIUqo/Vss7jnfS6z0j2R4JG8jG HmzVlmfIX9X53jkfHTuOBPufbAJLyj7iTO8BI+0jOPSFt5guafLSH+XVjbMRu/ShiXcvTi +cBuRCbAIQPKFBh9J5bAKei+YhlPPxI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672923402; 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=QO9hWfDOW9DrhTT+wMQN7/rZOBEhPnTfAjcEFxRLDNa+zVNB074oDuFvJfWlH4S4Xbsvd9 720Og5Ux3c6d2d6LkuqcKpsXs/wEAcXbUktYqPx2Hlg5ZuK7abi1bcZ3w4yrVZaTiRLfqa TlY1rgsg7SO6DcRz2kY2i3UBK13FOtQ= 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-115-ihzkEaxQNQebANYux16DrQ-1; Thu, 05 Jan 2023 07:56:41 -0500 X-MC-Unique: ihzkEaxQNQebANYux16DrQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D881101A52E; Thu, 5 Jan 2023 12:56:40 +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 2F20349BB6A; Thu, 5 Jan 2023 12:56:40 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 9695340502F36; Thu, 5 Jan 2023 09:54:47 -0300 (-03) Message-ID: <20230105125248.772766288@redhat.com> User-Agent: quilt/0.66 Date: Thu, 05 Jan 2023 09:52:19 -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 v13 1/6] mm/vmstat: Add CPU-specific variable to track a vmstat discrepancy References: <20230105125218.031928326@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 0F99FC0007 X-Stat-Signature: tu1d9z6sdky6zigjgmnpf79gqg7p7hqo X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1672923402-411423 X-HE-Meta: U2FsdGVkX19yQgqx41GX/L/qoL6rhtbnQWDn+o24dEnC/w1zqOzoMsvjJIa5sY0GxV9RJF/DWgazJxkCpqtneqeEabEDegnRClU8SHCMFSf0M6+LGWUJ52sXU89h2EVYDNXMqcogGYWX6mcDpBOYbW70s/EUQ+MJ7tDf5TgManFB7pZLMpDhYMORNqMs/1TsknD8drxQ0bBut5FNhr0mK8TkzRGxK+c0KB3q3DMLWZjQLn01AmwbtPpzzkD16Ow2YuK/LbxIGd9zIkm0Dzcar4RnzZZc68ot6HxXfzYzRRUa8wBMav80fCgQmhd8Yz3cSPX1FmGhMmeeAVmn86eVEYLpoMC3cbNzaSME6Pr2sVGX6wNMBg79nFGjLYyNbt81VoxIuu59jHtP1UAh/EFvS8S6G1it5cdqCLGSXSswBSV6zECbR1OcGos1ocjXgNLOtFsHrrUAD++gIN6YlrrR3DBtHtd37XDttcMCxpkMJDUA3pd67eTbLPR2vaFJTSWyRBqmGmqXz5IeUh06gbX8w2wKjVBJUjmEoEVmG5u8Qlfrnq2SgkI7w6AzGVPTDl8ybD95uiEKNrBf5qjl4OJAdmPgiVMlb0OZCrKVsynnikNGG112bF6ANawAho0ncHJ2PfQCmJpdClDCFdu1cIjJ8e8q5s0Fs6FGOIYhBmUyqCeeFksUn/jJ59fpuf7nd5yoOsxyVjhU39N+cZ1y/Elr+Uk1J1yFkKemt7ABIdx2kWauGdpqDn6p6KYpZVnNLD3lReooaRgSon1P1Me8jhMIZr5EwI6O8MofYzAv24T9Ui2kjiFiO5Mn8Q2ER1lgtpPTXvWGVS0CeCu0m7paA7IJLk4of6bYiEDI0D56bpcO5yVsrlp+cTi9AApKOXBSvEW6 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) {