From mboxrd@z Thu Jan 1 00:00:00 1970 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 D1760C3DA7A for ; Thu, 5 Jan 2023 12:56:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBD87900006; Thu, 5 Jan 2023 07:56:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E951D900005; Thu, 5 Jan 2023 07:56:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C72E1900006; Thu, 5 Jan 2023 07:56:48 -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 9B3E6900003 for ; Thu, 5 Jan 2023 07:56:48 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 696891C08E7 for ; Thu, 5 Jan 2023 12:56:48 +0000 (UTC) X-FDA: 80320744896.27.91880FC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id CF74F40003 for ; Thu, 5 Jan 2023 12:56:46 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b63X5ef8; spf=pass (imf04.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=1672923406; 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=obH2kSV1xTwWOzsn/8LbRJLy9Pbv5pi8kruc4NlsH/sshBU8zP20rmNxIhyq4SpvxTZHlo ersUboZIALHYt09kP0UnvMXMCn7uPRDGuXTP+c5GIeFuGXoi/26pi2+R9sC2p0LakEQGZ4 RjnhCWahGAEKWTa8YwUf1TEOoWQEDp0= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b63X5ef8; spf=pass (imf04.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=1672923406; a=rsa-sha256; cv=none; b=F8d2UstMVgrwrOr1UYm0GJBaZr7owmWZl3V6LH1ppbXlHGGcWQcYWDck6OYtNsQlVJbDzB 7gZ07uY931T9bnmhiFy49gsQICpJKy+WB4qWuyfS99dFeMxOsxnKoULBvlWqGrFV7G+ZIs thC3WJplG3aNAGQQfZA1cX6G8t9mSoc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672923406; 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=b63X5ef82Ne7rvWCJKbYJ6G5r8rK0A9jN4LP6vmchMg03NJNTP97JhZH1515paae4gurkZ 5wEZ2yNiHSlWB1JUjGniwpbeWDy1kehLFnU9qFpDiluRaQZCbPA458hXwbF92sivkp2WTA VFToAYtLcoWE5cfz4HqXBWcTt2RjzFM= 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-564-weQCRA3ZMGSGIUvUlcJqnw-1; Thu, 05 Jan 2023 07:56:43 -0500 X-MC-Unique: weQCRA3ZMGSGIUvUlcJqnw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7B67B3C0F425; Thu, 5 Jan 2023 12:56: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 45D0340C1141; Thu, 5 Jan 2023 12:56:42 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 9F2C340502F3F; Thu, 5 Jan 2023 09:54:47 -0300 (-03) Message-ID: <20230105125248.892336104@redhat.com> User-Agent: quilt/0.66 Date: Thu, 05 Jan 2023 09:52:22 -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 v13 4/6] tick/nohz_full: Ensure quiet_vmstat() is called on exit to user-mode when the idle tick is stopped References: <20230105125218.031928326@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CF74F40003 X-Stat-Signature: tsjjpxaansenrw5auis7hhyhpjobgnm7 X-HE-Tag: 1672923406-302199 X-HE-Meta: U2FsdGVkX1/Id+OTXFvMRJUwiNAmjEyNXl6ueqddl39Z/fAsopfZczsL4HWhBdr0dHkGMfSdFb5A9Avta1qXN6DLsj3pJJnseOqj2UNNLn/iV5u11x8Ju1GS+A6lylq8IvQ5HkwEndFlI5wzlLYIx0I3E3nuxhKJGyM45pHubyIDU8zyjaBnxfoiM2Y1oWiEDwEwA6dXDaFr9fSs9ZhUVIqRLYF384eE7Q14VoHtAO8iMPrLAXvLUF+89pefH0MUK9n+KLFcZG8U5tkceMSDDS9t2iS7h2j3SBTKofIcdJwhM0iSWTgXamcsCKou1tHbbSpsXxzS8TjBRsjIG2klw8385Vx+PFLeCwEX8qGjp5q00Qa7JacsOThFKT/Bwbr1Ab8h0duKhzYIlP46t6ng2hWEyWphktVBir4Ptk/QVG7dOx6RibFaw+VOeW6mQQRAKwPU9/ib1dCnSwCGqzg4wR0bZPovXiZ3KknRUkTCRSJB8jovR0lCqO54t84ZlNROsFpdeAQrt3y60MHFfxqYnYr1vUoO2UBUoMnB+PiHPyh8HxpOK1VGBpEUcbzxXeWP2XfzAWMWCm3R+pRMoKndeBqOkjQAGtcKWLudlk/6TVsowY//fceCm+KKKo58UwUEayqImu3jgbQN+toCItHcU3Xy3l0LuNCG9INlK03rYl2tfYclIFG3X4nwLLiDz3ylf/atAcbmBfnrWNDwcr2hTAckWTku9rEuQ/EntGXx+fK7JWtQz3AGRABF9SfjM59d6BTJqZvcI7ieDFZMdpgzDxgPi+a/BEEHn5NUtA0N3L6Nog5H60iI225xFqmSF92HE6CZGFlMIELv77sSdNP/mRlTiFBbTGC2zv63nv+cmsdef1OjxPxfTXIXLVunKr8YHiNCUG+24mQnpmY9Wq2F1mkYI1C/k68Ez6qQpsuBL9Y= 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) {