From nobody Mon Feb 9 11:47:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573641236; cv=none; d=zoho.com; s=zohoarc; b=MRf9sZehtCYCV9k9IX0z7fpPTdbfIx7i7rsgnxjwawhEmTQct5TeiZi8r0wctkgn1TKwH1r/DH8vK4gVW3g4mBdPONaCLHatevoRWF8dmeVIjukIf6RWvX8dAkPKDMjuKIcoCHvqdY5cDdEFE3hPW0upq3ivkOchySXyYSSKRuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573641236; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YNcpKF4thREkRyA9YnoxFoAhdRnYifQbz1/kExLoMbg=; b=Bxf2dtoLcI5Y3rlIVU+s2tgH1tZBHoiHNeWyD4I31v2Q/0FG5DX2qnuOxnv/jg3O8KabJmQjxU5zqAUfbDJIoraAxz+va360WaC955rgnG6hoVDw4cSUduqfftY+4IkMR6/tm17apbe7B639Mh7QdA3str0wZeeq35v6o7BIXtU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1573641236444217.74746288071935; Wed, 13 Nov 2019 02:33:56 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-173-tpmdsfcaMsCbH50zbrMo4w-1; Wed, 13 Nov 2019 05:33:53 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC6A98048E4; Wed, 13 Nov 2019 10:33:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF5216117E; Wed, 13 Nov 2019 10:33:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 69F474E566; Wed, 13 Nov 2019 10:33:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAD961aU025501 for ; Wed, 13 Nov 2019 04:06:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 394EB10D14E6; Wed, 13 Nov 2019 09:06:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3309B10D14E4 for ; Wed, 13 Nov 2019 09:05:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 109601065053 for ; Wed, 13 Nov 2019 09:05:59 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-o4dehcjtOiyiqLKnVP_O0Q-2; Wed, 13 Nov 2019 04:05:57 -0500 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2019 01:05:55 -0800 Received: from david-unc.bj.intel.com ([10.238.157.59]) by orsmga006.jf.intel.com with ESMTP; 13 Nov 2019 01:05:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573641235; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YNcpKF4thREkRyA9YnoxFoAhdRnYifQbz1/kExLoMbg=; b=MjExYge8MMG4Bx3pCBf+7sbbey2dirctjWw6Fa6MJ21Z3kZmzLhxyWXftRk9juLTSU83qL ot4topZ640IKuU4n6NGElNtv5EOuOI1T1ZcFJK/qGnf7UHfeGHAAY2BAQdVE9YTipYBkBn TYd2z8DGyfTUaFAWArbyyYuMldmKDFU= X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,299,1569308400"; d="scan'208";a="207740836" From: Wang Huaqiang To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 01:08:19 +0800 Message-Id: <20191113170823.17776-2-huaqiang.wang@intel.com> In-Reply-To: <20191113170823.17776-1-huaqiang.wang@intel.com> References: <20191113170823.17776-1-huaqiang.wang@intel.com> MIME-Version: 1.0 X-MC-Unique: o4dehcjtOiyiqLKnVP_O0Q-2 X-MC-Unique: tpmdsfcaMsCbH50zbrMo4w-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xAD961aU025501 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Wed, 13 Nov 2019 05:33:31 -0500 Cc: Huaqiang Subject: [libvirt] [PATCH 1/5] util, resctrl: using 64bit interface instead of 32bit for counters X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Huaqiang The underlying resctrl monitoring is actually using 64 bit counters, not the 32bit one. Correct this by using 64bit interfaces. Signed-off-by: Huaqiang --- src/qemu/qemu_driver.c | 4 ++-- src/util/virfile.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/util/virfile.h | 2 ++ src/util/virresctrl.c | 6 +++--- src/util/virresctrl.h | 2 +- 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f4ff2ba292..e396358871 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20587,8 +20587,8 @@ qemuDomainGetStatsCpuCache(virQEMUDriverPtr driver, "cpu.cache.monitor.%zu.bank.%zu.i= d", i, j) < 0) goto cleanup; =20 - if (virTypedParamListAddUInt(params, resdata[i]->stats[j]->val= s[0], - "cpu.cache.monitor.%zu.bank.%zu.b= ytes", i, j) < 0) + if (virTypedParamListAddULLong(params, resdata[i]->stats[j]->v= als[0], + "cpu.cache.monitor.%zu.bank.%zu= .bytes", i, j) < 0) goto cleanup; } } diff --git a/src/util/virfile.c b/src/util/virfile.c index ced0ea70b7..372498e69e 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -4204,6 +4204,46 @@ virFileReadValueUint(unsigned int *value, const char= *format, ...) } =20 =20 +/** + * virFileReadValueUllong: + * @value: pointer to unsigned long long to be filled in with the value + * @format, ...: file to read from + * + * Read unsigned int from @format and put it into @value. + * + * Return -2 for non-existing file, -1 on other errors and 0 if everything= went + * fine. + */ +int +virFileReadValueUllong(unsigned long long *value, const char *format, ...) +{ + g_autofree char *str =3D NULL; + g_autofree char *path =3D NULL; + va_list ap; + + va_start(ap, format); + path =3D g_strdup_vprintf(format, ap); + va_end(ap); + + if (!virFileExists(path)) + return -2; + + if (virFileReadAll(path, INT_BUFSIZE_BOUND(*value), &str) < 0) + return -1; + + virStringTrimOptionalNewline(str); + + if (virStrToLong_ullp(str, NULL, 10, value) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid unsigned long long value '%s' in file '%= s'"), + str, path); + return -1; + } + + return 0; +} + + /** * virFileReadValueScaledInt: * @value: pointer to unsigned long long int to be filled in with the value diff --git a/src/util/virfile.h b/src/util/virfile.h index a570529330..f77d8501c3 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -363,6 +363,8 @@ int virFileReadValueInt(int *value, const char *format,= ...) G_GNUC_PRINTF(2, 3); int virFileReadValueUint(unsigned int *value, const char *format, ...) G_GNUC_PRINTF(2, 3); +int virFileReadValueUllong(unsigned long long *value, const char *format, = ...) + G_GNUC_PRINTF(2, 3); int virFileReadValueBitmap(virBitmapPtr *value, const char *format, ...) G_GNUC_PRINTF(2, 3); int virFileReadValueScaledInt(unsigned long long *value, const char *forma= t, ...) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index b78fded026..684d2ce398 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2678,7 +2678,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, int rv =3D -1; int ret =3D -1; size_t i =3D 0; - unsigned int val =3D 0; + unsigned long long val =3D 0; DIR *dirp =3D NULL; char *datapath =3D NULL; char *filepath =3D NULL; @@ -2734,8 +2734,8 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, goto cleanup; =20 for (i =3D 0; resources[i]; i++) { - rv =3D virFileReadValueUint(&val, "%s/%s/%s", datapath, - ent->d_name, resources[i]); + rv =3D virFileReadValueUllong(&val, "%s/%s/%s", datapath, + ent->d_name, resources[i]); if (rv =3D=3D -2) { virReportError(VIR_ERR_INTERNAL_ERROR, _("File '%s/%s/%s' does not exist."), diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index 3dd7c96348..11f275acf4 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -204,7 +204,7 @@ struct _virResctrlMonitorStats { char **features; /* @vals store the statistical record values and @val[0] is the value = for * @features[0], @val[1] for@features[1] ... respectively */ - unsigned int *vals; + unsigned long long *vals; /* The length of @vals array */ size_t nvals; }; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list