Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2208774ybt; Mon, 15 Jun 2020 23:07:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFoLkW8v1vqv/wosfjx60+pZiHBgtNJPpEc43rrUVTM+zZ3OEHIwt2qdCLHKY6qETCXUmi X-Received: by 2002:aa7:d492:: with SMTP id b18mr1114910edr.339.1592287674565; Mon, 15 Jun 2020 23:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592287674; cv=none; d=google.com; s=arc-20160816; b=BmdGV6qinrXAbuXLgDtbqEEK2XJNDjCqUa8sBICPVVDyOf1B60zWinBVEWPdRJk+9N 5Q6Xvin4+b4Koe3ChsyarSTONdVGvCcLYZ+JKUqznAl17mQXfs8C+EAfkc+lztulIvNV ys5Cmi4OazIhxbyVdspf3/RuojjDolQODNBdtwe+04z4MiSTrr7BalXfSQ+AGDK0Sltg 1HNQ1gYP6V0Yboi9xkSK2CgRj4/GK5McWzqojRCNF8jNFwAGjSx0Kh6n+CrS7MjXT8yR vGuerxyCzMJyY/MyDjle/Q0vLokUm+5qKXFB+HrBvqRtb31Gika7+r21kZt5gQkC1lRr 3img== 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=BbJI5Qkkk3hjf83nrT59qJZBV8svH1BONzT6LsvIK4A=; b=fNTUN44vFQr3Vq0tCwtgE4Jiv66/bw8tgcpDGs64r1mOW3sVYkkpihjM9x8fVg+mRD 498JhyhvzQ53SRcUwITrnnwkeCZ2NJ5D1dExUoytb3MV7lAMtb4NG4JyR+UZzs2//rv/ Mw9biWkNIy2i57i0MRosowH7oQacnCuBgeVryMvdrQSSHQ3B05t4sPD0LzBdxD6y/02L 5K/6HnZeYis8SUdroanIrj29Qvg+JlU0tGAAzQr4sypCf//EIRfEKZOD4OjjyArHs6KN 7XEdi4LIXmlnnmZCQvKarGtn+zPPkT4JfX9fFcVninNwsrBJAC2C4gg3mTiA+LhKmJ9m FUjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id u3si10741375ejz.197.2020.06.15.23.07.31; Mon, 15 Jun 2020 23:07:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726878AbgFPGFs (ORCPT + 99 others); Tue, 16 Jun 2020 02:05:48 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:42234 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725775AbgFPGFr (ORCPT ); Tue, 16 Jun 2020 02:05:47 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01419;MF=rocking@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0U.l9QU7_1592287535; Received: from localhost(mailfrom:rocking@linux.alibaba.com fp:SMTPD_---0U.l9QU7_1592287535) by smtp.aliyun-inc.com(127.0.0.1); Tue, 16 Jun 2020 14:05:43 +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 Subject: [PATCH v2] sched/fair: Optimize dequeue_task_fair() Date: Tue, 16 Jun 2020 14:04:07 +0800 Message-Id: <701eef9a40de93dcf5fe7063fd607bca5db38e05.1592287263.git.rocking@linux.alibaba.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <6f2f195aea48bc50187dfb064aa530ba132be01b.1592230286.git.rocking@linux.alibaba.com> References: <6f2f195aea48bc50187dfb064aa530ba132be01b.1592230286.git.rocking@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While looking at enqueue_task_fair and dequeue_task_fair, it occurred to me that dequeue_task_fair can also be optimized as Vincent described in commit 7d148be69e3a ("sched/fair: Optimize enqueue_task_fair()"). When encountering throttled cfs_rq, dequeue_throttle label can ensure se not to be NULL, and rq->nr_running remains unchanged, so we can also skip the early balance check. Signed-off-by: Peng Wang --- kernel/sched/fair.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index cbcb2f7..05242b7 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5614,14 +5614,14 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) } -dequeue_throttle: - if (!se) - sub_nr_running(rq, 1); + /* At this point se is NULL and we are at root level*/ + sub_nr_running(rq, 1); /* balance early to pull high priority tasks */ if (unlikely(!was_sched_idle && sched_idle_rq(rq))) rq->next_balance = jiffies; +dequeue_throttle: util_est_dequeue(&rq->cfs, p, task_sleep); hrtick_update(rq); } -- 2.9.5