Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1208555ybl; Wed, 21 Aug 2019 11:43:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7B4f27fznkIFQgMBxgNNYrntrQ+ISAF1B9jgoLoEiKTRuIVEWOs13AFFbkoAbL19YpQnC X-Received: by 2002:a62:8688:: with SMTP id x130mr38862377pfd.162.1566413038837; Wed, 21 Aug 2019 11:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566413038; cv=none; d=google.com; s=arc-20160816; b=XuFQzSHUa5BTcCQFVcacHndrm+xfO8YGNj/Bs/RY+nAPYgHUWrCBRCxXLdwFuIdEUt 4epICT5qxYdEo6xUg2L5F8mS4N/3hPJqWrVr7HL8ehM3OJPPzLdJkGafuP34stks7ZRj 86qPuxFkuwMQp39J3W6tK8ffcm5mzsVhubnqRh0vnsia35A1vZeiCaYblcb5eSpg5jBH Z5Niik/mkvQRz3U45XcxfvDXgIJaiE2+j/bfsQXyZrtLjqWgXDW8dtA79PUQlCooJhj/ Gz/1T0ck0oVBiweiugd9dlnglS2AItwlTvNIdn5XK2979bpRdjrNbQ/82F+GwA+ZaKD8 xHpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kf5RXBkUmZn7pYyHjsUy7iUP0/zAm+AtDOJimInXYXs=; b=coDj1v3nHs6kjZf7574UWYFBMIdxufenwphL7PPtoY3snWPNWuQwQycb9yB+jqo9WD wUTQMD0kqy9R4yeQpm94FY6sLeXJbL3lwFxayaynVZx4vQlW7lo2rHlL3KEPl/AtxKZa DGfchznp2Qj11A9jAhgimwAfU9r6hVafyykny1TqYAJA+L/7AhX/RdZGuy+sv+5ADo8/ QBygvRtihyzyzKHCvUzV1WyCalqwCpUUx5kLEYniVhKzSIFO/sgj7r5dl4GzolQBVBuI leXd62cIKtIcZoB66troWDL8lAaFixWn0fJF0SJqRrhxkQ7s9rX0DQUzemwYnuVRWSXa psVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=BEhNKnjI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12si15077165plk.272.2019.08.21.11.43.44; Wed, 21 Aug 2019 11:43:58 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=BEhNKnjI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727559AbfHUShX (ORCPT + 99 others); Wed, 21 Aug 2019 14:37:23 -0400 Received: from merlin.infradead.org ([205.233.59.134]:49656 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726530AbfHUShX (ORCPT ); Wed, 21 Aug 2019 14:37:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kf5RXBkUmZn7pYyHjsUy7iUP0/zAm+AtDOJimInXYXs=; b=BEhNKnjIl46aLd+b4OgF/NX5h ViFJqdjHv2mz1fZq9Ct4OdFlbFaTh/+EY5D4JsJOLnbizBXD2BsHmoUaIbPBUSMjPodqk7/g7LNmp 1uxQjBeGnINhsh9WmGcBH69M3N4RtkBqn8o3ahkrevXa4z3MU9P2yQisVu/1cQbQxpnUxhTewbP5h YJVraVRCnStM8Z5Vu5E2pVzO2AKRp6+U/qyivZfCd8L+rzQUBJ6Mh1m9XeFHnrAXBE50x+c/3Rwkh +RhygbFOwCMDeachMiUjqAUhAo201m3r19dlg6ont+NIiHacLx1cB8QmitQOML8Ky2SzPvzkpX24C 3a+t0A1Ig==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i0VTx-0002D2-G4; Wed, 21 Aug 2019 18:37:17 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 6AD5F307456; Wed, 21 Aug 2019 20:36:42 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 040CD20A978FE; Wed, 21 Aug 2019 20:37:13 +0200 (CEST) Date: Wed, 21 Aug 2019 20:37:13 +0200 From: Peter Zijlstra To: Qais Yousef Cc: Peng Liu , linux-kernel@vger.kernel.org, mingo@redhat.com Subject: Re: [PATCH] sched/fair: eliminate redundant code in sched_slice() Message-ID: <20190821183713.GF2349@hirez.programming.kicks-ass.net> References: <20190816141202.GA3135@iZj6chx1xj0e0buvshuecpZ> <20190821151523.lwazjd2d6rp5otdh@e107158-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190821151523.lwazjd2d6rp5otdh@e107158-lin.cambridge.arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 21, 2019 at 04:15:24PM +0100, Qais Yousef wrote: > On 08/16/19 22:12, Peng Liu wrote: > > Since sched_slice() is used in high frequency, > > small change should also make sense. > > > > Signed-off-by: Peng Liu > > --- > > kernel/sched/fair.c | 11 ++++------- > > 1 file changed, 4 insertions(+), 7 deletions(-) > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index 1054d2cf6aaa..6ae2a507aac0 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -694,19 +694,16 @@ static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) > > u64 slice = __sched_period(cfs_rq->nr_running + !se->on_rq); > > > > for_each_sched_entity(se) { > > - struct load_weight *load; > > struct load_weight lw; > > > > cfs_rq = cfs_rq_of(se); > > - load = &cfs_rq->load; > > + lw = cfs_rq->load; > > > > - if (unlikely(!se->on_rq)) { > > + if (unlikely(!se->on_rq)) > > lw = cfs_rq->load; > > > > - update_load_add(&lw, se->load.weight); > > - load = &lw; > > - } > > - slice = __calc_delta(slice, se->load.weight, load); > > + update_load_add(&lw, se->load.weight); > > + slice = __calc_delta(slice, se->load.weight, &lw); > > Unless I misread the diff, you changed the behavior. > > update_load_add() is only called if (unlikely(!se->on_rq)), but with your > change it is called unconditionally. And lw is set twice. > > I think what you intended is this? So I'd really rather hold off on this; Rik is poking at getting rid of all of this hierarchical crud in one go.