Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6926203rdb; Tue, 2 Jan 2024 20:34:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0tZQXdQlfepmygS1bQNKg2ZD7PXILvf1AbpQvEYWa6DdlDFrXCYQBkfJWlFXDMCGzFHYr X-Received: by 2002:a05:6a00:1989:b0:6d9:3628:d50e with SMTP id d9-20020a056a00198900b006d93628d50emr560718pfl.32.1704256487228; Tue, 02 Jan 2024 20:34:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704256487; cv=none; d=google.com; s=arc-20160816; b=HJCtcFK7Zk1Keu2C7/TUQKOyv97mUMhMGIkG5kmnP+dxbICw/un3x6qS1rrwLK1KML nME/kI6Q+eCZkVlmBe2e5jJdSOU/Jk8DeX/rKblyVg0RZ8DDb1WoNO557ViRZrQ4qAb+ E1MtMDnDSZrIotAe0xENf1IQZPcV8zdromxIq0A04ekQyUC9a5GScMZ8KRITPgCKTj6M P/a4hT3aO9EjvY/FpaeSjH79EoA8r2gwI2ecaG6+PP9kE+9HXUzW8KZhdPHopgC4IsNi RNOpAta533v0WdOS3jn2ShmInB/rY/HoMB03YwZGwA6vAXZtcuhexFHJou0Rixy4h+Hh tKsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date; bh=bqClvV2P0czyZMsFCnU64D+UDftEZJpLB9zo9Kp2oek=; fh=f40UFx4PIoN5VHjot5Te0Vsnl2epc2I3Vpkjl2f6MCo=; b=wy43GuMI9+HguSWqQytGZD5M/u6+7Uj+aN/n69vU1sJOIoyQ4zt5ChyQhpx1PiJnCb a3ROgci3mbvuZZt/YzTCSYhHq/jp82A+eQ+l5Nl/N3BUE08fQsnCUiUMwUnrtBOhUDPv QAur8csXXXzrWWtUSApPzXPhw66j9aQ0MCU4JrkbtFfArLez4o2Ptqi73B/KHvxbfBFP Vit76FnrOHj39rKoayrhQK+R43DaEPZD8duEWQ0TwiT3Iv4sknJkUHBZ6W7llH9Z8+n/ QGpxvKH+4RECQDhXPEch5CWNaLgcyTCjNGBsg+Ou8d2dvejQ1W7JIWMGUfisLspzCWX9 0Giw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15153-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15153-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x188-20020a6263c5000000b006d98bbbd3cbsi18618756pfb.295.2024.01.02.20.34.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 20:34:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15153-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15153-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15153-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DC423284E75 for ; Wed, 3 Jan 2024 04:34:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D040317748; Wed, 3 Jan 2024 04:34:40 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from wxsgout04.xfusion.com (wxsgout03.xfusion.com [36.139.52.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80FA0171C4 for ; Wed, 3 Jan 2024 04:34:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xfusion.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xfusion.com Received: from wuxshcsitd00600.xfusion.com (unknown [10.32.133.213]) by wxsgout04.xfusion.com (SkyGuard) with ESMTPS id 4T4bw92tcmzB13y6; Wed, 3 Jan 2024 12:14:49 +0800 (CST) Received: from localhost (10.82.147.3) by wuxshcsitd00600.xfusion.com (10.32.133.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 3 Jan 2024 12:18:31 +0800 Date: Wed, 3 Jan 2024 12:18:31 +0800 From: Wang Jinchao To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , CC: , Subject: [PATCH] sched/fair: Optimize min_vruntime update on unchanged vruntime Message-ID: <202401031216+0800-wangjinchao@xfusion.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline X-ClientProxiedBy: wuxshcsitd00601.xfusion.com (10.32.135.241) To wuxshcsitd00600.xfusion.com (10.32.133.213) When (!(curr && curr->on_rq) && !se) is true, there is no need to update min_vruntime. Simplify the if-else logic accordingly. Signed-off-by: Wang Jinchao --- kernel/sched/fair.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d7a3c63a2171..a4afdeee515d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -755,21 +755,16 @@ static void update_min_vruntime(struct cfs_rq *cfs_rq) struct sched_entity *se = __pick_first_entity(cfs_rq); struct sched_entity *curr = cfs_rq->curr; - u64 vruntime = cfs_rq->min_vruntime; + u64 vruntime = U64_MAX; - if (curr) { - if (curr->on_rq) - vruntime = curr->vruntime; - else - curr = NULL; - } + if (curr && curr->on_rq) + vruntime = curr->vruntime; + if (se) + vruntime = min_vruntime(vruntime, se->vruntime); - if (se) { - if (!curr) - vruntime = se->vruntime; - else - vruntime = min_vruntime(vruntime, se->vruntime); - } + /* no need to update if vruntime is unchanged */ + if (vruntime == U64_MAX) + return; /* ensure we never gain time by being placed backwards. */ u64_u32_store(cfs_rq->min_vruntime, -- 2.40.0