From mboxrd@z Thu Jan 1 00:00:00 1970 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 9CBEAC07E9D for ; Sat, 24 Sep 2022 15:22:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D447E8E000C; Sat, 24 Sep 2022 11:22:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCC668E0007; Sat, 24 Sep 2022 11:22:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B44D98E000C; Sat, 24 Sep 2022 11:22:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A1FF78E0007 for ; Sat, 24 Sep 2022 11:22:46 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8ADAE1C6267 for ; Sat, 24 Sep 2022 15:22:46 +0000 (UTC) X-FDA: 79947346332.09.3F22BE3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 343DB18000B for ; Sat, 24 Sep 2022 15:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664032965; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TUeQREelS5Rh9IXzWSL5LmYfttFnlORFlEDP5NM1JJE=; b=gf9zEOe+osUNy6CMBwWvzDDvZD6am4Ek0i+vIBXD7tPFz8Ulxqau4VGvc/XRkpCB5xG764 HgNNucqBS265c2IA2ryPM1vOh8W42oDb1istMleCf0k07a8m0k2USfmsQFh33ihEqt6fTv +nnngur+RecBT2jteC/lZzmZM8rpSIQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-649-vIiwMX-GMaGICWZ8dpSCBQ-1; Sat, 24 Sep 2022 11:22:41 -0400 X-MC-Unique: vIiwMX-GMaGICWZ8dpSCBQ-1 Received: by mail-wm1-f72.google.com with SMTP id i129-20020a1c3b87000000b003b33e6160bdso4334818wma.7 for ; Sat, 24 Sep 2022 08:22:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=TUeQREelS5Rh9IXzWSL5LmYfttFnlORFlEDP5NM1JJE=; b=2NPKilgwtUardzFO9Epu+ogAw0S0Gvm7TJem59RQtBxX7RKelCtxYznkuS3nFaG3Nr XrOEx9cD52f0d3UYH6STJUG71GWmZPjV05uV55+gtbc77v+OvWj/21N4IRDmjP0WfRvT SwLnU7yNYdUYQ3xeR2BMD2w5a6wdugZFcbErBmVaf2pvgQ/uUgzJpYC3BHcC1ClaM/2K Ca0qFyHIjcflCe5EmBTcoZERF5gY5K1asBLbiyQgvUjC8da2emMr96z3+DkoLImhEeIw gHbCAJcOQKTn2psvsf8f213Y0TAKWk0T5GLowlViHQe+vSxsoPc4dQwobO20OTZFi2km MkPA== X-Gm-Message-State: ACrzQf1gQ2t20cwF6S0bpmO63xZGGzvWJr2MJJZU9gRc2WnrUf0rj+bv yCc09/UHEtePIwfsvQFvNij4S7AAN3aqXbJ7gfiTvZZ2V1RyyhKrWks9xrbDvZ/89WcLS4Na8/y ZqaysCY6Ecg== X-Received: by 2002:a05:600c:3781:b0:3a6:804a:afc with SMTP id o1-20020a05600c378100b003a6804a0afcmr16215760wmr.27.1664032960277; Sat, 24 Sep 2022 08:22:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5m/4w+5hkvjp8DxE5I0zgzzGcCHocqRX8TyR/j15JVMnw/b2kAHfK1Vm5eShxot1oDE/8fJQ== X-Received: by 2002:a05:600c:3781:b0:3a6:804a:afc with SMTP id o1-20020a05600c378100b003a6804a0afcmr16215737wmr.27.1664032960043; Sat, 24 Sep 2022 08:22:40 -0700 (PDT) Received: from localhost (cpc111743-lutn13-2-0-cust979.9-3.cable.virginm.net. [82.17.115.212]) by smtp.gmail.com with ESMTPSA id e19-20020a5d5953000000b00228c792aaaasm9941182wri.100.2022.09.24.08.22.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 08:22:39 -0700 (PDT) From: Aaron Tomlin To: frederic@kernel.org, mtosatti@redhat.com Cc: cl@linux.com, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, pauld@redhat.com, neelx@redhat.com, oleksandr@natalenko.name, atomlin@atomlin.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v8 3/5] mm/vmstat: Do not queue vmstat_update if tick is stopped Date: Sat, 24 Sep 2022 16:22:25 +0100 Message-Id: <20220924152227.819815-4-atomlin@redhat.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220924152227.819815-1-atomlin@redhat.com> References: <20220924152227.819815-1-atomlin@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gf9zEOe+; spf=pass (imf06.hostedemail.com: domain of atomlin@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=atomlin@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664032966; a=rsa-sha256; cv=none; b=cC5EPzkBNyRFWZ8A0pMPCUCurU9wxrBYMkAM6pUqEDqQ//+HaPN8J/yDJEIWOi1UGtOAdE 3qFNfpAoI81PEXJpS4EuwNNsSyr2XUobiAFERGqKRx2rzbCu7sB2Y21uOJxDC9aXB6oW6a 8IO7AHco6+sT+IVa/U9taFfKJuw2zcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664032966; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TUeQREelS5Rh9IXzWSL5LmYfttFnlORFlEDP5NM1JJE=; b=HaSJEMbTlWwjCQruZaqfKI5UpAqcGmtoW5uGafU6RhXX06/khZNBnyyeZ57E4wnxUKEKDH f3vVAOLogw8tSUTkBQaMnNcXGXZSXi9WODV7wkpJHMQXQeKykhua4vcaWzapek0pDUFQ0p HN5e2f7x+iRkr+Ueb/eKqkpRk1qvh/c= X-Stat-Signature: fktycxq1pezbcp8bo3djo8i9qmjsw3py X-Rspamd-Queue-Id: 343DB18000B Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gf9zEOe+; spf=pass (imf06.hostedemail.com: domain of atomlin@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=atomlin@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam03 X-HE-Tag: 1664032966-589050 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: Marcelo Tosatti >From the vmstat shepherd, for CPUs that have the tick stopped, do not queue local work to flush the per-CPU vmstats, since in that case the flush is performed on return to userspace or when entering idle. Also cancel any delayed work on the local CPU, when entering idle on nohz full CPUs. Per-CPU pages can be freed remotely from housekeeping CPUs. Signed-off-by: Marcelo Tosatti --- mm/vmstat.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 472175642bd9..3b9a497965b4 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "internal.h" @@ -1990,19 +1991,23 @@ static void vmstat_update(struct work_struct *w) */ void quiet_vmstat(void) { + struct delayed_work *dw; + if (system_state != SYSTEM_RUNNING) return; if (!is_vmstat_dirty()) return; + refresh_cpu_vm_stats(false); + /* - * Just refresh counters and do not care about the pending delayed - * vmstat_update. It doesn't fire that often to matter and canceling - * it would be too expensive from this path. - * vmstat_shepherd will take care about that for us. + * If the tick is stopped, cancel any delayed work to avoid + * interruptions to this CPU in the future. */ - refresh_cpu_vm_stats(false); + dw = &per_cpu(vmstat_work, smp_processor_id()); + if (delayed_work_pending(dw) && tick_nohz_tick_stopped()) + cancel_delayed_work(dw); } /* @@ -2024,6 +2029,9 @@ static void vmstat_shepherd(struct work_struct *w) for_each_online_cpu(cpu) { struct delayed_work *dw = &per_cpu(vmstat_work, cpu); + if (tick_nohz_tick_stopped_cpu(cpu)) + continue; + if (!delayed_work_pending(dw) && per_cpu(vmstat_dirty, cpu)) queue_delayed_work_on(cpu, mm_percpu_wq, dw, 0); -- 2.37.1