diff mbox series

[2/6] sched: avoid using ilog2() in sched.h

Message ID 20240528005648.182376-3-yury.norov@gmail.com (mailing list archive)
State New
Headers show
Series Cleanup cpumask.h inclusion in core headers | expand

Commit Message

Yury Norov May 28, 2024, 12:56 a.m. UTC
<linux/sched.h> indirectly via cpumask.h path includes the ilog2.h header
to calculate ilog2(TASK_REPORT_MAX). The following patches drops sched.h
dependency on cpumask.h, and to have a successful build, the header has
to be included explicitly.

sched.h is a frequently included header, and it's better to keep the
dependency list as small as possible. So, instead of including ilog2.h
for a single BUILD_BUG_ON() check, the same check may be implemented by
taking exponent of the other part of equation.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 include/linux/sched.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 61591ac6eab6..98abb07de149 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1604,7 +1604,7 @@  static inline char task_index_to_char(unsigned int state)
 {
 	static const char state_char[] = "RSDTtXZPI";
 
-	BUILD_BUG_ON(1 + ilog2(TASK_REPORT_MAX) != sizeof(state_char) - 1);
+	BUILD_BUG_ON(TASK_REPORT_MAX * 2 != 1 << (sizeof(state_char) - 1));
 
 	return state_char[state];
 }