From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGUbg-00054W-QZ for qemu-devel@nongnu.org; Wed, 09 May 2018 15:18:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGUbd-0002A8-IE for qemu-devel@nongnu.org; Wed, 09 May 2018 15:18:32 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:48590) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fGUbd-00029Y-7z for qemu-devel@nongnu.org; Wed, 09 May 2018 15:18:29 -0400 From: Thomas Tai Date: Wed, 9 May 2018 15:53:05 -0400 Message-Id: <1525895585-79023-2-git-send-email-thomas.tai@oracle.com> In-Reply-To: <1525895585-79023-1-git-send-email-thomas.tai@oracle.com> References: <1525895585-79023-1-git-send-email-thomas.tai@oracle.com> Subject: [Qemu-devel] [PATCH V2 1/1] virtio-balloon: fix internal stat name array to match Linux kernel List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mst@redhat.com Cc: jasowang@redhat.com, virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org, rob.gardner@oracle.com, thomas.tai@oracle.com The Linux kernel commit b40000325044 ("virtio_balloon: add array of stat names") defines an array of stat name strings for consumers of the virtio interface to use via the virtio_balloon.h header file, rather than requiring each consumer to define its own. But at present, the stat names defined in this array by the Linux kernel do not match up with those defined internally by QEMU. This patch fixes this inconsistency by importing the header file from linux and use the new macro to construct the balloon_stat_names array. Signed-off-by: Jonathan Helman Signed-off-by: Thomas Tai Cc: Rob Gardner --- docs/virtio-balloon-stats.txt | 2 ++ hw/virtio/virtio-balloon.c | 13 ++----------- include/standard-headers/linux/virtio_balloon.h | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/docs/virtio-balloon-stats.txt b/docs/virtio-balloon-stats.txt index 7a66d25..7c69fdb 100644 --- a/docs/virtio-balloon-stats.txt +++ b/docs/virtio-balloon-stats.txt @@ -34,6 +34,8 @@ which will return a dictionary containing: - stat-total-memory - stat-available-memory - stat-disk-caches + - stat-hugetlb-allocations + - stat-hugetlb-failures o A key named last-update, which contains the last stats update timestamp in seconds. Since this timestamp is generated by the host, diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index f456cea..646f2e0 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -43,17 +43,8 @@ static void balloon_page(void *addr, int deflate) } } -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 -}; +static const char *balloon_stat_names[VIRTIO_BALLOON_S_NR] = \ + VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("stat-"); /* * reset_stats - Mark all items in the stats array as unset diff --git a/include/standard-headers/linux/virtio_balloon.h b/include/standard-headers/linux/virtio_balloon.h index 7b0a41b..4dbb7dc 100644 --- a/include/standard-headers/linux/virtio_balloon.h +++ b/include/standard-headers/linux/virtio_balloon.h @@ -53,7 +53,24 @@ 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 + +#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. -- 1.8.3.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: virtio-dev-return-4056-cohuck=redhat.com@lists.oasis-open.org Sender: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Received: from lists.oasis-open.org (oasis-open.org [66.179.20.138]) by lists.oasis-open.org (Postfix) with ESMTP id 5D8F85818FBB for ; Wed, 9 May 2018 12:18:36 -0700 (PDT) From: Thomas Tai Date: Wed, 9 May 2018 15:53:05 -0400 Message-Id: <1525895585-79023-2-git-send-email-thomas.tai@oracle.com> In-Reply-To: <1525895585-79023-1-git-send-email-thomas.tai@oracle.com> References: <1525895585-79023-1-git-send-email-thomas.tai@oracle.com> Subject: [virtio-dev] [PATCH V2 1/1] virtio-balloon: fix internal stat name array to match Linux kernel To: mst@redhat.com Cc: jasowang@redhat.com, virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org, rob.gardner@oracle.com, thomas.tai@oracle.com List-ID: The Linux kernel commit b40000325044 ("virtio_balloon: add array of stat names") defines an array of stat name strings for consumers of the virtio interface to use via the virtio_balloon.h header file, rather than requiring each consumer to define its own. But at present, the stat names defined in this array by the Linux kernel do not match up with those defined internally by QEMU. This patch fixes this inconsistency by importing the header file from linux and use the new macro to construct the balloon_stat_names array. Signed-off-by: Jonathan Helman Signed-off-by: Thomas Tai Cc: Rob Gardner --- docs/virtio-balloon-stats.txt | 2 ++ hw/virtio/virtio-balloon.c | 13 ++----------- include/standard-headers/linux/virtio_balloon.h | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/docs/virtio-balloon-stats.txt b/docs/virtio-balloon-stats.txt index 7a66d25..7c69fdb 100644 --- a/docs/virtio-balloon-stats.txt +++ b/docs/virtio-balloon-stats.txt @@ -34,6 +34,8 @@ which will return a dictionary containing: - stat-total-memory - stat-available-memory - stat-disk-caches + - stat-hugetlb-allocations + - stat-hugetlb-failures o A key named last-update, which contains the last stats update timestamp in seconds. Since this timestamp is generated by the host, diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index f456cea..646f2e0 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -43,17 +43,8 @@ static void balloon_page(void *addr, int deflate) } } -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 -}; +static const char *balloon_stat_names[VIRTIO_BALLOON_S_NR] = \ + VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("stat-"); /* * reset_stats - Mark all items in the stats array as unset diff --git a/include/standard-headers/linux/virtio_balloon.h b/include/standard-headers/linux/virtio_balloon.h index 7b0a41b..4dbb7dc 100644 --- a/include/standard-headers/linux/virtio_balloon.h +++ b/include/standard-headers/linux/virtio_balloon.h @@ -53,7 +53,24 @@ 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 + +#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. -- 1.8.3.1 --------------------------------------------------------------------- To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org