Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1268414ybl; Fri, 23 Aug 2019 16:34:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQ+mDN4fJ8j4yndzAtGecdOUg9HGWmB4DUg7KUhzn2Q07N8yTJVqxrmCq9vypxRRz2lJKp X-Received: by 2002:a17:90a:17aa:: with SMTP id q39mr7753894pja.106.1566603273184; Fri, 23 Aug 2019 16:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566603273; cv=none; d=google.com; s=arc-20160816; b=n+5UBpHKUW03+OOBJzpSu7X00HedEtLtbydKX3MlmrGaGOb2usAhfLZItZw5uc+yL2 XXMrueupB+eD3fIXF7BvIp+1CMfWoJG6D6gSdl4gPc7862iKqr0R4sr9TbG1NMyjdO9J JukUG/G8d/x2IFnbgW1CwFf/U/2x44iY13ZeYf2NxTxiiHCY3kTmRdRTozi+jVrpkulg waqvBmDMMTR5IbRGfh33OpAxiQ551FR5DN9Ond3ggldShHSuIadMqlhhtwCCFqCluQ9C riBOMeGD43ZnTX7j6J6gN3Tn1vBE/bSloYCa0VLrYaIspWZ7s8TF/OAhOVWeDDGRFF62 z0OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dkim-signature; bh=LlY7R9oI63QnnjzzCPznegjo2e3AtB25U8NRGe3mrEs=; b=N+YsxaT/YtuJvRp0Pztm999RdN9f2UDvFD90lDTbToRd8E44tECkQHggtAMM1kBg3F gBJ3PikIP2RmlNkZmOdC0tElbDqCivtNxTHCDvVM9BMAjVhj/Z7Gzk9wAnAbEOxQDDeA boLabNRNUDssrAsWSX1VsjPYQUhqlVcxJmNWm/tUblndHVd0XLQ4CNzWW+Bl9mxFnZa6 Qvmh5xqCN1eee4xUBx5Y9bSGriMoWGr7NYFDOWu1B5s/9FFGz1zWNU6WJm1Cefaw/OuE Sgbhwc09F5gPR0jHjvYf1/ZTZ0vVu9LINAVODvQQVkWlQVsbnBOpB1fry5ywxD2L7wPQ r55Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BvZ0YZDV; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si3192484pgo.125.2019.08.23.16.34.17; Fri, 23 Aug 2019 16:34:33 -0700 (PDT) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=BvZ0YZDV; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389837AbfHWR2H (ORCPT + 99 others); Fri, 23 Aug 2019 13:28:07 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37821 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389408AbfHWR2G (ORCPT ); Fri, 23 Aug 2019 13:28:06 -0400 Received: by mail-pf1-f194.google.com with SMTP id y9so6503262pfl.4 for ; Fri, 23 Aug 2019 10:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=LlY7R9oI63QnnjzzCPznegjo2e3AtB25U8NRGe3mrEs=; b=BvZ0YZDVcFNF6hXlr+zCDxRH/ZfbM+zmnthSBPpJuKXNATNKTSumVzYUQobMNMz7k2 9tCfAUdSZw6Wg09MCJ2wgBoJtl/6fzJ+VeBv4MQOkEs1MJdW/79R7W/2rX4YqMTgaQB1 3Hk23csdEwwAWZLu1/wn0ChPrM1VAgzmWX4LwjC3uJKeH4TLQxxYKTmfO1I4xA2HyRG6 tUXDO+yATvuHlj0+gINMfXyzEUe/hqmrUu0L0+vuf61xGgik6LI6YGPu7YLe6D9BGj+n OQ/JjSOj4RWjdoxFOtwzKwzuVlPNPNdSx/xVnamfoHWz82uSiuAnimE9lJdhDSpU+bB/ 8Gpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=LlY7R9oI63QnnjzzCPznegjo2e3AtB25U8NRGe3mrEs=; b=MPHuqB1dTDo/3h/1wv6wyLKgPVCgvnInMMbHFjierIx8TY9aETnqVFDYMAqrOaBuNP ftWxZ3RS8g4+5pNzAjlM5NZLmGnPdPuwMgJK8bwQuk7csmTrf5mkXXp3XbtO+XnGPJoc XqlG3msmCPFXy6z69ONJEjYo3/jslbb6SdvhZlQCKdjwh95ZtSIYh0JUIibx06Pz4KiL 245UU9UKw7ee695VAUD//vpZUaEpDX+EjIZMYL79h2Bw1BgmebDRWELQKp/EJm1Xi9lb lJ0H4Yqhzmsn+Hv0v25iapRcccxpkzI8Iy/5m9VbRvwWNx48KjHZuKFpWkl8lZVDZ8JA f7uw== X-Gm-Message-State: APjAAAXyv1Or3CN51gFDlYSeLFiWwXpxAXH16yntr6vxtHutC4hCfTzV sbTq7L8YAKnetmTrJJ2dJbjfWAj30N8hAQ== X-Received: by 2002:a17:90a:8991:: with SMTP id v17mr6239174pjn.120.1566581284844; Fri, 23 Aug 2019 10:28:04 -0700 (PDT) Received: from bsegall-linux.svl.corp.google.com.localhost ([2620:15c:2cd:202:39d7:98b3:2536:e93f]) by smtp.gmail.com with ESMTPSA id f63sm3804969pfa.144.2019.08.23.10.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2019 10:28:03 -0700 (PDT) From: bsegall@google.com To: Dave Chiluk Cc: Qian Cai , Ingo Molnar , Peter Zijlstra , Phil Auld , Linux Kernel Mailing List Subject: Re: [PATCH -next v2] sched/fair: fix -Wunused-but-set-variable warnings References: <1566326455-8038-1-git-send-email-cai@lca.pw> Date: Fri, 23 Aug 2019 10:28:02 -0700 In-Reply-To: (Dave Chiluk's message of "Fri, 23 Aug 2019 09:48:08 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dave Chiluk writes: > On Wed, Aug 21, 2019 at 12:36 PM wrote: >> >> Qian Cai writes: >> >> > The linux-next commit "sched/fair: Fix low cpu usage with high >> > throttling by removing expiration of cpu-local slices" [1] introduced a >> > few compilation warnings, >> > >> > kernel/sched/fair.c: In function '__refill_cfs_bandwidth_runtime': >> > kernel/sched/fair.c:4365:6: warning: variable 'now' set but not used >> > [-Wunused-but-set-variable] >> > kernel/sched/fair.c: In function 'start_cfs_bandwidth': >> > kernel/sched/fair.c:4992:6: warning: variable 'overrun' set but not used >> > [-Wunused-but-set-variable] >> > >> > Also, __refill_cfs_bandwidth_runtime() does no longer update the >> > expiration time, so fix the comments accordingly. >> > >> > [1] https://lore.kernel.org/lkml/1558121424-2914-1-git-send-email-chiluk+linux@indeed.com/ >> > >> > Signed-off-by: Qian Cai >> >> Reviewed-by: Ben Segall >> >> > --- >> > >> > v2: Keep hrtimer_forward_now() in start_cfs_bandwidth() per Ben. >> > >> > kernel/sched/fair.c | 19 ++++++------------- >> > 1 file changed, 6 insertions(+), 13 deletions(-) >> > >> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> > index 84959d3285d1..06782491691f 100644 >> > --- a/kernel/sched/fair.c >> > +++ b/kernel/sched/fair.c >> > @@ -4354,21 +4354,16 @@ static inline u64 sched_cfs_bandwidth_slice(void) >> > } >> > >> > /* >> > - * Replenish runtime according to assigned quota and update expiration time. >> > - * We use sched_clock_cpu directly instead of rq->clock to avoid adding >> > - * additional synchronization around rq->lock. >> > + * Replenish runtime according to assigned quota. We use sched_clock_cpu >> > + * directly instead of rq->clock to avoid adding additional synchronization >> > + * around rq->lock. >> > * >> > * requires cfs_b->lock >> > */ >> > void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b) >> > { >> > - u64 now; >> > - >> > - if (cfs_b->quota == RUNTIME_INF) >> > - return; >> > - >> > - now = sched_clock_cpu(smp_processor_id()); >> > - cfs_b->runtime = cfs_b->quota; >> > + if (cfs_b->quota != RUNTIME_INF) >> > + cfs_b->runtime = cfs_b->quota; >> > } >> > >> > static inline struct cfs_bandwidth *tg_cfs_bandwidth(struct task_group *tg) >> > @@ -4989,15 +4984,13 @@ static void init_cfs_rq_runtime(struct cfs_rq *cfs_rq) >> > >> > void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b) >> > { >> > - u64 overrun; >> > - >> > lockdep_assert_held(&cfs_b->lock); >> > >> > if (cfs_b->period_active) >> > return; >> > >> > cfs_b->period_active = 1; >> > - overrun = hrtimer_forward_now(&cfs_b->period_timer, cfs_b->period); >> > + hrtimer_forward_now(&cfs_b->period_timer, cfs_b->period); >> > hrtimer_start_expires(&cfs_b->period_timer, HRTIMER_MODE_ABS_PINNED); >> > } > > Looks good. > Reviewed-by: Dave Chiluk > > Sorry for the slow response, I was on vacation. > > @Ben do you think it would be useful to still capture overrun, and > WARN on any overruns? We wouldn't expect overruns, but their > existence would indicate an over-loaded node or too short of a > cfs_period. Additionally, it would be interesting to see if we could > capture the offset between when the bandwidth was refilled, and when > the timer was supposed to fire. I've always done all my calculations > assuming that the timer fires and is handled exceedingly close to the > time it was supposed to fire. Although, if the node is running that > overloaded you probably have many more problems than worrying about > timer warnings. That "overrun" there is not really an overrun - it's the number of complete periods the timer has been inactive for. It was used so that a given tg's period timer would keep the same phase/offset/whatever-you-call-it, even if it goes idle for a while, rather than having the next period start N ms after a task wakes up. Also, poor choices by userspace is not generally something the kernel generally WARNs on, as I understand it.