Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36132330rwd; Mon, 10 Jul 2023 18:46:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlF5tuNOAl2Qh/OoHERw/B54p0vtePnJWQhJffadnziYu1xFBcMfc9BnBhtVJDs2GoqTOVGA X-Received: by 2002:a05:6402:192:b0:51d:d227:15d0 with SMTP id r18-20020a056402019200b0051dd22715d0mr12748805edv.0.1689039998408; Mon, 10 Jul 2023 18:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689039998; cv=none; d=google.com; s=arc-20160816; b=njeGAaziKlx5fx64aMAQcUvX+AQ+n/py4xkmd6g5+4saWpmrA5ZXioQAt8kJcufj2g KckUD7+F/lpyg8vtwJ4KRFtzAHEoqpbAAqqDfIFDulDjGBBQvmc5FsqFNl93sQ+BD9vw RdRQFp8LNbcVakuDEnLaf7dqBBRMsxpNZAPuGF3ab5Yg3o/pnQ1Fn4xc36yshu6QO5S+ DWpkxIaLjGzCdGIXCI/uFlTpB0kMQPc8cB7kHSskPAfKgGuy0/pVsu9jC6aE33XVmAOs ezkjzZyj+6xkNe/VGFOFJ6AfbS8sBCDpLX85d2UllK8xprWOFK5aUtHQHFhGY6J5W4Df WtiQ== 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:sender :dkim-signature; bh=iisu0eogwyT+XXqvCDr4lGty2Pch5Ifq4UOrbO8zY3o=; fh=zylO0YEpUnHSc8Ywd/Z+s3EorOLDcRolNKd2HCntRjE=; b=KFyfUyhyVvwxqdenmUhqRH6Rh6FbRBvaj4hf34+gKVnl68QnXvEAPsLI6RXFbqJW5t ERHBP9l1HGzi5M/e8HpIPp0nFQ5CbhvB/oal+RIoQObCovFXBXgnAu6BwpBmQbwYcyKD /kPZsqOrfDicqxkiwjhXuPMp5uxkpvcmiKTi6HbU8LGqNyZdbubiXl8jN/h8A37efZPI xDvSQZY9zarTblOSPb1uhIB8Tj2oivM379sJRpXWLDXwyYbC3WYRWPSGQgg5G5zZjAi0 YbPE49o9CXednBV7BuE6dBfur7rRAPfzRQiAMn3M7quUXldUooWYT2rb7LuavFBQCPQq TGug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="o9/eDCJ4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a50fa86000000b0051e0ec4bcd3si890366edr.410.2023.07.10.18.46.15; Mon, 10 Jul 2023 18:46:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="o9/eDCJ4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231334AbjGKBOy (ORCPT + 99 others); Mon, 10 Jul 2023 21:14:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbjGKBOl (ORCPT ); Mon, 10 Jul 2023 21:14:41 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06B04E77; Mon, 10 Jul 2023 18:14:31 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3a04e5baffcso4221946b6e.3; Mon, 10 Jul 2023 18:14:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689038070; x=1691630070; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=iisu0eogwyT+XXqvCDr4lGty2Pch5Ifq4UOrbO8zY3o=; b=o9/eDCJ410gkR18bZeg9M9uWieax/FIrM7WNdrRsd/DAQlVlUGOJtAjwaGFyklZllq BVpFUGz3XBK9p9g7NKKoXyDwqpqIAaZw7HUnc/AOUgGwhKnsGrdA2MDgdfbztSeh9eHt htGPIbY0zwnQfI/JjXhQu5njYYRJpPDDeDrO2RJfe09xvFT3xvAtpd+6DYaRK/uTf7HV +tD4WAHx5CLdCZGR5KCkN1ZPRtQnGfR8sf8Uwj11D/srNgsi+VRk3vCTv6a+DYQgrFXM 1Ejq5EfVR79h4dBM/zFvY0kDShfWKmjRrliiWZiE6FxkR4BkMbgujdhek4bD9Uk6OV+V B4pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689038070; x=1691630070; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=iisu0eogwyT+XXqvCDr4lGty2Pch5Ifq4UOrbO8zY3o=; b=Um7PQ9HaXG3brTF0rOmbUi9wKYnNikxWNfN71cUd2EPvG5FtHGpPq6T4oUgk0481Mg vTEQP9+V/69Q8iYYHHbR5uJbylUjW9RSePEt03uzHE+PTouYpaBp5GFUrZgY4zduaVon ktMNslaH6IMsPhmBqQDC0umcqPxHQr2bE5DSYN0EPLz1Rhi8jhkWE/J6u6YYkWBbMWSZ wfxS/LEcIXr9dx8Re78K+ekfDWvWJiJe9e6dNAHyOWATHIByQbQCirhrWjIzD40XNJOo SqFYk3gX0dAgLkpnWWyzjYxLa8v1SlPnKc+8uImwzWaU8ViCMlQrk9V1qbWod4B4nlUi BU/w== X-Gm-Message-State: ABy/qLZ9JPU+W+WExt8TpKl1g5iMrlSsgQd2NW3qsHBAOeZv2HbiN/se HV1Et+UAyfV5ct8jsLPXGig= X-Received: by 2002:a05:6808:138c:b0:3a3:9463:ccbf with SMTP id c12-20020a056808138c00b003a39463ccbfmr16743837oiw.15.1689038070048; Mon, 10 Jul 2023 18:14:30 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::5:e2fe]) by smtp.gmail.com with ESMTPSA id fe23-20020a056a002f1700b0066ebaeb149dsm403103pfb.88.2023.07.10.18.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 18:14:29 -0700 (PDT) Sender: Tejun Heo From: Tejun Heo To: torvalds@linux-foundation.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@kernel.org, joshdon@google.com, brho@google.com, pjt@google.com, derkling@google.com, haoluo@google.com, dvernet@meta.com, dschatzberg@meta.com, dskarlat@cs.cmu.edu, riel@surriel.com Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org, kernel-team@meta.com, Tejun Heo , kernel test robot Subject: [PATCH 07/34] sched: Expose css_tg() and __setscheduler_prio() Date: Mon, 10 Jul 2023 15:13:25 -1000 Message-ID: <20230711011412.100319-8-tj@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711011412.100319-1-tj@kernel.org> References: <20230711011412.100319-1-tj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These will be used by a new BPF extensible sched_class. css_tg() will be used in the init and exit paths to visit all task_groups by walking cgroups. __setscheduler_prio() is used to pick the sched_class matching the current prio of the task. For the new BPF extensible sched_class, the mapping from the task configuration to sched_class isn't static and depends on a few factors - e.g. whether the BPF progs implementing the scheduler are loaded and in a serviceable state. That mapping logic will be added to __setscheduler_prio(). When the BPF scheduler progs get loaded and unloaded, the mapping changes and the new sched_class will walk the tasks applying the new mapping using __setscheduler_prio(). v3: Dropped SCHED_CHANGE_BLOCK() as upstream is adding more generic cleanup mechanism. v2: Expose SCHED_CHANGE_BLOCK() too and update the description. Signed-off-by: Tejun Heo Reviewed-by: David Vernet Acked-by: Josh Don Acked-by: Hao Luo Acked-by: Barret Rhoden Reported-by: kernel test robot --- kernel/sched/core.c | 7 +------ kernel/sched/sched.h | 7 +++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 00d6751b0f8d..6818ed1a7a42 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7011,7 +7011,7 @@ int default_wake_function(wait_queue_entry_t *curr, unsigned mode, int wake_flag } EXPORT_SYMBOL(default_wake_function); -static void __setscheduler_prio(struct task_struct *p, int prio) +void __setscheduler_prio(struct task_struct *p, int prio) { if (dl_prio(prio)) p->sched_class = &dl_sched_class; @@ -10523,11 +10523,6 @@ void sched_move_task(struct task_struct *tsk) task_rq_unlock(rq, tsk, &rf); } -static inline struct task_group *css_tg(struct cgroup_subsys_state *css) -{ - return css ? container_of(css, struct task_group, css) : NULL; -} - static struct cgroup_subsys_state * cpu_cgroup_css_alloc(struct cgroup_subsys_state *parent_css) { diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 2eb5759f4be9..71343472e6b1 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -469,6 +469,11 @@ static inline int walk_tg_tree(tg_visitor down, tg_visitor up, void *data) return walk_tg_tree_from(&root_task_group, down, up, data); } +static inline struct task_group *css_tg(struct cgroup_subsys_state *css) +{ + return css ? container_of(css, struct task_group, css) : NULL; +} + extern int tg_nop(struct task_group *tg, void *data); extern void free_fair_sched_group(struct task_group *tg); @@ -2390,6 +2395,8 @@ extern void init_sched_dl_class(void); extern void init_sched_rt_class(void); extern void init_sched_fair_class(void); +extern void __setscheduler_prio(struct task_struct *p, int prio); + extern void resched_curr(struct rq *rq); extern void resched_cpu(int cpu); -- 2.41.0