Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7773643rwb; Tue, 6 Dec 2022 09:39:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf6NCT6iCouCrr6396KpNCmTwdVk0JQ3dFjC6nSyVvd1i5890bp4BvfDg9URJuOgLtJJCQVs X-Received: by 2002:a17:906:a094:b0:7ad:88f8:761f with SMTP id q20-20020a170906a09400b007ad88f8761fmr70020212ejy.417.1670348346833; Tue, 06 Dec 2022 09:39:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670348346; cv=none; d=google.com; s=arc-20160816; b=GBIV93ybn2fQK0sbCf+AioE89UBqXZk+IMf0CQhQSIXpG2ZAHmMIQuDCz+/32PO+sW vNWPGW0QR7p/CJS63i1PPw7do4+O5gqSdGDTYUmovPiacRyGGixo3Zm3RTSc+GBfFoCZ boS/VcbHcb+Kz6ioMnTM54c+wolkcocRQVTEDxi+8CyAHCmefFowH3HKGcl5QzAJYeU/ Wbae1gviLsRlXcgukbqNVgeWCsOwVXTL/mr7N48oQZVtHAN+u4+2+7ArVWrQkE+5AYWz AKtYNdsphjALD645lMMki1wxuNueUowkhANmdjGJAaEeV/8S/Y0ZGGkFgdtU7VMqyVWl d59A== 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=VGIeQOlE+MYPS8fgyARv+ctXmXZ7yTcBqE/3ohwUXpU=; b=QmhZEMQVdOxrpxfO1Z8JjgT4kK2IfWiSkptJuVep3G5MhaSev6QNN5v43pZk0LiN4I LhfDpH9r1F/gWedyRsmDo0BkZ7LMguwG5nC45rUir2Nr86vIGV8QieUvWEYgOMBOmUK/ jJ4MKaw8l5tuo9X0BiAV8nXjed6MA0oa016Pj/UU5xmdsSa6mickD4tuqksbyZZF9OFy LHiu0lIuJVRS4Fs9EOqYwEK7cZNaHwl92+6M1E4/W7BoypzZa9bornrH3q0+evciyQ13 TAhfwdM65hltawlWPWxhljEtgYD9mGIwpHDDn8BkxoaklRxNHx0QPO8AK/gWApZLS/TD +msA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q5MpW6eL; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs44-20020a1709072d2c00b007c11812c620si788245ejc.440.2022.12.06.09.38.48; Tue, 06 Dec 2022 09:39:06 -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=Q5MpW6eL; 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 S235368AbiLFRVM (ORCPT + 78 others); Tue, 6 Dec 2022 12:21:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235085AbiLFRUy (ORCPT ); Tue, 6 Dec 2022 12:20:54 -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 2F8A732BB1 for ; Tue, 6 Dec 2022 09:19:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670347197; 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=VGIeQOlE+MYPS8fgyARv+ctXmXZ7yTcBqE/3ohwUXpU=; b=Q5MpW6eLK+FghqUABD3yqcXryjvhJPKp0Zmjcm34OG/4qjLOii73PwigEyRzRS79/2rc5k B+1iYKJDQrXi2/nqZZ0SD/IBr+W9ErnQrua/rA5g9jQnFvOqem4HVX6LMjQfDhW8xaRkBz OuoBFj/5oZEbbv5JJwCUxhNAR+vzYuM= 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-196-ug--dlF1N-qCeDY4p4auHQ-1; Tue, 06 Dec 2022 12:19:42 -0500 X-MC-Unique: ug--dlF1N-qCeDY4p4auHQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1F23088646B; Tue, 6 Dec 2022 17:19:42 +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 AB1F4C15BA4; Tue, 6 Dec 2022 17:19:41 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id D1D4B409005E1; Tue, 6 Dec 2022 13:31:40 -0300 (-03) Message-ID: <20221206162416.509808578@redhat.com> User-Agent: quilt/0.66 Date: Tue, 06 Dec 2022 13:18:30 -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 Subject: [PATCH v9 4/5] tick/nohz_full: Ensure quiet_vmstat() is called on exit to user-mode when the idle tick is stopped References: <20221206161826.698593151@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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 From: Aaron Tomlin 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(-) 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,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(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) {