Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp298684lqh; Mon, 6 May 2024 21:58:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUl7x7xAKTbmKEsOugcCf9CIoH5jty1tZm/8rqoT/7fbz1FIfcdqB2OnIfKcxVL82cCiWnL24qcoMbb3QYWgF0wN75ixIafN08r1vY0eg== X-Google-Smtp-Source: AGHT+IGSy3zHmqga4j2Z/dAMHLtXUIEigGxZwGvydidbVXoqMoV2eMXycn+9hZzSEu7uFeLFhxcr X-Received: by 2002:a05:6a21:1585:b0:1aa:5b05:7926 with SMTP id nr5-20020a056a21158500b001aa5b057926mr10892189pzb.39.1715057933319; Mon, 06 May 2024 21:58:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715057933; cv=pass; d=google.com; s=arc-20160816; b=Ub/P6QqLtC39/YTJ26j74pDmiMcPzrf3G2Z15KJtarwdDhx1BM7YUFRQk8fQdwOadB 4RLytsotM3BjuKAcaYHpOv5gicei6OP7GnbcfGHYQB9iSS2FlXAsA5Q0ptczLACIfL6Q CzAKSX2ks9ctlrYB5xwjXj9KHqWDUTUGe4wz04JjmkpM872u4Cy3CwMmltdbqQjxQC7C 4R81sRaR0bVF+ZHldKGsMRnu8Nd+SgWiabIJB1GtgXy4KWLJ+t67ooJaG8TLFHv49UEp 2MmhzSZZNAGXDmHMKn+BmFMtRkqJgLOGpN5hoZgb7VOa4p+hCvoay2PFYy5TLbRkM2mB ekJg== 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=mkplDeMhqyzSjhNDkkKbm0Zp7QOfiWk6J51tAdtVLaQ=; fh=E9Cy+o/smpMZ7cja8l40XyLRCeKZDv8zSdoC80WtVWA=; b=bUmoHNfL2ZqeqSPIB+Iq4NQL8b2RCNhRITGBy9E26maCqf1msWyaAIZWWgiUZovLFR E8obtP8e0zHmNil8x2eEgVgJ8t2wWrjFHmEDtqRFG+kK1iOYnUvjSHHIMOLr7ktAnFOh 2D7DvS43iC7dQGwury3D8N/QLXND2X6xAv7JXgGFV3Aoh4hmxykVC5sNRfoSTLobAkus MsP31D3mPwSCkt+nIcyohbzm38c13aj6c6CB9JErlw//eAWzQRMaCktnDtb15OH2k2yQ ggXcEKDGVwM1Ms+nmaaAZUeChM5Sca4Fk5IFcb2mkl/VRXd/H3FbozDgt++gCQq4j5aW XzmQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3wvU7jLF; 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-170660-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a24-20020a17090ad81800b002b1153d6b42si12029329pjv.26.2024.05.06.21.58.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 21:58:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170660-linux.lists.archive=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; dkim=pass header.i=@google.com header.s=20230601 header.b=3wvU7jLF; 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-170660-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170660-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6F3DAB2499E for ; Tue, 7 May 2024 04:55:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F8A36A8C1; Tue, 7 May 2024 04:55:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3wvU7jLF" 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 BA29D6CDBA for ; Tue, 7 May 2024 04:55:04 +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=1715057706; cv=none; b=rqymENQYbngs7i7LBxCfiLmyCcV6Q4YdC3RB6BAiO4vVbkOLK4epgfQiTtkwBPA2yhZXwQiXzONPoh7dAWBi4DXFM7DGuHEkziQt72V0wOAPUbyOYblyavuetBvgZoXpgK4HUFGEsGvtUvSADQvCwpMdeOCrotq/ynTexKhSEI4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057706; c=relaxed/simple; bh=WOTPWSz2YlNs0MD/3Y+/7eM8LrVBYFxCR8h+6Ap+srY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YQr2fIC4z2QHKtJGcL4iHTM7tuwRfNqcG5PgFQRFvNvf0po8x6egAqhH/8fBJIxzULlDVY7gdYwtZFqEVwLN8JfnoCrGrbhFCpz60034IWWNG7j4en2FM6ETeD1I8rD+Btz693Oe9jx2QmW2lcpO9PrnFQ3/04V5DDy/obEKOMA= 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=3wvU7jLF; 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-ddaf165a8d9so4156384276.1 for ; Mon, 06 May 2024 21:55:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715057704; x=1715662504; 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=mkplDeMhqyzSjhNDkkKbm0Zp7QOfiWk6J51tAdtVLaQ=; b=3wvU7jLFFl0a4pvtq5g7vWKoEg1Xe9Ddi4iPVTeQzQMcNCEbLj2yzAD97i9B8TBwKE IVWkk+e1N+FHzFLbrsI73joOsVZBJKBbL/obMvNW0nrnBB8e4wERhDlqzatFapDQZjA8 tvHowSHFWBjblienuKvsMA2hjwgbmXH6YVt5AdHovaHh3YszMR8iYZWD5U8hY4UcvCze fneCFmU2rk8b76K8wo0ep9/mwzyYitgEOVqvJNcoX+qrhqhDjmZPhNzSRi+jLyy7c2CU ykRTOXE4wvzaDnsT4Q+Jdfkfc8Ok/sRfGluPbRDabFRa/4/cuiMdgXrkW6Rqet6eqd7z ASuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715057704; x=1715662504; 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=mkplDeMhqyzSjhNDkkKbm0Zp7QOfiWk6J51tAdtVLaQ=; b=EXZ9ldBFeexld4TO7+Lyo/TM0KKVke49sPivqZQIohxJbX297lzRGR1WX/75cg+J/3 l7CcaGUOPWBOptwO+nXZj3+fzyIK9IBOjjXPL55hQOCuXWwO2XOB9fAWjp/JtatjShG5 vs1qQvMe3GAm+tjo0l8RqubmYnFQy8Io4uBBiv+DJlEo0RZLNi7YIdf0DmXFkfgVbRJp JJXfHNNlOF0u0G6Rh8Jj0EodmyvZtQRd0BV08ZK7zlEEgnH4BXun67dzOxo2MHqHoAPN TX4nQaYe3eWr8anbsZPRtPcG0kYV92WsSJ5JszfGSdhrgBHdGDsez8kcd22gvWBKrZU/ uyqg== X-Gm-Message-State: AOJu0YzKHF7RXaar7nI2nB56j/UV+yjhVAdFwFlFIFjkWBhPv8cbmKsD Oq+zQcOEDISrjROFriCqtvrNpdtojij88w35tQ0J/e2oVOBEm2o3hpcVfzJM5fTfulJvuQG3D+Z P5gFyiY98q5o1A/4voiITj+6M0PA8s6cW7QD3AwI2D16vtDhG31ptJTu3WJqWhIEGbMdzUhLv9f L6rWz4POeK/YctAVNnS4RgAiyeeEmCz2/4yK27iQirQCWf X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a25:c504:0:b0:de4:654f:9ad0 with SMTP id v4-20020a25c504000000b00de4654f9ad0mr1516343ybe.6.1715057703421; Mon, 06 May 2024 21:55:03 -0700 (PDT) Date: Mon, 6 May 2024 21:54:33 -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-5-jstultz@google.com> Subject: [PATCH v10 4/7] sched: Add move_queued_task_locked 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 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 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] Signed-off-by: John Stultz --- v8: * Renamed from push_task_chain to do_push_task so it makes more sense without proxy-execution v10: * Changed name to move_queued_task_locked as suggested by Valentin --- kernel/sched/core.c | 4 +--- kernel/sched/deadline.c | 8 ++------ kernel/sched/rt.c | 8 ++------ kernel/sched/sched.h | 11 +++++++++++ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 7019a40457a6..48f0d4b381d5 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2712,9 +2712,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); + move_queued_task_locked(rq, lowest_rq, p); resched_curr(lowest_rq); } diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index a04a436af8cc..eaedc69c5e30 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); + move_queued_task_locked(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); + move_queued_task_locked(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..975cb49a64dc 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); + move_queued_task_locked(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); + move_queued_task_locked(src_rq, this_rq, p); resched = true; } /* diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index ae50f212775e..2d41ebe200c7 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3480,5 +3480,16 @@ 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 move_queued_task_locked(struct rq *rq, struct rq *dst_rq, struct task_struct *task) +{ + lockdep_assert_rq_held(rq); + lockdep_assert_rq_held(dst_rq); + 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.45.0.rc1.225.g2a3ae87e7f-goog