]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched_ext: Use sizeof_field for key_len in dsq_hash_params
authorLiang Jie <liangjie@lixiang.com>
Fri, 13 Dec 2024 09:52:54 +0000 (17:52 +0800)
committerTejun Heo <tj@kernel.org>
Fri, 13 Dec 2024 16:51:19 +0000 (06:51 -1000)
Update the `dsq_hash_params` initialization to use `sizeof_field`
for the `key_len` field instead of a hardcoded value.

This improves code readability and ensures the key length dynamically
matches the size of the `id` field in the `scx_dispatch_q` structure.

Signed-off-by: Liang Jie <liangjie@lixiang.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c

index 71342f3719c128853a58aa363e33cbef16ad7762..54e659ba9476255d9d9c8f4b9c9c969a9d41b468 100644 (file)
@@ -960,7 +960,7 @@ static DEFINE_PER_CPU(struct task_struct *, direct_dispatch_task);
 static struct scx_dispatch_q **global_dsqs;
 
 static const struct rhashtable_params dsq_hash_params = {
-       .key_len                = 8,
+       .key_len                = sizeof_field(struct scx_dispatch_q, id),
        .key_offset             = offsetof(struct scx_dispatch_q, id),
        .head_offset            = offsetof(struct scx_dispatch_q, hash_node),
 };