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: 34071 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1166154wrn; Fri, 16 Dec 2022 11:57:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf4MWW2JsS49JUhAaJQ7LKAAPlJw4U4xWyUdoLVCV7/h6rRRty8+funrAUmOOZedkzD0pn1N X-Received: by 2002:a17:906:2b46:b0:7c1:bb5:5704 with SMTP id b6-20020a1709062b4600b007c10bb55704mr28316853ejg.26.1671220674725; Fri, 16 Dec 2022 11:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671220674; cv=none; d=google.com; s=arc-20160816; b=STQ0FYyqtl7CQlte8biEpQ3YxGsi0UalifEA30VebBRuJfXE/1ILCxW6SdvYZDQzKk 2/SO/NFwf74jdYn+dWLTf+RMWXO8Wbh+AlMpBX5mlUKZ+0qMB+AJ9ffLaYzXOuOtLgBn AmVhExXTrxc7XpbiqyGxfyCwPB97xnZTnbh/0dq1gi9WyRkQAuDGRlRPc92k2IgdtKPD H+GI8NJ5HIPOF9dJgYRHX5SFkZMK+g1W7D7PJWB0NwgToC/mYmWUeBGoiQtwzLMnWK6s 1P4j1NQ/vpSWXM7FAlQELHekRqsxqWSLI+U6j0C+RiD5MguoydYAJuvC4MHYkXBuD91z ZWFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=Dj30RymbV1ceM4Dy8ttNJR7SWnDvhwByWmjv10/VX0U=; b=QkTDWLP0u0FycpwC86Y1hran8NbWQTgbNHLwqWPhM6ENmyUig92MWyqPBvzKvarJ/D nCpcgEAVSaQn5Gk68DW5TocMQxgpz0ysY4sFYx9pgpH/xe3NXyMtUzA61C14DdVAuUEP 0nGsCCArH0AM4V06LkwQ4cdoCKJ7UC+5tmARwllzGYrQ8hFFj8oOg1EVo2n3JASLvAX0 07BjavDOJZQitakVw7Xr6BBEGCWOg1cmmvic71NS0BmFxxnon1YVkWST7ZLIt5ySpchr oLDy7xfzDUErgtq/rXbuwplkOsAK+AbE7C0nKOAWZl88mIdu0DPO4ZapMrVp/qEaD+/g zaag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IPglY0aq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt13-20020a170907728d00b007d65ca940a0si3707005ejc.171.2022.12.16.11.57.31; Fri, 16 Dec 2022 11:57:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IPglY0aq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231469AbiLPTyk (ORCPT + 99 others); Fri, 16 Dec 2022 14:54:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbiLPTyG (ORCPT ); Fri, 16 Dec 2022 14:54:06 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B38AC6F0F1 for ; Fri, 16 Dec 2022 11:52:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671220361; 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=IPglY0aqvnEm0C1nSlCk3w7HoTeCEVH3uDsZbz4QVDqPNv0OP4+5DyUxyvQetIxODbtjGL NMRmaI6QIvtoIq7BxBF6I0BpGGSCWuGifwewZfZJO1KUx/8OmSx9dVzJtMeORs9KcVsbnI 4dbBez/tHQMMHrt7HnQ5VPf6X5RIjiw= 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752401890116511742?= X-GMAIL-MSGID: =?utf-8?q?1752401890116511742?= 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) {