Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp1091872lqp; Thu, 23 May 2024 08:45:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXR9sYv07ZR+u8eItyGMhWReQXa/wpdfUTV0rH7J7ugO9FBfXcchXec5L/sTpc8EcvBay6fj+ourD3F3OKHWHnnJrF96hqIux2/RsdS9g== X-Google-Smtp-Source: AGHT+IEKdHbgtXAz9jjyKII/et5VUyE3ba7U1m3Tu3Ddftmh+DGRojP/Ao0O8LWg8IR856aKEv9O X-Received: by 2002:a05:622a:164e:b0:43b:173e:ce1b with SMTP id d75a77b69052e-43fa74df0a0mr43746241cf.32.1716479108597; Thu, 23 May 2024 08:45:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716479108; cv=pass; d=google.com; s=arc-20160816; b=DLVop7VeujtQOnhdakOmZ54OqFo2wQ7DPq6oLpif4kVjfYUyI4iwHDb5nVcOe04XAZ u4CJuGwepWrMpO/PgnjOju2O5bbUc02jqsIKK7KwRD9iJOI8+wMCsBlKGEvTjW51RPee bswmIu+kakILF4U02VplhQOYd/5jbLbHQUu2YGOou+VxnDvD3oFvDHM0J8i5v6t9y68/ cHzAkuTRT/nokztl9/pN4mq4PsPwoSdOO/mXw8r+b9z+JSEC7+izaWQ6lW63cOORA7xb fg6cfPkag21ELNlN/UmsSc5vPQNx9iMWmWXNKbeBUhh4RveBQlzbXUefyQrQ3t6tUdj/ P66g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=cK/6CDfY125ekiINveTyF1l/aWNNdPbTIOKtjbCltmA=; fh=OWgi6pdo9f6RtM0SZUEs9BAsb0xLMHcBohS60rx9ab0=; b=ZNr2q77eimt2Jwoo0p3KRBs2B6KdDEQtxUwJn6T+TmoyvaCKkmVHvCGlYXbSqjGwWq gxRHa8DG5pyxm2ZfAlnC5LltRuWiJhL7lJUUfJRJDUnn43OKevX0FCBfYIQtQuOXkAaw 02RC2JFjL6LIRky4R0r+RQNqXYHMbKQVoz7Dv8n5cxEkxNvz7v5Ra1lSUktFHAaoqo+d ep0vIX8LwYhBdKASATDsh1fMilDIfWnZCFl79dZm7+z/+O/fFSa3nRoma8rPQKELybTG 62Q/LurWFo+o47vmBPxsyK+rvhDmFMbLea3SegwIe9tvi0Z9GhZJ4UW0EtO4JYsbQera MLtw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-187732-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187732-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df566f9c4si333223871cf.245.2024.05.23.08.45.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 08:45:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187732-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-187732-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187732-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5112A1C2090F for ; Thu, 23 May 2024 15:45:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C7FB12E75; Thu, 23 May 2024 15:44:59 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC87411720; Thu, 23 May 2024 15:44:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716479098; cv=none; b=b1j06ITsYVH34feGRvW3VxjcO59iudlFp0mcbam2zRIqpviNuUvuCC7+gbkQ/P3J/US2/Kpkuu2w3StgBiPB7+poyExUiuid+l59qb0gJ4eJdyXL1whqY8inEcqOrePETGGtdZ0nbH3n2TlVzIYlNN/gORA4unaVVGUkfeA23Xs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716479098; c=relaxed/simple; bh=0zM6tALU7shidJdLtZOrXtoH17h4De0WmF255Z4Mza4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MSo3pO5iv1z6aLQJIpKAIzWbh8MLoZAbc0PulfX7qd51GwQW+ksA1VM2sNw2W18xolbGE1O3BEqK4uXtQV0RDH36KGVszVyt1nAqVlh07QAtJFJtUJHPHEdel1h6fY/j3G4LdxNnZqBmjk1KMkguGGdViAQHBxbhdvDanVVFdl4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71C0EC2BD10; Thu, 23 May 2024 15:44:56 +0000 (UTC) Date: Thu, 23 May 2024 11:45:40 -0400 From: Steven Rostedt To: Qais Yousef Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Daniel Bristot de Oliveira , Thomas Gleixner , Sebastian Andrzej Siewior , Alexander Viro , Christian Brauner , Andrew Morton , Jens Axboe , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, Phil Auld Subject: Re: [PATCH v2] sched/rt: Clean up usage of rt_task() Message-ID: <20240523114540.2856c109@gandalf.local.home> In-Reply-To: <20240515220536.823145-1-qyousef@layalina.io> References: <20240515220536.823145-1-qyousef@layalina.io> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 15 May 2024 23:05:36 +0100 Qais Yousef wrote: > diff --git a/include/linux/sched/deadline.h b/include/linux/sched/deadline.h > index df3aca89d4f5..5cb88b748ad6 100644 > --- a/include/linux/sched/deadline.h > +++ b/include/linux/sched/deadline.h > @@ -10,8 +10,6 @@ > > #include > > -#define MAX_DL_PRIO 0 > - > static inline int dl_prio(int prio) > { > if (unlikely(prio < MAX_DL_PRIO)) > @@ -19,6 +17,10 @@ static inline int dl_prio(int prio) > return 0; > } > > +/* > + * Returns true if a task has a priority that belongs to DL class. PI-boosted > + * tasks will return true. Use dl_policy() to ignore PI-boosted tasks. > + */ > static inline int dl_task(struct task_struct *p) > { > return dl_prio(p->prio); > diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h > index ab83d85e1183..6ab43b4f72f9 100644 > --- a/include/linux/sched/prio.h > +++ b/include/linux/sched/prio.h > @@ -14,6 +14,7 @@ > */ > > #define MAX_RT_PRIO 100 > +#define MAX_DL_PRIO 0 > > #define MAX_PRIO (MAX_RT_PRIO + NICE_WIDTH) > #define DEFAULT_PRIO (MAX_RT_PRIO + NICE_WIDTH / 2) > diff --git a/include/linux/sched/rt.h b/include/linux/sched/rt.h > index b2b9e6eb9683..a055dd68a77c 100644 > --- a/include/linux/sched/rt.h > +++ b/include/linux/sched/rt.h > @@ -7,18 +7,43 @@ > struct task_struct; > > static inline int rt_prio(int prio) > +{ > + if (unlikely(prio < MAX_RT_PRIO && prio >= MAX_DL_PRIO)) > + return 1; > + return 0; > +} > + > +static inline int realtime_prio(int prio) > { > if (unlikely(prio < MAX_RT_PRIO)) > return 1; > return 0; > } I'm thinking we should change the above to bool (separate patch), as returning an int may give one the impression that it returns the actual priority number. Having it return bool will clear that up. In fact, if we are touching theses functions, might as well change all of them to bool when returning true/false. Just to make it easier to understand what they are doing. > > +/* > + * Returns true if a task has a priority that belongs to RT class. PI-boosted > + * tasks will return true. Use rt_policy() to ignore PI-boosted tasks. > + */ > static inline int rt_task(struct task_struct *p) > { > return rt_prio(p->prio); > } > > -static inline bool task_is_realtime(struct task_struct *tsk) > +/* > + * Returns true if a task has a priority that belongs to RT or DL classes. > + * PI-boosted tasks will return true. Use realtime_task_policy() to ignore > + * PI-boosted tasks. > + */ > +static inline int realtime_task(struct task_struct *p) > +{ > + return realtime_prio(p->prio); > +} > + > +/* > + * Returns true if a task has a policy that belongs to RT or DL classes. > + * PI-boosted tasks will return false. > + */ > +static inline bool realtime_task_policy(struct task_struct *tsk) > { > int policy = tsk->policy; > > diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c > index 0469a04a355f..19d737742e29 100644 > --- a/kernel/trace/trace_sched_wakeup.c > +++ b/kernel/trace/trace_sched_wakeup.c > @@ -545,7 +545,7 @@ probe_wakeup(void *ignore, struct task_struct *p) > * - wakeup_dl handles tasks belonging to sched_dl class only. > */ > if (tracing_dl || (wakeup_dl && !dl_task(p)) || > - (wakeup_rt && !dl_task(p) && !rt_task(p)) || > + (wakeup_rt && !realtime_task(p)) || > (!dl_task(p) && (p->prio >= wakeup_prio || p->prio >= current->prio))) > return; > Reviewed-by: Steven Rostedt (Google)