Skip to contentSkip to conversation

virtio_balloon: export hugetlb page allocation counts

PATCH In review Jonathan Helman 3 participants 22 messages Mar 19, 2018 – Apr 13, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 virtio_balloon: export hugetlb page allocation counts

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

---
 drivers/virtio/virtio_balloon.c     | 6 ++++++
 include/uapi/linux/virtio_balloon.h | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
 				pages_to_bytes(events[PSWPOUT]));
 	update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
 	update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+		    events[HTLB_BUDDY_PGALLOC]);
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+		    events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
 #endif
 	update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
 				pages_to_bytes(i.freeram));
include/uapi/linux/virtio_balloon.h +3 -1
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
 #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
 #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
 #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
 
 /*
  * Memory statistics structure.
Signature · 6 lines
1.8.3.1


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Quoted 27 lines
---
  drivers/virtio/virtio_balloon.c     | 6 ++++++
  include/uapi/linux/virtio_balloon.h | 4 +++-
  2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
  				pages_to_bytes(events[PSWPOUT]));
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+		    events[HTLB_BUDDY_PGALLOC]);
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+		    events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
  #endif
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
  				pages_to_bytes(i.freeram));
include/uapi/linux/virtio_balloon.h +0 -0
index 4e8b830..40297a3 100644

include/uapi/linux/virtio_balloon.h struct virtio_balloon_config { · line 61

Quoted 10 lines
include/uapi/linux/virtio_balloon.h +3 -1
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
  #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
  #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
  #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
 
  /*
   * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Thanks
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#2 lore raw
Quoted 6 lines · Jason Wang

On 2018年03月20日 06:14, Jonathan Helman wrote:

Quoted 8 lines
Quoted 6 lines

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 31 lines
Quoted 31 lines
---
 drivers/virtio/virtio_balloon.c     | 6 ++++++
 include/uapi/linux/virtio_balloon.h | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
 				pages_to_bytes(events[PSWPOUT]));
 	update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
 	update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+		    events[HTLB_BUDDY_PGALLOC]);
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+		    events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
 #endif
 	update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
 				pages_to_bytes(i.freeram));
include/uapi/linux/virtio_balloon.h +0 -0
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
 #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
 #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
 #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
Quoted 8 lines

include/uapi/linux/virtio_balloon.h struct virtio_balloon_config { · line 61

Quoted 6 lines
include/uapi/linux/virtio_balloon.h +3 -1
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
   /*
  * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Sorry, can you explain what you mean here?

Jon

Quoted 2 lines

Thanks

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#3 lore raw
Quoted 51 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 29 lines
Quoted 29 lines
---
  drivers/virtio/virtio_balloon.c     | 6 ++++++
  include/uapi/linux/virtio_balloon.h | 4 +++-
  2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
  				pages_to_bytes(events[PSWPOUT]));
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+		    events[HTLB_BUDDY_PGALLOC]);
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+		    events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
  #endif
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
  				pages_to_bytes(i.freeram));
include/uapi/linux/virtio_balloon.h +0 -0
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
  #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
  #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
Quoted 8 lines

include/uapi/linux/virtio_balloon.h struct virtio_balloon_config { · line 61

Quoted 7 lines
include/uapi/linux/virtio_balloon.h +3 -1
  #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
    /*
   * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Thanks

Quoted 7 lines
Quoted 2 lines

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#4 lore raw
In reply to Jonathan Helman
Quoted 51 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 29 lines
Quoted 29 lines
---
  drivers/virtio/virtio_balloon.c     | 6 ++++++
  include/uapi/linux/virtio_balloon.h | 4 +++-
  2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
  				pages_to_bytes(events[PSWPOUT]));
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+		    events[HTLB_BUDDY_PGALLOC]);
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+		    events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
  #endif
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
  				pages_to_bytes(i.freeram));
include/uapi/linux/virtio_balloon.h +0 -0
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
  #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
  #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
Quoted 8 lines

include/uapi/linux/virtio_balloon.h struct virtio_balloon_config { · line 61

Quoted 7 lines
include/uapi/linux/virtio_balloon.h +3 -1
  #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
    /*
   * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Thanks

Quoted 7 lines
Quoted 2 lines

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

#5 lore raw
Quoted 56 lines · Jason Wang
Quoted 53 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 29 lines
Quoted 29 lines
---
  drivers/virtio/virtio_balloon.c     | 6 ++++++
  include/uapi/linux/virtio_balloon.h | 4 +++-
  2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
  				pages_to_bytes(events[PSWPOUT]));
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+		    events[HTLB_BUDDY_PGALLOC]);
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+		    events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
  #endif
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
  				pages_to_bytes(i.freeram));
include/uapi/linux/virtio_balloon.h +0 -0
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
  #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
  #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
Quoted 8 lines

include/uapi/linux/virtio_balloon.h struct virtio_balloon_config { · line 61

Quoted 7 lines
include/uapi/linux/virtio_balloon.h +3 -1
  #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
    /*
   * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Sorry, can you explain what you mean here?

Quoted 8 lines
Quoted 1 line

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Thanks

Suggestions? I don't like to break build for people ...

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#6 lore raw
In reply to Jason Wang
Quoted 56 lines · Jason Wang
Quoted 53 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 29 lines
Quoted 29 lines
---
  drivers/virtio/virtio_balloon.c     | 6 ++++++
  include/uapi/linux/virtio_balloon.h | 4 +++-
  2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
  				pages_to_bytes(events[PSWPOUT]));
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+		    events[HTLB_BUDDY_PGALLOC]);
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+		    events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
  #endif
  	update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
  				pages_to_bytes(i.freeram));
include/uapi/linux/virtio_balloon.h +0 -0
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
  #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
  #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
Quoted 8 lines

include/uapi/linux/virtio_balloon.h struct virtio_balloon_config { · line 61

Quoted 7 lines
include/uapi/linux/virtio_balloon.h +3 -1
  #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
    /*
   * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Sorry, can you explain what you mean here?

Quoted 8 lines
Quoted 1 line

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Thanks

Suggestions? I don't like to break build for people ...

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

#7 lore raw
Quoted 55 lines · Michael S. Tsirkin
Quoted 54 lines · Jason Wang
Quoted 53 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 29 lines
Quoted 29 lines
---
   drivers/virtio/virtio_balloon.c     | 6 ++++++
   include/uapi/linux/virtio_balloon.h | 4 +++-
   2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
   				pages_to_bytes(events[PSWPOUT]));
   	update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
   	update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+		    events[HTLB_BUDDY_PGALLOC]);
+	update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+		    events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
   #endif
   	update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
   				pages_to_bytes(i.freeram));
include/uapi/linux/virtio_balloon.h +0 -0
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
   #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
   #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
Quoted 8 lines

include/uapi/linux/virtio_balloon.h struct virtio_balloon_config { · line 61

Quoted 7 lines
include/uapi/linux/virtio_balloon.h +3 -1
   #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Sorry, can you explain what you mean here?

Quoted 9 lines
Quoted 7 lines
Quoted 1 line

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#8 lore raw
Quoted 67 lines · Jason Wang
Quoted 64 lines · Michael S. Tsirkin
Quoted 63 lines · Jason Wang
Quoted 54 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 32 lines
Quoted 32 lines

---
   drivers/virtio/virtio_balloon.c     | 6 ++++++
   include/uapi/linux/virtio_balloon.h | 4 +++-

   2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int 
 update_balloon_stats(struct virtio_balloon *vb)
                    pages_to_bytes(events[PSWPOUT]));
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
    #endif
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,

                   pages_to_bytes(i.freeram));

include/uapi/linux/virtio_balloon.h +0 -1
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
Quoted 8 lines
Quoted 7 lines
include/uapi/linux/virtio_balloon.h +1 -0
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page 

allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#9 lore raw
In reply to Jason Wang
Quoted 67 lines · Jason Wang
Quoted 64 lines · Michael S. Tsirkin
Quoted 63 lines · Jason Wang
Quoted 54 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 32 lines
Quoted 32 lines

---
   drivers/virtio/virtio_balloon.c     | 6 ++++++
   include/uapi/linux/virtio_balloon.h | 4 +++-

   2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int 
 update_balloon_stats(struct virtio_balloon *vb)
                    pages_to_bytes(events[PSWPOUT]));
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
    #endif
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,

                   pages_to_bytes(i.freeram));

include/uapi/linux/virtio_balloon.h +0 -1
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
Quoted 8 lines
Quoted 7 lines
include/uapi/linux/virtio_balloon.h +1 -0
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page 

allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

#10 lore raw
Quoted 74 lines · Jonathan Helman
Quoted 71 lines · Jason Wang
Quoted 67 lines · Michael S. Tsirkin
Quoted 57 lines · Jason Wang
Quoted 56 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 32 lines
Quoted 32 lines

---
   drivers/virtio/virtio_balloon.c     | 6 ++++++
   include/uapi/linux/virtio_balloon.h | 4 +++-

   2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int 
 update_balloon_stats(struct virtio_balloon *vb)
                    pages_to_bytes(events[PSWPOUT]));
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
    #endif
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,

                   pages_to_bytes(i.freeram));

include/uapi/linux/virtio_balloon.h +0 -1
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
Quoted 8 lines
Quoted 7 lines
include/uapi/linux/virtio_balloon.h +1 -0
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page 

allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Sorry, can you explain what you mean here?

Quoted 7 lines
Quoted 1 line

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Thanks

Suggestions? I don't like to break build for people ...

Quoted 8 lines
Quoted 3 lines

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Hi Jon:

Have you tested new driver with old qemu?

Thanks

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#11 lore raw
In reply to Jonathan Helman
Quoted 74 lines · Jonathan Helman
Quoted 71 lines · Jason Wang
Quoted 67 lines · Michael S. Tsirkin
Quoted 57 lines · Jason Wang
Quoted 56 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 32 lines
Quoted 32 lines

---
   drivers/virtio/virtio_balloon.c     | 6 ++++++
   include/uapi/linux/virtio_balloon.h | 4 +++-

   2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int 
 update_balloon_stats(struct virtio_balloon *vb)
                    pages_to_bytes(events[PSWPOUT]));
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
    #endif
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,

                   pages_to_bytes(i.freeram));

include/uapi/linux/virtio_balloon.h +0 -1
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
Quoted 8 lines
Quoted 7 lines
include/uapi/linux/virtio_balloon.h +1 -0
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page 

allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Sorry, can you explain what you mean here?

Quoted 7 lines
Quoted 1 line

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Thanks

Suggestions? I don't like to break build for people ...

Quoted 8 lines
Quoted 3 lines

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Hi Jon:

Have you tested new driver with old qemu?

Thanks

#12 lore raw
Quoted 81 lines · Jason Wang
Quoted 78 lines · Jonathan Helman
Quoted 74 lines · Jason Wang
Quoted 58 lines · Michael S. Tsirkin
Quoted 57 lines · Jason Wang
Quoted 56 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 32 lines
Quoted 32 lines

---
   drivers/virtio/virtio_balloon.c     | 6 ++++++
   include/uapi/linux/virtio_balloon.h | 4 +++-

   2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int 
 update_balloon_stats(struct virtio_balloon *vb)
                    pages_to_bytes(events[PSWPOUT]));
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
    #endif
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,

                   pages_to_bytes(i.freeram));

include/uapi/linux/virtio_balloon.h +0 -1
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
Quoted 8 lines
Quoted 7 lines
include/uapi/linux/virtio_balloon.h +1 -0
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page 

allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Sorry, can you explain what you mean here?

Quoted 9 lines
Quoted 7 lines
Quoted 1 line

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

Quoted 8 lines
Quoted 4 lines

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Hi Jon:

Have you tested new driver with old qemu?

Yes, this testing scenario looks good. Thanks.

Jon

Quoted 4 lines

Thanks

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#13 lore raw
Quoted 89 lines · Jonathan Helman
Quoted 86 lines · Jason Wang
Quoted 82 lines · Jonathan Helman
Quoted 67 lines · Jason Wang
Quoted 64 lines · Michael S. Tsirkin
Quoted 63 lines · Jason Wang
Quoted 54 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 32 lines
Quoted 32 lines

---
   drivers/virtio/virtio_balloon.c     | 6 ++++++
   include/uapi/linux/virtio_balloon.h | 4 +++-

   2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int 
 update_balloon_stats(struct virtio_balloon *vb)
 pages_to_bytes(events[PSWPOUT]));
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
    #endif
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,

                   pages_to_bytes(i.freeram));

include/uapi/linux/virtio_balloon.h +0 -1
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
Quoted 8 lines
Quoted 7 lines
include/uapi/linux/virtio_balloon.h +1 -0
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page 

allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Quoted 7 lines
Quoted 3 lines

Hi Jon:

Have you tested new driver with old qemu?

Yes, this testing scenario looks good. Thanks.

Jon

Hi Jon:

I mean e.g compiling qemu with new linux headers. E.g current qemu has:

static const char *balloon_stat_names[] = { [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in", [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out", [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults", [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults", [VIRTIO_BALLOON_S_MEMFREE] = "stat-free-memory", [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory", [VIRTIO_BALLOON_S_AVAIL] = "stat-available-memory", [VIRTIO_BALLOON_S_CACHES] = "stat-disk-caches", [VIRTIO_BALLOON_S_NR] = NULL
};

I'm afraid it will be broken if VIRTIO_BALLOON_S_NR is 10.

Thanks
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#14 lore raw
In reply to Jonathan Helman
Quoted 89 lines · Jonathan Helman
Quoted 86 lines · Jason Wang
Quoted 82 lines · Jonathan Helman
Quoted 67 lines · Jason Wang
Quoted 64 lines · Michael S. Tsirkin
Quoted 63 lines · Jason Wang
Quoted 54 lines · Jonathan Helman
Quoted 12 lines · Jason Wang
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 32 lines
Quoted 32 lines

---
   drivers/virtio/virtio_balloon.c     | 6 ++++++
   include/uapi/linux/virtio_balloon.h | 4 +++-

   2 files changed, 9 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +6 -0
index dfe5684..6b237e3 100644
@@ -272,6 +272,12 @@ static unsigned int 
 update_balloon_stats(struct virtio_balloon *vb)
 pages_to_bytes(events[PSWPOUT]));
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
    #endif
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,

                   pages_to_bytes(i.freeram));

include/uapi/linux/virtio_balloon.h +0 -1
index 4e8b830..40297a3 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
Quoted 8 lines
Quoted 7 lines
include/uapi/linux/virtio_balloon.h +1 -0
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page 

allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend on such number in uapi.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Quoted 7 lines
Quoted 3 lines

Hi Jon:

Have you tested new driver with old qemu?

Yes, this testing scenario looks good. Thanks.

Jon

Hi Jon:

I mean e.g compiling qemu with new linux headers. E.g current qemu has:

static const char *balloon_stat_names[] = { [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in", [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out", [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults", [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults", [VIRTIO_BALLOON_S_MEMFREE] = "stat-free-memory", [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory", [VIRTIO_BALLOON_S_AVAIL] = "stat-available-memory", [VIRTIO_BALLOON_S_CACHES] = "stat-disk-caches", [VIRTIO_BALLOON_S_NR] = NULL
};

I'm afraid it will be broken if VIRTIO_BALLOON_S_NR is 10.

Thanks

#15 lore raw
Quoted 135 lines · Jason Wang
Quoted 108 lines · Jonathan Helman
Quoted 105 lines · Jason Wang
Quoted 101 lines · Jonathan Helman
Quoted 84 lines · Jason Wang
Quoted 81 lines · Michael S. Tsirkin
Quoted 80 lines · Jason Wang
Quoted 68 lines · Jonathan Helman
Quoted 5 lines

On Mar 19, 2018, at 7:31 PM, Jason
Wang<[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 45 lines
Quoted 45 lines

---
   drivers/virtio/virtio_balloon.c     | 6 ++++++
   include/uapi/linux/virtio_balloon.h | 4 +++-

   2 files changed, 9 insertions(+), 1 deletion(-)

diff --git
a/drivers/virtio/virtio_balloon.c
b/drivers/virtio/virtio_balloon.c
index dfe5684..6b237e3 100644

drivers/virtio/virtio_balloon.c +0 -0
@@ -272,6 +272,12 @@ static unsigned int

update_balloon_stats(struct
virtio_balloon *vb)
pages_to_bytes(events[PSWPOUT]));
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MAJFLT,
events[PGMAJFAULT]);
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MINFLT,
events[PGFAULT]);

drivers/virtio/virtio_balloon.c +6 -0
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif

   #endif
       update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE, pages_to_bytes(i.freeram)); diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h
index 4e8b830..40297a3 100644

include/uapi/linux/virtio_balloon.h +1 -1
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5  
 /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6  
 /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC 

8  /* Hugetlb page allocations */

Quoted 8 lines
Quoted 6 lines

+#define VIRTIO_BALLOON_S_HTLB_PGFAIL
9  /* Hugetlb page allocation failures
*/
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that
exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST
ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend
on such number in uapi.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Quoted 7 lines
Quoted 3 lines

Hi Jon:

Have you tested new driver with old qemu?

Yes, this testing scenario looks good. Thanks.

Jon

Hi Jon:

I mean e.g compiling qemu with new linux headers. E.g current qemu has:

static const char *balloon_stat_names[] = { [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in", [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out", [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults", [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults", [VIRTIO_BALLOON_S_MEMFREE] = "stat-free-memory", [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory", [VIRTIO_BALLOON_S_AVAIL] = "stat-available-memory", [VIRTIO_BALLOON_S_CACHES] = "stat-disk-caches", [VIRTIO_BALLOON_S_NR] = NULL
};

Quoted 3 lines

I'm afraid it will be broken if VIRTIO_BALLOON_S_NR is 10.

Thanks

Well it is handy for sizing arrays and this isn't the first time we did this:

commit 4d32029b8ddb7be4d1699c6d8e1675ff5476d149

Author: Tomáš Golembiovský <[email protected]>
Date:   Sun Nov 12 13:05:38 2017 +0100

virtio_balloon: include disk/file caches memory statistics

commit 5057dcd0f1aaad57e07e728ba20a99e205c6b9de

Author: Igor Redko <[email protected]>
Date:   Thu Mar 17 14:19:08 2016 -0700

virtio_balloon: export 'available' memory to balloon statistics

how about we give QEMU a hand and just put the list of names in the header?

I posted a patch like that, pls review.

Signature · 5 lines
MST
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#16 lore raw
In reply to Jason Wang
Quoted 135 lines · Jason Wang
Quoted 108 lines · Jonathan Helman
Quoted 105 lines · Jason Wang
Quoted 101 lines · Jonathan Helman
Quoted 84 lines · Jason Wang
Quoted 81 lines · Michael S. Tsirkin
Quoted 80 lines · Jason Wang
Quoted 68 lines · Jonathan Helman
Quoted 5 lines

On Mar 19, 2018, at 7:31 PM, Jason
Wang<[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 45 lines
Quoted 45 lines

---
   drivers/virtio/virtio_balloon.c     | 6 ++++++
   include/uapi/linux/virtio_balloon.h | 4 +++-

   2 files changed, 9 insertions(+), 1 deletion(-)

diff --git
a/drivers/virtio/virtio_balloon.c
b/drivers/virtio/virtio_balloon.c
index dfe5684..6b237e3 100644

drivers/virtio/virtio_balloon.c +0 -0
@@ -272,6 +272,12 @@ static unsigned int

update_balloon_stats(struct
virtio_balloon *vb)
pages_to_bytes(events[PSWPOUT]));
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MAJFLT,
events[PGMAJFAULT]);
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MINFLT,
events[PGFAULT]);

drivers/virtio/virtio_balloon.c +6 -0
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif

   #endif
       update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE, pages_to_bytes(i.freeram)); diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h
index 4e8b830..40297a3 100644

include/uapi/linux/virtio_balloon.h +1 -1
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5  
 /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6  
 /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC 

8  /* Hugetlb page allocations */

Quoted 8 lines
Quoted 6 lines

+#define VIRTIO_BALLOON_S_HTLB_PGFAIL
9  /* Hugetlb page allocation failures
*/
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that
exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST
ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend
on such number in uapi.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Quoted 7 lines
Quoted 3 lines

Hi Jon:

Have you tested new driver with old qemu?

Yes, this testing scenario looks good. Thanks.

Jon

Hi Jon:

I mean e.g compiling qemu with new linux headers. E.g current qemu has:

static const char *balloon_stat_names[] = { [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in", [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out", [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults", [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults", [VIRTIO_BALLOON_S_MEMFREE] = "stat-free-memory", [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory", [VIRTIO_BALLOON_S_AVAIL] = "stat-available-memory", [VIRTIO_BALLOON_S_CACHES] = "stat-disk-caches", [VIRTIO_BALLOON_S_NR] = NULL
};

Quoted 3 lines

I'm afraid it will be broken if VIRTIO_BALLOON_S_NR is 10.

Thanks

Well it is handy for sizing arrays and this isn't the first time we did this:

commit 4d32029b8ddb7be4d1699c6d8e1675ff5476d149

Author: Tomáš Golembiovský <[email protected]>
Date:   Sun Nov 12 13:05:38 2017 +0100

virtio_balloon: include disk/file caches memory statistics

commit 5057dcd0f1aaad57e07e728ba20a99e205c6b9de

Author: Igor Redko <[email protected]>
Date:   Thu Mar 17 14:19:08 2016 -0700

virtio_balloon: export 'available' memory to balloon statistics

how about we give QEMU a hand and just put the list of names in the header?

I posted a patch like that, pls review.

Signature · 1 line
MST
#17 lore raw
Quoted 155 lines · Michael S. Tsirkin
Quoted 135 lines · Jason Wang
Quoted 108 lines · Jonathan Helman
Quoted 105 lines · Jason Wang
Quoted 101 lines · Jonathan Helman
Quoted 84 lines · Jason Wang
Quoted 81 lines · Michael S. Tsirkin
Quoted 80 lines · Jason Wang
Quoted 68 lines · Jonathan Helman
Quoted 5 lines

On Mar 19, 2018, at 7:31 PM, Jason
Wang<[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 45 lines
Quoted 45 lines
---
    drivers/virtio/virtio_balloon.c     | 6 ++++++
    include/uapi/linux/virtio_balloon.h | 4 +++-
    2 files changed, 9 insertions(+), 1 deletion(-)

diff --git
a/drivers/virtio/virtio_balloon.c
b/drivers/virtio/virtio_balloon.c
index dfe5684..6b237e3 100644

drivers/virtio/virtio_balloon.c +0 -0
@@ -272,6 +272,12 @@ static unsigned int

update_balloon_stats(struct
virtio_balloon *vb)
pages_to_bytes(events[PSWPOUT]));
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MAJFLT,
events[PGMAJFAULT]);
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MINFLT,
events[PGFAULT]);

drivers/virtio/virtio_balloon.c +6 -0
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
    #endif
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
                    pages_to_bytes(i.freeram));

diff --git
a/include/uapi/linux/virtio_balloon.h
b/include/uapi/linux/virtio_balloon.h
index 4e8b830..40297a3 100644

include/uapi/linux/virtio_balloon.h +1 -1
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5
 /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6
 /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC

8  /* Hugetlb page allocations */

Quoted 8 lines
Quoted 6 lines

+#define VIRTIO_BALLOON_S_HTLB_PGFAIL
9  /* Hugetlb page allocation failures
*/
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that
exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST
ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend
on such number in uapi.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Quoted 7 lines
Quoted 3 lines

Hi Jon:

Have you tested new driver with old qemu?

Yes, this testing scenario looks good. Thanks.

Jon

Hi Jon:

I mean e.g compiling qemu with new linux headers. E.g current qemu has:

static const char *balloon_stat_names[] = {
   [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in", [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out", [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults", [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults", [VIRTIO_BALLOON_S_MEMFREE] = "stat-free-memory", [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory", [VIRTIO_BALLOON_S_AVAIL] = "stat-available-memory", [VIRTIO_BALLOON_S_CACHES] = "stat-disk-caches", [VIRTIO_BALLOON_S_NR] = NULL
};

Quoted 3 lines

I'm afraid it will be broken if VIRTIO_BALLOON_S_NR is 10.

Thanks

Well it is handy for sizing arrays and this isn't the first time we did this:

commit 4d32029b8ddb7be4d1699c6d8e1675ff5476d149

Author: Tomáš Golembiovský <[email protected]>
Date:   Sun Nov 12 13:05:38 2017 +0100

virtio_balloon: include disk/file caches memory statistics

commit 5057dcd0f1aaad57e07e728ba20a99e205c6b9de

Author: Igor Redko <[email protected]>
Date:   Thu Mar 17 14:19:08 2016 -0700
Quoted 8 lines

virtio_balloon: export 'available' memory to balloon statistics

how about we give QEMU a hand and just put the list of names in the header?

I posted a patch like that, pls review.

Sorry, maybe I'm missing something. We have an internal copy of the header file in qemu under include/standard-headers/linux/virtio_balloon.h, which hw/virtio/virtio-balloon.c includes (through including hw/virtio/virtio-balloon.h). I thought qemu would use internal header files so that it could be compiled on any Linux kernel version. So when would we ever have the issue Jason is discussing?

Thanks,
Jon
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#18 lore raw
In reply to Michael S. Tsirkin
Quoted 155 lines · Michael S. Tsirkin
Quoted 135 lines · Jason Wang
Quoted 108 lines · Jonathan Helman
Quoted 105 lines · Jason Wang
Quoted 101 lines · Jonathan Helman
Quoted 84 lines · Jason Wang
Quoted 81 lines · Michael S. Tsirkin
Quoted 80 lines · Jason Wang
Quoted 68 lines · Jonathan Helman
Quoted 5 lines

On Mar 19, 2018, at 7:31 PM, Jason
Wang<[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 45 lines
Quoted 45 lines
---
    drivers/virtio/virtio_balloon.c     | 6 ++++++
    include/uapi/linux/virtio_balloon.h | 4 +++-
    2 files changed, 9 insertions(+), 1 deletion(-)

diff --git
a/drivers/virtio/virtio_balloon.c
b/drivers/virtio/virtio_balloon.c
index dfe5684..6b237e3 100644

drivers/virtio/virtio_balloon.c +0 -0
@@ -272,6 +272,12 @@ static unsigned int

update_balloon_stats(struct
virtio_balloon *vb)
pages_to_bytes(events[PSWPOUT]));
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MAJFLT,
events[PGMAJFAULT]);
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MINFLT,
events[PGFAULT]);

drivers/virtio/virtio_balloon.c +6 -0
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
    #endif
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
                    pages_to_bytes(i.freeram));

diff --git
a/include/uapi/linux/virtio_balloon.h
b/include/uapi/linux/virtio_balloon.h
index 4e8b830..40297a3 100644

include/uapi/linux/virtio_balloon.h +1 -1
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5
 /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6
 /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC

8  /* Hugetlb page allocations */

Quoted 8 lines
Quoted 6 lines

+#define VIRTIO_BALLOON_S_HTLB_PGFAIL
9  /* Hugetlb page allocation failures
*/
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that
exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST
ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend
on such number in uapi.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Quoted 7 lines
Quoted 3 lines

Hi Jon:

Have you tested new driver with old qemu?

Yes, this testing scenario looks good. Thanks.

Jon

Hi Jon:

I mean e.g compiling qemu with new linux headers. E.g current qemu has:

static const char *balloon_stat_names[] = {
   [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in", [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out", [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults", [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults", [VIRTIO_BALLOON_S_MEMFREE] = "stat-free-memory", [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory", [VIRTIO_BALLOON_S_AVAIL] = "stat-available-memory", [VIRTIO_BALLOON_S_CACHES] = "stat-disk-caches", [VIRTIO_BALLOON_S_NR] = NULL
};

Quoted 3 lines

I'm afraid it will be broken if VIRTIO_BALLOON_S_NR is 10.

Thanks

Well it is handy for sizing arrays and this isn't the first time we did this:

commit 4d32029b8ddb7be4d1699c6d8e1675ff5476d149

Author: Tomáš Golembiovský <[email protected]>
Date:   Sun Nov 12 13:05:38 2017 +0100

virtio_balloon: include disk/file caches memory statistics

commit 5057dcd0f1aaad57e07e728ba20a99e205c6b9de

Author: Igor Redko <[email protected]>
Date:   Thu Mar 17 14:19:08 2016 -0700
Quoted 8 lines

virtio_balloon: export 'available' memory to balloon statistics

how about we give QEMU a hand and just put the list of names in the header?

I posted a patch like that, pls review.

Sorry, maybe I'm missing something. We have an internal copy of the header file in qemu under include/standard-headers/linux/virtio_balloon.h, which hw/virtio/virtio-balloon.c includes (through including hw/virtio/virtio-balloon.h). I thought qemu would use internal header files so that it could be compiled on any Linux kernel version. So when would we ever have the issue Jason is discussing?

Thanks,
Jon

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

#19 lore raw
Quoted 171 lines · Jonathan Helman
Quoted 153 lines · Michael S. Tsirkin
Quoted 135 lines · Jason Wang
Quoted 108 lines · Jonathan Helman
Quoted 105 lines · Jason Wang
Quoted 101 lines · Jonathan Helman
Quoted 84 lines · Jason Wang
Quoted 81 lines · Michael S. Tsirkin
Quoted 80 lines · Jason Wang
Quoted 68 lines · Jonathan Helman
Quoted 5 lines

On Mar 19, 2018, at 7:31 PM, Jason
Wang<[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 45 lines
Quoted 45 lines
---
    drivers/virtio/virtio_balloon.c     | 6 ++++++
    include/uapi/linux/virtio_balloon.h | 4 +++-
    2 files changed, 9 insertions(+), 1 deletion(-)

diff --git
a/drivers/virtio/virtio_balloon.c
b/drivers/virtio/virtio_balloon.c
index dfe5684..6b237e3 100644

drivers/virtio/virtio_balloon.c +0 -0
@@ -272,6 +272,12 @@ static unsigned int

update_balloon_stats(struct
virtio_balloon *vb)
pages_to_bytes(events[PSWPOUT]));
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MAJFLT,
events[PGMAJFAULT]);
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MINFLT,
events[PGFAULT]);

drivers/virtio/virtio_balloon.c +6 -0
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
    #endif
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
                    pages_to_bytes(i.freeram));

diff --git
a/include/uapi/linux/virtio_balloon.h
b/include/uapi/linux/virtio_balloon.h
index 4e8b830..40297a3 100644

include/uapi/linux/virtio_balloon.h +1 -1
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5
 /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6
 /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC

8  /* Hugetlb page allocations */

Quoted 8 lines
Quoted 6 lines

+#define VIRTIO_BALLOON_S_HTLB_PGFAIL
9  /* Hugetlb page allocation failures
*/
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that
exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST
ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend
on such number in uapi.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Quoted 7 lines
Quoted 3 lines

Hi Jon:

Have you tested new driver with old qemu?

Yes, this testing scenario looks good. Thanks.

Jon

Hi Jon:

I mean e.g compiling qemu with new linux headers. E.g current qemu has:

static const char *balloon_stat_names[] = {
   [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in", [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out", [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults", [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults", [VIRTIO_BALLOON_S_MEMFREE] = "stat-free-memory", [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory", [VIRTIO_BALLOON_S_AVAIL] = "stat-available-memory", [VIRTIO_BALLOON_S_CACHES] = "stat-disk-caches", [VIRTIO_BALLOON_S_NR] = NULL
};

Quoted 3 lines

I'm afraid it will be broken if VIRTIO_BALLOON_S_NR is 10.

Thanks

Well it is handy for sizing arrays and this isn't the first time we did this:

commit 4d32029b8ddb7be4d1699c6d8e1675ff5476d149

Author: Tomáš Golembiovský <[email protected]>
Date:   Sun Nov 12 13:05:38 2017 +0100

virtio_balloon: include disk/file caches memory statistics

commit 5057dcd0f1aaad57e07e728ba20a99e205c6b9de

Author: Igor Redko <[email protected]>
Date:   Thu Mar 17 14:19:08 2016 -0700
Quoted 7 lines

virtio_balloon: export 'available' memory to balloon statistics

how about we give QEMU a hand and just put the list of names in the header?

I posted a patch like that, pls review.

Sorry, maybe I'm missing something. We have an internal copy of the header file in qemu under include/standard-headers/linux/virtio_balloon.h, which hw/virtio/virtio-balloon.c includes (through including hw/virtio/virtio-balloon.h). I thought qemu would use internal header files so that it could be compiled on any Linux kernel version. So when would we ever have the issue Jason is discussing?

Quoted 2 lines

Thanks,
Jon

Whenever we update the headers.

Signature · 5 lines
MST
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#20 lore raw
In reply to Jonathan Helman
Quoted 171 lines · Jonathan Helman
Quoted 153 lines · Michael S. Tsirkin
Quoted 135 lines · Jason Wang
Quoted 108 lines · Jonathan Helman
Quoted 105 lines · Jason Wang
Quoted 101 lines · Jonathan Helman
Quoted 84 lines · Jason Wang
Quoted 81 lines · Michael S. Tsirkin
Quoted 80 lines · Jason Wang
Quoted 68 lines · Jonathan Helman
Quoted 5 lines

On Mar 19, 2018, at 7:31 PM, Jason
Wang<[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

Thanks.

Quoted 45 lines
Quoted 45 lines
---
    drivers/virtio/virtio_balloon.c     | 6 ++++++
    include/uapi/linux/virtio_balloon.h | 4 +++-
    2 files changed, 9 insertions(+), 1 deletion(-)

diff --git
a/drivers/virtio/virtio_balloon.c
b/drivers/virtio/virtio_balloon.c
index dfe5684..6b237e3 100644

drivers/virtio/virtio_balloon.c +0 -0
@@ -272,6 +272,12 @@ static unsigned int

update_balloon_stats(struct
virtio_balloon *vb)
pages_to_bytes(events[PSWPOUT]));
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MAJFLT,
events[PGMAJFAULT]);
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MINFLT,
events[PGFAULT]);

drivers/virtio/virtio_balloon.c +6 -0
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
    #endif
        update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
                    pages_to_bytes(i.freeram));

diff --git
a/include/uapi/linux/virtio_balloon.h
b/include/uapi/linux/virtio_balloon.h
index 4e8b830..40297a3 100644

include/uapi/linux/virtio_balloon.h +1 -1
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
    #define VIRTIO_BALLOON_S_MEMTOT   5
 /* Total amount of memory */
    #define VIRTIO_BALLOON_S_AVAIL    6
 /* Available memory as in /proc */
    #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC

8  /* Hugetlb page allocations */

Quoted 8 lines
Quoted 6 lines

+#define VIRTIO_BALLOON_S_HTLB_PGFAIL
9  /* Hugetlb page allocation failures
*/
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that
exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST
ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend
on such number in uapi.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Quoted 7 lines
Quoted 3 lines

Hi Jon:

Have you tested new driver with old qemu?

Yes, this testing scenario looks good. Thanks.

Jon

Hi Jon:

I mean e.g compiling qemu with new linux headers. E.g current qemu has:

static const char *balloon_stat_names[] = {
   [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in", [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out", [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults", [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults", [VIRTIO_BALLOON_S_MEMFREE] = "stat-free-memory", [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory", [VIRTIO_BALLOON_S_AVAIL] = "stat-available-memory", [VIRTIO_BALLOON_S_CACHES] = "stat-disk-caches", [VIRTIO_BALLOON_S_NR] = NULL
};

Quoted 3 lines

I'm afraid it will be broken if VIRTIO_BALLOON_S_NR is 10.

Thanks

Well it is handy for sizing arrays and this isn't the first time we did this:

commit 4d32029b8ddb7be4d1699c6d8e1675ff5476d149

Author: Tomáš Golembiovský <[email protected]>
Date:   Sun Nov 12 13:05:38 2017 +0100

virtio_balloon: include disk/file caches memory statistics

commit 5057dcd0f1aaad57e07e728ba20a99e205c6b9de

Author: Igor Redko <[email protected]>
Date:   Thu Mar 17 14:19:08 2016 -0700
Quoted 7 lines

virtio_balloon: export 'available' memory to balloon statistics

how about we give QEMU a hand and just put the list of names in the header?

I posted a patch like that, pls review.

Sorry, maybe I'm missing something. We have an internal copy of the header file in qemu under include/standard-headers/linux/virtio_balloon.h, which hw/virtio/virtio-balloon.c includes (through including hw/virtio/virtio-balloon.h). I thought qemu would use internal header files so that it could be compiled on any Linux kernel version. So when would we ever have the issue Jason is discussing?

Quoted 2 lines

Thanks,
Jon

Whenever we update the headers.

Signature · 1 line
MST
#21 lore raw
Quoted 172 lines · Michael S. Tsirkin
Quoted 171 lines · Jonathan Helman
Quoted 153 lines · Michael S. Tsirkin
Quoted 135 lines · Jason Wang
Quoted 108 lines · Jonathan Helman
Quoted 105 lines · Jason Wang
Quoted 101 lines · Jonathan Helman
Quoted 84 lines · Jason Wang
Quoted 81 lines · Michael S. Tsirkin
Quoted 80 lines · Jason Wang
Quoted 68 lines · Jonathan Helman
Quoted 5 lines

On Mar 19, 2018, at 7:31 PM, Jason
Wang<[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines · Jonathan Helman

Export the number of successful and failed hugetlb page
allocations via the virtio balloon driver. These 2 counts
come directly from the vm_events HTLB_BUDDY_PGALLOC and
HTLB_BUDDY_PGALLOC_FAIL.

Signed-off-by: Jonathan Helman<[email protected]>

Thanks.

Quoted 45 lines
Quoted 45 lines

---
   drivers/virtio/virtio_balloon.c     | 6 ++++++
   include/uapi/linux/virtio_balloon.h | 4 +++-
   2 files changed, 9 insertions(+), 1 deletion(-)

diff --git
a/drivers/virtio/virtio_balloon.c
b/drivers/virtio/virtio_balloon.c
index dfe5684..6b237e3 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -272,6 +272,12 @@ static unsigned int
update_balloon_stats(struct
virtio_balloon *vb)
pages_to_bytes(events[PSWPOUT]));
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MAJFLT,
events[PGMAJFAULT]);
       update_stat(vb, idx++,
VIRTIO_BALLOON_S_MINFLT,
events[PGFAULT]);
+#ifdef CONFIG_HUGETLB_PAGE
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+            events[HTLB_BUDDY_PGALLOC]);
+    update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGFAIL,
+            events[HTLB_BUDDY_PGALLOC_FAIL]);
+#endif
   #endif
       update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
                   pages_to_bytes(i.freeram));
diff --git
a/include/uapi/linux/virtio_balloon.h
b/include/uapi/linux/virtio_balloon.h
index 4e8b830..40297a3 100644
--- a/include/uapi/linux/virtio_balloon.h
+++ b/include/uapi/linux/virtio_balloon.h
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
   #define VIRTIO_BALLOON_S_MEMTOT   5
/* Total amount of memory */
   #define VIRTIO_BALLOON_S_AVAIL    6
/* Available memory as in /proc */
   #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC
8  /* Hugetlb page allocations */

Quoted 8 lines
Quoted 6 lines

+#define VIRTIO_BALLOON_S_HTLB_PGFAIL
9  /* Hugetlb page allocation failures
*/
+#define VIRTIO_BALLOON_S_NR       10
     /*
    * Memory statistics structure.

Not for this patch, but it looks to me that
exporting such nr through uapi is fragile.

Quoted 3 lines

Sorry, can you explain what you mean here?

Jon

Spec said "Within an output buffer submitted to the statsq, the device MUST
ignore entries with tag values that it does not recognize". So exporting VIRTIO_BALLOON_S_NR seems useless and device implementation can not depend
on such number in uapi.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thanks

Suggestions? I don't like to break build for people ...

Didn't have a good idea. But maybe we should keep VIRTIO_BALLOON_S_NR unchanged, and add a comment here.

Thanks

I think Jason's comment is for a future patch. Didn't see this patch get applied, so wondering if it could be.

Thanks,
Jon

Quoted 7 lines
Quoted 3 lines

Hi Jon:

Have you tested new driver with old qemu?

Yes, this testing scenario looks good. Thanks.

Jon

Hi Jon:

I mean e.g compiling qemu with new linux headers. E.g current qemu has:

static const char *balloon_stat_names[] = {
   [VIRTIO_BALLOON_S_SWAP_IN] = "stat-swap-in", [VIRTIO_BALLOON_S_SWAP_OUT] = "stat-swap-out", [VIRTIO_BALLOON_S_MAJFLT] = "stat-major-faults", [VIRTIO_BALLOON_S_MINFLT] = "stat-minor-faults", [VIRTIO_BALLOON_S_MEMFREE] = "stat-free-memory", [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory", [VIRTIO_BALLOON_S_AVAIL] = "stat-available-memory", [VIRTIO_BALLOON_S_CACHES] = "stat-disk-caches", [VIRTIO_BALLOON_S_NR] = NULL
};

Quoted 3 lines

I'm afraid it will be broken if VIRTIO_BALLOON_S_NR is 10.

Thanks

Well it is handy for sizing arrays and this isn't the first time we did this:

commit 4d32029b8ddb7be4d1699c6d8e1675ff5476d149

Author: Tomáš Golembiovský <[email protected]>
Date:   Sun Nov 12 13:05:38 2017 +0100

virtio_balloon: include disk/file caches memory statistics

commit 5057dcd0f1aaad57e07e728ba20a99e205c6b9de

Author: Igor Redko <[email protected]>
Date:   Thu Mar 17 14:19:08 2016 -0700
Quoted 7 lines

virtio_balloon: export 'available' memory to balloon statistics

how about we give QEMU a hand and just put the list of names in the header?

I posted a patch like that, pls review.

Sorry, maybe I'm missing something. We have an internal copy of the header file in qemu under include/standard-headers/linux/virtio_balloon.h, which hw/virtio/virtio-balloon.c includes (through including hw/virtio/virtio-balloon.h). I thought qemu would use internal header files so that it could be compiled on any Linux kernel version. So when would we ever have the issue Jason is discussing?

Quoted 5 lines
Quoted 2 lines

Thanks,
Jon

Whenever we update the headers.

Ah got it. Updating the headers without updating that string array breaks things. Thanks.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization