From nobody Wed Oct 29 09:10:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525893654680925.1233335769635; Wed, 9 May 2018 12:20:54 -0700 (PDT) Received: from localhost ([::1]:58618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGUdr-00075V-6C for importer@patchew.org; Wed, 09 May 2018 15:20:47 -0400 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 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w49JG4eV003642; Wed, 9 May 2018 19:18:25 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2hv6kp85w5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 May 2018 19:18:25 +0000 Received: from ban25uut181.us.oracle.com (ban25uut181.us.oracle.com [10.153.74.181]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w49JINLF012202; Wed, 9 May 2018 19:18:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=EWVOr4Wv+8TaZuh1K0bCenCRMZqzxnUFbWMoGeqIvRI=; b=F+ipfH/ht5DUnoV6gz3CpDF7EkUDrmBhb9MCHWCBaofi2eZrrns53ovO2hT37emOXrvo XoVQbrXGbfOtbAiIst5vuX77jc2ryDTfyuTNtkA2cvKjnenVcaoBx4BaUviidUpD2oOD OmuYJpPQVVseBDUv7anMEQ9e5p9/llyCKNeZHAyDTQU0AiEEMsQH+uCeiwSfMhozRZ2l vsYmMfpN2GNMCKqLtrCRCtJGnCskQT7wlkDaxGFWJt2lgoiSAe0sCV4xNnOR/sivTC6O DqilmTnef1gPjZEAsqQYIiAmWR9760PqXWYzv9qDfJsHDx3v1LLo8Xju1pwJpb/BC489 Xw== From: Thomas Tai To: mst@redhat.com Date: Wed, 9 May 2018 15:53:05 -0400 Message-Id: <1525895585-79023-2-git-send-email-thomas.tai@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525895585-79023-1-git-send-email-thomas.tai@oracle.com> References: <1525895585-79023-1-git-send-email-thomas.tai@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8888 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805090181 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH V2 1/1] virtio-balloon: fix internal stat name array to match Linux kernel X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.tai@oracle.com, virtio-dev@lists.oasis-open.org, jasowang@redhat.com, rob.gardner@oracle.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Stefan Hajnoczi --- 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 =20 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) } } =20 -static const char *balloon_stat_names[] =3D { - [VIRTIO_BALLOON_S_SWAP_IN] =3D "stat-swap-in", - [VIRTIO_BALLOON_S_SWAP_OUT] =3D "stat-swap-out", - [VIRTIO_BALLOON_S_MAJFLT] =3D "stat-major-faults", - [VIRTIO_BALLOON_S_MINFLT] =3D "stat-minor-faults", - [VIRTIO_BALLOON_S_MEMFREE] =3D "stat-free-memory", - [VIRTIO_BALLOON_S_MEMTOT] =3D "stat-total-memory", - [VIRTIO_BALLOON_S_AVAIL] =3D "stat-available-memory", - [VIRTIO_BALLOON_S_CACHES] =3D "stat-disk-caches", - [VIRTIO_BALLOON_S_NR] =3D NULL -}; +static const char *balloon_stat_names[VIRTIO_BALLOON_S_NR] =3D \ + VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("stat-"); =20 /* * reset_stats - Mark all items in the stats array as unset diff --git a/include/standard-headers/linux/virtio_balloon.h b/include/stan= dard-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 failu= res */ +#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("") =20 /* * Memory statistics structure. --=20 1.8.3.1