mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gcov: use memcpy for counter value dump in convert_to_gcda
@ 2026-09-01  9:06 Bradley Morgan
  2026-09-03  1:01 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Bradley Morgan @ 2026-09-01  9:06 UTC (permalink / raw)
  To: Peter Oberparleiter; +Cc: akpm, linux-kernel

From: Bradley Morgan <brads@mainlining.org>

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.

Signed-off-by: Bradley Morgan <brads@mainlining.org>
---
 kernel/gcov/gcc_4_7.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c
index 8fa22ababd94..94c240180906 100644
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -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++;
 		}
 	}
-- 
2.47.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gcov: use memcpy for counter value dump in convert_to_gcda
  2026-09-01  9:06 [PATCH] gcov: use memcpy for counter value dump in convert_to_gcda Bradley Morgan
@ 2026-09-03  1:01 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-09-03  1:01 UTC (permalink / raw)
  To: Bradley Morgan, Peter Oberparleiter; +Cc: oe-kbuild-all, akpm, linux-kernel

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/202609030814.OqCixUGW-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 10.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260903/202609030814.OqCixUGW-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609030814.OqCixUGW-lkp@intel.com/

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-03  1:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-01  9:06 [PATCH] gcov: use memcpy for counter value dump in convert_to_gcda Bradley Morgan
2026-09-03  1:01 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®