gcov: use memcpy for counter value dump in convert_to_gcda
PATCH 1/1 gcov: use memcpy for counter value dump in convert_to_gcda
From: Bradley Morgan <[email protected]>
The loop writing gcov_type values one by one is slow and ugly. The values are already in memory, just copy them.
store_gcov_u64 splits each value into two words with the low part first, which matches the gcov format on little endian. On big endian the split is still needed, so keep the loop for BE and use memcpy for LE.
--- kernel/gcov/gcc_4_7.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
kernel/gcov/gcc_4_7.c +13 -1
@@ -422,11 +422,23 @@ size_t convert_to_gcda(char *buffer, struct gcov_info *info) pos +=store_gcov_u32 (buffer, pos, ci_ptr->num *2 *GCOV_UNIT_SIZE ); +#ifdef __LITTLE_ENDIAN +/* +* The values are already in memory, just copy them. +* store_gcov_u64 splits each value into two words +* which matches the gcov format on LE. On BE the +* split is still needed so keep the loop there. +*/ +if (buffer) +memcpy (buffer + pos, ci_ptr->values, + ci_ptr->num *sizeof (gcov_type)); + pos += ci_ptr->num *sizeof (gcov_type); +#else for (cv_idx =0 ; cv_idx < ci_ptr->num; cv_idx++) { pos +=store_gcov_u64 (buffer, pos, ci_ptr->values[cv_idx]); } - +#endif ci_ptr++; } }
Signature · 1 line
2.47.3
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Bradley,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v7.3-rc1 next-20260902] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Bradley-Morgan/gcov-use-memcpy-for-counter-value-dump-in-convert_to_gcda/20260901-090622 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20260901090622.18431-1-include%40grrlz.net patch subject: [PATCH] gcov: use memcpy for counter value dump in convert_to_gcda config: alpha-randconfig-r061-20260903 (https://download.01.org/0day-ci/archive/20260903/[email protected]/config) compiler: alpha-linux-gcc (GCC) 10.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260903/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
kernel/gcov/gcc_4_7.c: In function 'convert_to_gcda':
>> kernel/gcov/gcc_4_7.c:389:15: warning: unused variable 'cv_idx' [-Wunused-variable]
389 | unsigned int cv_idx;
| ^~~~~~vim +/cv_idx +389 kernel/gcov/gcc_4_7.c
5f41ea0386a534 Frantisek Hrbata 2013-11-12 375
5f41ea0386a534 Frantisek Hrbata 2013-11-12 376 /**
5f41ea0386a534 Frantisek Hrbata 2013-11-12 377 * convert_to_gcda - convert profiling data set to gcda file format
5f41ea0386a534 Frantisek Hrbata 2013-11-12 378 * @buffer: the buffer to store file data or %NULL if no data should be stored
5f41ea0386a534 Frantisek Hrbata 2013-11-12 379 * @info: profiling data set to be converted
5f41ea0386a534 Frantisek Hrbata 2013-11-12 380 *
5f41ea0386a534 Frantisek Hrbata 2013-11-12 381 * Returns the number of bytes that were/would have been stored into the buffer.
5f41ea0386a534 Frantisek Hrbata 2013-11-12 382 */
7a1d55b987dfcb Johannes Berg 2021-05-06 383 size_t convert_to_gcda(char *buffer, struct gcov_info *info)
5f41ea0386a534 Frantisek Hrbata 2013-11-12 384 {
5f41ea0386a534 Frantisek Hrbata 2013-11-12 385 struct gcov_fn_info *fi_ptr;
5f41ea0386a534 Frantisek Hrbata 2013-11-12 386 struct gcov_ctr_info *ci_ptr;
5f41ea0386a534 Frantisek Hrbata 2013-11-12 387 unsigned int fi_idx;
5f41ea0386a534 Frantisek Hrbata 2013-11-12 388 unsigned int ct_idx;
5f41ea0386a534 Frantisek Hrbata 2013-11-12 @389 unsigned int cv_idx;
5f41ea0386a534 Frantisek Hrbata 2013-11-12 390 size_t pos = 0;
5f41ea0386a534 Frantisek Hrbata 2013-11-12 391
5f41ea0386a534 Frantisek Hrbata 2013-11-12 392 /* File header. */
5f41ea0386a534 Frantisek Hrbata 2013-11-12 393 pos += store_gcov_u32(buffer, pos, GCOV_DATA_MAGIC);
5f41ea0386a534 Frantisek Hrbata 2013-11-12 394 pos += store_gcov_u32(buffer, pos, info->version);
5f41ea0386a534 Frantisek Hrbata 2013-11-12 395 pos += store_gcov_u32(buffer, pos, info->stamp);
5f41ea0386a534 Frantisek Hrbata 2013-11-12 396 --
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki