From nobody Wed Oct 1 22:30:48 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F39F53093CA for ; Tue, 30 Sep 2025 17:01:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; cv=none; b=mj454+OSPawQGF4H69MIeAoJC4j9pvzfdvVGKNiR/xQAFQLVZvDiNABOFiLCKVCaK+4aOMB4p+DuctB/U/FUz4FxQ1KQLUoYjcbbdzilOwK8ufo5Xi04j50QmrXTwRMIpN7OsoJYdy0LnJu9DP4BV+u0wCG/iBrh/9Vm+s766VU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759251686; c=relaxed/simple; bh=9Has2rbY4I/41mqljMsduhjgNFk0/JrXOnwh9b4Jzv4=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=LglZiov/Aa+LxHuPJdQhyT5+qrYz9Jv8dMxknq1FVBd9BTNV2rc5YvVzFhmWwi4Awj6VWR/O6pH4O+c/gU/YtajZnvYun8rTsTLcF7WLzBEECm3NaSOOPQe/bI+TXrbnMG+PlCf9n6J4HArW+7XKweHx8e8Jjg3pquhLvv5CqkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XPJzoIxU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XPJzoIxU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B09F5C116D0; Tue, 30 Sep 2025 17:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759251685; bh=9Has2rbY4I/41mqljMsduhjgNFk0/JrXOnwh9b4Jzv4=; h=Date:From:To:Cc:Subject:References:From; b=XPJzoIxUiBrGX6ypsRSOTtdkHEylNcoJbvJcPsgEdAeS1Yt50+ckEU53G7ukBZyrw JZGIB6WpmkvBx9eHzNqcDwiEAZZRwvc/2COH8hJOMTOpccZW9iNKZSkTBeEra1znpw HLHt91Rrn31MbjZd5vf5E27woaDsEt6aW0TD1Wj6v5FHqJJ3tgjJ7Lh/RquFHvgklk P41/oL6PpQz0GpbI7OQUVkIZsEWd9q6+vGG/L9ZC8UsbeAVNWxbwDXUHUB+3ntemmq c5eBmcf6AqU5FJdKq/K7vKZLYFyMlB8kEMVPeB7IYNkdbcJ0ufQK16zEHqYY2e3Rg4 TYzTrurDVpU9Q== Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1v3dkj-0000000DIGq-3Yo1; Tue, 30 Sep 2025 13:03:01 -0400 Message-ID: <20250930170301.699930470@kernel.org> User-Agent: quilt/0.68 Date: Tue, 30 Sep 2025 13:01:38 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Qianfeng Rong Subject: [for-next][PATCH 03/11] tracing: Use vmalloc_array() to improve code References: <20250930170135.285740909@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Qianfeng Rong 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 Cc: Mathieu Desnoyers Link: https://lore.kernel.org/20250817084725.59477-1-rongqianfeng@vivo.com Signed-off-by: Qianfeng Rong Signed-off-by: Steven Rostedt (Google) --- kernel/trace/tracing_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c index 1921ade45be3..7f8da4dab69d 100644 --- a/kernel/trace/tracing_map.c +++ b/kernel/trace/tracing_map.c @@ -1076,7 +1076,7 @@ int tracing_map_sort_entries(struct tracing_map *map, struct tracing_map_sort_entry *sort_entry, **entries; int i, n_entries, ret; =20 - entries =3D vmalloc(array_size(sizeof(sort_entry), map->max_elts)); + entries =3D vmalloc_array(map->max_elts, sizeof(sort_entry)); if (!entries) return -ENOMEM; =20 --=20 2.50.1