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: 34068 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1165322wrn; Fri, 16 Dec 2022 11:55:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf55xlcWjBtB2cq5MhA+36rMwsD01dPkwSujdaBGXvxhuVdNiwO5dDP3AA/7glCm4cL3Mm8j X-Received: by 2002:aa7:d912:0:b0:46b:2b37:ffa6 with SMTP id a18-20020aa7d912000000b0046b2b37ffa6mr29399719edr.13.1671220535400; Fri, 16 Dec 2022 11:55:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671220535; cv=none; d=google.com; s=arc-20160816; b=W53TzjGfMkv8RiufC+DGBbB/MgIHxqkWFmszebTekUhuQtuxN4RcZ77YeLslha9c9Y 1Lgro2yPCJ1VeW4dN0l0z7UpWv6KhUU8jTEC+zfjLoXBmo31owiwP8lS0JFL2LWyU2Q4 xQIFGbfARXsCJFSOoxulkoUv63tF8ZDV7N45FfWxulJWYNxQ71NV4fQYdewQIkZQsIQb Fo7l7r1OqJwO8ZDIGfq2GeG3KgdTrzT/3kGoDa3ZJ66TBOV9L4v91qnF7xidxW9notwP z22dQCCdSd7z3ekFVEMcJb/lQfBpuR4al6WmMmCBYXXF9Jqo4q1InWd9w/er4CNFNINg zGLg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ee38-20020a056402292600b00461d60a86casi2848695edb.135.2022.12.16.11.55.12; Fri, 16 Dec 2022 11:55:35 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752401744518049087?= X-GMAIL-MSGID: =?utf-8?q?1752401744518049087?= 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) {