libtracefs: Address the comments that Tzvetomir had for the get affinity functions
cover libtracefs: Address the comments that Tzvetomir had for the get affinity functions
From: "Steven Rostedt (Google)" <[email protected]>
This set fixes the issues that Tzvetomir had on the commits that added the tracefs_instance_get_affinity*() functions.
Steven Rostedt (Google) (4):
libtracefs: Add the get_affinity functions to the main libtracefs man
page
libtracefs: Fix typos and grammar in get_affinity man page
libtracefs: Fix grammar in tracefs_instance_get_affinity() comment
libtracefs: Do not count CPUs beyond set size in get_affinity
Documentation/libtracefs-instances-affinity.txt | 4 ++-- Documentation/libtracefs.txt | 3 +++ src/tracefs-instance.c | 13 +++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-)
Signature · 1 line
2.33.0
PATCH 1/4 libtracefs: Add the get_affinity functions to the main libtracefs man page
From: "Steven Rostedt (Google)" <[email protected]>
The main libtracefs man page should contain all the available API functions.
--- Documentation/libtracefs.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/libtracefs.txt +3 -0
@@ -35,6 +35,9 @@ Trace instances: int *tracefs_instance_set_affinity*(struct tracefs_instance pass:[*]_instance_, const char pass:[*]_cpu_str_); int *tracefs_instance_set_affinity_set*(struct tracefs_instance pass:[*]_instance_, cpu_set_t pass:[*]_set_, size_t _set_size_); int *tracefs_instance_set_affinity_raw*(struct tracefs_instance pass:[*]_instance_, const char pass:[*]_mask_); + char pass:[*]*tracefs_instance_get_affinity*(struct tracefs_instance pass:[*]_instance_); + int *tracefs_instance_get_affinity_set*(struct tracefs_instance pass:[*]_instance_, cpu_set_t pass:[*]_set_, size_t _set_size_); + char pass:[*]*tracefs_instance_get_affinity_raw*(struct tracefs_instance pass:[*]_instance_); Trace events: char pass:[*]pass:[*]*tracefs_event_systems*(const char pass:[*]_tracing_dir_);
Signature · 1 line
2.33.0
PATCH 2/4 libtracefs: Fix typos and grammar in get_affinity man page
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
There were some mistakes in the man page for the get_affinity() API functions. Fix them.
--- Documentation/libtracefs-instances-affinity.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/libtracefs-instances-affinity.txt +2 -2
@@ -24,7 +24,7 @@ char pass:[*]*tracefs_instance_get_affinity_raw*(struct tracefs_instance pass:[* DESCRIPTION ----------- -These functions set or retrieves the CPU affinity that limits what CPUs will have tracing enabled +These functions set or retrieve the CPU affinity that limits what CPUs will have tracing enabled for a given instance defined by the _instance_ parameter. If _instance_ is NULL, then the top level instance is affected.
@@ -71,7 +71,7 @@ RETURN VALUE ------------ All the set functions return 0 on success and -1 on error. -The functinos *tracefs_instance_get_affinity()* and *tracefs_instance_get_affinity_raw()* +The functions *tracefs_instance_get_affinity()* and *tracefs_instance_get_affinity_raw()* returns an allocated string that must be freed with *free*(3), or NULL on error. The function *tracefs_instance_get_affinity_set()* returns the number of CPUs that
Signature · 1 line
2.33.0
PATCH 3/4 libtracefs: Fix grammar in tracefs_instance_get_affinity() comment
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
There was a grammar mistake in the comment describing the tracefs_instance_get_affinity() function. Fix it.
--- src/tracefs-instance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/tracefs-instance.c +1 -1
@@ -1112,7 +1112,7 @@ static inline int update_cpu(int cpus, int cpu_set, int cpu, int s, char **set)* If no CPUs are set, an empty string is returned "\0", and it too needs * to be freed. * -* Returns an allocate string containing the CPU affinity in "human readable" +* Returns an allocated string containing the CPU affinity in "human readable" * format which needs to be freed with free(), or NULL on error. */ char *tracefs_instance_get_affinity (struct tracefs_instance *instance)
Signature · 1 line
2.33.0
PATCH 4/4 libtracefs: Do not count CPUs beyond set size in get_affinity
In reply to Steven RostedtFrom: "Steven Rostedt (Google)" <[email protected]>
If the string of CPUs has bits set that are beyond the size that the passed in cpu_set_t size can hold, do not set them.
This relies on the _S version of the CPU_SET macros from not crashing if the size if too big. One would think that the _S versions would be made specifically to protect against being too big.
If a CPU is set in the string but is outside the size limit of the cpu_set_t passed in, then do not add it to the count that is returned by tracefs_instance_get_affinity_set().
--- src/tracefs-instance.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
src/tracefs-instance.c +10 -1
@@ -1000,7 +1000,16 @@ static inline int update_cpu_set(int cpus, int cpu_set, int cpu,return 0 ;CPU_SET_S (cpu_set + cpu, set_size, set); -return 1 ; + +/* +* It is possible that the passed in set_size is not big enough +* to hold the cpu we just set. If that's the case, do not report +* it as being set. +* +* The CPU_ISSET_S() should return false if the CPU given to it +* is bigger than the set itself. +*/ +return CPU_ISSET_S (cpu_set + cpu, set_size, set) ?1 :0 ; }/**
Signature · 1 line
2.33.0