From patchwork Fri Dec 16 19:45:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13075346 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 7A329C4332F for ; Fri, 16 Dec 2022 19:52:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC4408E0006; Fri, 16 Dec 2022 14:52:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D4D718E0005; Fri, 16 Dec 2022 14:52:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB3A58E0005; Fri, 16 Dec 2022 14:52:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id AC4E78E0001 for ; Fri, 16 Dec 2022 14:52:42 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8A6C11A05C8 for ; Fri, 16 Dec 2022 19:52:42 +0000 (UTC) X-FDA: 80249216964.30.D698816 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id DB1DEA000A for ; Fri, 16 Dec 2022 19:52:40 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YjaXeekc; spf=pass (imf15.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671220360; a=rsa-sha256; cv=none; b=vATapVfn/nC+mPKvg5dQstyEusdrW+IbleGtw67C5cRkgGMUr1Xl9F/SafGQwpEXn7gBcE rpQNyNVVK1fOfPzTte7mCJHqeR06HX569v8B+/PquxFvkW5SD9PMSoci91/I+4uz6uT7zF DFg2S0mZGuavEHkfCoY1nCnuvkOB5vE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YjaXeekc; spf=pass (imf15.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671220360; 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=Dj30RymbV1ceM4Dy8ttNJR7SWnDvhwByWmjv10/VX0U=; b=u1oUWKWxuOlap2P9rzQEfOmtUdzds+spYoFwGR3m7pmf9CUpPivVTP2JyS9YeIOghjB+mi jtqHTVrmhcWJESJK/FiVkrfrFbmbMf/dqKuWlGxHfiB2vBZsNI6gJ0GhqeRNbtk7QaCy3I 6vAWj1n9wuR7q6YCWlubdKZlUMWAY48= 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=Dj30RymbV1ceM4Dy8ttNJR7SWnDvhwByWmjv10/VX0U=; b=YjaXeekcJTS+v18mECAtDSLFsFwWMRcQmQSiXDBKeOt4DfEuaOwYA2UabYX8VxCMN19Fbn KPEbGHADJdGkr45obqN/eFQN3yfqloliiDRISDJ3VlLNhuVsFAqzUz8Gf/O6BEsyWfup4P JBIeHUulTp80EHM13OxoJ+rfY/TIuPk= 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-60-JsGNMvx0Nm2XLJKR7vCj_w-1; Fri, 16 Dec 2022 14:52:36 -0500 X-MC-Unique: JsGNMvx0Nm2XLJKR7vCj_w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 28B64183B3C8; 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 7479440C2064; Fri, 16 Dec 2022 19:52:35 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id CD8CF4269CA82; Fri, 16 Dec 2022 16:52:10 -0300 (-03) Message-ID: <20221216194904.194285953@redhat.com> User-Agent: quilt/0.66 Date: Fri, 16 Dec 2022 16:45:44 -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 4/6] tick/nohz_full: Ensure quiet_vmstat() is called on exit to user-mode when the idle tick is stopped References: <20221216194540.202752779@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: DB1DEA000A X-Stat-Signature: b5dhphgw554bwgx4b9kerpo4otzk6ed3 X-HE-Tag: 1671220360-993607 X-HE-Meta: U2FsdGVkX19X1nw6kthCZqqwM/Ny1uIMItC4huFB5FL0kjwnD6G0moxi16i+3zEBzvZywA2EYp2Oc1awJKGYERwgeQzx3n53KkJqII2cTNZr/twuJdYEHq/fRDkbzVd2adJA5tj5DIppgMH3CLaEwrmgdqIO7nHK/b4ZYYzN0ja/JoGKmX2WGRy1KwEmlxHDGqLCQ+HlVMNPgN+YqZgRonHfFp0ckAWR4k6uSjGAcWM8Cv0sAKw4NrcGZ+ajUrwjehp87omFawFVRvyGRMEVoZqIPZDNlbkjLlabpbz+/F3oyegTD1Bpe4uMOckfhWbmx3v/JLjqk1Gj3snJeDbG9JUi+pebWuiXn9Suyt04fbar/qFob0fQu8NuRD5DBuTI0AUanXEjuIo2EB+Xx8Tps4FOx8YFjyxzF+w/+5RYCzyTzwHb/EBR4qJEFRcAUhzMqcVGCsXgSKjWzoJKuZVv/QNEfZK1n/Hh7o6gCGg3SZfDfacRxXiTsGRPcAB55RFsf0q35yjDy2WMJln8CFU5fRXQAZ3o5cAmm0D6heyOHfKolVNTA4lwXodnazgUi29M2lmW4kssOamCeR5XkzTnAuVRzwx7ZNIwtYKtdnI5TXuTyZhvaFJhKPp5tgpoTgs/FEulbzXW//BF/ghgXezGg4BotIiusCFPTWzsgKkles0tkQXv4nHauYGiVo/iW9V2lj7hsf07OqRAfWEDIBMipJd2nqKYEpQ5F07SvGGw39XtxgHeYQIa9rwPa6AbTJruOWs0xNHHP17/Rx6nbwteN7p0u2l1+dzZhjSnksEVVsIv79x3FbDMncF7v304BB4QMbfJB7a9kncSUYss0wMFB4Lxi1dP+f4OCKg6nq0KNdDpUVbsa83/m/u2a6pWA92lG18fVZiezRVtSwYprXDcqXqbW+nHuZVMAQXa0har3V4= 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,22 @@ void __tick_nohz_task_switch(void) } } +void __tick_nohz_user_enter_prepare(void) +{ + if (tick_nohz_full_cpu(smp_processor_id())) { +#ifdef CONFIG_FLUSH_WORK_ON_RESUME_USER + struct tick_sched *ts; + + ts = this_cpu_ptr(&tick_cpu_sched); + + if (ts->tick_stopped) + quiet_vmstat(true); +#endif + 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) {