Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp298347lqh; Mon, 6 May 2024 21:57:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXAUxBFNB2jDpWJFg9b70wZJGn8E3qCg2HIJpmip+MWaSzOy/7Ye05efUypnCqoS3C1tSuTTTg+Q9fOhfw6z2FRQVx+dLmBR/KWbYnM4w== X-Google-Smtp-Source: AGHT+IGff2rmeADSCvrmuQa7g3GqG69yKSHDpnzET1Hz5gVVh7ZFNir1ZsUfZvVT7WhIh49ZZiAj X-Received: by 2002:a05:6a00:22c2:b0:6ec:db05:36cd with SMTP id f2-20020a056a0022c200b006ecdb0536cdmr12997256pfj.9.1715057856022; Mon, 06 May 2024 21:57:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715057856; cv=pass; d=google.com; s=arc-20160816; b=TOOkVjWCrddzApU42/6fXx2hCP1tQ904J/L9RcytWO6/dTkAKX7qON+7YD9eu0jmqc Pc2RDCsfmOEEWxLl/LbOhYCAJrZEANUbO58Ssxf6NDDK4mAkLhSKpdul5lbV/BqWR8LO MDE10JwvrygftSshTOr6pL/0aSdzNTh7dWXHq6xP2LmRFZQjTL2O0Vhqr2LSAgZoUl/G Mus8D5UGlULBwhcT1DFz5opd6wqRtGfdN9+hGXiluF7PQ3aApF9IMxmSLqIJB+lxt423 w9rMAfqOHcmz+mJ4XnpDbZGMqld0olEvHzX46yoE/rJnuOnPq+9cUaWOEFvBVUQT26rP /cFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=RJRHvCMvLtcKdBlmKBDsb8/B612809tuo4BzdlxZuvg=; fh=E9Cy+o/smpMZ7cja8l40XyLRCeKZDv8zSdoC80WtVWA=; b=PCpnLC6pMjiJC1bSDc8asJTBLtqMS6lmz1UFG6NuaeE5k9glTTA9ZuJtIs+D9q/j9+ og9MOWsfbdPvCDkUhgVqy268L5q22WpkCIhiX+owSWn2aoGsnBnr8r2KRZKlbh3KEcYz Uu5RlEEcuTiDCmR3GYkQOYp7b3DAaSrvHuMPNKuVIO7dFa03Q/zcZDpc7zeaLwSzPBik Qu0PjJA3r0v3tXnwDnNBHPWtQbBjwgbJKMDL3ukBwNKSU9DCaVSPWlDKosxY6oDYyc7z bknJur8lgdw5GTr/u5h/fpe51yAFvn0xrQopaf/Npnn7LFjGSPHay5cuVXTaDwTD5FxO 1x3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=eRw8vXNs; arc=pass (i=1 spf=pass spfdomain=flex--jstultz.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-170661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170661-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n1-20020a635901000000b0061a1bb517c8si9931600pgb.655.2024.05.06.21.57.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 21:57:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170661-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; dkim=pass header.i=@google.com header.s=20230601 header.b=eRw8vXNs; arc=pass (i=1 spf=pass spfdomain=flex--jstultz.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-170661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170661-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CB2A82876A8 for ; Tue, 7 May 2024 04:56:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C02371722; Tue, 7 May 2024 04:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eRw8vXNs" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 748546A8DE for ; Tue, 7 May 2024 04:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057708; cv=none; b=QRWOT1cSTkh2ZIVDfTwpgcWZYpv+f2o58+kD3X4p5iF9ZlqeOacYN1rH81ahWvOgskH9BsgsmFv8QJrsyHcSZbs5pAeDZ7tb7ZLhXUWK2ENjwEGJcmHcpd+29Bc0PJjg1F1+rQgYt344VefO8TKsYzqQYdsJIA8GlfYfDVOG2s4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057708; c=relaxed/simple; bh=QRM6rt9Y2CwgCYANXyI4MGSWhlWefGEY58W8j/wW5v0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=l1wU6smykxzDm0V7gYJSf7jA2dytA/5NWae8Bh+o2M5KHobl7RVxj9b0zh+uOBlElQ2Zfe9NvIHZA/u1pgkEPyhxBITNIfkxMHl98AkH5ShK2tsQoksZ9Xy2BRk5qPDxBFbhf1fBAB54iF8r4m8GKx0lDiETzTU6ZZQyou1wLVg= 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=eRw8vXNs; arc=none smtp.client-ip=209.85.219.201 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 Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-deb45f85880so4894417276.2 for ; Mon, 06 May 2024 21:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715057705; x=1715662505; 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=RJRHvCMvLtcKdBlmKBDsb8/B612809tuo4BzdlxZuvg=; b=eRw8vXNseaAHh68cxxb9IBF7jzaieJYBvk/yUNamGQPTknGnQmIjx7vyPmui35s6ct bUS6T1NcHhyfZbsX47xYCjxS6rEUxfXa7F7WD49uQ5agGLegt0f6+4GRA3ohis4TJ3LW I+T8/BO3uwN/CNimpcsSbNeBo9gfjpGoayMBMRtai1tJHh7I1ZsrS4c+wBTZh8al+wgV ygB+31shcu7wGd0Vv5cL7xJ6ByYaX8djfHJVHPEI2BJoS1GfUIMJyW83PqIePVULNIsE np44Hpd9sS0QXssRaU1cKWiNknXpXQB+R0pZ6zIH+77PNdoG5EhJx98t3wev6Q7dSq+e M9tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715057705; x=1715662505; 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=RJRHvCMvLtcKdBlmKBDsb8/B612809tuo4BzdlxZuvg=; b=B8xMn0WY+VPuwrpPfSMvVlDAtcJ+AbUf+uUzDt6U9AxFqFAA+jhVXRlsotYcrT0B1w +dCnP42+AgSt0tH+BS0hmaU1wX7gh4u1bgaYpDV4n5aAW6KBc7uU0L9F04DufeS2Q15W 1jfe8XoT/saIuz7EjI3Q6IgSRADy+THWaXn98mFZgnWxVK0+yD8lVjrnPrKS84avGCRf 5KLacIMul6R+k2kNFv/a0tmtj/hoaBmbL/XWWeh3WhYQl6dWEut09qEHUgIqQZsExhR9 afxA1QvP29Fw31uCuMZFjtJNBTBfHRt5mTFB7CWllYo3VptIk6ZpnHxIWwhxw8GTqyXc AgGQ== X-Gm-Message-State: AOJu0YwQT+o/59SAPYvPpiHDFvDGt440Ck7CFmBVeSWQi+qu1vTF5ql5 2NW5zlfxNoPdvc7uBRxr6y1aLr7BRPbSHbIEa49RvhmMbRTJcMKkNZauCYl4JxIxI+3O9UelC3V TlQcNwVezsmnKKmg/nu2rH0+JTcA7k3zLU1i3686S9vML3lj4cE73puIvneYmDV0VLkAqtoTHyL R7kxnTMKedL9f3u76bivAXa4CeG1ltEDk9yoB8OUF7RLMc X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a25:2f53:0:b0:de1:d49:7ff6 with SMTP id v80-20020a252f53000000b00de10d497ff6mr1469308ybv.7.1715057705297; Mon, 06 May 2024 21:55:05 -0700 (PDT) Date: Mon, 6 May 2024 21:54:34 -0700 In-Reply-To: <20240507045450.895430-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: <20240507045450.895430-1-jstultz@google.com> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog Message-ID: <20240507045450.895430-6-jstultz@google.com> Subject: [PATCH v10 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 , Youssef Esmat , Mel Gorman , Daniel Bristot de Oliveira , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Metin Kaya , Xuewen Yan , K Prateek Nayak , Thomas Gleixner , kernel-team@android.com, Metin Kaya , John Stultz 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: Youssef Esmat Cc: Mel Gorman Cc: Daniel Bristot de Oliveira 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: kernel-team@android.com Tested-by: K Prateek Nayak Tested-by: Metin Kaya Reviewed-by: Metin Kaya Reviewed-by: Valentin Schneider 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 --- 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 eaedc69c5e30..ae583a427539 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2179,14 +2179,6 @@ static void task_fork_dl(struct task_struct *p) /* Only try algorithms three times */ #define DL_MAX_TRIES 3 -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: @@ -2205,7 +2197,7 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu if (next_node) { p = __node_2_pdl(next_node); - if (pick_dl_task(rq, p, cpu)) + if (task_is_pushable(rq, p, cpu) == 1) return p; next_node = rb_next(next_node); diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 975cb49a64dc..8b6fb77e095b 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1791,15 +1791,6 @@ static void put_prev_task_rt(struct rq *rq, struct task_struct *p) /* Only try algorithms three times */ #define RT_MAX_TRIES 3 -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 @@ -1813,7 +1804,7 @@ static struct task_struct *pick_highest_pushable_task(struct rq *rq, int cpu) return NULL; plist_for_each_entry(p, head, pushable_tasks) { - if (pick_rt_task(rq, p, cpu)) + if (task_is_pushable(rq, p, cpu) == 1) return p; } diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 2d41ebe200c7..e46f69ba9ba2 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3490,6 +3490,16 @@ void move_queued_task_locked(struct rq *rq, struct rq *dst_rq, struct task_struc set_task_cpu(task, dst_rq->cpu); activate_task(dst_rq, task, 0); } + +static inline +int 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 1; + + return 0; +} #endif #endif /* _KERNEL_SCHED_SCHED_H */ -- 2.45.0.rc1.225.g2a3ae87e7f-goog