Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36126754rwd; Mon, 10 Jul 2023 18:39:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGkxoptc5XF+vSdgdMs5wXc4gsTeIlLXJQbxcRNrqSrbPeszC1k3qUlydSRVdqn48qcI5kJ X-Received: by 2002:a05:622a:d1:b0:3fd:e37c:edea with SMTP id p17-20020a05622a00d100b003fde37cedeamr20300638qtw.45.1689039560511; Mon, 10 Jul 2023 18:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689039560; cv=none; d=google.com; s=arc-20160816; b=UctW915MUHvc5JA4LfwZsZTGAdUyfjIgokOuE/J0R2dtIHX7u5r1JC14WWWd4zu3C8 l2c4YbNeMYOQrDHj7gvograAxV10V8pmNv1+Xu4M5nvqaf1DZbp59ZskUn2BuWSuWh5p zm/ONOhbNp0xbJ7SbOBCKVgWGmX0hvyw02hnbl2Rn5s5v0jejffMfiYgXj6F9GvVDeQ7 2U78NXDHIckV0RUqgP9pbe2QbLsbd/erG+lFzV0n/lLt/tFzDlZ7Z6Sg7L6ibdFbYn1+ +F93D1YseZu6WUCuAn6THmHv65jR84E7mKqR+34h4UCro4YTR6UqznPDgAGGEK0XnOGo quKA== 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=vrW7vMiU6ZQ4Vgx18JIyoYqnBVStESkiqVqm2bESiQI=; fh=5bvFqXZy/VrzcWOXnXaaKVCt2r2P+2FQUI6EKkM71t8=; b=TNB+GWFlr4ULuI4/VUIUR2v3Lrc1Us8OQEr2PZcktezBdLX9SV+H+CJUYzD2pUtUiF /3AQdTgEy4bEeufb+FOqRV+XLClA5A1V6Yks/R6dEr25tZvzvrPu2jMik28+7E5zgl4R hjXn1r6ge3PoNjHYJZFhjvBs1lD8vtsvPiEMjooD7FFMQIc9P2w/by/7ubBeTDA6yNzN XhJrV7jooxW4vQayUOevKsmPPQGc2IEPC/YtUSE7mzHqKmqBnW9v8vos2Zvo36CnPtCk CxvOOsQJ4YgX7YoCc3MAo3diEIVZ3ZaFjO+p5Xms5s07Bd590qXznQhX2GMFdwU6daCf k4Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=gPnSJZMq; 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 cb10-20020a056a00430a00b00653c0edfd34si614348pfb.139.2023.07.10.18.39.08; Mon, 10 Jul 2023 18:39:20 -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=gPnSJZMq; 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 S231373AbjGKBPP (ORCPT + 99 others); Mon, 10 Jul 2023 21:15:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231251AbjGKBOz (ORCPT ); Mon, 10 Jul 2023 21:14:55 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CFDE170E; Mon, 10 Jul 2023 18:14:36 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1b8ad356f03so33090705ad.1; Mon, 10 Jul 2023 18:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689038076; x=1691630076; 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=vrW7vMiU6ZQ4Vgx18JIyoYqnBVStESkiqVqm2bESiQI=; b=gPnSJZMqYT30Hp5QRloTeBIS6H9BPBU69IBaEk4+5Fy6zStNqLF/zj4/Lsa59GPc3Q Fa4B95G/mLXInqYGQfDBmwHrbmWepdpLz/tajkkWTKUjeUu5w4uxFJaxwDXDKWSnUivN aerYIwloicHSx6Jiulqn3sDQArDY56bZcHDDjeclJ7dcHIzLU4Qx0JQrJmj04lizYbz8 orODbJO0JiLFUymcGG5+SxXCN2fxKsGBDujqHaemyO6c5eLeelXC6n/IVvJWFOYaD86g b+wgHYYUjzvmkOSUYWxJ1PCPDn6zudn5OSUaopuSCD39t7/PRjmVI5YkQVSMuo2zTBhC kHeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689038076; x=1691630076; 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=vrW7vMiU6ZQ4Vgx18JIyoYqnBVStESkiqVqm2bESiQI=; b=UFw5q6AYIZII37lj5DlqpYSAZES5QcGeddgTCSzZw48ns3DbUkExNX5y40G4hS9k+b xzPcLD6JgQdXSM42MBuj/snkbcx9Pnexm4WXvlJTGS0jqe8rQBeq6+wKSNxc0Bez9MSQ 8ki5ohnHD6PDiJz0gKocxBP9Sa1Xhwm8E5RyydX3J2akaDjQqC2RrOsJUF2ZEDzk9bZO ppsmFyDL9MKvwFob5DB3fF5T1q4wIrxoOVfZIRpcZCKUmDBONf9K6P1iQrSdba0umr/a emrbsX87pQBL5YRgw8wfzc9d46yhRoNitJg22oGOWnoqBpZKnu8YtuFEVLCy1ad78177 D4Rw== X-Gm-Message-State: ABy/qLZgirpWx8NP1GaO3R5QYcsBOQzFawG3gmkKyxHo3wQ3ay8CSKh7 1hp1+Qyl53jvQfu+3sQUNlE= X-Received: by 2002:a17:902:ce89:b0:1b8:7625:3042 with SMTP id f9-20020a170902ce8900b001b876253042mr13465115plg.10.1689038075896; Mon, 10 Jul 2023 18:14:35 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::5:e2fe]) by smtp.gmail.com with ESMTPSA id jw20-20020a170903279400b001aaecc0b6ffsm511586plb.160.2023.07.10.18.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 18:14:35 -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 Subject: [PATCH 10/34] sched: Add normal_policy() Date: Mon, 10 Jul 2023 15:13:28 -1000 Message-ID: <20230711011412.100319-11-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 A new BPF extensible sched_class will need to dynamically change how a task picks its sched_class. For example, if the loaded BPF scheduler progs fail, the tasks will be forced back on CFS even if the task's policy is set to the new sched_class. To support such mapping, add normal_policy() which wraps testing for %SCHED_NORMAL. This doesn't cause any behavior changes. v2: Update the description with more details on the expected use. Signed-off-by: Tejun Heo Reviewed-by: David Vernet Acked-by: Josh Don Acked-by: Hao Luo Acked-by: Barret Rhoden --- kernel/sched/fair.c | 2 +- kernel/sched/sched.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 9838c82230e1..5ba7e1f2e7c7 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7900,7 +7900,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_ * Batch and idle tasks do not preempt non-idle tasks (their preemption * is driven by the tick): */ - if (unlikely(p->policy != SCHED_NORMAL) || !sched_feat(WAKEUP_PREEMPTION)) + if (unlikely(!normal_policy(p->policy)) || !sched_feat(WAKEUP_PREEMPTION)) return; find_matching_se(&se, &pse); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index cd11bf9de7f9..7eee863942f4 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -182,9 +182,15 @@ static inline int idle_policy(int policy) { return policy == SCHED_IDLE; } + +static inline int normal_policy(int policy) +{ + return policy == SCHED_NORMAL; +} + static inline int fair_policy(int policy) { - return policy == SCHED_NORMAL || policy == SCHED_BATCH; + return normal_policy(policy) || policy == SCHED_BATCH; } static inline int rt_policy(int policy) -- 2.41.0