Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1738800ybt; Mon, 15 Jun 2020 08:12:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD/dr9RrGapEdHwgeXfZAypvy/2wLswowXQpDyYv82KQ7wjsdBxuj9h42vk5vH73gY/4cJ X-Received: by 2002:a17:906:90d4:: with SMTP id v20mr25568188ejw.471.1592233932577; Mon, 15 Jun 2020 08:12:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592233932; cv=none; d=google.com; s=arc-20160816; b=bXE43/4+P5atCjzA1SUSrD4/e5HUXgSaxIZMu/vlb4czJRa9uNE2wwGFk5T3XnJdtT dEXtWo2GI/KkIkN326egCz/H12HdZaB0nnTxb286vnkDRfyGVxv4NwA4hin5eR/wRN4+ /Xh7Kjs/QU9CryVmwXoeZTqO7cWI2bKm3+9WabkEbTeh8qftDuyyGEzrJ1TWCXPHDcoo iOaF4OHbVG650Dy3C5DxvtJXlIsako5Kg3hrhEYJ/Mar6uqQmZ+ZbH9vAUPSu5CdMj6H iAzEvKnTCgEdLrG3uA5zKYbrf8HWmuLVwkRDQGKlsr2hopTIaAbE5b6aSSjxkZxt0oC3 695g== 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=P4sVMM7TaNawdbsHgDCWa8zSnS2h9z0AXuq8X1e8ReQ=; b=zVCD7Xi8P1V+GLxSenTaXhIeHevnslLKs4GDiSGis4IfzLxR8fPeWIYPtShdTeOeUF sH4grTCAdOTJ8zwcI1yThjFXYNTGQBZ7ArXZ74I7clxSYS428PbLL9OeWblJ4by4voLD 0D+NaiBEn4TKLg4HMcZm6N5xCt073yfvuDBGXtqc8IVJnGNuq9qWPCbY8566voI02Shr Ru5b9G3WUr/Hx8rfJ4qyK5JMc35LuevhMC6otm4jyKLT13QpYv2AtdXLuy2bfJm9QvL4 SLybizuWlfxIfY+guRDyVk/50kK+dM+yFs3Cpta745irKNnsxDaNQhxj7urys1GMTwSE QyJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vRNGuRQZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b22si8111183edx.194.2020.06.15.08.11.50; Mon, 15 Jun 2020 08:12:12 -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; dkim=pass header.i=@linaro.org header.s=google header.b=vRNGuRQZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730804AbgFOPKH (ORCPT + 99 others); Mon, 15 Jun 2020 11:10:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729875AbgFOPKG (ORCPT ); Mon, 15 Jun 2020 11:10:06 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F96CC061A0E for ; Mon, 15 Jun 2020 08:10:05 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id x18so19592876lji.1 for ; Mon, 15 Jun 2020 08:10:05 -0700 (PDT) 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=P4sVMM7TaNawdbsHgDCWa8zSnS2h9z0AXuq8X1e8ReQ=; b=vRNGuRQZjesjUflGiRKEGce7m37DbhtoGaMt5c9miL80zJacRgCqaFj88HlLnKbQZV VThb+a3WLwphv0AzeTjNvjFY1u/sWfwGUhD/fd6EZVWdMajCACk8nKx5LeR6TZuSduTR Ow5p1T9ltleg2ul7/5H0fCYq6apXcTA9xI+15VzOF5tfGIgZ7CjAB5IV/GN/CwgkUhFc tjPailaxNrN8SAkwNPqgg8rChdsY/DmP/vX+wkjMHXed5NNTL/YgtTUiCSoM5WayfNyU HY+3096zEW3bTBWeBGIrIe88rL6tvhYldzO1OtRX0iXIYNh0Nr3SKW4JAKKHnDM5c5Sv F76w== 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=P4sVMM7TaNawdbsHgDCWa8zSnS2h9z0AXuq8X1e8ReQ=; b=KtIkczNgv8QINYpfurbWXuf0Px6P2CzmnaulWtBbD8l9MtVH64uHgfbgExKwrqErQB 5mS2D24bZ6IQYl1aCa6i67pSKNcc7u2WjD4Otc5r4wlD1n0GdoRyk0N925UNpMA8Fg5o cAePIFGFzfi1wL3OVyPND9Cq0imau8t6NrIwdo1ro7fSr8+PQ9spGshXqrIfeL/Q5jeU 5eFu8ZY+BmOM2vGILirD8JfPLyo2pjY9HsMqP3ovsJbx8DmOK/VuVG39Irmz7LgFbbj9 JyCeDvue3aRlpamqr2RSzy65qutc8vJEZMUQKtyueiKgeYoMnHn+ahVaZLyjnZgeeR7v 2Asg== X-Gm-Message-State: AOAM532DA0NCpAeTrVhgVm0iUpZSjGl1ayBDhjCU6lnQIcoiYz1aDIL8 bUnLTUi/QqD0lLmkivQl9aNvmvgP/0KoDxGcdCCESA== X-Received: by 2002:a2e:96da:: with SMTP id d26mr13367284ljj.25.1592233803627; Mon, 15 Jun 2020 08:10:03 -0700 (PDT) MIME-Version: 1.0 References: <6f2f195aea48bc50187dfb064aa530ba132be01b.1592230286.git.rocking@linux.alibaba.com> In-Reply-To: <6f2f195aea48bc50187dfb064aa530ba132be01b.1592230286.git.rocking@linux.alibaba.com> From: Vincent Guittot Date: Mon, 15 Jun 2020 17:09:51 +0200 Message-ID: Subject: Re: [PATCH] sched/fair: Optimize dequeue_task_fair() 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 On Mon, 15 Jun 2020 at 16:20, Peng Wang wrote: > > 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()"). good point > > dequeue_throttle label can ensure se not to be NULL, and se is > always NULL when reaching root level. > > 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..e6be952 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -5614,10 +5614,10 @@ 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); > > +dequeue_throttle: > /* balance early to pull high priority tasks */ > if (unlikely(!was_sched_idle && sched_idle_rq(rq))) > rq->next_balance = jiffies; You can move the label here because sched_idle_rq() uses rq->nr-running and rq->cfs.idle_h_nr_running so they will not change if we jump to the label before reaching root level > -- > 2.9.5 >