From patchwork Mon Jun 10 19:20:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 13692378 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 4E492C27C5F for ; Mon, 10 Jun 2024 19:20:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC76C6B0085; Mon, 10 Jun 2024 15:20:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C76606B009B; Mon, 10 Jun 2024 15:20:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7A3A6B009C; Mon, 10 Jun 2024 15:20:27 -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 830366B0085 for ; Mon, 10 Jun 2024 15:20:27 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3BF6180128 for ; Mon, 10 Jun 2024 19:20:27 +0000 (UTC) X-FDA: 82215945294.05.81B9785 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by imf18.hostedemail.com (Postfix) with ESMTP id 4CBAF1C0025 for ; Mon, 10 Jun 2024 19:20:25 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=layalina-io.20230601.gappssmtp.com header.s=20230601 header.b="n/xwF1FT"; dmarc=none; spf=pass (imf18.hostedemail.com: domain of qyousef@layalina.io designates 209.85.128.42 as permitted sender) smtp.mailfrom=qyousef@layalina.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718047225; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nOj7aZ/thIDDH6yaDvxXVxqezFIWfnXGgSKAWzL621g=; b=cvZmiNWPvABGiEBwsEaFlGwFwhdrw+HTfq73Dxmx82JTRf7HhFK8BQ3kCvVIFUCFkP2V19 4qGj6fwOTWlYTumw43coWTnxBKvlrwdWjv42XDQkZZ3bqkx7UD1IPjpV5Ylk9kUSfKrh+D HQtwin09zzJp/kqEkOlEWsRYZksXb7w= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=layalina-io.20230601.gappssmtp.com header.s=20230601 header.b="n/xwF1FT"; dmarc=none; spf=pass (imf18.hostedemail.com: domain of qyousef@layalina.io designates 209.85.128.42 as permitted sender) smtp.mailfrom=qyousef@layalina.io ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718047225; a=rsa-sha256; cv=none; b=aCpyMRY8jO3zv/MFcYvOOasI+ojENL/CX3v2vR044e0QMHMf2jybAIwfTQ6X3LtvP5nkDC rIM+k7okexlyZfz931x7JAtTyPhAieyEk3aewpjmlmJ8SS3OOB5iwWs+9nVf9tZv6hZ19q LnKZKI3CZzUmHpTM2giYKaJs8wRkpus= Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-42108856c33so35301675e9.1 for ; Mon, 10 Jun 2024 12:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1718047224; x=1718652024; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nOj7aZ/thIDDH6yaDvxXVxqezFIWfnXGgSKAWzL621g=; b=n/xwF1FT5YRpQQLOjYq3G7KZQJtOwE5gELh3g/MlTYZnrXIRO73mo+RTdmdLWpMoj9 HnFk3nEijWZ2rdhO6u8ZK9m6AM316/6Fkdal+sxAWCLu7CJQw55ck9kpdAeJYJzTNJvO MbS5AvTcMFkgQ9ppBiuxEB1zzl47OANJNZUU6J2Ta44MY26cKdB0OqY17fIW5KRczerq gwz9e+gxvFARw8F0TCpjx10AJ484HPrzzAbKrznRHJK8phttphwRifNpBIphOlQ+HKVR WSOQlKxRGfaVZOn19n2HE/FwWYbfwnhuHRIh3FYQQ6akNS8deJy4wAWbB5ASAq+5TCEf CSow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718047224; x=1718652024; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nOj7aZ/thIDDH6yaDvxXVxqezFIWfnXGgSKAWzL621g=; b=f/x18/xAogf+DIaCTjcijTfzetH3QWXyjIKskeiUq1KOsmMA/ug8v/wP8nx0MJNV4E ctnkj0JOheWgHRPnt+xejFcbqpLGkkXNUHWCv31l701LkMNk85a5QF6hCXEz1OXkuCEj 847OcaTw8k+nMQ2tVL5Ybh710ylUCnxOTmO7iS7gZJXM2465n0XVCn1SXKOSLfh1X4SD Mn2+GnAsqBwsXHbkeDSgNhx7Fj0rTP43xgIif7jE9+MLxB/7PEvW2Yh8XUhIEZ2XX/w2 DAmNMW1bCKSLdIn9GeAoVkFACRov5xq7HWq9Cgw8lxDLxGW+phpEkRfJ3WxRTUn/zZkp zMAQ== X-Forwarded-Encrypted: i=1; AJvYcCVojTLRgKvV7nkDPliCuNoSvnnRoH0VeMuGExey0HWaJvmMT2gwz4Vb+/bc02Gvwr1zvQNOSCpFaBeRBQJMfPadb/g= X-Gm-Message-State: AOJu0YwvmX5XUFhtSoR8WLiDq+/NEGWvOWLobm+Z6/25BhelFww/swB0 2aT8599JilVaiXkl++Be+78es0h44NKHIblB5tTAy8AVzcJDJAObMl42SIvrLXk= X-Google-Smtp-Source: AGHT+IGQsBk7L1DEGAh7C31itA8/qSm9syQoGkh6Ovze0BzlTpWdOlb0hVr4Q71C5k8t/taAmYzA/Q== X-Received: by 2002:a5d:4583:0:b0:35d:bd7e:70bd with SMTP id ffacd0b85a97d-35f2b2c690bmr542878f8f.28.1718047223321; Mon, 10 Jun 2024 12:20:23 -0700 (PDT) Received: from airbuntu.. (host81-157-90-255.range81-157.btcentralplus.com. [81.157.90.255]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f1f30c3ccsm4988326f8f.7.2024.06.10.12.20.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 12:20:23 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt Cc: Vincent Guittot , Daniel Bristot de Oliveira , Thomas Gleixner , Sebastian Andrzej Siewior , Alexander Viro , Christian Brauner , Andrew Morton , Jens Axboe , Metin Kaya , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, Qais Yousef , Phil Auld Subject: [PATCH v6 1/3] sched/rt: Clean up usage of rt_task() Date: Mon, 10 Jun 2024 20:20:16 +0100 Message-Id: <20240610192018.1567075-2-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610192018.1567075-1-qyousef@layalina.io> References: <20240610192018.1567075-1-qyousef@layalina.io> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4CBAF1C0025 X-Stat-Signature: npqr6sow1ne95ekxxhngu9jntirorycy X-Rspam-User: X-HE-Tag: 1718047225-88384 X-HE-Meta: U2FsdGVkX181B0Hc+d4MPqlX7McOXEWQOOT65meLF9+jqV5l4r9edwbWSu2lgBWiPgqwssRY0Ghf/SIkcD+qYsePjt6+OU1tguvw7JgDr6XUY+UCiOGWtrGzUsDXHbCp6MD6oLtYeF22fpBEXH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Pv6UZXyQ3Tjuw+RcZJGyGima3n34dYWA4ba/0r7braZMu9l8+YLB9jSEnFnS6+q848nvXuj3AfkZB/HF5zuPI7FbNJAOa/J/O+y7OlW253GWT3K5E+a8SMqTBX5FGYC3GRMc+ailFtvTSEFMxX7pzlmuo7SQvls8uENCXBGkZbjS3+lcMKTwJ/bQ0bXPV23bkdNDNzgu4WvvpJ2foaPAn2N1LSPgXhtAbPOQn3L4/Zme28KNnK+4qVeOIE8QY3QgNLq5fsyheMIsRbMyUHQ0ll0+Bc7rA+MGWSybWTAs33p7izfwQPtco74YVq74o/MK3YBiPitFXxRMnXhsALKZ1shnR9fK9Gn2cwueSPK8ndZBiqX6jXnQchw= 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: 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. Since this has caused some confusion already on discussion [1], it seemed a clean up is due. 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. Move MAX_DL_PRIO to prio.h so it can be used in the new definitions. 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. Rename task_is_realtime() to realtime_task_policy() as the old name is confusing against the new realtime_task(). No functional changes were intended. [1] https://lore.kernel.org/lkml/20240506100509.GL40213@noisy.programming.kicks-ass.net/ Reviewed-by: Phil Auld Reviewed-by: Steven Rostedt (Google) Reviewed-by: Sebastian Andrzej Siewior Signed-off-by: Qais Yousef --- fs/bcachefs/six.c | 2 +- fs/select.c | 2 +- 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 | 4 ++-- kernel/sched/syscalls.c | 2 +- kernel/time/hrtimer.c | 6 +++--- kernel/trace/trace_sched_wakeup.c | 2 +- mm/page-writeback.c | 4 ++-- mm/page_alloc.c | 2 +- 15 files changed, 49 insertions(+), 21 deletions(-) diff --git a/fs/bcachefs/six.c b/fs/bcachefs/six.c index 3a494c5d1247..b30870bf7e4a 100644 --- a/fs/bcachefs/six.c +++ b/fs/bcachefs/six.c @@ -335,7 +335,7 @@ static inline bool six_owner_running(struct six_lock *lock) */ rcu_read_lock(); struct task_struct *owner = READ_ONCE(lock->owner); - bool ret = owner ? owner_on_cpu(owner) : !rt_task(current); + bool ret = owner ? owner_on_cpu(owner) : !realtime_task(current); rcu_read_unlock(); return ret; diff --git a/fs/select.c b/fs/select.c index 9515c3fa1a03..8d5c1419416c 100644 --- a/fs/select.c +++ b/fs/select.c @@ -82,7 +82,7 @@ u64 select_estimate_accuracy(struct timespec64 *tv) * Realtime tasks get a slack of 0 for obvious reasons. */ - if (rt_task(current)) + if (realtime_task(current)) return 0; ktime_get_ts64(&now); diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h index db1249cd9692..75859b78d540 100644 --- a/include/linux/ioprio.h +++ b/include/linux/ioprio.h @@ -40,7 +40,7 @@ static inline int task_nice_ioclass(struct task_struct *task) { if (task->policy == SCHED_IDLE) return IOPRIO_CLASS_IDLE; - else if (task_is_realtime(task)) + else if (realtime_task_policy(task)) return IOPRIO_CLASS_RT; else return IOPRIO_CLASS_BE; 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; } +/* + * 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/locking/rtmutex.c b/kernel/locking/rtmutex.c index 88d08eeb8bc0..55c9dab37f33 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -347,7 +347,7 @@ static __always_inline int __waiter_prio(struct task_struct *task) { int prio = task->prio; - if (!rt_prio(prio)) + if (!realtime_prio(prio)) return DEFAULT_PRIO; return prio; @@ -435,7 +435,7 @@ static inline bool rt_mutex_steal(struct rt_mutex_waiter *waiter, * Note that RT tasks are excluded from same priority (lateral) * steals to prevent the introduction of an unbounded latency. */ - if (rt_prio(waiter->tree.prio) || dl_prio(waiter->tree.prio)) + if (realtime_prio(waiter->tree.prio)) return false; return rt_waiter_node_equal(&waiter->tree, &top_waiter->tree); diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c index c6d17aee4209..ad8d4438bc91 100644 --- a/kernel/locking/rwsem.c +++ b/kernel/locking/rwsem.c @@ -631,7 +631,7 @@ static inline bool rwsem_try_write_lock(struct rw_semaphore *sem, * if it is an RT task or wait in the wait queue * for too long. */ - if (has_handoff || (!rt_task(waiter->task) && + if (has_handoff || (!realtime_task(waiter->task) && !time_after(jiffies, waiter->timeout))) return false; @@ -914,7 +914,7 @@ static bool rwsem_optimistic_spin(struct rw_semaphore *sem) if (owner_state != OWNER_WRITER) { if (need_resched()) break; - if (rt_task(current) && + if (realtime_task(current) && (prev_owner_state != OWNER_WRITER)) break; } diff --git a/kernel/locking/ww_mutex.h b/kernel/locking/ww_mutex.h index 3ad2cc4823e5..fa4b416a1f62 100644 --- a/kernel/locking/ww_mutex.h +++ b/kernel/locking/ww_mutex.h @@ -237,7 +237,7 @@ __ww_ctx_less(struct ww_acquire_ctx *a, struct ww_acquire_ctx *b) int a_prio = a->task->prio; int b_prio = b->task->prio; - if (rt_prio(a_prio) || rt_prio(b_prio)) { + if (realtime_prio(a_prio) || realtime_prio(b_prio)) { if (a_prio > b_prio) return true; diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5d861b59d737..22c7efed83b4 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -163,7 +163,7 @@ static inline int __task_prio(const struct task_struct *p) if (p->sched_class == &stop_sched_class) /* trumps deadline */ return -2; - if (rt_prio(p->prio)) /* includes deadline */ + if (realtime_prio(p->prio)) /* includes deadline */ return p->prio; /* [-1, 99] */ if (p->sched_class == &idle_sched_class) @@ -8522,7 +8522,7 @@ void normalize_rt_tasks(void) schedstat_set(p->stats.sleep_start, 0); schedstat_set(p->stats.block_start, 0); - if (!dl_task(p) && !rt_task(p)) { + if (!realtime_task(p)) { /* * Renice negative nice level userspace * tasks back to 0: diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c index ae1b42775ef9..6d60326d73e4 100644 --- a/kernel/sched/syscalls.c +++ b/kernel/sched/syscalls.c @@ -57,7 +57,7 @@ static int effective_prio(struct task_struct *p) * keep the priority unchanged. Otherwise, update priority * to the normal priority: */ - if (!rt_prio(p->prio)) + if (!realtime_prio(p->prio)) return p->normal_prio; return p->prio; } diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 492c14aac642..89d4da59059d 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1973,7 +1973,7 @@ static void __hrtimer_init_sleeper(struct hrtimer_sleeper *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 |= HRTIMER_MODE_HARD; } @@ -2073,7 +2073,7 @@ long hrtimer_nanosleep(ktime_t rqtp, const enum hrtimer_mode mode, u64 slack; slack = current->timer_slack_ns; - if (rt_task(current)) + if (realtime_task(current)) slack = 0; hrtimer_init_sleeper_on_stack(&t, clockid, mode); @@ -2278,7 +2278,7 @@ schedule_hrtimeout_range_clock(ktime_t *expires, u64 delta, * Override any slack passed by the user if under * rt contraints. */ - if (rt_task(current)) + if (realtime_task(current)) delta = 0; 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 >= wakeup_prio || p->prio >= current->prio))) return; diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 12c9297ed4a7..d9464af1d992 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -418,7 +418,7 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc) if (bg_thresh >= thresh) bg_thresh = thresh / 2; tsk = current; - if (rt_task(tsk)) { + if (realtime_task(tsk)) { bg_thresh += bg_thresh / 4 + global_wb_domain.dirty_limit / 32; thresh += thresh / 4 + global_wb_domain.dirty_limit / 32; } @@ -468,7 +468,7 @@ static unsigned long node_dirty_limit(struct pglist_data *pgdat) else dirty = vm_dirty_ratio * node_memory / 100; - if (rt_task(tsk)) + if (realtime_task(tsk)) dirty += dirty / 4; return dirty; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2e22ce5675ca..807dd6aa3edb 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3962,7 +3962,7 @@ gfp_to_alloc_flags(gfp_t gfp_mask, unsigned int order) */ if (alloc_flags & ALLOC_MIN_RESERVE) alloc_flags &= ~ALLOC_CPUSET; - } else if (unlikely(rt_task(current)) && in_task()) + } else if (unlikely(realtime_task(current)) && in_task()) alloc_flags |= ALLOC_MIN_RESERVE; alloc_flags = gfp_to_alloc_flags_cma(gfp_mask, alloc_flags); From patchwork Mon Jun 10 19:20:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 13692379 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 4D4D9C27C5E for ; Mon, 10 Jun 2024 19:20:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65E4C6B009B; Mon, 10 Jun 2024 15:20:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F0386B009D; Mon, 10 Jun 2024 15:20:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4616F6B009E; Mon, 10 Jun 2024 15:20:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1DEEF6B009B for ; Mon, 10 Jun 2024 15:20:28 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AB4DD80128 for ; Mon, 10 Jun 2024 19:20:27 +0000 (UTC) X-FDA: 82215945294.30.B4AE4D8 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by imf17.hostedemail.com (Postfix) with ESMTP id D3FD040018 for ; Mon, 10 Jun 2024 19:20:25 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=g6H2CByY; spf=pass (imf17.hostedemail.com: domain of qyousef@layalina.io designates 209.85.221.42 as permitted sender) smtp.mailfrom=qyousef@layalina.io; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718047225; a=rsa-sha256; cv=none; b=qGTFsUsTe2xproWNx4F/uTOS+H6oZ5iOQu0Kap0vLYvlgvpVabxt1QWlUrwqfKFsKdmml1 1yq5Q2PoQy7XZDOPEqjzQ9kCUbCbXN2JnjWgMDbqHhZ7G7yr0cr/FmHuILlVf4OJgMgyh3 aZzX5HUsZYkPlGnRIRf18ncmtb0BQWA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=g6H2CByY; spf=pass (imf17.hostedemail.com: domain of qyousef@layalina.io designates 209.85.221.42 as permitted sender) smtp.mailfrom=qyousef@layalina.io; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718047225; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Aqecuk/j+cWcR1uWGatEcThGq+5RIRJx4qSyiIgAFX8=; b=U+SYytpv7quf3zt2tKLS4sb5XFsjOVS3G6iYzwOD6IXOUhzhNDlE2Y4vfHW6Exyz//BnEb mrwkRojulMY77ME7btOuho6jJvIOscibrikMVJ923eI/jvk/CUpx+OOA6wuhrezlNed7q9 5p8ijLr/Iw4EgmrgeWOCNkRGhl0zz6I= Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-35f236a563cso264481f8f.2 for ; Mon, 10 Jun 2024 12:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1718047224; x=1718652024; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Aqecuk/j+cWcR1uWGatEcThGq+5RIRJx4qSyiIgAFX8=; b=g6H2CByYExst8/XKi+oJwviiJSspWKVp9Yv0+6qheaLm5Z5iUARc+vCQ8AVbPAU5YE RT426ahsIT1WmnmAp7boOEQJcC9KNSDlPvmOTm8gHePq9CEyBqhtu99Fhx1J5eY1wvBI bdHOR1Mfzx9Z/8B4cFmXHS+/xmfnXqTHZZbs/NjU3G3cGlaGKMz0lYcStaWeU0ZJzLLI 3dgOF49T63XJcxW2oMRFhSJDVDuqk8anPGx8tTfP3XMXa3xei+GS5wt+59cuIKQJmizb Y0jCGFBFJNLmQzR39fOCNeje2Y96V+6J3/gi0AHN2JUJfQl+ajMlF94FDtKw2eUlDIiP deNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718047224; x=1718652024; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Aqecuk/j+cWcR1uWGatEcThGq+5RIRJx4qSyiIgAFX8=; b=nYl/AqgHBszkJ42W2i3e+dwFxw2PimRPUWvHx5jDvTLN+9hohbaKJyEGB/JkZHTH6a 5SJQFtL6OMxhbNwKYZCeJURIIyAqkflM5E7d48ms6VIK0xshJRXxRfXLYyL2MDOgvR3f X4he0zJIzhpHqXnfmtnt77mFIS3ogvHrtyyDqQHC0FiVVl2mboCfNZoCzafFbMpspC+X 3vE49lGWWC9rRxhtf2liwP+wqQOGrRyDrJn6yZWa/EBM3cuPNlDw8JEwYvC6VNjHOknx fRPcrxb3cju4lHWvg2JyxDmBTYVztZttLIq+U7FFBPKdV/Lyz68nz5YNh04o1NhKb4tW Kfpg== X-Forwarded-Encrypted: i=1; AJvYcCX0MbyipmovXKoy+6TjO4evUhqUFlN467AWTHUNRpPtkbuaujq/BE/k/uTGczhe7mzOLlMM7R9i+2u3U38fUbrwWfg= X-Gm-Message-State: AOJu0Yx4V3DFpzPiorA1aVslbXkLTvvY7vCyND8mlY77zwCil7m4Dzcw Il7jKd8fIum0AdjUQQSvPbSyuAmji9kItv0vpRtlqmn/qxXY+5VJqGYMR8VU0yE= X-Google-Smtp-Source: AGHT+IEPW9YFcQ2VxHIOQv4sUvLowLBf5ILbQcop/NQ40oDtk2hX5iHMJ7fOb4sgyat3imPvhg5Q1g== X-Received: by 2002:a05:6000:154c:b0:355:2db:a0e with SMTP id ffacd0b85a97d-35efed1e599mr8511407f8f.13.1718047224576; Mon, 10 Jun 2024 12:20:24 -0700 (PDT) Received: from airbuntu.. (host81-157-90-255.range81-157.btcentralplus.com. [81.157.90.255]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f1f30c3ccsm4988326f8f.7.2024.06.10.12.20.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 12:20:24 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt Cc: Vincent Guittot , Daniel Bristot de Oliveira , Thomas Gleixner , Sebastian Andrzej Siewior , Alexander Viro , Christian Brauner , Andrew Morton , Jens Axboe , Metin Kaya , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, Qais Yousef Subject: [PATCH v6 2/3] sched/rt, dl: Convert functions to return bool Date: Mon, 10 Jun 2024 20:20:17 +0100 Message-Id: <20240610192018.1567075-3-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610192018.1567075-1-qyousef@layalina.io> References: <20240610192018.1567075-1-qyousef@layalina.io> MIME-Version: 1.0 X-Stat-Signature: aauziwdwjtcz4pmthd7jetxgwemy45dc X-Rspamd-Queue-Id: D3FD040018 X-Rspamd-Server: rspam04 X-Rspam-User: X-HE-Tag: 1718047225-135399 X-HE-Meta: U2FsdGVkX1/9P+i+3EaPazo5WEXCNyZ2PbnfW4NXVTzKV066rId7JytL4tk4m4xaTsNTL7HAwcMN38v0j1r0QRCzYcY+My+isEq4LLOnumQCLyMTOmIutYVSZZJngdDcPLSv7nEJFz/+zJtveYcSOTN9Im3XvZqBBlwQtyHG1Nr8aH905BZNZr7Mb6DuB3YviGJesI3Bi46Eamwff9BjP0YGkQL6CpJSvWyCtJduDRB1QklS2OTdV1N/zPIOBZvv5M5EHLeXo6iILwZE8TKDufqw3R2R2mvfwDHHeF31V3hDAb05YyzZ7tJEGTPThxyAUHLMcb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HMW29jKSPh0Ej X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: {rt, realtime, dl}_{task, prio}() functions' return value is actually a bool. Convert their return type to reflect that. Suggested-by: Steven Rostedt (Google) Reviewed-by: Sebastian Andrzej Siewior Reviewed-by: Steven Rostedt (Google) Reviewed-by: Metin Kaya Signed-off-by: Qais Yousef --- include/linux/sched/deadline.h | 8 +++----- include/linux/sched/rt.h | 16 ++++++---------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/include/linux/sched/deadline.h b/include/linux/sched/deadline.h index 5cb88b748ad6..3a912ab42bb5 100644 --- a/include/linux/sched/deadline.h +++ b/include/linux/sched/deadline.h @@ -10,18 +10,16 @@ #include -static inline int dl_prio(int prio) +static inline bool dl_prio(int prio) { - if (unlikely(prio < MAX_DL_PRIO)) - return 1; - return 0; + return unlikely(prio < MAX_DL_PRIO); } /* * 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) +static inline bool dl_task(struct task_struct *p) { return dl_prio(p->prio); } diff --git a/include/linux/sched/rt.h b/include/linux/sched/rt.h index a055dd68a77c..91ef1ef2019f 100644 --- a/include/linux/sched/rt.h +++ b/include/linux/sched/rt.h @@ -6,25 +6,21 @@ struct task_struct; -static inline int rt_prio(int prio) +static inline bool rt_prio(int prio) { - if (unlikely(prio < MAX_RT_PRIO && prio >= MAX_DL_PRIO)) - return 1; - return 0; + return unlikely(prio < MAX_RT_PRIO && prio >= MAX_DL_PRIO); } -static inline int realtime_prio(int prio) +static inline bool realtime_prio(int prio) { - if (unlikely(prio < MAX_RT_PRIO)) - return 1; - return 0; + return unlikely(prio < MAX_RT_PRIO); } /* * 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) +static inline bool rt_task(struct task_struct *p) { return rt_prio(p->prio); } @@ -34,7 +30,7 @@ static inline int rt_task(struct task_struct *p) * PI-boosted tasks will return true. Use realtime_task_policy() to ignore * PI-boosted tasks. */ -static inline int realtime_task(struct task_struct *p) +static inline bool realtime_task(struct task_struct *p) { return realtime_prio(p->prio); } From patchwork Mon Jun 10 19:20:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 13692380 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 B4AF6C27C65 for ; Mon, 10 Jun 2024 19:20:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 945116B009E; Mon, 10 Jun 2024 15:20:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CD556B009F; Mon, 10 Jun 2024 15:20:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A9496B00A0; Mon, 10 Jun 2024 15:20:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4365F6B009E for ; Mon, 10 Jun 2024 15:20:29 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D15E21A02B6 for ; Mon, 10 Jun 2024 19:20:28 +0000 (UTC) X-FDA: 82215945336.26.C60A7AA Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by imf01.hostedemail.com (Postfix) with ESMTP id E34F840003 for ; Mon, 10 Jun 2024 19:20:26 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=layalina-io.20230601.gappssmtp.com header.s=20230601 header.b="mZa/+u2L"; spf=pass (imf01.hostedemail.com: domain of qyousef@layalina.io designates 209.85.221.50 as permitted sender) smtp.mailfrom=qyousef@layalina.io; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718047227; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7+BUyWTb5ejwb40scgMVV37IExcyB94GWmaml8ACZ5M=; b=ZZtlm7NgT/9RdRIW6OnKQmZvaBtRXYZjrBRchIvjBsabMDeZTqqEGHaHJl0GZvfnMbjUAy 2RnYJrhnDUa2dTgXkRdhUkoPpMPhlIaEJXTv+POxpaRa7dnTNF+e9IQ8aa7IG5qmx8c8R3 ORWDq7RrXKDH1sP/I0nr2nsNI6g8xOM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718047227; a=rsa-sha256; cv=none; b=rhVJDllBdRgMBfgYfSOJsZOZXNKQ1RXTPDHrfuUt0LH+ztLAvWo0bHo6NS523B1BZvqtMb waiorAf9DGu1b5DIx2w1Ib1U9M1aQXHhdNiaOV5VSLmFd4FYKb7xKIeVhJjI7RTTWQdEu8 hlAR2KpfbzwlFGJ0SdvS17k/dDT+ujE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=layalina-io.20230601.gappssmtp.com header.s=20230601 header.b="mZa/+u2L"; spf=pass (imf01.hostedemail.com: domain of qyousef@layalina.io designates 209.85.221.50 as permitted sender) smtp.mailfrom=qyousef@layalina.io; dmarc=none Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-35f2bca1f33so73110f8f.0 for ; Mon, 10 Jun 2024 12:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1718047225; x=1718652025; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7+BUyWTb5ejwb40scgMVV37IExcyB94GWmaml8ACZ5M=; b=mZa/+u2Lqs7lL5PCKJzBTFYRGnHMLhHgMebCFTEzpymCVw2YFcEoAVdTHzISmfHGM2 nLYwqbvEUA7m/FX8q6P1knkhdGvyqwGjYXuDoCI/Xg0vW1tg3mXc9V6Ea7VraKZZQbXV Qkrbgfy7wc7L3cDbfNkQ6Ch5cDc98xzCSoFs9VrHds02JDe/GqFkaPv++p9i7NmtKkan kXsIOQHaVmSkaYcXTX1nqkCEyHMz+GNDxkFi23o7VMaH5VTITsTrI/+V/YMh+JUXnEj2 w9DJ+kBMTDYGOHjMuZNoi7E0I5X7GHVfHlkmMJRwDAfeCvv8/8/3wLlGw6+CEhQZg/Q5 rXkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718047225; x=1718652025; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7+BUyWTb5ejwb40scgMVV37IExcyB94GWmaml8ACZ5M=; b=mkv+DNfw6QklC2OxOA8xAZsn0zW0haKQO3hh8RmFwGdjfqHpCKjf9ZXeKEqSgDcq+n 8a7Y/rlrdGzl+dVRu0h1V4iwtyLw5+7ei6sq/l7LXEFvFNlezWws+KuaZVzOc690UGgt w/j7y7WZxtJ8Ri13xHFLF6ac+E9VF0ocNzODqvm3jcH3HgFAAW6k9DhmdeSO3U5/2m2q 4yCt2eShhc0peu+x1YrxNlEv2hDtchtwuEi7Gf88X2+N7qM/bOIMvXTSGJysJzZLhyph S9vBI8jqoY6u9Sf71nJ5qi543d5FK0YXAykNEuqZwW+++Ddomy/ypxUZnS2+w3KC7fbP tLqw== X-Forwarded-Encrypted: i=1; AJvYcCVaYun/7R/cQh2cygy9qwqxUvxK5FJaSSVY7N+T7wVKqfjboi7BZ/vW2qMz46Tq2w/tKLkYotjuEsKzFA8KOYtGQpE= X-Gm-Message-State: AOJu0YwZe6tcCR4D43W5Aw4p/f2ms1tWFAwmY3DVOP5XnK+1U12lIIoo +jdviSa7xghFEoyTUXPXNc2K7Yd2erXmFe184iKQQ90/5KMQnpaOc80/qg9vICM= X-Google-Smtp-Source: AGHT+IFEmccaDRTErf+/IywJcGZdVGcKvF9RKr33D7xwLfXpEeid9aCnSjIIdSDXO7wD+fLR4ulleA== X-Received: by 2002:adf:f38b:0:b0:354:e4da:ba52 with SMTP id ffacd0b85a97d-35f2b27ede7mr548597f8f.10.1718047225355; Mon, 10 Jun 2024 12:20:25 -0700 (PDT) Received: from airbuntu.. (host81-157-90-255.range81-157.btcentralplus.com. [81.157.90.255]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f1f30c3ccsm4988326f8f.7.2024.06.10.12.20.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 12:20:25 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Steven Rostedt Cc: Vincent Guittot , Daniel Bristot de Oliveira , Thomas Gleixner , Sebastian Andrzej Siewior , Alexander Viro , Christian Brauner , Andrew Morton , Jens Axboe , Metin Kaya , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, Qais Yousef Subject: [PATCH v6 3/3] sched/rt: Rename realtime_{prio, task}() to rt_or_dl_{prio, task}() Date: Mon, 10 Jun 2024 20:20:18 +0100 Message-Id: <20240610192018.1567075-4-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610192018.1567075-1-qyousef@layalina.io> References: <20240610192018.1567075-1-qyousef@layalina.io> MIME-Version: 1.0 X-Rspamd-Queue-Id: E34F840003 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TZ974tMr EyCQo65+wn/npv0VRgpnfzqJrThaDEnyc1JMkb6Bn77yz+OnDJA/kgdHQTFGjcwoeprZlQSd/l2TVi3tTFLl+HQ45992DeuPcEDwUyLY7e1FTTmxtq6ifH5apRS4Xqc5MLBm0PKhDpbyIpqRhF1aI21XPcde/LER///P03WR3ollTmYEL385LEPCHJ8gKyIAQl8hWvGwR9tHhPQoT1drHKpmM22kQiReV7rBU/koRWwcr42WeTeNdS1zrgb+CNxhgcSmyoRYyOM9OJvkQjrRDrDuLKY4LvX6qzyxTumWPrAkCWmrFmLbE0FvYFKplHWACYhwm2aGkrHxP/4WzYrXruE0ac8VFNW1eWtXtzcLgzLuX4l4= 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: Some find the name realtime overloaded. Use rt_or_dl() as an alternative, hopefully better, name. Suggested-by: Daniel Bristot de Oliveira Signed-off-by: Qais Yousef --- fs/bcachefs/six.c | 2 +- fs/select.c | 2 +- include/linux/ioprio.h | 2 +- include/linux/sched/rt.h | 10 +++++----- kernel/locking/rtmutex.c | 4 ++-- kernel/locking/rwsem.c | 4 ++-- kernel/locking/ww_mutex.h | 2 +- kernel/sched/core.c | 4 ++-- kernel/sched/syscalls.c | 2 +- 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, 23 insertions(+), 23 deletions(-) diff --git a/fs/bcachefs/six.c b/fs/bcachefs/six.c index b30870bf7e4a..9cbd3c14c94f 100644 --- a/fs/bcachefs/six.c +++ b/fs/bcachefs/six.c @@ -335,7 +335,7 @@ static inline bool six_owner_running(struct six_lock *lock) */ rcu_read_lock(); struct task_struct *owner = READ_ONCE(lock->owner); - bool ret = owner ? owner_on_cpu(owner) : !realtime_task(current); + bool ret = owner ? owner_on_cpu(owner) : !rt_or_dl_task(current); rcu_read_unlock(); return ret; diff --git a/fs/select.c b/fs/select.c index 8d5c1419416c..73fce145eb72 100644 --- a/fs/select.c +++ b/fs/select.c @@ -82,7 +82,7 @@ u64 select_estimate_accuracy(struct timespec64 *tv) * Realtime tasks get a slack of 0 for obvious reasons. */ - if (realtime_task(current)) + if (rt_or_dl_task(current)) return 0; ktime_get_ts64(&now); diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h index 75859b78d540..b25377b6ea98 100644 --- a/include/linux/ioprio.h +++ b/include/linux/ioprio.h @@ -40,7 +40,7 @@ static inline int task_nice_ioclass(struct task_struct *task) { if (task->policy == SCHED_IDLE) return IOPRIO_CLASS_IDLE; - else if (realtime_task_policy(task)) + else if (rt_or_dl_task_policy(task)) return IOPRIO_CLASS_RT; else return IOPRIO_CLASS_BE; diff --git a/include/linux/sched/rt.h b/include/linux/sched/rt.h index 91ef1ef2019f..4e3338103654 100644 --- a/include/linux/sched/rt.h +++ b/include/linux/sched/rt.h @@ -11,7 +11,7 @@ static inline bool rt_prio(int prio) return unlikely(prio < MAX_RT_PRIO && prio >= MAX_DL_PRIO); } -static inline bool realtime_prio(int prio) +static inline bool rt_or_dl_prio(int prio) { return unlikely(prio < MAX_RT_PRIO); } @@ -27,19 +27,19 @@ static inline bool rt_task(struct task_struct *p) /* * 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 will return true. Use rt_or_dl_task_policy() to ignore * PI-boosted tasks. */ -static inline bool realtime_task(struct task_struct *p) +static inline bool rt_or_dl_task(struct task_struct *p) { - return realtime_prio(p->prio); + return rt_or_dl_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) +static inline bool rt_or_dl_task_policy(struct task_struct *tsk) { int policy = tsk->policy; diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 55c9dab37f33..c2a530d704b4 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -347,7 +347,7 @@ static __always_inline int __waiter_prio(struct task_struct *task) { int prio = task->prio; - if (!realtime_prio(prio)) + if (!rt_or_dl_prio(prio)) return DEFAULT_PRIO; return prio; @@ -435,7 +435,7 @@ static inline bool rt_mutex_steal(struct rt_mutex_waiter *waiter, * Note that RT tasks are excluded from same priority (lateral) * steals to prevent the introduction of an unbounded latency. */ - if (realtime_prio(waiter->tree.prio)) + if (rt_or_dl_prio(waiter->tree.prio)) return false; return rt_waiter_node_equal(&waiter->tree, &top_waiter->tree); diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c index ad8d4438bc91..dcbd7b45359a 100644 --- a/kernel/locking/rwsem.c +++ b/kernel/locking/rwsem.c @@ -631,7 +631,7 @@ static inline bool rwsem_try_write_lock(struct rw_semaphore *sem, * if it is an RT task or wait in the wait queue * for too long. */ - if (has_handoff || (!realtime_task(waiter->task) && + if (has_handoff || (!rt_or_dl_task(waiter->task) && !time_after(jiffies, waiter->timeout))) return false; @@ -914,7 +914,7 @@ static bool rwsem_optimistic_spin(struct rw_semaphore *sem) if (owner_state != OWNER_WRITER) { if (need_resched()) break; - if (realtime_task(current) && + if (rt_or_dl_task(current) && (prev_owner_state != OWNER_WRITER)) break; } diff --git a/kernel/locking/ww_mutex.h b/kernel/locking/ww_mutex.h index fa4b416a1f62..76d204b7d29c 100644 --- a/kernel/locking/ww_mutex.h +++ b/kernel/locking/ww_mutex.h @@ -237,7 +237,7 @@ __ww_ctx_less(struct ww_acquire_ctx *a, struct ww_acquire_ctx *b) int a_prio = a->task->prio; int b_prio = b->task->prio; - if (realtime_prio(a_prio) || realtime_prio(b_prio)) { + if (rt_or_dl_prio(a_prio) || rt_or_dl_prio(b_prio)) { if (a_prio > b_prio) return true; diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 22c7efed83b4..001da474518e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -163,7 +163,7 @@ static inline int __task_prio(const struct task_struct *p) if (p->sched_class == &stop_sched_class) /* trumps deadline */ return -2; - if (realtime_prio(p->prio)) /* includes deadline */ + if (rt_or_dl_prio(p->prio)) return p->prio; /* [-1, 99] */ if (p->sched_class == &idle_sched_class) @@ -8522,7 +8522,7 @@ void normalize_rt_tasks(void) schedstat_set(p->stats.sleep_start, 0); schedstat_set(p->stats.block_start, 0); - if (!realtime_task(p)) { + if (!rt_or_dl_task(p)) { /* * Renice negative nice level userspace * tasks back to 0: diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c index 6d60326d73e4..60e70c889d91 100644 --- a/kernel/sched/syscalls.c +++ b/kernel/sched/syscalls.c @@ -57,7 +57,7 @@ static int effective_prio(struct task_struct *p) * keep the priority unchanged. Otherwise, update priority * to the normal priority: */ - if (!realtime_prio(p->prio)) + if (!rt_or_dl_prio(p->prio)) return p->normal_prio; return p->prio; } diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 89d4da59059d..a4319131d4d0 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1973,7 +1973,7 @@ static void __hrtimer_init_sleeper(struct hrtimer_sleeper *sl, * expiry. */ if (IS_ENABLED(CONFIG_PREEMPT_RT)) { - if (realtime_task_policy(current) && !(mode & HRTIMER_MODE_SOFT)) + if (rt_or_dl_task_policy(current) && !(mode & HRTIMER_MODE_SOFT)) mode |= HRTIMER_MODE_HARD; } @@ -2073,7 +2073,7 @@ long hrtimer_nanosleep(ktime_t rqtp, const enum hrtimer_mode mode, u64 slack; slack = current->timer_slack_ns; - if (realtime_task(current)) + if (rt_or_dl_task(current)) slack = 0; hrtimer_init_sleeper_on_stack(&t, clockid, mode); @@ -2278,7 +2278,7 @@ schedule_hrtimeout_range_clock(ktime_t *expires, u64 delta, * Override any slack passed by the user if under * rt contraints. */ - if (realtime_task(current)) + if (rt_or_dl_task(current)) delta = 0; 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 19d737742e29..3477fd858491 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 && !realtime_task(p)) || + (wakeup_rt && !rt_or_dl_task(p)) || (!dl_task(p) && (p->prio >= wakeup_prio || p->prio >= current->prio))) return; diff --git a/mm/page-writeback.c b/mm/page-writeback.c index d9464af1d992..43c189456cef 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -418,7 +418,7 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc) if (bg_thresh >= thresh) bg_thresh = thresh / 2; tsk = current; - if (realtime_task(tsk)) { + if (rt_or_dl_task(tsk)) { bg_thresh += bg_thresh / 4 + global_wb_domain.dirty_limit / 32; thresh += thresh / 4 + global_wb_domain.dirty_limit / 32; } @@ -468,7 +468,7 @@ static unsigned long node_dirty_limit(struct pglist_data *pgdat) else dirty = vm_dirty_ratio * node_memory / 100; - if (realtime_task(tsk)) + if (rt_or_dl_task(tsk)) dirty += dirty / 4; return dirty; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 807dd6aa3edb..623df61834be 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3962,7 +3962,7 @@ gfp_to_alloc_flags(gfp_t gfp_mask, unsigned int order) */ if (alloc_flags & ALLOC_MIN_RESERVE) alloc_flags &= ~ALLOC_CPUSET; - } else if (unlikely(realtime_task(current)) && in_task()) + } else if (unlikely(rt_or_dl_task(current)) && in_task()) alloc_flags |= ALLOC_MIN_RESERVE; alloc_flags = gfp_to_alloc_flags_cma(gfp_mask, alloc_flags);