From patchwork Tue Dec 27 12:11: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: 13082278 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 98A1AC4332F for ; Tue, 27 Dec 2022 12:36:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E56138E0008; Tue, 27 Dec 2022 07:36:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D9ACA8E000A; Tue, 27 Dec 2022 07:36:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 924688E0008; Tue, 27 Dec 2022 07:36:40 -0500 (EST) 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 69AFA8E0009 for ; Tue, 27 Dec 2022 07:36:40 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 37AFB140BDF for ; Tue, 27 Dec 2022 12:36:40 +0000 (UTC) X-FDA: 80288034960.13.8472F2B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 97B21C000E for ; Tue, 27 Dec 2022 12:36:38 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JPZcxvGR; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.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=1672144598; 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=hIc0vPvNI1VykGTxKET9i/kMr1uqEk68mXFfOdiRry8=; b=jdqQiMw52UWAoILafyRDwBCkqK7ENId/lt6wlUiiARR887OJoFMrV/UX/RFkB+xl87K80P IPPaWJF2ZNuODgZeXtMehmD49uUvmijKwbmqP/YgYI+F81WWKEPR3rmMO+rcnkjkzvDOSh E7SaIReyfkrDqr7ptVExi0fpsSL6C7Y= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JPZcxvGR; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.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=1672144598; a=rsa-sha256; cv=none; b=8LkEIO34FNXueAfsvd2OeBDR3SEcwiWv4LrcrV6Mh5Geu7zKUxKGmmNBq3FcCNNt6D38lV CbXEXGEROwd9dHzNPMyXLq4afPwCtvt9yD5aYBnHmpLtrX4vVCRB3oCdkYmYYr9Zo5CHHv NDLYd2yeplIKr3AT7jDpNm2soHT6tn8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672144598; 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=hIc0vPvNI1VykGTxKET9i/kMr1uqEk68mXFfOdiRry8=; b=JPZcxvGRC8M/ZE4cXjg0pSyA8doqgvwOHgpgfRMoXxjSqX3VvebWcUA+OyeMgw5jYPPu9S JRceFEEXRZu7SZCaUYt5wjCLzuWFlP/Y6qJcij4CD3OCLIpf3ns3JRfVJVMiFZjKux8XuY wews7D8+ST7autpnKJJgtxqkccifrV0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-625-tDoyWPJcMYanbhPprYBZTQ-1; Tue, 27 Dec 2022 07:36:32 -0500 X-MC-Unique: tDoyWPJcMYanbhPprYBZTQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC3CD2803D60; Tue, 27 Dec 2022 12:36:31 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6D15C492B00; Tue, 27 Dec 2022 12:36:31 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id C28B14257A81F; Tue, 27 Dec 2022 09:14:52 -0300 (-03) Message-ID: <20221227121342.060153015@redhat.com> User-Agent: quilt/0.66 Date: Tue, 27 Dec 2022 09:11:41 -0300 From: Marcelo Tosatti To: atomlin@atomlin.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 v12 4/6] tick/nohz_full: Ensure quiet_vmstat() is called on exit to user-mode when the idle tick is stopped References: <20221227121137.102497574@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 97B21C000E X-Stat-Signature: uw4wgfi95banckifcisjpbpjb9xbi6iz X-HE-Tag: 1672144598-708415 X-HE-Meta: U2FsdGVkX1+vSoSRJNAL4gkvlmtQcin+FR6MW2NYxSSDwFO4Qub4U6Z2m/5jyVTUgOOq0WjFSYOR0EwCB95as4mCiCezDEZOmsdQ3V6y6iDG5RqIPIYAaMeiBqdj8V0PtQ+85KsmpWxxAHPLGJ201/UDRRZ596/3nmenlDUXeZcI6Fli6rO6cqTb9juL5unVOT9C3aqIx6nmKS4+BuEO78ebq5a+u6k/ZoFZhbPguf1LYRR1W346D/JxQYQOiomqJ3Nvt3/Yn0JgDLVScjLe+SIttjG4Jvg/hx1jwT2TnSxWDsHP103NI/Bn8BFwuAXWXiceZNibRFdQWdMYfi4kE/Nqx5az4PRScVJFwWVKH7uHjjWfGNCIxPA6VW7M1KphK5Vwf1KPC3hJ9rq0GGuCaVdV8s1UBjllWkwyb5+1OiIvhXvBoeezGZhHfXJUgXo41YgKCDKrql90ba3BYx4ULZncNWknLHvM0oHC+FUrnwjbCVmdFLVoO3lsxNTfuUwMud6lOSGc8Tax8Gip/m57hBiu9bAqyb4Iesw5x2L8wND6ZKNHtKrcXuwk7uVotR5vIID7PU2I6ILEYO8BKK0wpmX2dLOVb7RAwoXJiPNuhlNe2yDbBu+5yxaKRnm0GALkg7qoYp+UfeVVwl+dZ5f+97aArnVOrzZwpGyUSPP006Q6jBw/uwvSzo1guvr18LHTLLdOWBrlAfXPWv+S2ag7+zxbw0SxIGujpqsSFrbWqprMsfYR37F2wH4E5NF1J9M6V95n9ISctC9D/2TAjECLzPhbDR3jP08dfYKW+QsvqdHq42+WegwIZDImEBoHZ+oGHOyarB3Ir39WIO8NIoPG8DylZbHaqnffbdlE8cQjk8IHuX8cCHUD9nDn9BpKkYj7W1dw2YMu0+GdBcAzrzoV8Leaq1PuDruwxks0rSsP6Nc= 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 For nohz full CPUs, we'd like the per-CPU vm statistics to be synchronized when userspace is executing. Otherwise, the vmstat_shepherd might queue a work item to synchronize them, which is undesired intereference for isolated CPUs. This patch syncs CPU-specific vmstat differentials, on return to userspace, if CONFIG_FLUSH_WORK_ON_RESUME_USER is enabled and the tick is stopped. 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 Signed-off-by: Marcelo Tosatti --- include/linux/tick.h | 5 +++-- kernel/time/tick-sched.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) Index: linux-2.6/include/linux/tick.h =================================================================== --- linux-2.6.orig/include/linux/tick.h +++ linux-2.6/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 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 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 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 Index: linux-2.6/kernel/time/tick-sched.c =================================================================== --- linux-2.6.orig/kernel/time/tick-sched.c +++ linux-2.6/kernel/time/tick-sched.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -519,6 +520,23 @@ void __tick_nohz_task_switch(void) } } +void __tick_nohz_user_enter_prepare(void) +{ + if (tick_nohz_full_cpu(smp_processor_id())) { + if (IS_ENABLED(CONFIG_FLUSH_WORK_ON_RESUME_USER)) { + struct tick_sched *ts; + + ts = this_cpu_ptr(&tick_cpu_sched); + + if (ts->tick_stopped) + quiet_vmstat(true); + } + + 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) {