Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7287522rwb; Mon, 12 Dec 2022 12:35:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf7TymPhdhyKjKci1oLlSe1KLq1IvyNQG7Zx4HdJPNb+wk/PiXnUMxEcYDpLrPyVm6hiWaP/ X-Received: by 2002:a05:6a20:94c9:b0:a7:ce31:f32b with SMTP id ht9-20020a056a2094c900b000a7ce31f32bmr21114717pzb.56.1670877358529; Mon, 12 Dec 2022 12:35:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670877358; cv=none; d=google.com; s=arc-20160816; b=BVj6xh2NULPbfjGvdxKDqT1jGmTM180ebla+7pPaG/WaFH3fqTCRptzXPillJ7AohA bQSgIjVu28+kadHtuoLMl4fR86G9w/Dv4ux/3WJb5eM2jus7jEU6hSu+e3+i0pq7x8t8 6DXsACqp29aqC/porG9IbDK/lfT0vimwAgq3gJ72JfT30muXPpIF+4uUwMVObVVxpAVI jZSpqDwEFhnNz3Mo2pBTb7aa35xi2wz84vPzBS36USCHhJdo7UXpPTSr4oyQX8Yidhrv Rhqokz2WXPsZaLbqoPuM/lW8K9y/ZDnKFKQURpphXu66tExtl9XZF2MxeaA/Dto//FYU 2ioA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=QxiD9QOWm22ozh4cTtuGcvlN+TVb9Fc8vBBhLu2C8CM=; b=YM6s+dduLWqFOfLF1DNTorOjHHcTwF0oblYF/WDtVtn9zkejHqv/m8h+rbRMeDenlk kMBHyYzgyf2qsjpf2c8LaYHshXNEUM2f37guHuHgSlncsvSRKWX74wKuf9I751qHm0Vv dID0RfJk7PW4ykjbTShGCQLAYE2M7nfTrBTvLlHfjE44FCjnvjt+b6I7Zzacq65HdRYE rI6sH76RMpZAuacdmYnbZPRM4xn+q2J1XpiFdcE/fb3CuJVJ89Q56o90+ZoK3B3WkUxS DQod60lUNIBy9qKR10A85LykbVYiSs/ihmPun6V9iWRvi5IbV2TsayFN05E/yLDhcI/9 KMoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aCUTOAHu; 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 l1-20020a6542c1000000b0046f75bc53d0si9892632pgp.241.2022.12.12.12.35.48; Mon, 12 Dec 2022 12:35:58 -0800 (PST) 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=20210112 header.b=aCUTOAHu; 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 S233100AbiLLUED (ORCPT + 74 others); Mon, 12 Dec 2022 15:04:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233389AbiLLUEA (ORCPT ); Mon, 12 Dec 2022 15:04:00 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02BFD1788A; Mon, 12 Dec 2022 12:03:59 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id 21so688651pfw.4; Mon, 12 Dec 2022 12:03:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=QxiD9QOWm22ozh4cTtuGcvlN+TVb9Fc8vBBhLu2C8CM=; b=aCUTOAHu/xmm8z9cyKediliIPVmUzLeCJEMjJhv7iONzRgrgWaQAYxmDwiwP6GwFvd hEPkAFqbmYYHm3abENgM/UlBrKOcKBzwbn+gTg56JPRj6c3YRupUDWaWst5YQWkV+USa fV3CBrAevzb7fval2VL4gt2C2jaPTDRQoQRuf99HDLl7o2rYmUC+YZ8n+QcuRcztxxpD DAwoqrviplWG8HzDSTSHfI/lzThCaaC2P9EFGGU1xLYVAcnqzI/SsyekwSk/RXz0v6QU j19Zu6Y701NNU+R26N4SGJIRDFpOw5TuT/uR806juxtNkywIVt+7ZbV1+Y8S0zdsChbJ /DMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QxiD9QOWm22ozh4cTtuGcvlN+TVb9Fc8vBBhLu2C8CM=; b=h0LQF7nJSsYhQ4tl192qXGIlZ5zyRcbHWW5XNnpRTQCP/5cX3XySdqmuMAU2kTLdLs BXqbx3aVJZ7loZ+kIVXCLv0YOicxGTuVo+kAWUN0kZTrgxOHhRS7Z5H7NxVS680dRjD2 uQLhnPGLjXK1m5nbspJy5dCEOfge1qWBRDgNyUKzc++vieaKG5EP4hu/JY4lSNnoozGs rhhNLIwncl51TeRg+O1mlXo9q94HyxRZRVzQXLLgbozKcaazMogB353Bk7vo2Ar5pbKc IMCBh/vt43U3SSXCwQjEtJKCdGDz30VB+ZafFVjf6kszFM8pdeoTfT/c6d4XATga3atq sf1w== X-Gm-Message-State: ANoB5pkTe1AIEZX/T93d6jl2ghZgHpaDHGZHODDng8XfLPkJQBEvxQUh gkG2peFQ9epYG0uY0CwAGEM= X-Received: by 2002:a05:6a00:1f0f:b0:56c:881d:b128 with SMTP id be15-20020a056a001f0f00b0056c881db128mr15894319pfb.22.1670875438318; Mon, 12 Dec 2022 12:03:58 -0800 (PST) Received: from localhost (2603-800c-1a02-1bae-a7fa-157f-969a-4cde.res6.spectrum.com. [2603:800c:1a02:1bae:a7fa:157f:969a:4cde]) by smtp.gmail.com with ESMTPSA id a15-20020aa795af000000b00576670cc170sm6347939pfk.93.2022.12.12.12.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 12:03:57 -0800 (PST) Sender: Tejun Heo Date: Mon, 12 Dec 2022 10:03:56 -1000 From: Tejun Heo To: Peter Zijlstra Cc: torvalds@linux-foundation.org, mingo@redhat.com, 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, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH 14/31] sched_ext: Implement BPF extensible scheduler class Message-ID: References: <20221130082313.3241517-1-tj@kernel.org> <20221130082313.3241517-15-tj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 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_NONE,SPF_HELO_NONE, SPF_PASS 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 Hello, On Mon, Dec 12, 2022 at 01:31:11PM +0100, Peter Zijlstra wrote: > On Tue, Nov 29, 2022 at 10:22:56PM -1000, Tejun Heo wrote: > > @@ -11242,3 +11268,38 @@ void call_trace_sched_update_nr_running(struct rq *rq, int count) > > { > > trace_sched_update_nr_running_tp(rq, count); > > } > > + > > +#ifdef CONFIG_SCHED_CLASS_EXT > > +void sched_deq_and_put_task(struct task_struct *p, int queue_flags, > > + struct sched_enq_and_set_ctx *ctx) > > +{ > > + struct rq *rq = task_rq(p); > > + > > + lockdep_assert_rq_held(rq); > > + > > + *ctx = (struct sched_enq_and_set_ctx){ > > + .p = p, > > + .queue_flags = queue_flags | DEQUEUE_NOCLOCK, > > + .queued = task_on_rq_queued(p), > > + .running = task_current(rq, p), > > + }; > > + > > + update_rq_clock(rq); > > + if (ctx->queued) > > + dequeue_task(rq, p, queue_flags); > > + if (ctx->running) > > + put_prev_task(rq, p); > > +} > > + > > +void sched_enq_and_set_task(struct sched_enq_and_set_ctx *ctx) > > +{ > > + struct rq *rq = task_rq(ctx->p); > > + > > + lockdep_assert_rq_held(rq); > > + > > + if (ctx->queued) > > + enqueue_task(rq, ctx->p, ctx->queue_flags); > > + if (ctx->running) > > + set_next_task(rq, ctx->p); > > +} > > +#endif /* CONFIG_SCHED_CLASS_EXT */ > > So no. Like the whole __setscheduler_prio() thing, this doesn't make > sense outside of the core code, policy/class code should never need to > do this. Continuing from the __setscheduler_prio() discussion, the need arises from the fact that whether a task is on SCX or CFS changes depending on whether the BPF scheduler is loaded or not - e.g. when the BPF scheduler gets disabled, all tasks that were on it need to be moved back into CFS. There are different ways to implement this but it needs to be solved somehow. > Also: https://lkml.kernel.org/r/20220330162228.GH14330@worktop.programming.kicks-ass.net Yeah, it'd be nice to encapsulate this sequence. The FOR_CHANGE_GUARD naming throws me off a bit tho as it's not really a loop. Wouldn't it be better to call it CHANGE_GUARD_BLOCK or sth? Thanks. -- tejun