Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp549812lqb; Thu, 14 Mar 2024 21:41:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVqypxkr/8AjzXEnt060w8rjlON1+qiqa+jhVCAMhRgAvfBBev7hY7V85HjVhREb4wy8lAAd88TMtOKEOSaU/Xm152u2dL50PFkLcJZkA== X-Google-Smtp-Source: AGHT+IGEyQGieNv1AaSo81Sk56rSgcCIom+AN2RGOOJ3F9w2ObTj1vc2/6H5NsuWreP8YHRepjbK X-Received: by 2002:a05:6830:1e05:b0:6e6:7adc:e4ed with SMTP id s5-20020a0568301e0500b006e67adce4edmr1013647otr.29.1710477687859; Thu, 14 Mar 2024 21:41:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710477687; cv=pass; d=google.com; s=arc-20160816; b=fb8IzF4s7Pr61wFxKB4AXRX3CKCLuCfbRjo9bJ4y7m20G5xWvRSjFqRdy99nAJ1JRL v0mCQHpgqKDtjQc8YnRJIqylq89H3+eBL2AEV1o+1F5QbWjIq8zTb81zJVb6HBcfsc05 Bk+rh5OywmzPtyR88ftFDC2oaeiWSOUlCiUGK8wlTHLoQatzlRnFHpmbP+X8KQZ0j9Dv 9vn8304O4xcmk994aj/7Erq2dBd5VIhjYGMJqtUmdtNcx11y0XI5UaLOPz6BBtbOYdCb 77pzwL56UpyiJXFqtM0oVbM7tYwCS4OY56snhuojAv5/EsIBhJQvSvfR9bWkIl41nPHh xr8w== 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=QyAOgwNdCvCdtkb02Cz+1RqE/hO9U+hZcKT3Z9MgUA0=; fh=OA4B84zChEo2N2zZSnRgF4ImSezDLuvwskDfqEiOYJk=; b=03vPtKsycINrIqEnfFND8IpZkHHXYzKo1AU/N2R9TgcK9oJ+0oyyEabIbl0SFvoTU6 DseY9KhgoQNnuLzoKqhNIKfLTyp+PyoP5NhvQUb/jP43yP5wWXV6rfUlaPU3fncYL0d2 JLhNIdwzCPBc28gQ1Fqpu15iTyeYzzfmAtindX9dlvbpzXLCo6j86DR4k3STBln3wiWL 8+1H0bWbacPC90kSww/a9jEQ4BZD6t8aQve4gcPXwrbFlGQ3/zIRhVW+zLZGR19jmtbX Ma12kfkRqrhCvWWcSrLWlUoUJHj1ZZHsOJPk4baD3L3FJu1vXBU4+aGQObjAZxTYyH8q qmuA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Mk6yaSuE; 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-104052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104052-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 h37-20020a635325000000b005e44b47f272si1919284pgb.410.2024.03.14.21.41.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 21:41:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104052-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=Mk6yaSuE; 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-104052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104052-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 7E021282F79 for ; Fri, 15 Mar 2024 04:41:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 704F7DDBC; Fri, 15 Mar 2024 04:40:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Mk6yaSuE" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 B57DE134A6 for ; Fri, 15 Mar 2024 04:40:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710477631; cv=none; b=Xbf5m9kB2zNPw5kwwRV9+0CuYnvkExERjLDGqOWre7ioVO75bn0TUJXQ7aXzKSa4oKSapinvRQBm46fT6moP6AAfsWM/SCkCTGswlqgKuROwXQSrpJPLNwxWiNKpUuyvG8PStzLH5hAqC54VN26F6UoM4XOd27tvFBKg7urVIDs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710477631; c=relaxed/simple; bh=Grd0qwTsRfhLF5lqUVRBIRt9w7nSWKZcCX7ikkMuX/g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=HxGJkwClHwA9gSzbv+iqph8FSQ994RXLKJ6z032qOnfN5+TDIvhbrQBJDH7+9yRIBdRr5PkVWoyGRr1p+FA9TDY1KK3WSHLR7YlZvYIl/iB0ga4at1z1TkL1IHhwFU4VraRCbpg1/wAybAx6R4Kpvkeprf+Ce8VnVPw3D9q8kzw= 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=Mk6yaSuE; arc=none smtp.client-ip=209.85.128.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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-60a20c33f0bso30021237b3.2 for ; Thu, 14 Mar 2024 21:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710477628; x=1711082428; 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=QyAOgwNdCvCdtkb02Cz+1RqE/hO9U+hZcKT3Z9MgUA0=; b=Mk6yaSuEepPc4CjgCPp2EekIk3fqeCTrUvo6Zd2UKw9O/2yqQz02DDeKvUQofUnZl5 V+dVuNGUdIicq5B745+5v4iscvTNP/KFcnczaqNBh2j4tksfNio3HFpZfomtOrUctNlt UCwD5GclAo1lyPVoc9trgLruh9nD63PJgLijSYZ5lmptSFG+T+/H8Mw/Q+qcC/DEEIaU +lZQdniMqmxWxE7pTI5Md9dm1kbFCxiDE1wVIhs9PSjLwfOl/4k048kkqw5kv0WybqGw WdgiwPXNDlxG2dVS2cFhaG22GxZPRhkb0X6UC0cwft6ZjHZJ6OoLpjpl5qhbsdkaRHQl rQuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710477628; x=1711082428; 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=QyAOgwNdCvCdtkb02Cz+1RqE/hO9U+hZcKT3Z9MgUA0=; b=DSpee3l/bjbt99LiUT9CA1+ekJgHUrxf3zRlIej/cKTexSR9oW/r2E4dbsdhYry4Pq W+QhufcnezIAD4UeirBw+xV42fnzbS9UA6MHS+MOdaMo3AJibINajieXZXLdY6/4pom6 rdCNZp4u1qAw/NBRA5BBFq1OQ59l8xvkjSqo68o7Ix3tf/yJ1L1zOh0c+1Qc6DpKB1tD hL1p1OrikjyqiMSVUs55FXcvz2LzoJ54RbmxxtCrRIMyAIhf9WR/s0p3Ka1XEsi/Jl+S HNvhzgd75NHnqZX+h1YEoMKlVNHvnvkyft0Ra3l/RIa5ZCVyikrz8L2w5YzKesXIRTnN A+nQ== X-Gm-Message-State: AOJu0YzAc0E6f4cnhK+MRim1FTiJddhPAyDDV93nDQbskJX4w5vP4jf5 FgAeFbKL8yqJ3qHl4Yj9+coVy4SerU9mSrvYY+Vz0gTpRyZp+UDemQhjhXvp9YFWaiNbXM65/gG 3MpRmcYFU1fLA2pKT0xvuxrCZBMYr8DEzK9wf4ebV5vWaknezF2dMTYRaQjcRKfoolRn9x6wwna ELPIwVV1OSrNoigLFfGvw7CM2O+J16MCBaOVi8ODZHXOvx X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a05:690c:996:b0:60a:512a:1b22 with SMTP id ce22-20020a05690c099600b0060a512a1b22mr593648ywb.2.1710477628555; Thu, 14 Mar 2024 21:40:28 -0700 (PDT) Date: Thu, 14 Mar 2024 21:39:50 -0700 In-Reply-To: <20240315044007.2778856-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: <20240315044007.2778856-1-jstultz@google.com> X-Mailer: git-send-email 2.44.0.291.gc1ea87d7ee-goog Message-ID: <20240315044007.2778856-6-jstultz@google.com> Subject: [PATCH v9 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, 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 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 e68d88963e89..1b9cdb507498 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 dd072d11cc02..638e7c158ae4 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 6ca83837e0f4..c83e5e0672dc 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3480,6 +3480,16 @@ void do_push_task(struct rq *rq, struct rq *dst_rq, struct task_struct *task) 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.44.0.291.gc1ea87d7ee-goog