Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp361011ybl; Thu, 12 Dec 2019 20:05:31 -0800 (PST) X-Google-Smtp-Source: APXvYqw476T7ZbudEeI5m3c7xLvP6hv1IhhurF58ynQX0svHPobEuezEOm9pTr1L2bC5MOv4huzH X-Received: by 2002:a9d:5888:: with SMTP id x8mr11664276otg.361.1576209931147; Thu, 12 Dec 2019 20:05:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576209931; cv=none; d=google.com; s=arc-20160816; b=Tp9j5DIyH+Yq4qKU9jbqV7K4yTYzVdoiA9d1orfXbimbfF0/PODqYL4ehGifxmh9lq XewDwGxrvI9i6cjkcz7n9g1hISXAnlcMiNPnzgwiwipjbCtr+/EEK8jBoXzoH6C4e1Yn 5zJWcoBmLFSREq1OKI7tyNEzWbPO12BSUKyz07IKFjiC89lDUoXk1DUUxiw0XopqTN8Y nj0ky2aE7fvhi6+9tnJej84aLZUiNWD0zkSms4ew5gYvCBYZW33RwtOdludBDLdidK8o SNKlj346TNxNiuyIqyAc2mtVUZ/QLZkZzwsFAzp5JBzVUcCMFFWw3T+XEbAct2v4eHWP THsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=+M/6rXQ+3C4S9kUKW0wMInpKWUXyGr648m/0Y/7hVEk=; b=XPwVBFhtDzJWqgT6A/Ycxx3IbkicMqdCoUO+m6b9uWAefEuHkzVAypzrhI+3v2nP4S H3l0ur2SX5Av25d4qh8k+1NUQONhOS+CWckPT1W5eq8GDlm2hgRsIlmT3HGOSo2GWXo/ gd+HhPUa6tXcIk7SYbErcDbck1sM+uQ1767MeaVBPtgE7z0XFnfZpe/56kUby2GTXnWI mFtU7tLcUep2w096zX1wdzYR5QzCZqhm9coc+3hxRYdW/h1se4LZyG54ohaKJB/H4G4g kxQIpVdKOC2t5k98Z/SunTcjaJu0Zns2VE5MleqRUKCoLs6mfpFJf9st5CWm/pUZ7EHa VP9w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si4356422oie.9.2019.12.12.20.04.47; Thu, 12 Dec 2019 20:05:31 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731496AbfLMDqD (ORCPT + 99 others); Thu, 12 Dec 2019 22:46:03 -0500 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:39756 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731357AbfLMDqD (ORCPT ); Thu, 12 Dec 2019 22:46:03 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04427;MF=rocking@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0TklN2C6_1576208759; Received: from localhost(mailfrom:rocking@linux.alibaba.com fp:SMTPD_---0TklN2C6_1576208759) by smtp.aliyun-inc.com(127.0.0.1); Fri, 13 Dec 2019 11:45:59 +0800 From: Peng Wang To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de Cc: linux-kernel@vger.kernel.org, Peng Wang Subject: [PATCH v2] schied/fair: Skip calculating @contrib without load Date: Fri, 13 Dec 2019 11:45:40 +0800 Message-Id: <1576208740-35609-1-git-send-email-rocking@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575648862-12095-1-git-send-email-rocking@linux.alibaba.com> References: <1575648862-12095-1-git-send-email-rocking@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Perhaps we can gain some performance advantage by saving these unnecessary calculation. 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