Re: [PATCH v2 02/10] PM: sleep: stats: Use an array of step failure counters

From: Stanislaw Gruszka
Date: Tue Jan 30 2024 - 02:02:33 EST


On Mon, Jan 29, 2024 at 05:11:57PM +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
>
> Instead of using a set of individual struct suspend_stats fields
> representing suspend step failure counters, use an array of counters
> indexed by enum suspend_stat_step for this purpose, which allows
> dpm_save_failed_step() to increment the appropriate counter
> automatically, so that its callers don't need to do that directly.
>
> It also allows suspend_stats_show() to carry out a loop over the
> counters array to print their values.
>
> Because the counters cannot become negative, use unsigned int for
> representing them.
>
> The only user-observable impact of this change is a different
> ordering of entries in the suspend_stats debugfs file which is not
> expected to matter.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> ---
>
> v1 -> v2:
> * Use one cell less in suspend_stats.step_failures[] to avoid
> introducing an unused array cell (Stanislaw).
>
> @Stanislaw: This is different from setting SUSPEND_FREEZE to 0, because
> that would complicate printing in the sysfs attributes and the debugfs
> code, so I've not added the R-by.

LGTM.

Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@xxxxxxxxxxxxxxx>

> + for (step = SUSPEND_FREEZE; step <= SUSPEND_NR_STEPS; step++)
> + seq_printf(s, "failed_%s: %u\n", suspend_step_names[step],
> + suspend_stats.step_failures[step-1]);

Consider (in separate patch) removing SUSPEND_NONE from suspend_step_names[]
and use step-1 for it as well.

Regards
Stanislaw