Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4330234rdb; Mon, 11 Dec 2023 16:32:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrOloHWDhVla6crewV1zNCy/Cq1kqlUwm2kvQBdrSlwaMW9iz9a5ck+/UsYlZAwz6jkB5h X-Received: by 2002:a92:c564:0:b0:35d:7de6:c388 with SMTP id b4-20020a92c564000000b0035d7de6c388mr6290548ilj.30.1702341144178; Mon, 11 Dec 2023 16:32:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702341144; cv=none; d=google.com; s=arc-20160816; b=knzeHRYPuBeOH8wqyhWbFEixcZezjV1g0f1O2TKyqtZwkD7MsCqqarl9n8jeD+Jspg gmfs5UhpmUB0uMhID1sROqKmsOiy2UvenJ/uG9EcMASu2DGwZmAv6cgWvrPnTTT5dlVL WVK0VvnJAVY0EFc6yLL8EuKlhEQezEYtHAGldqZV4FcVeZAbMEgPFizyyqnU6hHihd/b dKgYhHxqPcBA2AgGGdvvXvthFTJ7qDQU4S2JVNBIYD711Z3d2bH3C65F37UJMfOu7GYO G4Nf+HgWHxkSNCvvf/KYJafZls8sby8cTP3E8U++zoWrLpTuf5JbXW9ZnMehtXJhltl7 WsBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5p7jSbmFWzlgqILy1ydi3XwmgeUDLIb9gpoZhCX/f6c=; fh=M1Y4hH0c3aJh0Tk+r5qI6oW+pPzAHXWG1oPGqjHDYxM=; b=kUUf5VOfrVVkMmxxS9RGkWPFdWhJUw5Yq0JlSd3kZE2NwRaL9jdJ1+gopJJDH4QkgV tRk3Nq8/2o+OgRRxoNwqe8ODmZMBLnuvipX831RxrGYvrWRaJ5IyOGVb+5HABU9hIgz/ XAw5Jo0ThgG+bfDL1UOmZmjJAV131CIJey6699wIfojWdpmX/60xt1LPloj3+kbpJAf+ VTt05H2XSsd9WOwRBxjnKGw3sNA29Pa1kqZqpLcnz9Mx0jzBtVGrnRfbX0/XC9FKQjSs 9cEHgoklj7gp5xgNTJvWjp4vQKXsR8H8ZPyTXmyMTRBt49PkbeiBPrC7Ux4cntYN0bl7 e8+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id u6-20020a6540c6000000b005b92fb731a9si6725517pgp.834.2023.12.11.16.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 16:32:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 73E4F80CF515; Mon, 11 Dec 2023 16:32:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345483AbjLLAb6 (ORCPT + 99 others); Mon, 11 Dec 2023 19:31:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231442AbjLLAbv (ORCPT ); Mon, 11 Dec 2023 19:31:51 -0500 Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D258FC4 for ; Mon, 11 Dec 2023 16:31:51 -0800 (PST) Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-35d62401a3dso20370205ab.3 for ; Mon, 11 Dec 2023 16:31:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702341110; x=1702945910; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5p7jSbmFWzlgqILy1ydi3XwmgeUDLIb9gpoZhCX/f6c=; b=eM/7R4dlU+3Hvnd1ff3PxRy31YeSDSlrkl5wUAjSllATS6DsQ+sB1W8rn0uvsQZRq8 mMVSNkX4pMiGmresjtn31hMW6NVcivPqAxnTT+TyuzNaEwzTROAcIe2nGcZy8EY36sQ5 herordhLEeKcbjhfJ58TUMUCsBJib0VTcYq0oQNi6RXOy2aE6hyDtiEGR/3JkXhzk25d 7GXqyoIsJuHKmWoFXkuvjw9FJOuRg7juoUd9veffCb8b3MRdtBYArvF/mEhIfBTPx/oL a1iTvIwjZFaFLeOF6nEh+0Vgw2bGIk8N2CPJVUQJGI9QyN4PXZzq+bghax/xblwyQZgR V5Eg== X-Gm-Message-State: AOJu0YzJESYTraqvLntSPio7r+KOX7eIIKtrIAGY0qsO3UJYNcmv7qhz zjCPFR8f9nqINL5o68rXeGFvA6wGpkFBNgc5 X-Received: by 2002:a92:c54a:0:b0:35d:7c07:cc99 with SMTP id a10-20020a92c54a000000b0035d7c07cc99mr6715539ilj.49.1702341110590; Mon, 11 Dec 2023 16:31:50 -0800 (PST) Received: from localhost (c-24-1-27-177.hsd1.il.comcast.net. [24.1.27.177]) by smtp.gmail.com with ESMTPSA id bl1-20020a056e0232c100b0035d79f5d8acsm2598851ilb.79.2023.12.11.16.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 16:31:50 -0800 (PST) From: David Vernet To: linux-kernel@vger.kernel.org Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, youssefesmat@google.com, joelaf@google.com, roman.gushchin@linux.dev, yu.c.chen@intel.com, kprateek.nayak@amd.com, gautham.shenoy@amd.com, aboorvad@linux.vnet.ibm.com, wuyun.abel@bytedance.com, tj@kernel.org, kernel-team@meta.com Subject: [PATCH v4 1/8] sched: Expose move_queued_task() from core.c Date: Mon, 11 Dec 2023 18:31:34 -0600 Message-ID: <20231212003141.216236-2-void@manifault.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231212003141.216236-1-void@manifault.com> References: <20231212003141.216236-1-void@manifault.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 11 Dec 2023 16:32:20 -0800 (PST) The migrate_task_to() function exposed from kernel/sched/core.c migrates the current task, which is silently assumed to also be its first argument, to the specified CPU. The function uses stop_one_cpu() to migrate the task to the target CPU, which won't work if @p is not the current task as the stop_one_cpu() callback isn't invoked on remote CPUs. While this operation is useful for task_numa_migrate() in fair.c, it would be useful if move_queued_task() in core.c was given external linkage, as it actually can be used to migrate any task to a CPU. A follow-on patch will call move_queued_task() from fair.c when migrating a task in a shared runqueue to a remote CPU. Suggested-by: Peter Zijlstra Signed-off-by: David Vernet --- kernel/sched/core.c | 4 ++-- kernel/sched/sched.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index db4be4921e7f..fb6f505d5792 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2518,8 +2518,8 @@ static inline bool is_cpu_allowed(struct task_struct *p, int cpu) * * Returns (locked) new rq. Old rq's lock is released. */ -static struct rq *move_queued_task(struct rq *rq, struct rq_flags *rf, - struct task_struct *p, int new_cpu) +struct rq *move_queued_task(struct rq *rq, struct rq_flags *rf, + struct task_struct *p, int new_cpu) { lockdep_assert_rq_held(rq); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index e58a54bda77d..5afdbd7e2381 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1787,6 +1787,9 @@ init_numa_balancing(unsigned long clone_flags, struct task_struct *p) #ifdef CONFIG_SMP + +extern struct rq *move_queued_task(struct rq *rq, struct rq_flags *rf, + struct task_struct *p, int new_cpu); static inline void queue_balance_callback(struct rq *rq, struct balance_callback *head, -- 2.42.1