From patchwork Sat Jun 1 21:33:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 13682558 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 73956C27C44 for ; Sat, 1 Jun 2024 21:33:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07FCA6B00A0; Sat, 1 Jun 2024 17:33:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EAC7C6B00A1; Sat, 1 Jun 2024 17:33:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDA486B00A4; Sat, 1 Jun 2024 17:33:34 -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 92DCD6B00A1 for ; Sat, 1 Jun 2024 17:33:34 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 30ED41C0A9D for ; Sat, 1 Jun 2024 21:33:34 +0000 (UTC) X-FDA: 82183621548.20.F79093A Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by imf24.hostedemail.com (Postfix) with ESMTP id 4431C18000F for ; Sat, 1 Jun 2024 21:33:32 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=gqHkJXIi; spf=pass (imf24.hostedemail.com: domain of qyousef@layalina.io designates 209.85.128.52 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=1717277612; 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=GXEctD+/EB3461EYts4njlT0zGyad7Kh+tMqKCzOAgc=; b=iJqXyxrdvijsPp6UoBHbNuPke6xu3xwE7vkbR6CG4Zl+leufCI1t1J+mlVMA/BOmPF8/2j GAePAbs6PmScdjRU6yT011IqIpUjdUf4YLIpqY1PrPLfEIzw5Xg95AePgUrA/FsAE28/Fq TX/wXUjXwqMOsOdtcMkUAVrPVuATzS4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=gqHkJXIi; spf=pass (imf24.hostedemail.com: domain of qyousef@layalina.io designates 209.85.128.52 as permitted sender) smtp.mailfrom=qyousef@layalina.io; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717277612; a=rsa-sha256; cv=none; b=t12YaDbqeXSzfRlYwICIpALxsRiTw23TSeUNd7BD96llDQOIg41GzAvSzMa0yU1LelV0vw oNCGZEoT0+VnHenHlHYb5lOHOtvKTEz+xeJNbq5OC2RFkq1zfDaBIjfTzV0h77YRu3AZuo PfT0tKkdA9iPhHonKBMy1PDcYibHANM= Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-42139c66027so385185e9.3 for ; Sat, 01 Jun 2024 14:33:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1717277611; x=1717882411; 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=GXEctD+/EB3461EYts4njlT0zGyad7Kh+tMqKCzOAgc=; b=gqHkJXIiSn+tObZ5FHmQKwfA3Gx00b3tcfpTby9lfgGpoxtox0fYQqxPaXPo4lW+qm 3ZQ939YD2ky9I6ehD5+8XvaQ7PjCWmlQUxQJr0CsrPsyFPhi1fRsR2pNk8k9MquhETNl WhNGy5euD+zjnUBQpyGwH64Vz8ckUUDmrAHojeYS1BZdAPxz+GzdxtBaxMseXUgMp/gL D1lZM65VfhxJSmTPjFzG4j8McuZRSu9chE+BLtQcr66qCs2JEEM2/I3TMStndQM+5yxc n/7k6bR9c4qmWiOtcKIwCCSH09UYhc0qOSQZx8ka+JTQGLWb4KH9fWznGjL5Xu4tv3R9 HDvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717277611; x=1717882411; 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=GXEctD+/EB3461EYts4njlT0zGyad7Kh+tMqKCzOAgc=; b=Sdt0T1KIPcSI1fjmL4IPqpe/hRJzBRBQUGIq11C9wwIhApLjwwnTo9sk8jDTRC+ZVZ MraMZQaWflETstpUy1gavEAIjfjG84cFEGVYxyL137F7ACHk17rXc8KVdmaRLhMtTxPh VP6Tbo2rrvKI2ZOVl59f/zMpXhU2BW0nD8WiFPaispyKguxSj+1yd2Wtym2Npp0qEArr zJN1aF9jLsFmENF0z+Tmof0W2U7YNQ1+r4Ig15xU06aZw1admyHpiB0l5bUFvCT3+2az Gg0ZHe817alcz4WqHwG7puZ8ENLb5fPvzXdTiU3gJBsJegmD7TjynIj35yhvePTQn1s5 s3rQ== X-Forwarded-Encrypted: i=1; AJvYcCW8zM1M3Seh4qZMnVh+XLOOxXahjQL6jnRvV5AyxE6lEPQGBlRFxitlBb7J62qOlsNt7zIKBb5CJifHYbMoSqG1A5Y= X-Gm-Message-State: AOJu0YwIP0g7qUi4FrctNbITXl2qL3dQJQF+iEbtISLJuO6d18UEk5nj dWZhmLPrgsoOs2fOdRCVOT4N6mp7Co5neLjT2x009Wuxa0dfnhKF7czaJ9d88cg= X-Google-Smtp-Source: AGHT+IFf3j/N5xUTr7a6XrrbbattC9gyfqiFjLNQnpzGM0ZL9+BCAHYBb4yf6WNo3o6k2OktMieuUQ== X-Received: by 2002:a5d:4905:0:b0:343:efb7:8748 with SMTP id ffacd0b85a97d-35e0f32f33fmr3959639f8f.66.1717277610698; Sat, 01 Jun 2024 14:33:30 -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-35dd04c0839sm4751324f8f.23.2024.06.01.14.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 14:33:30 -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 , 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 v4 1/2] sched/rt: Clean up usage of rt_task() Date: Sat, 1 Jun 2024 22:33:08 +0100 Message-Id: <20240601213309.1262206-2-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240601213309.1262206-1-qyousef@layalina.io> References: <20240601213309.1262206-1-qyousef@layalina.io> MIME-Version: 1.0 X-Stat-Signature: wwjy65j88exsq1robxf11w87do7d4sd5 X-Rspamd-Queue-Id: 4431C18000F X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1717277612-842638 X-HE-Meta: U2FsdGVkX1+h3DBpBwDwvOW9zIH/mAVosZmrdHMlaYWotR6oCD2CNK3n1KCB1NzlLRF94CjcFUe01R2lFZfIcbSy7A5tkaFk0j83VHAPOIsaHQpCFErqyUfMLRgTZLlTcoB6/FyOAK49XrdLi3nIEtDCiU/Gjc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Qt8xgb2xwAZnSZQ4F4CVnOTNUCPlzkI5U3qKGZ6oK4N2mWq8OwAExMw0krLUTIqFE5qpd3udylskNLoibKVGg5Bcend+9D+DLNceg6Mao05f2raDKdtvH+3mzTWyTKc3zqfvzAdZ9wa+Z7VLvrNmBB3VXSAkRX+L1nBAfIePWtfiKjUtN70jvAuEPfxx2Q/MBr7oo42ZjKe4FMJzST/fdKaucpvtM/5p94n8alaewFYWoY76Ql9Px+qXDmYjO8P1/lz5RxBl/moa5fQpP6MtJHqxY2ekOYeyi4/GBT3sBpbWC4fGH0mjxicpbSR7f4oVW9e6DZsyKi+sosu0zD2HIP9zmCL3SQqvw23j/9Vkt8v6U1+loFlNO7VzNPpY9CKrlqGKBZVixWmiY 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) 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 Sat Jun 1 21:33:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 13682559 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 DD8D3C25B76 for ; Sat, 1 Jun 2024 21:33:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18FFA6B00A1; Sat, 1 Jun 2024 17:33:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1186D6B00A3; Sat, 1 Jun 2024 17:33:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE93B6B00A4; Sat, 1 Jun 2024 17:33:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B1F566B00A1 for ; Sat, 1 Jun 2024 17:33:35 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6BDFBA1481 for ; Sat, 1 Jun 2024 21:33:35 +0000 (UTC) X-FDA: 82183621590.20.43B05B7 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by imf28.hostedemail.com (Postfix) with ESMTP id 8C103C000E for ; Sat, 1 Jun 2024 21:33:33 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=I2ZROOxn; spf=pass (imf28.hostedemail.com: domain of qyousef@layalina.io designates 209.85.208.173 as permitted sender) smtp.mailfrom=qyousef@layalina.io; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717277613; a=rsa-sha256; cv=none; b=ZPUqIeik6JkIlPgfCx0do+MXz646lIHad/6tJYvufJh5vJ7/mTnLrZqwufkWq2YjGf9Ba1 v8JX/XTlEEGnz2FRSyjcXe8SWe9uCWv1BlKsc9efho/vU3QnvKJNieRJ4bbseDS+/dG5pW a0pzI7nVhqMa5HMysodS8Z2Dj7mSl6g= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=I2ZROOxn; spf=pass (imf28.hostedemail.com: domain of qyousef@layalina.io designates 209.85.208.173 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=1717277613; 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=3sT0UxPJVsFvbizWQFXaFxd+myFLbvt1Djq9NxHiO/k=; b=hQo2CeRvFWhkygYC7A8ZgPBgginnbS38fHu0YmkqBCAAjo/n93s17PkabrVf3VwkuPy+8H Xeftrr57eX0Fxjyzq6GtFMWyRugT1AuEktSqXJzpOWlH8oQDPD3X5w+P6FHxO4C8k4exiy Qk4nAkDxI56aNBLcNlB3pq7GFtkMWLU= Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2e96f298fbdso33245851fa.1 for ; Sat, 01 Jun 2024 14:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1717277612; x=1717882412; 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=3sT0UxPJVsFvbizWQFXaFxd+myFLbvt1Djq9NxHiO/k=; b=I2ZROOxnEPF8sSZudLEAEadtetGoX9SFIPZEHs/yMLInoBc/NwIL6Jn+f3PW48uqBA ww09rJY1k96eo/6iZwcsgmeNyG4+ysaSFLpY+Y/RvkzxERU6yGIWtPYmaw9jhwfNOUNB r30KFamRQz4xXjCq4mutsEU9pQ42PuKz2dJfFZKKBzT7qhJGhNYuX2GV7fmscXvjD2qi atL03CxaMmSo/TDW/5N7oAkMvZXjqbf5CM6/rk8P6/Bq2SoEkqciqjYL/KqQEzwZKuQT kXnZ42Wm8N8OHbaj9FSRhmkmyuby9fNUVhSpUR686+BEW/sVNT3zNxSAnPGK3q5b+2kS DaLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717277612; x=1717882412; 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=3sT0UxPJVsFvbizWQFXaFxd+myFLbvt1Djq9NxHiO/k=; b=eEPEmVungEj+632TEHuhrqmXeu+tyDlJQOo2shjK9PeaSL2AiYEgZR79atPXpXSkr9 AFsyZ+ezG5B3mcsCBeMT8XnKgYb0v4Vs5vi6Qe2a+aOxQQ46jDhrlDO9+B08CA5TfZOu JrzQTBiUS/iRDvd5mQeNoUk+tCPIsKqjj7mUKkgPunogM9g8f1PBL07BA4pTC/Xhy8HI ln3J9Vj+mEpHUApInZqSKeyx56yBwDmiA0VyLJSseSgJPwidPiwdOA9KikgXbS80n3X/ QI8QzDW6hek9bHMms62QOPRxl4YEdwe8Tj1C88DkmlHCkXOC+gjVYpagfUaJJ+fesTtj pKWg== X-Forwarded-Encrypted: i=1; AJvYcCWWVMvzWoUrsj0MJVNMvJY4x1k6oQ/LTelx+GVvPJ254k7tpVFG3D94u97Ujqgcv8rilAWrk5KC62tJbtrTnQLmtiU= X-Gm-Message-State: AOJu0Yy3XkU/GosZ9LJ5hotSmoURktN3LXqkZkhgPnVKcEOiPyViO8qT Jd5hhHrWJnpg0PuVGPYfrPYj/KwCah/h4xEsB6tVnZfbAIN+9ujQPMf/rSkcPqQ= X-Google-Smtp-Source: AGHT+IHTtXDQYUCHcup+VdBP7H+9TJT0tVCvzBLqaigZ6UCn3zIJ6feyXGCuTgk0t3iYmSADXLLaag== X-Received: by 2002:a2e:8e62:0:b0:2ea:7954:3777 with SMTP id 38308e7fff4ca-2ea950f8c22mr29792601fa.18.1717277611480; Sat, 01 Jun 2024 14:33:31 -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-35dd04c0839sm4751324f8f.23.2024.06.01.14.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 14:33:31 -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 , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, Qais Yousef Subject: [PATCH v4 2/2] sched/rt, dl: Convert functions to return bool Date: Sat, 1 Jun 2024 22:33:09 +0100 Message-Id: <20240601213309.1262206-3-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240601213309.1262206-1-qyousef@layalina.io> References: <20240601213309.1262206-1-qyousef@layalina.io> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8C103C000E X-Stat-Signature: qzobi4bznydhc7hm6hfc7yfg14gjt95q X-HE-Tag: 1717277613-779997 X-HE-Meta: U2FsdGVkX1/bRctxrNT1gZBEVFtkr9pmQ4bHqJKs7SP9EJBvKfKuZx05X9Jz15jfrV67DKqEs0sA81lDvrUta44zUN2ODCvNjkNY0EwgmB3CTKBL5lDWlgyt1mdoJgAe0Yuf8ghr+BUAuOgbx7hPZqzQgBL9G70405gcHMvczoUPuxWRC3lejvheUJuG/9f5OO/IJMKtFlhKSjPc/+Nwb+84sm/pmg9tPgvz03pHPya1YDB3tqYZwdWJg3UIBsX8EBA3HWNPx4D1QVKXzWAwPWtYjIMA4Afvd9Q/nnv/KQHtFoCfOX4f1R7e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YFPA28H/qEE9r0lorp9V2jEPZqli93S1l3V+jmxSFOA60W 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, realtime, dl}_{task, prio}() functions return value is actually a bool. Convert their return type to reflect that. Suggested-by: Steven Rostedt (Google) Signed-off-by: Qais Yousef --- include/linux/sched/deadline.h | 8 ++++---- include/linux/sched/rt.h | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/linux/sched/deadline.h b/include/linux/sched/deadline.h index 5cb88b748ad6..f2053f46f1d5 100644 --- a/include/linux/sched/deadline.h +++ b/include/linux/sched/deadline.h @@ -10,18 +10,18 @@ #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 true; + return false; } /* * 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..efbdd2e57765 100644 --- a/include/linux/sched/rt.h +++ b/include/linux/sched/rt.h @@ -6,25 +6,25 @@ 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 true; + return false; } -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 true; + return false; } /* * 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 +34,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); }