* [PATCH] KVM: Move binary stats helpers to header to effectively export them
@ 2021-08-11 16:53 Sean Christopherson
2021-08-11 17:55 ` Jing Zhang
2021-08-13 7:38 ` Paolo Bonzini
0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2021-08-11 16:53 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel, Jing Zhang, Sean Christopherson
Move kvm_stats_linear_hist_update() and kvm_stats_log_hist_update() to
kvm_host.h as static inline helpers to resolve a linker error on PPC,
which references the latter from module code. This also fixes a goof
where the functions are tagged as "inline", despite being externs and
thus not inline-friendy.
ERROR: modpost: ".kvm_stats_log_hist_update" [arch/powerpc/kvm/kvm-hv.ko] undefined!
Fixes: c8ba95948182 ("KVM: stats: Support linear and logarithmic histogram statistics")
Cc: Jing Zhang <jingzhangos@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
include/linux/kvm_host.h | 38 +++++++++++++++++++++++++++++++++++---
virt/kvm/binary_stats.c | 34 ----------------------------------
2 files changed, 35 insertions(+), 37 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index d447b21cdd73..e4d712e9f760 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -1467,9 +1467,41 @@ ssize_t kvm_stats_read(char *id, const struct kvm_stats_header *header,
const struct _kvm_stats_desc *desc,
void *stats, size_t size_stats,
char __user *user_buffer, size_t size, loff_t *offset);
-inline void kvm_stats_linear_hist_update(u64 *data, size_t size,
- u64 value, size_t bucket_size);
-inline void kvm_stats_log_hist_update(u64 *data, size_t size, u64 value);
+
+/**
+ * kvm_stats_linear_hist_update() - Update bucket value for linear histogram
+ * statistics data.
+ *
+ * @data: start address of the stats data
+ * @size: the number of bucket of the stats data
+ * @value: the new value used to update the linear histogram's bucket
+ * @bucket_size: the size (width) of a bucket
+ */
+static inline void kvm_stats_linear_hist_update(u64 *data, size_t size,
+ u64 value, size_t bucket_size)
+{
+ size_t index = div64_u64(value, bucket_size);
+
+ index = min(index, size - 1);
+ ++data[index];
+}
+
+/**
+ * kvm_stats_log_hist_update() - Update bucket value for logarithmic histogram
+ * statistics data.
+ *
+ * @data: start address of the stats data
+ * @size: the number of bucket of the stats data
+ * @value: the new value used to update the logarithmic histogram's bucket
+ */
+static inline void kvm_stats_log_hist_update(u64 *data, size_t size, u64 value)
+{
+ size_t index = fls64(value);
+
+ index = min(index, size - 1);
+ ++data[index];
+}
+
#define KVM_STATS_LINEAR_HIST_UPDATE(array, value, bsize) \
kvm_stats_linear_hist_update(array, ARRAY_SIZE(array), value, bsize)
#define KVM_STATS_LOG_HIST_UPDATE(array, value) \
diff --git a/virt/kvm/binary_stats.c b/virt/kvm/binary_stats.c
index 9bd595c92d3a..eefca6c69f51 100644
--- a/virt/kvm/binary_stats.c
+++ b/virt/kvm/binary_stats.c
@@ -142,37 +142,3 @@ ssize_t kvm_stats_read(char *id, const struct kvm_stats_header *header,
*offset = pos;
return len;
}
-
-/**
- * kvm_stats_linear_hist_update() - Update bucket value for linear histogram
- * statistics data.
- *
- * @data: start address of the stats data
- * @size: the number of bucket of the stats data
- * @value: the new value used to update the linear histogram's bucket
- * @bucket_size: the size (width) of a bucket
- */
-inline void kvm_stats_linear_hist_update(u64 *data, size_t size,
- u64 value, size_t bucket_size)
-{
- size_t index = div64_u64(value, bucket_size);
-
- index = min(index, size - 1);
- ++data[index];
-}
-
-/**
- * kvm_stats_log_hist_update() - Update bucket value for logarithmic histogram
- * statistics data.
- *
- * @data: start address of the stats data
- * @size: the number of bucket of the stats data
- * @value: the new value used to update the logarithmic histogram's bucket
- */
-inline void kvm_stats_log_hist_update(u64 *data, size_t size, u64 value)
-{
- size_t index = fls64(value);
-
- index = min(index, size - 1);
- ++data[index];
-}
--
2.32.0.605.g8dce9f2422-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: Move binary stats helpers to header to effectively export them
2021-08-11 16:53 [PATCH] KVM: Move binary stats helpers to header to effectively export them Sean Christopherson
@ 2021-08-11 17:55 ` Jing Zhang
2021-08-13 7:38 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Jing Zhang @ 2021-08-11 17:55 UTC (permalink / raw)
To: Sean Christopherson; +Cc: Paolo Bonzini, KVM, linux-kernel
On Wed, Aug 11, 2021 at 9:53 AM Sean Christopherson <seanjc@google.com> wrote:
>
> Move kvm_stats_linear_hist_update() and kvm_stats_log_hist_update() to
> kvm_host.h as static inline helpers to resolve a linker error on PPC,
> which references the latter from module code. This also fixes a goof
> where the functions are tagged as "inline", despite being externs and
> thus not inline-friendy.
>
> ERROR: modpost: ".kvm_stats_log_hist_update" [arch/powerpc/kvm/kvm-hv.ko] undefined!
>
> Fixes: c8ba95948182 ("KVM: stats: Support linear and logarithmic histogram statistics")
> Cc: Jing Zhang <jingzhangos@google.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> include/linux/kvm_host.h | 38 +++++++++++++++++++++++++++++++++++---
> virt/kvm/binary_stats.c | 34 ----------------------------------
> 2 files changed, 35 insertions(+), 37 deletions(-)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index d447b21cdd73..e4d712e9f760 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -1467,9 +1467,41 @@ ssize_t kvm_stats_read(char *id, const struct kvm_stats_header *header,
> const struct _kvm_stats_desc *desc,
> void *stats, size_t size_stats,
> char __user *user_buffer, size_t size, loff_t *offset);
> -inline void kvm_stats_linear_hist_update(u64 *data, size_t size,
> - u64 value, size_t bucket_size);
> -inline void kvm_stats_log_hist_update(u64 *data, size_t size, u64 value);
> +
> +/**
> + * kvm_stats_linear_hist_update() - Update bucket value for linear histogram
> + * statistics data.
> + *
> + * @data: start address of the stats data
> + * @size: the number of bucket of the stats data
> + * @value: the new value used to update the linear histogram's bucket
> + * @bucket_size: the size (width) of a bucket
> + */
> +static inline void kvm_stats_linear_hist_update(u64 *data, size_t size,
> + u64 value, size_t bucket_size)
> +{
> + size_t index = div64_u64(value, bucket_size);
> +
> + index = min(index, size - 1);
> + ++data[index];
> +}
> +
> +/**
> + * kvm_stats_log_hist_update() - Update bucket value for logarithmic histogram
> + * statistics data.
> + *
> + * @data: start address of the stats data
> + * @size: the number of bucket of the stats data
> + * @value: the new value used to update the logarithmic histogram's bucket
> + */
> +static inline void kvm_stats_log_hist_update(u64 *data, size_t size, u64 value)
> +{
> + size_t index = fls64(value);
> +
> + index = min(index, size - 1);
> + ++data[index];
> +}
> +
> #define KVM_STATS_LINEAR_HIST_UPDATE(array, value, bsize) \
> kvm_stats_linear_hist_update(array, ARRAY_SIZE(array), value, bsize)
> #define KVM_STATS_LOG_HIST_UPDATE(array, value) \
> diff --git a/virt/kvm/binary_stats.c b/virt/kvm/binary_stats.c
> index 9bd595c92d3a..eefca6c69f51 100644
> --- a/virt/kvm/binary_stats.c
> +++ b/virt/kvm/binary_stats.c
> @@ -142,37 +142,3 @@ ssize_t kvm_stats_read(char *id, const struct kvm_stats_header *header,
> *offset = pos;
> return len;
> }
> -
> -/**
> - * kvm_stats_linear_hist_update() - Update bucket value for linear histogram
> - * statistics data.
> - *
> - * @data: start address of the stats data
> - * @size: the number of bucket of the stats data
> - * @value: the new value used to update the linear histogram's bucket
> - * @bucket_size: the size (width) of a bucket
> - */
> -inline void kvm_stats_linear_hist_update(u64 *data, size_t size,
> - u64 value, size_t bucket_size)
> -{
> - size_t index = div64_u64(value, bucket_size);
> -
> - index = min(index, size - 1);
> - ++data[index];
> -}
> -
> -/**
> - * kvm_stats_log_hist_update() - Update bucket value for logarithmic histogram
> - * statistics data.
> - *
> - * @data: start address of the stats data
> - * @size: the number of bucket of the stats data
> - * @value: the new value used to update the logarithmic histogram's bucket
> - */
> -inline void kvm_stats_log_hist_update(u64 *data, size_t size, u64 value)
> -{
> - size_t index = fls64(value);
> -
> - index = min(index, size - 1);
> - ++data[index];
> -}
> --
> 2.32.0.605.g8dce9f2422-goog
>
Thanks for fixing it, Sean!
Reviewed-by: Jing Zhang <jingzhangos@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: Move binary stats helpers to header to effectively export them
2021-08-11 16:53 [PATCH] KVM: Move binary stats helpers to header to effectively export them Sean Christopherson
2021-08-11 17:55 ` Jing Zhang
@ 2021-08-13 7:38 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2021-08-13 7:38 UTC (permalink / raw)
To: Sean Christopherson; +Cc: kvm, linux-kernel, Jing Zhang
On 11/08/21 18:53, Sean Christopherson wrote:
> Move kvm_stats_linear_hist_update() and kvm_stats_log_hist_update() to
> kvm_host.h as static inline helpers to resolve a linker error on PPC,
> which references the latter from module code. This also fixes a goof
> where the functions are tagged as "inline", despite being externs and
> thus not inline-friendy.
>
> ERROR: modpost: ".kvm_stats_log_hist_update" [arch/powerpc/kvm/kvm-hv.ko] undefined!
>
> Fixes: c8ba95948182 ("KVM: stats: Support linear and logarithmic histogram statistics")
> Cc: Jing Zhang <jingzhangos@google.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> include/linux/kvm_host.h | 38 +++++++++++++++++++++++++++++++++++---
> virt/kvm/binary_stats.c | 34 ----------------------------------
> 2 files changed, 35 insertions(+), 37 deletions(-)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index d447b21cdd73..e4d712e9f760 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -1467,9 +1467,41 @@ ssize_t kvm_stats_read(char *id, const struct kvm_stats_header *header,
> const struct _kvm_stats_desc *desc,
> void *stats, size_t size_stats,
> char __user *user_buffer, size_t size, loff_t *offset);
> -inline void kvm_stats_linear_hist_update(u64 *data, size_t size,
> - u64 value, size_t bucket_size);
> -inline void kvm_stats_log_hist_update(u64 *data, size_t size, u64 value);
> +
> +/**
> + * kvm_stats_linear_hist_update() - Update bucket value for linear histogram
> + * statistics data.
> + *
> + * @data: start address of the stats data
> + * @size: the number of bucket of the stats data
> + * @value: the new value used to update the linear histogram's bucket
> + * @bucket_size: the size (width) of a bucket
> + */
> +static inline void kvm_stats_linear_hist_update(u64 *data, size_t size,
> + u64 value, size_t bucket_size)
> +{
> + size_t index = div64_u64(value, bucket_size);
> +
> + index = min(index, size - 1);
> + ++data[index];
> +}
> +
> +/**
> + * kvm_stats_log_hist_update() - Update bucket value for logarithmic histogram
> + * statistics data.
> + *
> + * @data: start address of the stats data
> + * @size: the number of bucket of the stats data
> + * @value: the new value used to update the logarithmic histogram's bucket
> + */
> +static inline void kvm_stats_log_hist_update(u64 *data, size_t size, u64 value)
> +{
> + size_t index = fls64(value);
> +
> + index = min(index, size - 1);
> + ++data[index];
> +}
> +
> #define KVM_STATS_LINEAR_HIST_UPDATE(array, value, bsize) \
> kvm_stats_linear_hist_update(array, ARRAY_SIZE(array), value, bsize)
> #define KVM_STATS_LOG_HIST_UPDATE(array, value) \
> diff --git a/virt/kvm/binary_stats.c b/virt/kvm/binary_stats.c
> index 9bd595c92d3a..eefca6c69f51 100644
> --- a/virt/kvm/binary_stats.c
> +++ b/virt/kvm/binary_stats.c
> @@ -142,37 +142,3 @@ ssize_t kvm_stats_read(char *id, const struct kvm_stats_header *header,
> *offset = pos;
> return len;
> }
> -
> -/**
> - * kvm_stats_linear_hist_update() - Update bucket value for linear histogram
> - * statistics data.
> - *
> - * @data: start address of the stats data
> - * @size: the number of bucket of the stats data
> - * @value: the new value used to update the linear histogram's bucket
> - * @bucket_size: the size (width) of a bucket
> - */
> -inline void kvm_stats_linear_hist_update(u64 *data, size_t size,
> - u64 value, size_t bucket_size)
> -{
> - size_t index = div64_u64(value, bucket_size);
> -
> - index = min(index, size - 1);
> - ++data[index];
> -}
> -
> -/**
> - * kvm_stats_log_hist_update() - Update bucket value for logarithmic histogram
> - * statistics data.
> - *
> - * @data: start address of the stats data
> - * @size: the number of bucket of the stats data
> - * @value: the new value used to update the logarithmic histogram's bucket
> - */
> -inline void kvm_stats_log_hist_update(u64 *data, size_t size, u64 value)
> -{
> - size_t index = fls64(value);
> -
> - index = min(index, size - 1);
> - ++data[index];
> -}
>
Squashed, thanks.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-13 7:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 16:53 [PATCH] KVM: Move binary stats helpers to header to effectively export them Sean Christopherson
2021-08-11 17:55 ` Jing Zhang
2021-08-13 7:38 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).