From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF713C25B7A for ; Tue, 21 May 2024 11:00:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 236846B008C; Tue, 21 May 2024 07:00:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E7B86B0092; Tue, 21 May 2024 07:00:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AEB66B0093; Tue, 21 May 2024 07:00:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DCD2B6B008C for ; Tue, 21 May 2024 07:00:41 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 44D3BC1062 for ; Tue, 21 May 2024 11:00:41 +0000 (UTC) X-FDA: 82142109882.06.FF27D38 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf01.hostedemail.com (Postfix) with ESMTP id 2569640024 for ; Tue, 21 May 2024 11:00:38 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=FRQFlY5f; dkim=pass header.d=linutronix.de header.s=2020e header.b=6JINQMdp; spf=pass (imf01.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716289239; a=rsa-sha256; cv=none; b=AXg5egGRIH17nuBP9KulxZ1qkjx0CTU6nl096LYav49+ob2ITimmQmC6EoenY2L4OaWz68 k9a48E7aLTWOqW4I+sBpP9iicJboDn4cjJoekol5RdqYyGcC0+37qMK/Ihi+CEBHGBshWk wkUyIIzT+ZSN7MTy7aZ9WdI3vhw5miY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=FRQFlY5f; dkim=pass header.d=linutronix.de header.s=2020e header.b=6JINQMdp; spf=pass (imf01.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716289239; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/SKqiKY3fPfFrak3zoFgzP4YhDQY8tnNkx/mXavMpSw=; b=Rg3PgaJIX8wzvu+PuYRBzPpgJsb/wyY+H7fQpT/TeDhqoUXRFZEDeg0a4bCS8g7/RLc/E2 Fd+IxECX9vp7l8Vfui7j7kmNZWhilwdCumqGzxeV0i3k8FpbgtiitIrxqwPpfl8+UO9cwe KB/eBFbCDcmvtWBgc/MsFNoBAUaC+c4= Date: Tue, 21 May 2024 13:00:35 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1716289236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/SKqiKY3fPfFrak3zoFgzP4YhDQY8tnNkx/mXavMpSw=; b=FRQFlY5ffVxx8kUFmC0jx5rMqBpFzKeZH41Rq+N8SgCWVWEyt1zyWLKwZeKbBLRZckUHxP 3ZecqZU/4oAZPmzLmFjWAymZK5GmmDbQ9ZUaSFLxijU5FeSNJ78QPknI8k8SYSUIvCTVKH Z7GP4piQL3qIMOrpguhh45A5lD2rDfi/7Ll9EujkhRxmilGycuQatQX9pSAUN2Kscgr3ab OCLCV8NyrT1rNT2nuJYVE/ZVuwM465v+Cnd288JvHFu+ayaUrWpJDPn0kQsAFe8VClF5Gt RgyYimqytc+W9AhUH1eFwVYf/Bx4N9w3/7laag/KIvkhm7YT61swbU4b0z/h+w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1716289236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/SKqiKY3fPfFrak3zoFgzP4YhDQY8tnNkx/mXavMpSw=; b=6JINQMdpOPpHBR1iFBmVIaq+lA45HD37UNR4XddxkdAxN5OycpjJSBl/4PhNdTDmrOJ0SB ZyMpkCCSdbU4tQBA== From: Sebastian Andrzej Siewior To: Qais Yousef Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt , Vincent Guittot , Daniel Bristot de Oliveira , Thomas Gleixner , 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: <20240521110035.KRIwllGe@linutronix.de> References: <20240515220536.823145-1-qyousef@layalina.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20240515220536.823145-1-qyousef@layalina.io> X-Rspamd-Queue-Id: 2569640024 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: obyshbq1akniqjxduyzyef11q6hm4mag X-HE-Tag: 1716289238-430040 X-HE-Meta: U2FsdGVkX18QH0FiFBsNDxKwcft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K+iNxOKBFuTE991KFH2o85FVyuAovyS/LuzmOyfciHTfVaXwZ4ekzVhhzhz/9f7xUs7jDJHjO2ozu8KylSDhget38FW8HOxIXrcvwF8Sn/A/Fn55A7rdcgMS6z6MnRvoRtkPSMhFE15619mKgJuGILvT7HqxZTTJnoSUQVrlZBuZhAm4X9goN2gerN7g X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2024-05-15 23:05:36 [+0100], Qais Yousef wrote: > rt_task() checks if a task has RT priority. But depends on your > dictionary, this could mean it belongs to RT class, or is a 'realtime' > task, which includes RT and DL classes. >=20 > Since this has caused some confusion already on discussion [1], it > seemed a clean up is due. >=20 > I define the usage of rt_task() to be tasks that belong to RT class. > Make sure that it returns true only for RT class and audit the users and > replace the ones required the old behavior with the new realtime_task() > which returns true for RT and DL classes. Introduce similar > realtime_prio() to create similar distinction to rt_prio() and update > the users that required the old behavior to use the new function. >=20 > Move MAX_DL_PRIO to prio.h so it can be used in the new definitions. >=20 > Document the functions to make it more obvious what is the difference > between them. PI-boosted tasks is a factor that must be taken into > account when choosing which function to use. >=20 > Rename task_is_realtime() to realtime_task_policy() as the old name is > confusing against the new realtime_task(). I *think* everyone using rt_task() means to include DL tasks. And everyone means !SCHED-people since they know when the difference matters. > No functional changes were intended. >=20 > [1] https://lore.kernel.org/lkml/20240506100509.GL40213@noisy.programming= =2Ekicks-ass.net/ >=20 > Reviewed-by: Phil Auld > Signed-off-by: Qais Yousef > --- >=20 > Changes since v1: >=20 > * Use realtime_task_policy() instead task_has_realtime_policy() (Peter) > * Improve commit message readability about replace some rt_task() > users. >=20 > v1 discussion: https://lore.kernel.org/lkml/20240514234112.792989-1-qyous= ef@layalina.io/ >=20 > fs/select.c | 2 +- fs/bcachefs/six.c six_owner_running() has rt_task(). But imho should have realtime_task() to consider DL. But I think it is way worse that it has its own locking rather than using what everyone else but then again it wouldn't be the new hot thing=E2=80=A6 > include/linux/ioprio.h | 2 +- > include/linux/sched/deadline.h | 6 ++++-- > include/linux/sched/prio.h | 1 + > include/linux/sched/rt.h | 27 ++++++++++++++++++++++++++- > kernel/locking/rtmutex.c | 4 ++-- > kernel/locking/rwsem.c | 4 ++-- > kernel/locking/ww_mutex.h | 2 +- > kernel/sched/core.c | 6 +++--- > kernel/time/hrtimer.c | 6 +++--- > kernel/trace/trace_sched_wakeup.c | 2 +- > mm/page-writeback.c | 4 ++-- > mm/page_alloc.c | 2 +- > 13 files changed, 48 insertions(+), 20 deletions(-) =E2=80=A6 > diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c > index 70625dff62ce..08b95e0a41ab 100644 > --- a/kernel/time/hrtimer.c > +++ b/kernel/time/hrtimer.c > @@ -1996,7 +1996,7 @@ static void __hrtimer_init_sleeper(struct hrtimer_s= leeper *sl, > * expiry. > */ > if (IS_ENABLED(CONFIG_PREEMPT_RT)) { > - if (task_is_realtime(current) && !(mode & HRTIMER_MODE_SOFT)) > + if (realtime_task_policy(current) && !(mode & HRTIMER_MODE_SOFT)) > mode |=3D HRTIMER_MODE_HARD; > } > =20 > @@ -2096,7 +2096,7 @@ long hrtimer_nanosleep(ktime_t rqtp, const enum hrt= imer_mode mode, > u64 slack; > =20 > slack =3D current->timer_slack_ns; > - if (rt_task(current)) > + if (realtime_task(current)) > slack =3D 0; > =20 > hrtimer_init_sleeper_on_stack(&t, clockid, mode); > @@ -2301,7 +2301,7 @@ schedule_hrtimeout_range_clock(ktime_t *expires, u6= 4 delta, > * Override any slack passed by the user if under > * rt contraints. > */ > - if (rt_task(current)) > + if (realtime_task(current)) > delta =3D 0; I know this is just converting what is already here but=E2=80=A6 __hrtimer_init_sleeper() looks at the policy to figure out if the task is realtime do decide if should expire in HARD-IRQ context. This is correct, a boosted task should not sleep. hrtimer_nanosleep() + schedule_hrtimeout_range_clock() is looking at priority to decide if slack should be removed. This should also look at policy since a boosted task shouldn't sleep. In order to be PI-boosted you need to acquire a lock and the only lock you can sleep while acquired without generating a warning is a mutex_t (or equivalent sleeping lock) on PREEMPT_RT.=20 > hrtimer_init_sleeper_on_stack(&t, clock_id, mode); > 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 >=3D wakeup_prio || p->prio >=3D current->= prio))) > return; > =20 Sebastian