Re: [PATCH v7 2/7] lib/ref_tracker: improve printing stats

From: Eric Dumazet
Date: Fri Apr 21 2023 - 10:21:50 EST


On Fri, Apr 21, 2023 at 1:35 PM Andrzej Hajda <andrzej.hajda@xxxxxxxxx> wrote:
>
> In case the library is tracking busy subsystem, simply
> printing stack for every active reference will spam log
> with long, hard to read, redundant stack traces. To improve
> readabilty following changes have been made:
> - reports are printed per stack_handle - log is more compact,
> - added display name for ref_tracker_dir - it will differentiate
> multiple subsystems,
> - stack trace is printed indented, in the same printk call,
> - info about dropped references is printed as well.
>
> Signed-off-by: Andrzej Hajda <andrzej.hajda@xxxxxxxxx>
> Reviewed-by: Andi Shyti <andi.shyti@xxxxxxxxxxxxxxx>
> ---
> include/linux/ref_tracker.h | 15 ++++++--
> lib/ref_tracker.c | 90 +++++++++++++++++++++++++++++++++++++++------
> 2 files changed, 91 insertions(+), 14 deletions(-)
>
> diff --git a/include/linux/ref_tracker.h b/include/linux/ref_tracker.h
> index 87a92f2bec1b88..fc9ef9952f01fd 100644
> --- a/include/linux/ref_tracker.h
> +++ b/include/linux/ref_tracker.h
> @@ -17,12 +17,19 @@ struct ref_tracker_dir {
> bool dead;
> struct list_head list; /* List of active trackers */
> struct list_head quarantine; /* List of dead trackers */
> + char name[32];
> #endif
> };
>
> #ifdef CONFIG_REF_TRACKER
> -static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
> - unsigned int quarantine_count)
> +
> +/* Temporary allow two and three arguments, until consumers are converted */
> +#define ref_tracker_dir_init(_d, _q, args...) _ref_tracker_dir_init(_d, _q, ##args, #_d)
> +#define _ref_tracker_dir_init(_d, _q, _n, ...) __ref_tracker_dir_init(_d, _q, _n)
> +

We only have four callers of ref_tracker_dir_init() .

Why not simply add a name on them, and avoid this magic ?