All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Christian Gmeiner <christian.gmeiner@gmail.com>,
	linux-kernel@vger.kernel.org
Cc: David Airlie <airlied@linux.ie>,
	"moderated list:DRM DRIVERS FOR VIVANTE GPU IP" 
	<etnaviv@lists.freedesktop.org>,
	"open list:DRM DRIVERS FOR VIVANTE GPU IP" 
	<dri-devel@lists.freedesktop.org>,
	Daniel Vetter <daniel@ffwll.ch>,
	Russell King <linux+etnaviv@armlinux.org.uk>
Subject: Re: [PATCH v2 1/4] drm/etnaviv: add simple moving average (SMA)
Date: Fri, 24 Jun 2022 11:22:39 +0200	[thread overview]
Message-ID: <1a694037c631c298c6952cdf4bf54fcc6d2f08e9.camel@pengutronix.de> (raw)
In-Reply-To: <20220621072050.76229-2-christian.gmeiner@gmail.com>

Hi Christian,

Am Dienstag, dem 21.06.2022 um 09:20 +0200 schrieb Christian Gmeiner:
> This adds a SMA algorithm inspired by Exponentially weighted moving
> average (EWMA) algorithm found in the kernel.
> 
Still not sure about this one. I _feel_ that a simple moving average
over a period of one second does not do a good job of reflecting the
real GPU load for a bursty workload, where EWMA might be better suited.
But then I also don't have a real informed opinion to offer on this.

Regards,
Lucas

> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_sma.h | 53 +++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
>  create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_sma.h
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sma.h b/drivers/gpu/drm/etnaviv/etnaviv_sma.h
> new file mode 100644
> index 000000000000..81564d5cbdc3
> --- /dev/null
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_sma.h
> @@ -0,0 +1,53 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (C) 2020 Etnaviv Project
> + */
> +
> +#ifndef __ETNAVIV_SMA_H__
> +#define __ETNAVIV_SMA_H__
> +
> +#include <linux/bug.h>
> +#include <linux/compiler.h>
> +
> +/*
> + * Simple moving average (SMA)
> + *
> + * This implements a fixed-size SMA algorithm.
> + *
> + * The first argument to the macro is the name that will be used
> + * for the struct and helper functions.
> + *
> + * The second argument, the samples, expresses how many samples are
> + * used for the SMA algorithm.
> + */
> +
> +#define DECLARE_SMA(name, _samples) \
> +    struct sma_##name { \
> +        unsigned long pos; \
> +        unsigned long sum; \
> +        unsigned long samples[_samples]; \
> +    }; \
> +    static inline void sma_##name##_init(struct sma_##name *s) \
> +    { \
> +        BUILD_BUG_ON(!__builtin_constant_p(_samples));	\
> +        memset(s, 0, sizeof(struct sma_##name)); \
> +    } \
> +    static inline unsigned long sma_##name##_read(struct sma_##name *s) \
> +    { \
> +        BUILD_BUG_ON(!__builtin_constant_p(_samples));	\
> +        return s->sum / _samples; \
> +    } \
> +    static inline void sma_##name##_add(struct sma_##name *s, unsigned long val) \
> +    { \
> +        unsigned long pos = READ_ONCE(s->pos); \
> +        unsigned long sum = READ_ONCE(s->sum); \
> +        unsigned long sample = READ_ONCE(s->samples[pos]); \
> +      \
> +        BUILD_BUG_ON(!__builtin_constant_p(_samples));	\
> +      \
> +       WRITE_ONCE(s->sum, sum - sample + val); \
> +       WRITE_ONCE(s->samples[pos], val); \
> +       WRITE_ONCE(s->pos, pos + 1 == _samples ? 0 : pos + 1); \
> +    }
> +
> +#endif /* __ETNAVIV_SMA_H__ */



WARNING: multiple messages have this Message-ID (diff)
From: Lucas Stach <l.stach@pengutronix.de>
To: Christian Gmeiner <christian.gmeiner@gmail.com>,
	 linux-kernel@vger.kernel.org
Cc: David Airlie <airlied@linux.ie>,
	"moderated list:DRM DRIVERS FOR VIVANTE GPU IP"
	<etnaviv@lists.freedesktop.org>,
	"open list:DRM DRIVERS FOR VIVANTE GPU IP"
	<dri-devel@lists.freedesktop.org>,
	Russell King <linux+etnaviv@armlinux.org.uk>
Subject: Re: [PATCH v2 1/4] drm/etnaviv: add simple moving average (SMA)
Date: Fri, 24 Jun 2022 11:22:39 +0200	[thread overview]
Message-ID: <1a694037c631c298c6952cdf4bf54fcc6d2f08e9.camel@pengutronix.de> (raw)
In-Reply-To: <20220621072050.76229-2-christian.gmeiner@gmail.com>

Hi Christian,

Am Dienstag, dem 21.06.2022 um 09:20 +0200 schrieb Christian Gmeiner:
> This adds a SMA algorithm inspired by Exponentially weighted moving
> average (EWMA) algorithm found in the kernel.
> 
Still not sure about this one. I _feel_ that a simple moving average
over a period of one second does not do a good job of reflecting the
real GPU load for a bursty workload, where EWMA might be better suited.
But then I also don't have a real informed opinion to offer on this.

Regards,
Lucas

> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_sma.h | 53 +++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
>  create mode 100644 drivers/gpu/drm/etnaviv/etnaviv_sma.h
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_sma.h b/drivers/gpu/drm/etnaviv/etnaviv_sma.h
> new file mode 100644
> index 000000000000..81564d5cbdc3
> --- /dev/null
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_sma.h
> @@ -0,0 +1,53 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (C) 2020 Etnaviv Project
> + */
> +
> +#ifndef __ETNAVIV_SMA_H__
> +#define __ETNAVIV_SMA_H__
> +
> +#include <linux/bug.h>
> +#include <linux/compiler.h>
> +
> +/*
> + * Simple moving average (SMA)
> + *
> + * This implements a fixed-size SMA algorithm.
> + *
> + * The first argument to the macro is the name that will be used
> + * for the struct and helper functions.
> + *
> + * The second argument, the samples, expresses how many samples are
> + * used for the SMA algorithm.
> + */
> +
> +#define DECLARE_SMA(name, _samples) \
> +    struct sma_##name { \
> +        unsigned long pos; \
> +        unsigned long sum; \
> +        unsigned long samples[_samples]; \
> +    }; \
> +    static inline void sma_##name##_init(struct sma_##name *s) \
> +    { \
> +        BUILD_BUG_ON(!__builtin_constant_p(_samples));	\
> +        memset(s, 0, sizeof(struct sma_##name)); \
> +    } \
> +    static inline unsigned long sma_##name##_read(struct sma_##name *s) \
> +    { \
> +        BUILD_BUG_ON(!__builtin_constant_p(_samples));	\
> +        return s->sum / _samples; \
> +    } \
> +    static inline void sma_##name##_add(struct sma_##name *s, unsigned long val) \
> +    { \
> +        unsigned long pos = READ_ONCE(s->pos); \
> +        unsigned long sum = READ_ONCE(s->sum); \
> +        unsigned long sample = READ_ONCE(s->samples[pos]); \
> +      \
> +        BUILD_BUG_ON(!__builtin_constant_p(_samples));	\
> +      \
> +       WRITE_ONCE(s->sum, sum - sample + val); \
> +       WRITE_ONCE(s->samples[pos], val); \
> +       WRITE_ONCE(s->pos, pos + 1 == _samples ? 0 : pos + 1); \
> +    }
> +
> +#endif /* __ETNAVIV_SMA_H__ */



  reply	other threads:[~2022-06-24  9:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21  7:20 [PATCH v2 0/4] Add support for GPU load values Christian Gmeiner
2022-06-21  7:20 ` Christian Gmeiner
2022-06-21  7:20 ` [PATCH v2 1/4] drm/etnaviv: add simple moving average (SMA) Christian Gmeiner
2022-06-21  7:20   ` Christian Gmeiner
2022-06-24  9:22   ` Lucas Stach [this message]
2022-06-24  9:22     ` Lucas Stach
2022-07-02 11:41     ` Christian Gmeiner
2022-07-02 11:41       ` Christian Gmeiner
2022-06-21  7:20 ` [PATCH v2 2/4] drm/etnaviv: add loadavg accounting Christian Gmeiner
2022-06-21  7:20   ` Christian Gmeiner
2022-06-24  9:38   ` Lucas Stach
2022-06-24  9:38     ` Lucas Stach
2022-07-02 11:53     ` Christian Gmeiner
2022-07-02 11:53       ` Christian Gmeiner
2022-06-21  7:20 ` [PATCH v2 3/4] drm/etnaviv: show loadavg in debugfs Christian Gmeiner
2022-06-21  7:20   ` Christian Gmeiner
2022-06-21  7:20 ` [PATCH v2 4/4] drm/etnaviv: export loadavg via perfmon Christian Gmeiner
2022-06-21  7:20   ` Christian Gmeiner
2022-06-24  9:44   ` Lucas Stach
2022-06-24  9:44     ` Lucas Stach
2022-07-02 11:57     ` Christian Gmeiner
2022-07-02 11:57       ` Christian Gmeiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1a694037c631c298c6952cdf4bf54fcc6d2f08e9.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=airlied@linux.ie \
    --cc=christian.gmeiner@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=etnaviv@lists.freedesktop.org \
    --cc=linux+etnaviv@armlinux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.