From patchwork Fri Dec 16 19:45:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13075350 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 F24A8C4167B for ; Fri, 16 Dec 2022 19:52:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 527BB8E0005; Fri, 16 Dec 2022 14:52:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3765E8E0008; Fri, 16 Dec 2022 14:52:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DC6B8E0005; Fri, 16 Dec 2022 14:52:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DD7358E0007 for ; Fri, 16 Dec 2022 14:52:42 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B397112083E for ; Fri, 16 Dec 2022 19:52:42 +0000 (UTC) X-FDA: 80249216964.28.DED3434 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 2DBEF1C0019 for ; Fri, 16 Dec 2022 19:52:41 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Pc6GAknH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671220361; 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=kyxh01Z6aQw9/MQYaoI58SSLBFSUwnSJa8fNd5lmbmc=; b=DJJQLBOEnc86ZsvBlsVN/DWNN9XgMABoRz7q6tc9hLHDJO4SlGTbe9cA4HVWwNX/y+EfR8 g61q2e1NN02yMrj1U+ndU4ZwnujvLvHCgx+SJGsCbWo6/Bz3e967Vicy5WtKcswp6JQNfs xUePyS6cIv+GbSTW5EjZAbuiOMGge64= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Pc6GAknH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671220361; a=rsa-sha256; cv=none; b=eejCk0wQc0RFly9PXTIKT9qfnOyr8YO0YFtQp76EzKfaMwMQN/ZwdSPMu1tlZ657G5M2QW srlYVA0x8dXAeqrL5PsUK1furZckOC0eqzQz+SsVBrtzBIbopm9gZHujSf4/aTO8BHsvKu 4Xfro+K7rskU8nnO3cyP2r4HNZYZunw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671220360; 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=kyxh01Z6aQw9/MQYaoI58SSLBFSUwnSJa8fNd5lmbmc=; b=Pc6GAknHVru0jDDUdiEOUCmXEkySXRTKi+jp3N62g0vB9ktKXLLO4MFXxu7Yff49Hw9bka QW6ae9eZIoEsxPwx4LhFvw9zJKYm8DZ0QIqYANI4QWHwXZkveO90Pv/4XmApCNOzLVTv4G NhvwgDrvRYFhgSiqWQwlUS9M0GwFHaQ= 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-607-kZFRYmw_Ofm-GfhYazO0XA-1; Fri, 16 Dec 2022 14:52:37 -0500 X-MC-Unique: kZFRYmw_Ofm-GfhYazO0XA-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 2681D85CCE3; Fri, 16 Dec 2022 19:52:36 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-3.gru2.redhat.com [10.97.112.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CA27492C14; Fri, 16 Dec 2022 19:52:35 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id C48684097957F; Fri, 16 Dec 2022 16:52:10 -0300 (-03) Message-ID: <20221216194904.075275493@redhat.com> User-Agent: quilt/0.66 Date: Fri, 16 Dec 2022 16:45:41 -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, Marcelo Tosatti Subject: [PATCH v10 1/6] mm/vmstat: Add CPU-specific variable to track a vmstat discrepancy References: <20221216194540.202752779@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: 2DBEF1C0019 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: jgixz79ccys97t7ka4shzkkoy5w99kqx X-HE-Tag: 1671220361-874837 X-HE-Meta: U2FsdGVkX19appYz8aQwiE1CNEAeI9QD/pmm78NjB3zI/LTD+aIzg5PWFYHyaJ8XsOLXV9HgOsPgQEAuvcvhFJ289CHMcRP2oY6aAJlEA2yy8nQWuLnCjbnUSKeTeozjaQzXmypL1o49zqNR/3V4m1mGnMSJ49LIuPr/8BpFUhaBjhLqvTBHxoQCheEcRNvTIoqDKbtdzOwBf7rSL/YinB+EnSD8i+ZKi6GOFEfseoMZzfk3gFIIb31lKFcmPf4UlTYVkU5yBeheqpZZT8FCr+dxe4tysfVnFwlSF3vHANUtF/SFeQK6GiGePdDo7MQt1f7BFjOiEejezhFrUBASM2paoG0WHFQBppSGW4W7jBDEzih7ZV4mXLjxLcUY1/O1v4DhzNHMEfnRYqP0hYUGfjsgTP5jH20QzdItfiqeuLn6w1aRzopagdxMi0DTWQWvW7nVk8xG/zKvBE7UpOAtOfvqaU87+Es0N8pL37IoSZnqEywaCPRVjtBdSnrUuudRKaBTJLkGWDm9368e9VSBxeRWiL0YJ3sBjSK6kA8xARfmgQPQ2aqSSDkiWBWKEBl4oIswmL+YEoo0/RzkpAzI59MU70JuTikbbkfrVA4MoPu4Ae4nVoKGe9+aNVTBk45Sk3C+Darz5vHZoTZUMZtRqcfW8gk445M3Uj84gHXkyXD2d7kIRo1Ltw88+TOE6FIgDAA4UGwzCgWn9sx6WETwncU2dx999XVHueoqbL/fXZ/g2FZEFrOMIVqWLtc8SUR+pmbUcgqQLd4hU16poBOdKBNjL+K8XWT2suyGD87eZeKnG+UBHx+102Y5fpdtbFvSNcT9sJ+yJU3NfIZ2QJsZKPTJDTSnvOmhhoeofFjpFVEX6JGyRvBB+vGrGA3ul8in 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) {