From patchwork Mon Jan 15 14:34:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 188178 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1740923dyc; Mon, 15 Jan 2024 06:35:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEKptnS+xX5Hl/9coRYND4DEf2bVCzcRirkNKvHbMTSOHXVrfKqQF9oS1FvnJ0xKCOWPbxa X-Received: by 2002:a05:6a20:e68a:b0:19b:1da3:cb9a with SMTP id mz10-20020a056a20e68a00b0019b1da3cb9amr409616pzb.77.1705329322459; Mon, 15 Jan 2024 06:35:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705329322; cv=none; d=google.com; s=arc-20160816; b=Gn9nFkcf5+iwKuTvDH1TzjdEAag7m6UDby0IgqvM90f6vukm42Wch3TT1XQv2Cdwq5 Ig4YbpxaNo2CbpkWb8AWF/iYpdSaKoaZfZVkLYl5HynfBNzHWvtqBDDTxw3kJinSbAdt 17zd4GtA378SGyL2eTEq2C9bwv+yGC2QhNY2tybHoXWJp34WUFuCI2V/F5ehj6mxurT1 MZrT2DdDMxRxY5tw6HJoFdNrT6X+5Z4doYyaBElWiv67YlSYd4ctHK4nV6uD6ZSfOl/W WplFIYqZMMRsKs8orI6nPtYRvegDmW9c2Tir9z7JhbzMUBbaFdjuPraKahrfzNWl3+Ix 7G5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=WjxTrimjM26wwyfFq5FNwjyJHZRbmStprdkoDShR1tQ=; fh=ceGY8gx3ag7g2dEDXECiNTMxyZp1SjBjuBUw72Wx2IM=; b=tKSAb7OtZiqITPhspaNXK4WscSd46452IGVZQzoH1pZuVgUKnej0hsdrxOlJjh4yPr OK7oHqg3xneTjeMqUlKM7Ma/NTMRtSpC36ainfuzzokya64QErAmiVg4gWyTRoSx2V6L +jCGx9QUVmfp07cvw0UMEqDG9mdPI2r73IDZNlCduqHw8/zroXlQPmEG8MWkhYoUZDw6 lC+qdOy8HkT+KzNTcSULCQqlF/1TLiIOUbVUAPPVl+rqMaVCrdT+6H00E1zxMy4kyIYs gR6A2LSCm47fYhcQpeOgrbgB5hXt+VJMl6xOTOy6oIutSA6aWoMe4qoQLFbstT6mDSVa AbKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26092-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26092-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e5-20020aa79805000000b006dab3629a78si8826750pfl.373.2024.01.15.06.35.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:35:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26092-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26092-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26092-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6D00DB214FE for ; Mon, 15 Jan 2024 14:35:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6C891799C; Mon, 15 Jan 2024 14:34:46 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01BD117743 for ; Mon, 15 Jan 2024 14:34:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3A047150C; Mon, 15 Jan 2024 06:35:29 -0800 (PST) Received: from e126645.arm.com (e126645.nice.arm.com [10.34.100.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B64623F6C4; Mon, 15 Jan 2024 06:34:40 -0800 (PST) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Shrikanth Hegde , Pierre Gondois , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Huang Ying Subject: [PATCH v2 2/3] sched/fair: Use rq in idle_cpu_without() Date: Mon, 15 Jan 2024 15:34:25 +0100 Message-Id: <20240115143427.1820628-3-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240115143427.1820628-1-pierre.gondois@arm.com> References: <20240115143427.1820628-1-pierre.gondois@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788167399633406164 X-GMAIL-MSGID: 1788167399633406164 idle_cpu_without() could receive a 'struct rq' instead of a CPU number to avoid converting the CPU number to a 'struct rq' two times. Indeed update_sg_wakeup_stats() already makes the conversion. idle_cpu_without() is also renamed to idle_rq_without() to match the input parameter. Reviewed-by: Shrikanth Hegde Signed-off-by: Pierre Gondois --- kernel/sched/fair.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d7a3c63a2171..97d9e0d32337 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10105,23 +10105,21 @@ static unsigned int task_running_on_cpu(int cpu, struct task_struct *p) } /** - * idle_cpu_without - would a given CPU be idle without p ? - * @cpu: the processor on which idleness is tested. + * idle_rq_without - would a given rq be idle without p ? + * @rq: the rq on which idleness is tested. * @p: task which should be ignored. * - * Return: 1 if the CPU would be idle. 0 otherwise. + * Return: 1 if the rq would be idle. 0 otherwise. */ -static int idle_cpu_without(int cpu, struct task_struct *p) +static int idle_rq_without(struct rq *rq, struct task_struct *p) { - struct rq *rq = cpu_rq(cpu); - if (rq->curr != rq->idle && rq->curr != p) return 0; /* * rq->nr_running can't be used but an updated version without the * impact of p on cpu must be used instead. The updated nr_running - * be computed and tested before calling idle_cpu_without(). + * be computed and tested before calling idle_rq_without(). */ #ifdef CONFIG_SMP @@ -10166,9 +10164,9 @@ static inline void update_sg_wakeup_stats(struct sched_domain *sd, sgs->sum_nr_running += nr_running; /* - * No need to call idle_cpu_without() if nr_running is not 0 + * No need to call idle_rq_without() if nr_running is not 0 */ - if (!nr_running && idle_cpu_without(i, p)) + if (!nr_running && idle_rq_without(rq, p)) sgs->idle_cpus++; /* Check if task fits in the CPU */