diff mbox series

[v2,net-next,5/6] bitops: make BYTES_TO_BITS() treewide-available

Message ID 20221018140027.48086-6-alexandr.lobakin@intel.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series netlink: add universal 'bigint' attribute type | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 17828 this patch: 18031
netdev/cc_maintainers warning 11 maintainers not CCed: alexander.shishkin@linux.intel.com elver@google.com mhiramat@kernel.org mingo@redhat.com rostedt@goodmis.org peterz@infradead.org jolsa@kernel.org namhyung@kernel.org linux-perf-users@vger.kernel.org mark.rutland@arm.com acme@kernel.org
netdev/build_clang fail Errors and warnings before: 4358 this patch: 4371
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 18623 this patch: 18828
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 30 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Alexander Lobakin Oct. 18, 2022, 2 p.m. UTC
Avoid open-coding that simple expression each time by moving
BYTES_TO_BITS() from the probes code to <linux/bitops.h> to export
it to the rest of the kernel.
Do the same for the tools ecosystem as well (incl. its version of
bitops.h).

Suggested-by: Andy Shevchenko <andy.shevchenko@linux.intel.com>
Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
---
 include/linux/bitops.h         | 1 +
 kernel/trace/trace_probe.c     | 2 --
 tools/include/linux/bitops.h   | 1 +
 tools/perf/util/probe-finder.c | 2 --
 4 files changed, 2 insertions(+), 4 deletions(-)

Comments

Jakub Kicinski Oct. 18, 2022, 7:55 p.m. UTC | #1
On Tue, 18 Oct 2022 16:00:26 +0200 Alexander Lobakin wrote:
> Avoid open-coding that simple expression each time by moving
> BYTES_TO_BITS() from the probes code to <linux/bitops.h> to export
> it to the rest of the kernel.
> Do the same for the tools ecosystem as well (incl. its version of
> bitops.h).

This needs to be before patch 4?
Alexander Lobakin Oct. 19, 2022, 3:26 p.m. UTC | #2
From: Jakub Kicinski <kuba@kernel.org>
Date: Tue, 18 Oct 2022 12:55:20 -0700

> On Tue, 18 Oct 2022 16:00:26 +0200 Alexander Lobakin wrote:
> > Avoid open-coding that simple expression each time by moving
> > BYTES_TO_BITS() from the probes code to <linux/bitops.h> to export
> > it to the rest of the kernel.
> > Do the same for the tools ecosystem as well (incl. its version of
> > bitops.h).
> 
> This needs to be before patch 4?

Indeed :s Thanks for catching.

Olek
diff mbox series

Patch

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 2ba557e067fe..e11f19f96853 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -20,6 +20,7 @@ 
 #define BITS_TO_U64(nr)		__KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u64))
 #define BITS_TO_U32(nr)		__KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u32))
 #define BITS_TO_BYTES(nr)	__KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(char))
+#define BYTES_TO_BITS(nb)	((nb) * BITS_PER_LONG / sizeof(long))
 
 extern unsigned int __sw_hweight8(unsigned int w);
 extern unsigned int __sw_hweight16(unsigned int w);
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 36dff277de46..89e73eebc72c 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -523,8 +523,6 @@  parse_probe_arg(char *arg, const struct fetch_type *type,
 	return ret;
 }
 
-#define BYTES_TO_BITS(nb)	((BITS_PER_LONG * (nb)) / sizeof(long))
-
 /* Bitfield type needs to be parsed into a fetch function */
 static int __parse_bitfield_probe_arg(const char *bf,
 				      const struct fetch_type *t,
diff --git a/tools/include/linux/bitops.h b/tools/include/linux/bitops.h
index f18683b95ea6..aee8667ce941 100644
--- a/tools/include/linux/bitops.h
+++ b/tools/include/linux/bitops.h
@@ -19,6 +19,7 @@ 
 #define BITS_TO_U64(nr)		DIV_ROUND_UP(nr, BITS_PER_TYPE(u64))
 #define BITS_TO_U32(nr)		DIV_ROUND_UP(nr, BITS_PER_TYPE(u32))
 #define BITS_TO_BYTES(nr)	DIV_ROUND_UP(nr, BITS_PER_TYPE(char))
+#define BYTES_TO_BITS(nb)	((nb) * BITS_PER_LONG / sizeof(long))
 
 extern unsigned int __sw_hweight8(unsigned int w);
 extern unsigned int __sw_hweight16(unsigned int w);
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 50d861a80f57..2a0b7aacabc0 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -304,8 +304,6 @@  static int convert_variable_location(Dwarf_Die *vr_die, Dwarf_Addr addr,
 	return ret2;
 }
 
-#define BYTES_TO_BITS(nb)	((nb) * BITS_PER_LONG / sizeof(long))
-
 static int convert_variable_type(Dwarf_Die *vr_die,
 				 struct probe_trace_arg *tvar,
 				 const char *cast, bool user_access)