Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp450473ybl; Wed, 29 Jan 2020 03:36:16 -0800 (PST) X-Google-Smtp-Source: APXvYqz2n2+XvveHEVbhA5f2KyRubKH85/w8TCy90RJS4usaVo7QKacxwv4Drxyo7COzv38S6/PM X-Received: by 2002:a05:6830:4b9:: with SMTP id l25mr20595878otd.266.1580297776498; Wed, 29 Jan 2020 03:36:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580297776; cv=none; d=google.com; s=arc-20160816; b=YU450YuGP5xqACoL3kZ5NDIb+NvRuZWyTC0XLqlI+x8R2tPF2gq54QuCcE+gTU/ne6 7BhYVV3pB4FIDG2lPlC+Y7WSKq849pwH0CRpNC2C+txfXnpIilN0GJvEuKiBm4dqcx1s ozoZCY1ee70uja7IQKRK4Psy2PxLZ+GzwvSDIzAu/ZKFi85L0ryqI1cQ420P4tEIKUgm y0kXDXLVd9XPukxZuELZ1O64es36rlbbhrJCWeIZvjgzZNPwXJQZz8KrG8V1dwY7rJcB pb5xq4K5EwjffN3akRfdcPsIB5cz3wOoCW97cTsFvMspsJRccdgIqen0LycaR+j9lYJn 5kvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=f8OJHSJto0r+LqVEsXGXzioPrKq28sTn7aAV47h2R6A=; b=hJ0SuCXZGy7djO5NftzYKnxd+ypGK+KZvPwGB7hx6qU1ewX1fvMyaqOb5+cIneEYdO G95n7p5UqnECUr71VLoWxNLuviTaW23oKUlGk9ZpsdG5lmMe5Z0q98Qd/Th+FcN/AUqj xL2vfs83gbX4GFcKd79d898vllBah7403LcPhEsFl0vZEVhYbzlN30oSQigeKVvSwwLK ZCSScoHb3nr+MyZZoYO9Chs0QLF5ztNTZRrvG3XO3CscwvjalWNQOldqY6GUcmgryGXg 5BVAzJ/nwl5OwNiY+z2TtHlWVtOb+ULpuLzaQ4NKBtBfG0MytDc85j5OgmdE/6Dz0V1l I6zg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x22si974805otp.107.2020.01.29.03.36.04; Wed, 29 Jan 2020 03:36:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726996AbgA2Ldr (ORCPT + 99 others); Wed, 29 Jan 2020 06:33:47 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:51115 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726751AbgA2LdM (ORCPT ); Wed, 29 Jan 2020 06:33:12 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iwlah-0007o9-NS; Wed, 29 Jan 2020 12:33:03 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 5A3751C1C1D; Wed, 29 Jan 2020 12:33:00 +0100 (CET) Date: Wed, 29 Jan 2020 11:33:00 -0000 From: "tip-bot2 for Peter Zijlstra (Intel)" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] timers/nohz: Update NOHZ load in remote tick Cc: "Peter Zijlstra (Intel)" , Scott Wood , Ingo Molnar , x86 , LKML In-Reply-To: <1578736419-14628-3-git-send-email-swood@redhat.com> References: <1578736419-14628-3-git-send-email-swood@redhat.com> MIME-Version: 1.0 Message-ID: <158029758015.396.8419469539001860762.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: 1.5 X-Linutronix-Spam-Level: + X-Linutronix-Spam-Status: No , 1.5 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_DBL_ABUSE_MALW=2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: ebc0f83c78a2d26384401ecf2d2fa48063c0ee27 Gitweb: https://git.kernel.org/tip/ebc0f83c78a2d26384401ecf2d2fa48063c0ee27 Author: Peter Zijlstra (Intel) AuthorDate: Sat, 11 Jan 2020 04:53:39 -05:00 Committer: Ingo Molnar CommitterDate: Tue, 28 Jan 2020 21:36:44 +01:00 timers/nohz: Update NOHZ load in remote tick The way loadavg is tracked during nohz only pays attention to the load upon entering nohz. This can be particularly noticeable if full nohz is entered while non-idle, and then the cpu goes idle and stays that way for a long time. Use the remote tick to ensure that full nohz cpus report their deltas within a reasonable time. [ swood: Added changelog and removed recheck of stopped tick. ] Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Scott Wood Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Link: https://lkml.kernel.org/r/1578736419-14628-3-git-send-email-swood@redhat.com --- include/linux/sched/nohz.h | 2 ++ kernel/sched/core.c | 4 +++- kernel/sched/loadavg.c | 33 +++++++++++++++++++++++---------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/include/linux/sched/nohz.h b/include/linux/sched/nohz.h index 1abe91f..6d67e9a 100644 --- a/include/linux/sched/nohz.h +++ b/include/linux/sched/nohz.h @@ -15,9 +15,11 @@ static inline void nohz_balance_enter_idle(int cpu) { } #ifdef CONFIG_NO_HZ_COMMON void calc_load_nohz_start(void); +void calc_load_nohz_remote(struct rq *rq); void calc_load_nohz_stop(void); #else static inline void calc_load_nohz_start(void) { } +static inline void calc_load_nohz_remote(struct rq *rq) { } static inline void calc_load_nohz_stop(void) { } #endif /* CONFIG_NO_HZ_COMMON */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index cf8b33d..4ff03c2 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3677,6 +3677,7 @@ static void sched_tick_remote(struct work_struct *work) if (cpu_is_offline(cpu)) goto out_unlock; + curr = rq->curr; update_rq_clock(rq); if (!is_idle_task(curr)) { @@ -3689,10 +3690,11 @@ static void sched_tick_remote(struct work_struct *work) } curr->sched_class->task_tick(rq, curr, 0); + calc_load_nohz_remote(rq); out_unlock: rq_unlock_irq(rq, &rf); - out_requeue: + /* * Run the remote tick once per second (1Hz). This arbitrary * frequency is large enough to avoid overload but short enough diff --git a/kernel/sched/loadavg.c b/kernel/sched/loadavg.c index 28a5165..de22da6 100644 --- a/kernel/sched/loadavg.c +++ b/kernel/sched/loadavg.c @@ -231,16 +231,11 @@ static inline int calc_load_read_idx(void) return calc_load_idx & 1; } -void calc_load_nohz_start(void) +static void calc_load_nohz_fold(struct rq *rq) { - struct rq *this_rq = this_rq(); long delta; - /* - * We're going into NO_HZ mode, if there's any pending delta, fold it - * into the pending NO_HZ delta. - */ - delta = calc_load_fold_active(this_rq, 0); + delta = calc_load_fold_active(rq, 0); if (delta) { int idx = calc_load_write_idx(); @@ -248,6 +243,24 @@ void calc_load_nohz_start(void) } } +void calc_load_nohz_start(void) +{ + /* + * We're going into NO_HZ mode, if there's any pending delta, fold it + * into the pending NO_HZ delta. + */ + calc_load_nohz_fold(this_rq()); +} + +/* + * Keep track of the load for NOHZ_FULL, must be called between + * calc_load_nohz_{start,stop}(). + */ +void calc_load_nohz_remote(struct rq *rq) +{ + calc_load_nohz_fold(rq); +} + void calc_load_nohz_stop(void) { struct rq *this_rq = this_rq(); @@ -268,7 +281,7 @@ void calc_load_nohz_stop(void) this_rq->calc_load_update += LOAD_FREQ; } -static long calc_load_nohz_fold(void) +static long calc_load_nohz_read(void) { int idx = calc_load_read_idx(); long delta = 0; @@ -323,7 +336,7 @@ static void calc_global_nohz(void) } #else /* !CONFIG_NO_HZ_COMMON */ -static inline long calc_load_nohz_fold(void) { return 0; } +static inline long calc_load_nohz_read(void) { return 0; } static inline void calc_global_nohz(void) { } #endif /* CONFIG_NO_HZ_COMMON */ @@ -346,7 +359,7 @@ void calc_global_load(unsigned long ticks) /* * Fold the 'old' NO_HZ-delta to include all NO_HZ CPUs. */ - delta = calc_load_nohz_fold(); + delta = calc_load_nohz_read(); if (delta) atomic_long_add(delta, &calc_load_tasks);