Re: [PATCH v8 06/11] fs: add percpu counters for significant multigrain timestamp events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Sep 14 2024 at 13:07, Jeff Layton wrote:
>  fs/inode.c                         | 76 ++++++++++++++++++++++++++++++++++++--
>  include/linux/timekeeping.h        |  1 +
>  kernel/time/timekeeping.c          |  3 +-
>  kernel/time/timekeeping_debug.c    | 12 ++++++
>  kernel/time/timekeeping_internal.h |  3 ++

So the subject says 'fs:'. This is not how it works.

Provide the timekeeping changes in a separate patch and then add the fs
voodoo. Documentation is pretty clear about this, no?

> diff --git a/kernel/time/timekeeping_debug.c b/kernel/time/timekeeping_debug.c
> index b73e8850e58d..9a3792072762 100644
> --- a/kernel/time/timekeeping_debug.c
> +++ b/kernel/time/timekeeping_debug.c
> @@ -17,6 +17,9 @@
>  
>  #define NUM_BINS 32
>  
> +/* incremented every time mg_floor is updated */

Sentences start with a uppercase letter.

> +DEFINE_PER_CPU(long, mg_floor_swaps);

Why is this long? This is a counter which always counts up..

>  static unsigned int sleep_time_bin[NUM_BINS] = {0};
>  
>  static int tk_debug_sleep_time_show(struct seq_file *s, void *data)
> @@ -53,3 +56,12 @@ void tk_debug_account_sleep_time(const struct timespec64 *t)
>  			   (s64)t->tv_sec, t->tv_nsec / NSEC_PER_MSEC);
>  }
>  
> +long get_mg_floor_swaps(void)

Can we please have a proper subsystem prefix and not this get_*()
notation. It's horrible to grep for. timekeeping_mg_get_...() makes it
clear where this function belongs to, no?

> +{
> +	int i;
> +	long sum = 0;

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#variable-declarations

Also please use 'cpu' instead of 'i'. Self explanatory variable names
have a value.

> +	for_each_possible_cpu(i)
> +		sum += per_cpu(mg_floor_swaps, i);

This needs annotation for kcsan as this is a racy access.

> +	return sum < 0 ? 0 : sum;
> +}
> diff --git a/kernel/time/timekeeping_internal.h b/kernel/time/timekeeping_internal.h
> index 4ca2787d1642..2b49332b45a5 100644
> --- a/kernel/time/timekeeping_internal.h
> +++ b/kernel/time/timekeeping_internal.h
> @@ -11,8 +11,11 @@
>   */
>  #ifdef CONFIG_DEBUG_FS
>  extern void tk_debug_account_sleep_time(const struct timespec64 *t);
> +DECLARE_PER_CPU(long, mg_floor_swaps);
> +#define mgtime_counter_inc(__var)	this_cpu_inc(__var)

Please use static inlines for this.

Thanks,

        tglx




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux