Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1267883rdb; Fri, 9 Feb 2024 16:24:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGoem1B76MfDmbSzmmNOpX+TGj4u/owxdh4QVcGufemcutYAId5BrrObBaUpl6aJE/tTuXS X-Received: by 2002:a17:906:f1d5:b0:a38:29b7:33e5 with SMTP id gx21-20020a170906f1d500b00a3829b733e5mr2035442ejb.17.1707524689116; Fri, 09 Feb 2024 16:24:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707524689; cv=pass; d=google.com; s=arc-20160816; b=zrlGxEicCMUVcJRL4vrrA8OY5z7FbQFOWUt2625VQc1VaXA0UpVDvK2lrCjPRX3Vol XGxU2F58gIVlpokiEr3LXTE1NstYoajIeDWtY3sUkcXlFOWG3/zDnkyBbsvaovEumB59 wtQncT3AOHPejaseHICVRbcW7xZk91GMSK41OdDhymiT0+A4MbAeKwzK7WOvP88GkRVj vPcs+XYr0wbkqLs8QxTrJ5wx5T3Y+i2xtrN/sDucWIbfP51kUA3pZMvBKbUZ7IPHqPM0 +Sx5wnoXZ9301jDU3VpBSCBhsPv1fd7wJ+ocLdhIj5TQSh80Ys/Zeq8+ebX9YwTgn6s1 fL7w== 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=tHWaFb2dLNabyhWAVRZBb4OwekggJuLpGLrM9aWYM2E=; fh=E9o1snfjUnQlb49OAlzvL7UwU/tMmGLexACtOyrdFLw=; b=lr/EM1jvQ4+ymGScJXyvZlrS1viPeIrm/ZBjb32ymlul9No+vOuQ1+ERAowO8hLhkz z13VQzZpRZvHftNEB2lCRHh0nXN/NnLdEc3pyj81vs2s3B14yzIExYmXdUuhxw1JnVH9 tUI6VeornWMWWg9YMI3wFCmJ5TPcoD4TrbCFcKSBrUjlxEMVezsAdx52PrSvuRwlq4NS EqhGKa4Wab4vPGZhopBw1pr8/QwIEGBUaWVcqvlbqpNMnuQ0atIZD4OEfQjXURG1Zxio 8La6eWvwfNq1gOl+LaFJpy2A7ZYUYbtbeRtVneeHmhOa11Vo6/Ad8rK6eGxpWU0Aq69I S19Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=B7hylp7P; 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-60182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCX/xB3Ob4qZ7xNbKF3stgt0ZK+OUquPCgTqzkf+vXxFp7C2YcqvsCbIMf80em+M9CQb8c1jPgwkFh+6sQq8hrBUmjtRJvWYMCjbfUwFYQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id le12-20020a170907170c00b00a381de492a6si1377046ejc.969.2024.02.09.16.24.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 16:24:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=B7hylp7P; 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-60182-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60182-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B03DD1F2A9B3 for ; Sat, 10 Feb 2024 00:24:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DF3A6FB3; Sat, 10 Feb 2024 00:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="B7hylp7P" 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 B61E3440E for ; Sat, 10 Feb 2024 00:23:44 +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=1707524626; cv=none; b=sHeH73DpK3FTUesCpXiChthhRSvbptpYZXJQArRP1HANUEHBAVCBnfDvZC8ooTNcPMoSKoHM7QcDtsEFeJcQbbrGvDsIVAIWpqWwsPfyL6hbwRMWLP7/32lOUWMO53RHi0CmRPNsin/sWagrHog0XMYFaXgcR/4m5xpNSB0dfwc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707524626; c=relaxed/simple; bh=M0EQp4w0btavUbmp0WUrlEWQstIAdnxSA4WvzN2eeyw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YRcs1/hxpjl3VR2b0x8xAYbL8XZBgY44mMowR1qPk/YhQrK3pM9uxm7emSOwqI4qIMz55lJCWHYpTF+oKB7NPmcqKQu+QFeHS+Wo7tgNXpdIxtadafj4qO3pUqPrEXjQgEUaQbwFfpSXbPm3HnddgRrfBYnhEQcm1vmAvtPqyMQ= 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=B7hylp7P; 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-604a4923adaso28027877b3.0 for ; Fri, 09 Feb 2024 16:23:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707524623; x=1708129423; 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=tHWaFb2dLNabyhWAVRZBb4OwekggJuLpGLrM9aWYM2E=; b=B7hylp7PkYfyBx8nhneEFcn+/hdJFNH/mza1eHbGu1vSRkxx8qKWk/oQURI6+/7PpD GqkCdTUYQMz1pJEkzi/WRsQ8l1MCjMJ3diz5pCfnmQEQ9qV9CtRxIQnRtypziBAUu7ar fWJS5W4rgDweesYLjMmN45R99Pqd72wbGFiq0AVguFOQisDvqoCoyMFch7/jzCSBJVC0 R9AQ+TSnCSSQPR4prCd6TStJpAfR4k+SQHjn+xhZsyJVGWFL8r0tNhP34eauBqHY5YtH X0goGkzK0DUUyisApfuALWnUsFEHgodKvt8Yvev2OLl6TOU1nseA0dHmHGT+3hEbpYGf vwVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707524623; x=1708129423; 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=tHWaFb2dLNabyhWAVRZBb4OwekggJuLpGLrM9aWYM2E=; b=HsGoCQ0P7ivoWHaUXWqtVOdz0NUYrgorVCfjBgYnGeclZ5/0skbi6VjE7onQ3z2zHj yfy8Ydn3YgeWDs0KH67Q6+z+Qg9pUCGzKkoI0l8nBh+LouYu3B8lt/50IccqeWANu9N8 DbJgOTKkjO2P02UY/wBvvVvyIXUUQZTfjFos/sZyRZKTTHHHcfcoId2bv2CCvr5Nhfk0 58tWyYNPoNIb4p6lMvve/4WzUrBMFK0RKLqgkLYwuMxdETM++zTBYfNc+in5t+P+yxXK jXrOq+kSjpDrPZCVeTDwDBhg3QSwuRqimfmTQyBBRYPU3RvlWyxUJ53jGeJouDD+eZiP mE0Q== X-Gm-Message-State: AOJu0YxjUpm82Si7fD7eApmZBuiaYmFKqFYVuoYe67tCEogylAr7M1YO rFQSLkTHOpuOxk+HFHSuomRrwgHVCIPODtk7WmTmN2WKM8LkRwhAibQhKLsiN0yEAa0tuF+wBt+ DVjQv69hUaFlN+9zjlnBe+Tsh8UCLGQDlkq5mGEqpZQUYgVZ6EvcX+Vfr0uzpsaTg5sjVLelq/s WY89DMjrCQ8evXv9A21npxxwA5qwfNNZCJOo9hG0X3Z5/n X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a05:6902:1027:b0:dc6:207c:dc93 with SMTP id x7-20020a056902102700b00dc6207cdc93mr29352ybt.2.1707524622932; Fri, 09 Feb 2024 16:23:42 -0800 (PST) Date: Fri, 9 Feb 2024 16:23:13 -0800 In-Reply-To: <20240210002328.4126422-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: <20240210002328.4126422-1-jstultz@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240210002328.4126422-5-jstultz@google.com> Subject: [PATCH v8 4/7] sched: Add do_push_task 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 Switch logic that deactivates, sets the task cpu, and reactivates a task on a different rq to use a helper that will be later extended to push entire blocked task chains. 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] Signed-off-by: John Stultz --- v8: * Renamed from push_task_chain to do_push_task so it makes more sense without proxy-execution --- kernel/sched/core.c | 4 +--- kernel/sched/deadline.c | 8 ++------ kernel/sched/rt.c | 8 ++------ kernel/sched/sched.h | 9 +++++++++ 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9116bcc90346..ad4748327651 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2714,9 +2714,7 @@ int push_cpu_stop(void *arg) // XXX validate p is still the highest prio task if (task_rq(p) == rq) { - deactivate_task(rq, p, 0); - set_task_cpu(p, lowest_rq->cpu); - activate_task(lowest_rq, p, 0); + do_push_task(rq, lowest_rq, p); resched_curr(lowest_rq); } diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index a04a436af8cc..e68d88963e89 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2443,9 +2443,7 @@ static int push_dl_task(struct rq *rq) goto retry; } - deactivate_task(rq, next_task, 0); - set_task_cpu(next_task, later_rq->cpu); - activate_task(later_rq, next_task, 0); + do_push_task(rq, later_rq, next_task); ret = 1; resched_curr(later_rq); @@ -2531,9 +2529,7 @@ static void pull_dl_task(struct rq *this_rq) if (is_migration_disabled(p)) { push_task = get_push_task(src_rq); } else { - deactivate_task(src_rq, p, 0); - set_task_cpu(p, this_cpu); - activate_task(this_rq, p, 0); + do_push_task(src_rq, this_rq, p); dmin = p->dl.deadline; resched = true; } diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 3261b067b67e..dd072d11cc02 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -2106,9 +2106,7 @@ static int push_rt_task(struct rq *rq, bool pull) goto retry; } - deactivate_task(rq, next_task, 0); - set_task_cpu(next_task, lowest_rq->cpu); - activate_task(lowest_rq, next_task, 0); + do_push_task(rq, lowest_rq, next_task); resched_curr(lowest_rq); ret = 1; @@ -2379,9 +2377,7 @@ static void pull_rt_task(struct rq *this_rq) if (is_migration_disabled(p)) { push_task = get_push_task(src_rq); } else { - deactivate_task(src_rq, p, 0); - set_task_cpu(p, this_cpu); - activate_task(this_rq, p, 0); + do_push_task(src_rq, this_rq, p); resched = true; } /* diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 001fe047bd5d..6ca83837e0f4 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3472,5 +3472,14 @@ static inline void init_sched_mm_cid(struct task_struct *t) { } extern u64 avg_vruntime(struct cfs_rq *cfs_rq); extern int entity_eligible(struct cfs_rq *cfs_rq, struct sched_entity *se); +#ifdef CONFIG_SMP +static inline +void do_push_task(struct rq *rq, struct rq *dst_rq, struct task_struct *task) +{ + deactivate_task(rq, task, 0); + set_task_cpu(task, dst_rq->cpu); + activate_task(dst_rq, task, 0); +} +#endif #endif /* _KERNEL_SCHED_SCHED_H */ -- 2.43.0.687.g38aa6559b0-goog