]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
cgroup/rdma: refactor resource parsing with match_table_t/match_token()
authorTao Cui <cuitao@kylinos.cn>
Wed, 22 Apr 2026 02:17:09 +0000 (10:17 +0800)
committerTejun Heo <tj@kernel.org>
Thu, 23 Apr 2026 17:00:36 +0000 (07:00 -1000)
commit5bbb3453e8f35e1eacde30459e1fa7625c8d6d21
tree0cdf3c912d7a0526f150bc5e04f03c073561c7db
parent41d701ddc36d5301b44ea79529f3cf03c541c1e1
cgroup/rdma: refactor resource parsing with match_table_t/match_token()

Replace the hand-rolled strsep/strcmp/match_string parsing in
rdmacg_resource_set_max() with a match_table_t and match_token()
pattern, following the convention used by user_proactive_reclaim()
and ioc_cost_model_write().

The old strncmp(value, RDMACG_MAX_STR, strlen(value)) also had two
bugs that are fixed by this refactor:

  - It matched "ma" as "max" because strncmp only compared the
    shorter strlen(value) bytes.

  - It silently accepted "hca_handle=" (empty value) as "max"
    because strncmp with n=0 always returns 0.

The match_token() approach also robustly handles extra whitespace in
the input by splitting on " \t\n" and skipping empty tokens.

Suggested-by: "Michal Koutný" <mkoutny@suse.com>
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/rdma.c