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

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®