From: Bradley Morgan <include@grrlz.net>
To: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [PATCH] gcov: use memcpy for counter value dump in convert_to_gcda
Date: Tue, 1 Sep 2026 09:06:22 +0000 [thread overview]
Message-ID: <20260901090622.18431-1-include@grrlz.net> (raw)
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
next reply other threads:[~2026-09-01 9:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 9:06 Bradley Morgan [this message]
2026-09-03 1:01 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260901090622.18431-1-include@grrlz.net \
--to=include@grrlz.net \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oberpar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®