From nobody Wed Nov 27 08:47:13 2024 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DE431D278A for ; Fri, 11 Oct 2024 23:25:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728689149; cv=none; b=k//0tvsSNK+uZFmgvHXcHLi61Y4zJ9ftZS4lMk275cpFS2pE6GufqZoMO06LXByGQePUTKdkuVbtUJKqBnv7+f2oEPHyEa7oPM2MMvUK+URMsXB6bxAuQnwRkjlwjmpnMBrwHhAyUbeLZm4rBpMATwe20+r5yS4IZxztOWJrktg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728689149; c=relaxed/simple; bh=vKVhXyUCQW3VrmxMgwIAKNIWXaRjutTkmiYmUdOL7y8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YA4uORysuDtxLLp2zWpafnPfXxhnRIfhJicG/DhpuKScwuFFUOCpRjDX4qinDR5PlW99Zw/rwUkZWL6kfYpSA7uCISd6nXJbsnrMMuY7LLuQAolkOW0Cxy0aihkjh8kHPF3w9eYy8fQ0i3PSRFECjqDVQLP6GX3q1PYHUTjDJrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Pb4BnJea; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Pb4BnJea" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-20c98aa6b4bso16147685ad.0 for ; Fri, 11 Oct 2024 16:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728689147; x=1729293947; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=JZKyKnHvG8nikVkXgW9xs5MrACmc1p4QGfsCdciCMo4=; b=Pb4BnJea98IaD5B0gKRVwf0d5wzJ4bPU8h5Ez95erQpL4AolgPM5zjF4B7sHBcrzDl 0f+4jlpLXjCDX+YyEh9FGcIbsSJvgNfTvi04aZh/ykfS//W3eqLB776VTj9mbu0EBYUY xU5ex9BnfesmpMgUTvpLw3kCjJvjE/wrvWs3KooV2FpHP7CSkjZetyWik6G5VputEMD/ CNjP0e0ZtxC/AYVF+J+EY0K1VPKPLWV9v7RNgh8VklOafWY72iG3WZDHNbjHZinW2tyk D4mPRX6hIqM/RMoEODxg2y2S4AhqHp0jz/95Rgs3+Ixnhuw7PaWArtdxMjvhWhYbptzF tG+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728689147; x=1729293947; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JZKyKnHvG8nikVkXgW9xs5MrACmc1p4QGfsCdciCMo4=; b=t9BjToq5HSaOdcAVyAPWRavOMbISmtqdBDgz+Y/k0viJ6t9hY2RTw/pkslyWRbtZTp vFmrvNi4svEGEi29pd29YX+qzgHziGvC5WoOZ80+cA2sWkESF6ovEX8+3oe1y+zGAu36 3BFDmP91vMMsz2Heuilue5N/mbzv26mtNUtM/JGR8ThISjfjazpUJcMyrfObFegios+3 mzVyH+Copj3s0QXH3uBV+6TUcN7R3692hF6BauZ+kK8MHuH156eNhBrJuXpQNm9iApKX PAqeYmZBYJ2gO2tO6u7gtNDnFysa8WrbEMAMINB3RBzyHeBNtGvk84msF/NAXC1muXjd Euww== X-Gm-Message-State: AOJu0Yw3bp+PSpahx5y9gMIlZctOMB+BCP/PhwIu7t7ed4o0TbT7KuVW bwzyoc2eKVNfN0WlT9IMoh/bMDsYOS2yQmW1qBEhDt+lh9cFLksfQXWtuQ2wrSlnAhN9Lp1Rff+ sU10dj8+f/c1Bhgxegnjz6q3o02dCEpMshyYfcx/44hyH+c7cFjdBs1pvCAtqPTvGPv7V98m91o 2JK3xnR4MydAX+hzBXVg2N8QTPH8DCF5FgmKyqAlvWQcBv X-Google-Smtp-Source: AGHT+IFnuEvQlaT8Q+rAgHUYmvhhqBT1iMhn0UnSzE2/kqSQ0d+r4yswJ7gwmgr3nI8NpsGnXcI/Qyig4jzH X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a17:902:c94b:b0:20c:8b07:c66b with SMTP id d9443c01a7336-20ca17378efmr94865ad.11.1728689144888; Fri, 11 Oct 2024 16:25:44 -0700 (PDT) Date: Fri, 11 Oct 2024 16:25:17 -0700 In-Reply-To: <20241011232525.2513424-1-jstultz@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241011232525.2513424-1-jstultz@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241011232525.2513424-6-jstultz@google.com> Subject: [PATCH v13 5/7] sched: Consolidate pick_*_task to task_is_pushable helper From: John Stultz To: LKML Cc: "Connor O'Brien" , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Mel Gorman , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Metin Kaya , Xuewen Yan , K Prateek Nayak , Thomas Gleixner , Daniel Lezcano , kernel-team@android.com, Metin Kaya , Christian Loehle , John Stultz Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Connor O'Brien This patch consolidates rt and deadline pick_*_task functions to a task_is_pushable() helper This patch was broken out from a larger chain migration patch originally by Connor O'Brien. Cc: Joel Fernandes Cc: Qais Yousef Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Valentin Schneider Cc: Steven Rostedt Cc: Ben Segall Cc: Zimuzo Ezeozue Cc: Mel Gorman Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: "Paul E. McKenney" Cc: Metin Kaya Cc: Xuewen Yan Cc: K Prateek Nayak Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: kernel-team@android.com Tested-by: K Prateek Nayak Tested-by: Metin Kaya Reviewed-by: Metin Kaya Reviewed-by: Valentin Schneider Reviewed-by: Christian Loehle Signed-off-by: Connor O'Brien [jstultz: split out from larger chain migration patch, renamed helper function] Signed-off-by: John Stultz --- v7: * Split from chain migration patch * Renamed function v11: * Switched to bool (though later in the series it goes to a tri-state return) for now to simplify review. Will add tri-state handling later in the series when its needed. Suggested by Metin and others. --- kernel/sched/deadline.c | 10 +--------- kernel/sched/rt.c | 11 +---------- kernel/sched/sched.h | 10 ++++++++++ 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 6c87d812efbe..56260a80a268 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2487,14 +2487,6 @@ static void task_fork_dl(struct task_struct *p) /* Only try algorithms three times */ #define DL_MAX_TRIES 3 =20 -static int pick_dl_task(struct rq *rq, struct task_struct *p, int cpu) -{ - if (!task_on_cpu(rq, p) && - cpumask_test_cpu(cpu, &p->cpus_mask)) - return 1; - return 0; -} - /* * Return the earliest pushable rq's task, which is suitable to be executed * on the CPU, NULL otherwise: @@ -2513,7 +2505,7 @@ static struct task_struct *pick_earliest_pushable_dl_= task(struct rq *rq, int cpu if (next_node) { p =3D __node_2_pdl(next_node); =20 - if (pick_dl_task(rq, p, cpu)) + if (task_is_pushable(rq, p, cpu)) return p; =20 next_node =3D rb_next(next_node); diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index e2506ab33c97..c5c22fc51824 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1773,15 +1773,6 @@ static void put_prev_task_rt(struct rq *rq, struct t= ask_struct *p, struct task_s /* Only try algorithms three times */ #define RT_MAX_TRIES 3 =20 -static int pick_rt_task(struct rq *rq, struct task_struct *p, int cpu) -{ - if (!task_on_cpu(rq, p) && - cpumask_test_cpu(cpu, &p->cpus_mask)) - return 1; - - return 0; -} - /* * Return the highest pushable rq's task, which is suitable to be executed * on the CPU, NULL otherwise @@ -1795,7 +1786,7 @@ static struct task_struct *pick_highest_pushable_task= (struct rq *rq, int cpu) return NULL; =20 plist_for_each_entry(p, head, pushable_tasks) { - if (pick_rt_task(rq, p, cpu)) + if (task_is_pushable(rq, p, cpu)) return p; } =20 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index b904a5004eae..cb74a577c89d 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3779,6 +3779,16 @@ void move_queued_task_locked(struct rq *src_rq, stru= ct rq *dst_rq, struct task_s set_task_cpu(task, dst_rq->cpu); activate_task(dst_rq, task, 0); } + +static inline +bool task_is_pushable(struct rq *rq, struct task_struct *p, int cpu) +{ + if (!task_on_cpu(rq, p) && + cpumask_test_cpu(cpu, &p->cpus_mask)) + return true; + + return false; +} #endif =20 #ifdef CONFIG_RT_MUTEXES --=20 2.47.0.rc1.288.g06298d1525-goog