Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Use vmalloc_array() to improve code

Remove array_size() calls and replace vmalloc() with vmalloc_array() in
tracing_map_sort_entries(). vmalloc_array() is optimized better, uses
fewer instructions, and handles overflow more concisely[1].

[1]: https://lore.kernel.org/lkml/abc66ec5-85a4-47e1-9759-2f60ab111971@vivo.com/

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/20250817084725.59477-1-rongqianfeng@vivo.com
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Qianfeng Rong and committed by
Steven Rostedt (Google)
09da5934 3add2d34

+1 -1
+1 -1
kernel/trace/tracing_map.c
··· 1076 1076 struct tracing_map_sort_entry *sort_entry, **entries; 1077 1077 int i, n_entries, ret; 1078 1078 1079 - entries = vmalloc(array_size(sizeof(sort_entry), map->max_elts)); 1079 + entries = vmalloc_array(map->max_elts, sizeof(sort_entry)); 1080 1080 if (!entries) 1081 1081 return -ENOMEM; 1082 1082