Re: [RFC PATCHv4 4/6] nvme-multipath: add debugfs attribute adaptive_ewma_shift

Hannes Reinecke
2025-11-04T14:58:13Z

On 11/4/25 11:45, Nilay Shroff wrote:
> By default, the EWMA (Exponentially Weighted Moving Average) shift
> value, used for storing latency samples for adaptive iopolicy, is set
> to 3. The EWMA is calculated using the following formula:
>
> ewma = (old * ((1 << ewma_shift) - 1) + new) >> ewma_shift;
>
> The default value of 3 assigns ~87.5% weight to the existing EWMA value
> and ~12.5% weight to the new latency sample. This provides a stable
> average that smooths out short-term variations.
>
> However, different workloads may require faster or slower adaptation to
> changing conditions. This commit introduces a new debugfs attribute,
> adaptive_ewma_shift, allowing users to tune the weighting factor.
>
> For example:
> - adaptive_ewma_shift = 2 => 75% old, 25% new
> - adaptive_ewma_shift = 1 => 50% old, 50% new
> - adaptive_ewma_shift = 0 => 0% old, 100% new
>
> Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
> ---
> drivers/nvme/host/core.c | 3 +++
> drivers/nvme/host/debugfs.c | 46 +++++++++++++++++++++++++++++++++++
> drivers/nvme/host/multipath.c | 8 +++---
> drivers/nvme/host/nvme.h | 1 +
> 4 files changed, 54 insertions(+), 4 deletions(-)
>
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich