Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3252950rwb; Fri, 16 Dec 2022 12:10:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXuHZ3e4HmlFN9B80gNY+KEdprTlVsABPDbLQFcOpBUm790vBrpcrfBv2m+HahbjCAZETTQH X-Received: by 2002:a17:902:a615:b0:190:eb38:f097 with SMTP id u21-20020a170902a61500b00190eb38f097mr11665605plq.45.1671221423373; Fri, 16 Dec 2022 12:10:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671221423; cv=none; d=google.com; s=arc-20160816; b=McSdyXN+dwynLnfPSngfcHAce6FtgOSxQIyuoZRsDw5omWN85Of/cSciQrA37ma0wJ 13Tw4QpLB0VutLb9U7r0lwm5wSHtd+7jK8IMVzNXeIPliTB+wcnZNXzOuFoIxSjyiMDY T5x36Dj7lSO5/kb49bc8fIEB2S+vxinmsUAIYbbcqlDpo3JS2GRUW1MN7+KXVmdVxGIa LNxTUJ6g1SjLmGciMUYqhIi5HtpjxML9wOPBLfZJEbmeyztB+ETlKn21w+EZo7kjfmdv a5ZfNwoiB87Omd+x1VX3VfhZXlwKsaI3jxYKHlJj0vszpe8uvUrZq0EynHljB0gnrx8X kNaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=kyxh01Z6aQw9/MQYaoI58SSLBFSUwnSJa8fNd5lmbmc=; b=w6OmDifO5TDBgRAsvKKqiRvdSR613sRqy4inQ5+DpSxAI5xLPGaz8S14R6j9e8I7HY rrWRWCRKnXhvDMCqo37rb961PT88cteHEXvFeeID9KqQf0TjAseOHdMAx0+jLbk8idP4 iYmdaufYuktk9MEDG8brII3iuT4D5GKEyvQCLvmqtLGcRQOsTBAnWR3oQ0eBHbryEtw4 t1XRssLfg6rNSSSL5MuLvbiUuuU/62CPtCUGZ1yy6UPUBzI3M0GejTxd49pyxgQvQjTy E3nnaaPKQCYdbALuamEMtw0BdO2U8xO4kwZRWry4jSBq9hibxJos2y6DN/ZZNLucAdEz MaTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pc6GAknH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 30-20020a63195e000000b004827ef5f0b8si3594374pgz.355.2022.12.16.12.10.13; Fri, 16 Dec 2022 12:10:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pc6GAknH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231414AbiLPTxe (ORCPT + 69 others); Fri, 16 Dec 2022 14:53:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231736AbiLPTx0 (ORCPT ); Fri, 16 Dec 2022 14:53:26 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57FB1659BE for ; Fri, 16 Dec 2022 11:52:41 -0800 (PST) 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 Content-Type: text/plain; charset=UTF-8 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) {