Skip to contentSkip to conversation

virtio_balloon: add array of stat names

PATCH In review Michael S. Tsirkin 2 participants 6 messages Apr 13, 2018

Subsystems (2)
lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH 1/1 virtio_balloon: add array of stat names

Jason Wang points out that it's vary hard for users to build an array of stat names. The naive thing is to use VIRTIO_BALLOON_S_NR but that breaks if we add more stats.

Let's add an array of reasonably readable names.

Fixes 6c64fe7f2 ("virtio_balloon: export hugetlb page allocation counts")
Cc Jason Wang <[email protected]>
Cc Jonathan Helman <[email protected]>,
---
 include/uapi/linux/virtio_balloon.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
include/uapi/linux/virtio_balloon.h +15 -0
index 9e02137..1477c17 100644
@@ -64,6 +64,21 @@ struct virtio_balloon_config {
 #define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
 #define VIRTIO_BALLOON_S_NR       10
 
+#define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-out", \
+	VIRTIO_BALLOON_S_NAMES_prefix "major-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "minor-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "free-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "total-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "available-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures" \
+}
+
+#define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")
+
 /*
  * Memory statistics structure.
  * Driver fills an array of these structures and passes to device.
Signature · 1 line
MST
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Michael S. Tsirkin

Jason Wang points out that it's vary hard for users to build an array of

s/vary/very

Quoted 4 lines

stat names. The naive thing is to use VIRTIO_BALLOON_S_NR but that breaks if we add more stats.

Let's add an array of reasonably readable names.

Thanks for doing this, this is goodness. Clients of this interface will now only require a modification to their internal copy of the header file (if they have one), rather than updating their string array as well.

Quoted 2 lines
Fixes 6c64fe7f2 ("virtio_balloon: export hugetlb page allocation counts")

I think this is a tad bit confusing since the only way you'd know why this patch "fixes" 6c64fe7f2 is by reading the LKML archives and finding Jason's comment.

Quoted 2 lines
Cc Jason Wang <[email protected]>
Cc Jonathan Helman <[email protected]>, > Signed-off-by: Michael S. Tsirkin <[email protected]>
Quoted 30 lines
---
  include/uapi/linux/virtio_balloon.h | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
include/uapi/linux/virtio_balloon.h +14 -0
index 9e02137..1477c17 100644
@@ -64,6 +64,21 @@ struct virtio_balloon_config {
  #define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
  #define VIRTIO_BALLOON_S_NR       10
 
+#define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-out", \
+	VIRTIO_BALLOON_S_NAMES_prefix "major-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "minor-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "free-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "total-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "available-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures" \ > +}
+
+#define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")
+
  /*
   * Memory statistics structure.
   * Driver fills an array of these structures and passes to device.
Reviewed-by on v1 1/1
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 1 line · Michael S. Tsirkin

Jason Wang points out that it's vary hard for users to build an array of

s/vary/very

Quoted 4 lines

stat names. The naive thing is to use VIRTIO_BALLOON_S_NR but that breaks if we add more stats.

Let's add an array of reasonably readable names.

Thanks for doing this, this is goodness. Clients of this interface will now only require a modification to their internal copy of the header file (if they have one), rather than updating their string array as well.

Quoted 2 lines
Fixes 6c64fe7f2 ("virtio_balloon: export hugetlb page allocation counts")

I think this is a tad bit confusing since the only way you'd know why this patch "fixes" 6c64fe7f2 is by reading the LKML archives and finding Jason's comment.

Quoted 2 lines
Cc Jason Wang <[email protected]>
Cc Jonathan Helman <[email protected]>, > Signed-off-by: Michael S. Tsirkin <[email protected]>
Quoted 30 lines
---
  include/uapi/linux/virtio_balloon.h | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
include/uapi/linux/virtio_balloon.h +14 -0
index 9e02137..1477c17 100644
@@ -64,6 +64,21 @@ struct virtio_balloon_config {
  #define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
  #define VIRTIO_BALLOON_S_NR       10
 
+#define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-out", \
+	VIRTIO_BALLOON_S_NAMES_prefix "major-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "minor-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "free-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "total-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "available-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures" \ > +}
+
+#define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")
+
  /*
   * Memory statistics structure.
   * Driver fills an array of these structures and passes to device.
author maintainer
#3 lore raw
Quoted 17 lines · Jonathan Helman
Quoted 1 line · Michael S. Tsirkin

Jason Wang points out that it's vary hard for users to build an array of

s/vary/very

Quoted 4 lines

stat names. The naive thing is to use VIRTIO_BALLOON_S_NR but that breaks if we add more stats.

Let's add an array of reasonably readable names.

Thanks for doing this, this is goodness. Clients of this interface will now only require a modification to their internal copy of the header file (if they have one), rather than updating their string array as well.

Quoted 1 line
Quoted 5 lines
Quoted 1 line
Fixes 6c64fe7f2 ("virtio_balloon: export hugetlb page allocation counts")

I think this is a tad bit confusing since the only way you'd know why this patch "fixes" 6c64fe7f2 is by reading the LKML archives and finding Jason's comment.

So

... add more stats as recently by commit 6c64fe7f2 ("virtio_balloon: export hugetlb page allocation counts")

Quoted 34 lines
Quoted 2 lines
Cc Jason Wang <[email protected]>
Cc Jonathan Helman <[email protected]>, > Signed-off-by: Michael S. Tsirkin <[email protected]>
Quoted 29 lines
---
  include/uapi/linux/virtio_balloon.h | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
include/uapi/linux/virtio_balloon.h +14 -0
index 9e02137..1477c17 100644
@@ -64,6 +64,21 @@ struct virtio_balloon_config {
  #define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
  #define VIRTIO_BALLOON_S_NR       10
+#define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-out", \
+	VIRTIO_BALLOON_S_NAMES_prefix "major-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "minor-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "free-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "total-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "available-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures" \ > +}
+
+#define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")
+
  /*
   * Memory statistics structure.
   * Driver fills an array of these structures and passes to device.
 
#4 lore raw
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Jonathan Helman
Quoted 1 line · Michael S. Tsirkin

Jason Wang points out that it's vary hard for users to build an array of

s/vary/very

Quoted 4 lines

stat names. The naive thing is to use VIRTIO_BALLOON_S_NR but that breaks if we add more stats.

Let's add an array of reasonably readable names.

Thanks for doing this, this is goodness. Clients of this interface will now only require a modification to their internal copy of the header file (if they have one), rather than updating their string array as well.

Quoted 2 lines
Fixes 6c64fe7f2 ("virtio_balloon: export hugetlb page allocation counts")
Quoted 9 lines
Quoted 3 lines

I think this is a tad bit confusing since the only way you'd know why this patch "fixes" 6c64fe7f2 is by reading the LKML archives and finding Jason's comment.

So

... add more stats as recently by commit 6c64fe7f2 ("virtio_balloon: export hugetlb page allocation counts")

Sure. Thanks.

Jon

Quoted 36 lines
Quoted 36 lines
Quoted 4 lines
Cc Jason Wang <[email protected]>
Cc Jonathan Helman <[email protected]>, > Signed-off-by: Michael S. Tsirkin <[email protected]>
Quoted 29 lines
---
   include/uapi/linux/virtio_balloon.h | 15 +++++++++++++++
   1 file changed, 15 insertions(+)
include/uapi/linux/virtio_balloon.h +14 -0
index 9e02137..1477c17 100644
@@ -64,6 +64,21 @@ struct virtio_balloon_config {
   #define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
   #define VIRTIO_BALLOON_S_NR       10
+#define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-out", \
+	VIRTIO_BALLOON_S_NAMES_prefix "major-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "minor-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "free-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "total-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "available-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures" \ > +}
+
+#define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")
+
   /*
    * Memory statistics structure.
    * Driver fills an array of these structures and passes to device.
 
#5 lore raw
In reply to Michael S. Tsirkin
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Jonathan Helman
Quoted 1 line · Michael S. Tsirkin

Jason Wang points out that it's vary hard for users to build an array of

s/vary/very

Quoted 4 lines

stat names. The naive thing is to use VIRTIO_BALLOON_S_NR but that breaks if we add more stats.

Let's add an array of reasonably readable names.

Thanks for doing this, this is goodness. Clients of this interface will now only require a modification to their internal copy of the header file (if they have one), rather than updating their string array as well.

Quoted 2 lines
Fixes 6c64fe7f2 ("virtio_balloon: export hugetlb page allocation counts")
Quoted 9 lines
Quoted 3 lines

I think this is a tad bit confusing since the only way you'd know why this patch "fixes" 6c64fe7f2 is by reading the LKML archives and finding Jason's comment.

So

... add more stats as recently by commit 6c64fe7f2 ("virtio_balloon: export hugetlb page allocation counts")

Sure. Thanks.

Jon

Quoted 36 lines
Quoted 36 lines
Quoted 4 lines
Cc Jason Wang <[email protected]>
Cc Jonathan Helman <[email protected]>, > Signed-off-by: Michael S. Tsirkin <[email protected]>
Quoted 29 lines
---
   include/uapi/linux/virtio_balloon.h | 15 +++++++++++++++
   1 file changed, 15 insertions(+)
include/uapi/linux/virtio_balloon.h +14 -0
index 9e02137..1477c17 100644
@@ -64,6 +64,21 @@ struct virtio_balloon_config {
   #define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
   #define VIRTIO_BALLOON_S_NR       10
+#define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \
+	VIRTIO_BALLOON_S_NAMES_prefix "swap-out", \
+	VIRTIO_BALLOON_S_NAMES_prefix "major-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "minor-faults", \
+	VIRTIO_BALLOON_S_NAMES_prefix "free-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "total-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "available-memory", \
+	VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures" \ > +}
+
+#define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")
+
   /*
    * Memory statistics structure.
    * Driver fills an array of these structures and passes to device.