From patchwork Sat Sep 24 15:22:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Tomlin X-Patchwork-Id: 12987728 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 34FEBC32771 for ; Sat, 24 Sep 2022 15:22:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EBF58E000B; Sat, 24 Sep 2022 11:22:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 79B0D8E0007; 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 63C178E000B; Sat, 24 Sep 2022 11:22:46 -0400 (EDT) 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 517358E0007 for ; Sat, 24 Sep 2022 11:22:46 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 244A340854 for ; Sat, 24 Sep 2022 15:22:46 +0000 (UTC) X-FDA: 79947346332.15.338A156 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id A5AE84000A for ; Sat, 24 Sep 2022 15:22:45 +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=FfsmTvmGXeM1/5qFA1Qh7h37ne6tkdVL6kPv6MNEep4=; b=P4rzTqCevCxROlEU4wsc+c5YT7ZRCcHzIOsQr+8sg4soEKmWiceSjzqjoDlD+C/c8j50ut xUQb8H8Gn7BE4D2JM29dDnPL1RQf9Bm+Zy1PJiPrnyGHR3t8ivg1/NKXtkCmeQ69ZVDfuP 2698CSW6xFdIdxzYWo5ehW7sTbmxW9o= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-12-9MQ6R1VyMXqtYhZWxmZoag-1; Sat, 24 Sep 2022 11:22:44 -0400 X-MC-Unique: 9MQ6R1VyMXqtYhZWxmZoag-1 Received: by mail-wr1-f70.google.com with SMTP id i26-20020adfa51a000000b0022c8fe3f26cso374840wrb.15 for ; Sat, 24 Sep 2022 08:22:43 -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=FfsmTvmGXeM1/5qFA1Qh7h37ne6tkdVL6kPv6MNEep4=; b=A+gRX8ooR6UeGN3mnVoKV81leTqVeejTHfEc7dQ3wlVbg4hA2aK4z75O6ruxy+tCeD IajIGJOSd4Dai4cJVVBvOaMBmYnYZ8y6jaeWw5lHr43F0paCTCxjwEa73DVlSzzbzhIl gzSgk1VexB4z5dF4MgU3pQpdfTqUNDoAn1fHKK7GkwYLS8ZOKzq5WoGxeF5FODENKJUu Zz5jwLPFKa0NcTf3qyyyb8WideBdSKMfKVXzNB5FuyN0D7W8zvWmmyBJ3paIFgmDnXoV 0+rF+BwIkRgtjSPCpTGND6M/RzBDCx8fhlik6PlGSLeuts9qhYZbyj965zRxDf8P+TZd CbBQ== X-Gm-Message-State: ACrzQf1OXeEssGW1a5SdUQLLPNpej03kpw+nUuq39rgYKYcRDi4WTF+e xiG+Ei1y6MV1EdTKn5bAM1iW34p4kr6bOIjnu0CJ1Cem2tmWwCxuRxgDSK/A2N1ethtkg4I6agR J1RqxhB65eg== X-Received: by 2002:a05:6000:18aa:b0:22a:b61d:877a with SMTP id b10-20020a05600018aa00b0022ab61d877amr8412526wri.512.1664032961876; Sat, 24 Sep 2022 08:22:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM56wiVnnOEt4nyShWrMqWg2SekETLv7jY1m2hDmQ/noBoVfgCeZVDYazjwtyeDkFVI65YEN6g== X-Received: by 2002:a05:6000:18aa:b0:22a:b61d:877a with SMTP id b10-20020a05600018aa00b0022ab61d877amr8412517wri.512.1664032961709; Sat, 24 Sep 2022 08:22:41 -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 o3-20020a05600c378300b003b48dac344esm5421645wmr.43.2022.09.24.08.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 08:22:41 -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 4/5] tick/nohz_full: Ensure quiet_vmstat() is called on exit to user-mode when the idle tick is stopped Date: Sat, 24 Sep 2022 16:22:26 +0100 Message-Id: <20220924152227.819815-5-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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664032965; a=rsa-sha256; cv=none; b=zCx8uW+QShuCdNSoUaF6yMCAZI0MpNERAJoOcr7JRQs+EK/DQU0NrvRkUPENIbBtFn71Vx sXINmLiWbExjrqQjt1x23rSCfwknU6+95Payt5DgXI9vAbyx9bnF4OyLAqLSzaKTtKkVGk ho/qmRS/n8KP0dmMQH8h1BFBow51Blw= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P4rzTqCe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of atomlin@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=atomlin@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664032965; 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=FfsmTvmGXeM1/5qFA1Qh7h37ne6tkdVL6kPv6MNEep4=; b=UP+eucSZq0q+QDa3CKmtdDlFTsS/HXLT10Ara2UCnhYePDuRMWgYe9eHfzFhLOSjR0cw6h PLYyYzLlJSEl2G3k8qfkdlueIXDlgB5Fp796vwGlCbvpR/05U5aHjUKOUFBJQzZPabvoVz JOimyeChKUihBVYnIIuf+5jHtygYtqY= Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P4rzTqCe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of atomlin@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=atomlin@redhat.com X-Rspam-User: X-Stat-Signature: xg4xmeofq5td9aycekhdjhzfcj38zami X-Rspamd-Queue-Id: A5AE84000A X-Rspamd-Server: rspam06 X-HE-Tag: 1664032965-12713 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: This patch ensures CPU-specific vmstat differentials do not remain when the scheduling-tick is stopped and before exiting to user-mode in the context of nohz_full only. A trivial test program was used to determine the impact of the proposed changes and under vanilla. The mlock(2) and munlock(2) system calls was used solely to modify vmstat item 'NR_MLOCK'. The following is an average count of CPU-cycles across the aforementioned system calls: Vanilla Modified Cycles per syscall 8461 8690 (+2.6%) Signed-off-by: Aaron Tomlin --- include/linux/tick.h | 5 +++-- kernel/time/tick-sched.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/linux/tick.h b/include/linux/tick.h index bfd571f18cfd..a2bbd6d32e33 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -11,7 +11,6 @@ #include #include #include -#include #ifdef CONFIG_GENERIC_CLOCKEVENTS extern void __init tick_init(void); @@ -272,6 +271,7 @@ static inline void tick_dep_clear_signal(struct signal_struct *signal, extern void tick_nohz_full_kick_cpu(int cpu); extern void __tick_nohz_task_switch(void); +void __tick_nohz_user_enter_prepare(void); extern void __init tick_nohz_full_setup(cpumask_var_t cpumask); #else static inline bool tick_nohz_full_enabled(void) { return false; } @@ -296,6 +296,7 @@ static inline void tick_dep_clear_signal(struct signal_struct *signal, static inline void tick_nohz_full_kick_cpu(int cpu) { } static inline void __tick_nohz_task_switch(void) { } +static inline void __tick_nohz_user_enter_prepare(void) { } static inline void tick_nohz_full_setup(cpumask_var_t cpumask) { } #endif @@ -308,7 +309,7 @@ static inline void tick_nohz_task_switch(void) static inline void tick_nohz_user_enter_prepare(void) { if (tick_nohz_full_cpu(smp_processor_id())) - rcu_nocb_flush_deferred_wakeup(); + __tick_nohz_user_enter_prepare(); } #endif diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index b0e3c9205946..634cd0fac267 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -519,6 +520,20 @@ void __tick_nohz_task_switch(void) } } +void __tick_nohz_user_enter_prepare(void) +{ + struct tick_sched *ts; + + if (tick_nohz_full_cpu(smp_processor_id())) { + ts = this_cpu_ptr(&tick_cpu_sched); + + if (ts->tick_stopped) + quiet_vmstat(); + rcu_nocb_flush_deferred_wakeup(); + } +} +EXPORT_SYMBOL_GPL(__tick_nohz_user_enter_prepare); + /* Get the boot-time nohz CPU list from the kernel parameters. */ void __init tick_nohz_full_setup(cpumask_var_t cpumask) {