Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp598409ybl; Fri, 13 Dec 2019 01:24:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzTOUGqQ6z3248cbrq65pbZUEWj7BY0nrmLEI7kv9HNG7uTMyuxIIh/Eku54WCjVrcHaqDP X-Received: by 2002:a9d:6045:: with SMTP id v5mr12717570otj.252.1576229053760; Fri, 13 Dec 2019 01:24:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576229053; cv=none; d=google.com; s=arc-20160816; b=OuMsYz34ftTc2KVLCIZDsQ/dXTNZKRxyQMQ4RLwzdTQt7zgbgry7x0I311b1hOnXfG ywYlWbFg/1/BrB60iBLgCT3FXtwYPX5b6MkNFQqaGg1W1mSpPm+K+Am6tbOkq2FcRawg /xlc7LOZrztwXcjJyNfJWZrYqghMx3ZdsnNdmxmqgF/hVdKQspQp5uFf6r2pHu59OyB5 /GeXskiamEm/is8kCpeFoB6ZBRh7z8zJzcdK8cfArGMlpIORTQDiGeI8y9CLAqrWdY00 JzWO0a23YVdE9M5W1jnW3f57zfBkobx2VDOOY/fzQdcOjyVN3X7F2E6c2oBVwHn/F5F9 chyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ZwmaUZJnMZMjAykwzuMYq1+U7baQKDrVjVyjfWLNTpw=; b=fgc9sXSYrHMNi8grP+dIHIa1cI/QMUFE/U+n2XnL7qSBvdPbQBMJZNEpR0+pPfrHss EBuCpE6F3xQDeKdyFvwFYHh2vHlUgXC3hC3DW2kFjrAZv71wkWfbGoA4b3Qpm+34UwZJ DBBCAxXRdRnMb9PmpR2DRCajmxbPrXIQyOUmF+uxcOauh1YPm5lXACMpAlqZQnM8lJff kXKHUcj2LaHEoTvc6xFmFHxp5874HhEd1stagb9CZZ/74NxgQUNdF83C5Td8Kek2Z0JH ZsDAPtP0hFdXFC9ApIHF8FDlmnVdB/aATSs/RiTlsfvz15YJasDXzAPPoDHq5x+rnFUb 0bFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KF2Cvyk+; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j13si4797410otq.146.2019.12.13.01.24.00; Fri, 13 Dec 2019 01:24:13 -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; dkim=pass header.i=@linaro.org header.s=google header.b=KF2Cvyk+; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726141AbfLMJWI (ORCPT + 99 others); Fri, 13 Dec 2019 04:22:08 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37071 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbfLMJWH (ORCPT ); Fri, 13 Dec 2019 04:22:07 -0500 Received: by mail-lf1-f65.google.com with SMTP id b15so1427809lfc.4 for ; Fri, 13 Dec 2019 01:22:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZwmaUZJnMZMjAykwzuMYq1+U7baQKDrVjVyjfWLNTpw=; b=KF2Cvyk+um/v+kxXqA2S5wHAkj8D6+AhKHlmdTVTCbha2Go4osgSNgw4BUNQFXQoDg P0GyScEVl0N4NFlb/b9/x4kz+6JbSUIwpvjNerr8IDahYkRxoRa25OtqjbzKGupwkVny qOgGjvMy41bDFgRQVetDMtkYOeO5K+6++Tc6LXxiSsP7b1kJmVqR8kBl3yukcYQYeQBR 6iFMa7q3heLX6iJilsN8ZEsbqwhPGMxX/c8RAvEXJaVHTa2kMU46it/oaCEOVOwimAuI gjrOODSkF3rNwVwsDQ9RlHNbiirhCbTk+iMCBO9gCdFVtSE8OLYkPAMIeFSqmcmk+CE5 au+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZwmaUZJnMZMjAykwzuMYq1+U7baQKDrVjVyjfWLNTpw=; b=M58q77m+3y9dg04sAsnjqPqJ0sZHJPOKx91k7MqT2HEMQ7aRo+hnD/HTOZD4RURAgD MOfE/qLw4lwVH9glIWKK4B0L2SGrBSRNdZ3nvrr0byoLJuLhcRvaQomXJujbzLIROnnK TB/AwsKRdnGq5Ce4e4jtiAKxq8wNVzPPfO1Q7CkX3H+mxvR+qtlyxX7+QpedLhhT17uL wozzj7N73GVeZUIm5UCIYGjHYMzNnCCOZE3v7uXM7S4nsjJMlM8tYgWbGlp1MoAcvb8M 1VACHCQu990X4oY4buiEs/kDGILh2pOO9/FdVVO9pkv/Nm7BYR616yAA98N/bvL3prU7 06lQ== X-Gm-Message-State: APjAAAXNCTpJWwnIU43w7g6cnn5Gd0bo4DRfFmRY2vut96TQm2ZQp98h /wyjFIWb64Nt9wkg43YKpb4X5eOk0cklCq+iF2oGbFM9 X-Received: by 2002:a19:6b0e:: with SMTP id d14mr8059708lfa.151.1576228925551; Fri, 13 Dec 2019 01:22:05 -0800 (PST) MIME-Version: 1.0 References: <1575648862-12095-1-git-send-email-rocking@linux.alibaba.com> <1576208740-35609-1-git-send-email-rocking@linux.alibaba.com> In-Reply-To: <1576208740-35609-1-git-send-email-rocking@linux.alibaba.com> From: Vincent Guittot Date: Fri, 13 Dec 2019 10:21:54 +0100 Message-ID: Subject: Re: [PATCH v2] schied/fair: Skip calculating @contrib without load To: Peng Wang Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peng, minor typo on the subject s/schied/sched/ On Fri, 13 Dec 2019 at 04:46, Peng Wang wrote: > > Because of the: > > if (!load) > runnable = running = 0; > > clause in ___update_load_sum(), all the actual users of @contrib in > accumulate_sum(): > > if (load) > sa->load_sum += load * contrib; > if (runnable) > sa->runnable_load_sum += runnable * contrib; > if (running) > sa->util_sum += contrib << SCHED_CAPACITY_SHIFT; > > don't happen, and therefore we don't care what @contrib actually is and > calculating it is pointless. > > If we count the times when @load equals zero and not as below: > > if (load) { > load_is_not_zero_count++; > contrib = __accumulate_pelt_segments(periods, > 1024 - sa->period_contrib,delta); > } else > load_is_zero_count++; > > As we can see, load_is_zero_count is much bigger than > load_is_zero_count, and the gap is gradually widening: > > load_is_zero_count: 6016044 times > load_is_not_zero_count: 244316 times > 19:50:43 up 1 min, 1 user, load average: 0.09, 0.06, 0.02 > > load_is_zero_count: 7956168 times > load_is_not_zero_count: 261472 times > 19:51:42 up 2 min, 1 user, load average: 0.03, 0.05, 0.01 > > load_is_zero_count: 10199896 times > load_is_not_zero_count: 278364 times > 19:52:51 up 3 min, 1 user, load average: 0.06, 0.05, 0.01 > > load_is_zero_count: 14333700 times > load_is_not_zero_count: 318424 times > 19:54:53 up 5 min, 1 user, load average: 0.01, 0.03, 0.00 your system looks pretty idle so i'm not sure to see a benefit of your patch in such situation > > Perhaps we can gain some performance advantage by saving these > unnecessary calculation. load == 0 when - system is idle and we updates blocked load but we don't really care about performance in this case and we will stop the trigger the update once the load_avg reach null value - a rt/dl/cfs rq or a sched_entity wakes up. In this case, skipping the calculation of the contribution should fasten the wake up path although i'm not sure about the amount Nevertheless, this change makes sense Reviewed-by: Vincent Guittot < vincent.guittot@linaro.org> > > Signed-off-by: Peng Wang > --- > kernel/sched/pelt.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c > index a96db50..4392953 100644 > --- a/kernel/sched/pelt.c > +++ b/kernel/sched/pelt.c > @@ -129,8 +129,9 @@ static u32 __accumulate_pelt_segments(u64 periods, u32 d1, u32 d3) > * Step 2 > */ > delta %= 1024; > - contrib = __accumulate_pelt_segments(periods, > - 1024 - sa->period_contrib, delta); > + if (load) > + contrib = __accumulate_pelt_segments(periods, > + 1024 - sa->period_contrib, delta); > } > sa->period_contrib = delta; > > -- > 1.8.3.1 >