From patchwork Wed Dec 21 16:58:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13078952 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 C5B1AC3DA7A for ; Wed, 21 Dec 2022 17:10:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 829E48E0003; Wed, 21 Dec 2022 12:10:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D9838E0005; Wed, 21 Dec 2022 12:10:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6337D8E0003; Wed, 21 Dec 2022 12:10:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 458198E0005 for ; Wed, 21 Dec 2022 12:10:51 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EF1ED40694 for ; Wed, 21 Dec 2022 17:10:50 +0000 (UTC) X-FDA: 80266953060.15.3A08DC2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 520DF100012 for ; Wed, 21 Dec 2022 17:10:48 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HfzeWMFr; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.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=1671642648; 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=C7fcHUyzcW4F+ucufGFezQLMgXWfhaM9eBPMwThasic=; b=gWu7+M/80TFAR/Xqm3dmWziUaUvho6nHH2kAciYDK6pwLNaqStDv1uUUxpo5yuCsKWd6rO Croll52TAjRy4iLLxQEjz9oTsuvmSOslisciBogLZCdEg3rt4r3Ydu290/AXb1lI/CdOqr peu5LgsZ3kt+cEMXr4KP8r6uDNuIoVE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HfzeWMFr; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.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=1671642648; a=rsa-sha256; cv=none; b=2rSytdXOemY6a9Xl9IqWmhQ38FKVUrvI+8oQe0vEYaMn+pwTHXTLzZlN6BklW99r88g538 YmKIjbxVBJXfY/4uY3XxUCK/ZYuU1ugjtRXP0m7Z1bRg/WoarXKmaNQnTWy8lCtVPFwdvp pvvlRw2SPBtaEQNKVBwKnyiNaVfzFAg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671642647; 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=C7fcHUyzcW4F+ucufGFezQLMgXWfhaM9eBPMwThasic=; b=HfzeWMFruT5vmiWNp5IexF9VOEJfvJS/9gbovyrkwH1gSVu0BqQkJfDMThVy+jTx1pJPq3 d2fmgCJix9EXzFtffzTXxlMAGAwU1VrrutNeTf/iwsraxtUZjXoe3R2xibdrGKKAmvf9bC cgMyOw7TppLyEfTkg2xc/R75kOo3EHo= 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-25-i--luYGMNhq27CYJNt6lVw-1; Wed, 21 Dec 2022 12:10:45 -0500 X-MC-Unique: i--luYGMNhq27CYJNt6lVw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 23A8B18E0045; Wed, 21 Dec 2022 17:10:45 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-4.gru2.redhat.com [10.97.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CADF8112132C; Wed, 21 Dec 2022 17:10:44 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id A883040408D5D; Wed, 21 Dec 2022 14:09:34 -0300 (-03) Message-ID: <20221221170436.370028855@redhat.com> User-Agent: quilt/0.66 Date: Wed, 21 Dec 2022 13:58:05 -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 v11 4/6] tick/nohz_full: Ensure quiet_vmstat() is called on exit to user-mode when the idle tick is stopped References: <20221221165801.362118576@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: 520DF100012 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: s8bdknbtycmq4eqw3kkonbgg3ruzfciw X-HE-Tag: 1671642648-955717 X-HE-Meta: U2FsdGVkX19PEhsv6jzhE1clw9eDyzs1q8z7o9+EZxW+yz7jnmbO5awlMCEeHNAFNqvcUjVKZebi711iojDhJoTDNu29hJRzii198jKja34Nz3GeY6v6j+rW5fPmTIeRzuBu7xTZgKkUsQ4bk2lZ9sdPs0arD6zO1zmvGBlEXcrl1cLRtnpYPOz5m5Am1GW5mj51DQyJ3x86IhTPnJ5NcAUL8TEziYV+vvdH7UNERB/hSn6umxWXGWe0IKVU8wx72DjCvTtqVsoHOWe19lTAYiLybw2WRzenZDiNOOdL/rCsEhKYd8w0ypTAUolOP3vqoSg4nj/5yxFaBEyWrWJ+3iGdLo/nCKLmGmkezEqBryBVsqhDQJY5tccLFh8FRq2lDev0bGfJNJJR7bLNWvp3MMh9JKqpNVC7lMX+mkuHlhKUrTsdqJRRmoLMQjozuAnqsWPn0q7jvqWx7gtGjLk3DC2Ow7Lyig5D6QWis/hRYO3jXuK4JjtEcCHtnFfdX1CqMwxxWcGVr1osM2kQclhZC8BePS1hFLQlzgVWVrv25xF3y28qdRxMLV/JeQQ4J1RU/kITW3IKtgxhfDN7YC2+2GZ/6Bnl6BQGYL0XdXr/7sB6bF7FC29URdengGN59WGBSTGi4BCYOrCT6c1st73MEXEegb/nJEXJk4BC0MwxXBDpl3i0nxFIJoX+KMe6BmI3BP3PXTLcCaBerb301qVqBBW5pWghWGR0HIy+UhedeQYnn/KmvQxLwqdIBt4/RFIZ79wx+Bgfq4Bpcn4O8QPYQb3RhSIWfFL4Zn0ZDETBo/GDyA1JJnOhOwXAdwf23KzzcZLV9yRwl9x5Tc3jLAyrGGKjkfyb35HyKW+l1UcQmyLVcyVptsNkmkP/9LbK5uQTsNetSRpvX63zAYCe0+LHR42emwNgwpQrn9EN/BQ9sng= 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) {