From nobody Tue Feb 10 01:15:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1564382375; cv=none; d=zoho.com; s=zohoarc; b=GI39Mw8N+h5OjDNlzmcuZ4TQV0vqRVVjWJbYrjmdVrKiQCIsOg2X+hXCpgiSHOyP1ehuk3lqrxOs0hg95XZyl1lxX5q9/Bqog6nXRbXiIfJ8XYXJZ4v27rCpCiqK5q85D+Pg/pVxJijoMfvaXLUzLl59HMqThsCL5qT94S4BGqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564382375; h=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:ARC-Authentication-Results; bh=eSOlTHCf1tHdXlbSjYW07EFh+2eDYRkQsMm80a4V/wk=; b=ajo9KcOCpowfe81hnUjJoG6waVa0ia8Rvxxs2+P1SesZwa6AeTBpeUU36Up3TDZxs+Lt+ZtMUgbeQXDtkGEYgrfTOtxyyDSYSJQVDqMSBMLpMn0cpgUIxzBjgbCICciD5uS5LY11ZB+VpE3J94P0UBBjPIs/1DgtrkDHJmVJ47Q= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564382375292545.8803019991898; Sun, 28 Jul 2019 23:39:35 -0700 (PDT) Received: from localhost ([::1]:49910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hrzJm-00084B-8V for importer@patchew.org; Mon, 29 Jul 2019 02:39:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54245) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hrzCg-0005OI-DL for qemu-devel@nongnu.org; Mon, 29 Jul 2019 02:32:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hrzCd-0001tB-Qb for qemu-devel@nongnu.org; Mon, 29 Jul 2019 02:32:14 -0400 Received: from mga11.intel.com ([192.55.52.93]:47116) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hrzCd-0001Br-54 for qemu-devel@nongnu.org; Mon, 29 Jul 2019 02:32:11 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jul 2019 23:31:52 -0700 Received: from tao-optiplex-7060.sh.intel.com ([10.239.159.37]) by fmsmga005.fm.intel.com with ESMTP; 28 Jul 2019 23:31:50 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,321,1559545200"; d="scan'208";a="370357314" From: Tao Xu To: imammedo@redhat.com, eblake@redhat.com, ehabkost@redhat.com Date: Mon, 29 Jul 2019 14:31:26 +0800 Message-Id: <20190729063127.2801-11-tao3.xu@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190729063127.2801-1-tao3.xu@intel.com> References: <20190729063127.2801-1-tao3.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Subject: [Qemu-devel] [PATCH v8 10/11] numa: Extend the CLI to provide memory side cache information X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jingqi.liu@intel.com, tao3.xu@intel.com, fan.du@intel.com, qemu-devel@nongnu.org, jonathan.cameron@huawei.com, dan.j.williams@intel.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Liu Jingqi Add -numa hmat-cache option to provide Memory Side Cache Information. These memory attributes help to build Memory Side Cache Information Structure(s) in ACPI Heterogeneous Memory Attribute Table (HMAT). Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu --- No changes in v8. --- hw/core/numa.c | 67 +++++++++++++++++++++++++++++++++++ include/sysemu/numa.h | 2 ++ qapi/machine.json | 81 +++++++++++++++++++++++++++++++++++++++++-- qemu-options.hx | 14 +++++++- 4 files changed, 161 insertions(+), 3 deletions(-) diff --git a/hw/core/numa.c b/hw/core/numa.c index 83ead77191..75db35ac19 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -304,6 +304,67 @@ void parse_numa_hmat_lb(MachineState *ms, NumaHmatLBOp= tions *node, } } =20 +void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node, + Error **errp) +{ + int nb_numa_nodes =3D ms->numa_state->num_nodes; + HMAT_Cache_Info *hmat_cache =3D NULL; + + if (node->node_id >=3D nb_numa_nodes) { + error_setg(errp, "Invalid node-id=3D%" PRIu32 + ", it should be less than %d.", + node->node_id, nb_numa_nodes); + return; + } + + if (node->total > MAX_HMAT_CACHE_LEVEL) { + error_setg(errp, "Invalid total=3D%" PRIu8 + ", it should be less than or equal to %d.", + node->total, MAX_HMAT_CACHE_LEVEL); + return; + } + if (node->level > node->total) { + error_setg(errp, "Invalid level=3D%" PRIu8 + ", it should be less than or equal to" + " total=3D%" PRIu8 ".", + node->level, node->total); + return; + } + if (ms->numa_state->hmat_cache[node->node_id][node->level]) { + error_setg(errp, "Duplicate configuration of the side cache for " + "node-id=3D%" PRIu32 " and level=3D%" PRIu8 ".", + node->node_id, node->level); + return; + } + + if ((node->level > 1) && + ms->numa_state->hmat_cache[node->node_id][node->level - 1] && + (node->size >=3D + ms->numa_state->hmat_cache[node->node_id][node->level - 1]->si= ze)) { + error_setg(errp, "Invalid size=3D0x%" PRIx64 + ", the size of level=3D%" PRIu8 + " should be less than the size(0x%" PRIx64 + ") of level=3D%" PRIu8 ".", + node->size, node->level, + ms->numa_state->hmat_cache[node->node_id] + [node->level - 1]->size, + node->level - 1); + return; + } + + hmat_cache =3D g_malloc0(sizeof(*hmat_cache)); + + hmat_cache->mem_proximity =3D node->node_id; + hmat_cache->size =3D node->size; + hmat_cache->total_levels =3D node->total; + hmat_cache->level =3D node->level; + hmat_cache->associativity =3D node->assoc; + hmat_cache->write_policy =3D node->policy; + hmat_cache->line_size =3D node->line; + + ms->numa_state->hmat_cache[node->node_id][node->level] =3D hmat_cache; +} + void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp) { Error *err =3D NULL; @@ -348,6 +409,12 @@ void set_numa_options(MachineState *ms, NumaOptions *o= bject, Error **errp) goto end; } break; + case NUMA_OPTIONS_TYPE_HMAT_CACHE: + parse_numa_hmat_cache(ms, &object->u.hmat_cache, &err); + if (err) { + goto end; + } + break; default: abort(); } diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index f0857b7ee6..9009bbdee3 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -43,6 +43,8 @@ void set_numa_options(MachineState *ms, NumaOptions *obje= ct, Error **errp); void parse_numa_opts(MachineState *ms); void parse_numa_hmat_lb(MachineState *ms, NumaHmatLBOptions *node, Error **errp); +void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node, + Error **errp); void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[], MachineState *ms); extern QemuOptsList qemu_numa_opts; diff --git a/qapi/machine.json b/qapi/machine.json index 25f5b0321d..65a3584b92 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -379,10 +379,12 @@ # # @hmat-lb: memory latency and bandwidth information (Since: 4.2) # +# @hmat-cache: memory side cache information (Since: 4.2) +# # Since: 2.1 ## { 'enum': 'NumaOptionsType', - 'data': [ 'node', 'dist', 'cpu', 'hmat-lb' ] } + 'data': [ 'node', 'dist', 'cpu', 'hmat-lb', 'hmat-cache' ] } =20 ## # @NumaOptions: @@ -398,7 +400,8 @@ 'node': 'NumaNodeOptions', 'dist': 'NumaDistOptions', 'cpu': 'NumaCpuOptions', - 'hmat-lb': 'NumaHmatLBOptions' }} + 'hmat-lb': 'NumaHmatLBOptions', + 'hmat-cache': 'NumaHmatCacheOptions' }} =20 ## # @NumaNodeOptions: @@ -600,6 +603,80 @@ '*latency': 'uint16', '*bandwidth': 'uint16' }} =20 +## +# @HmatCacheAssociativity: +# +# Cache associativity in the Memory Side Cache +# Information Structure of HMAT +# +# For more information of @HmatCacheAssociativity see +# the chapter 5.2.27.5: Table 5-143 of ACPI 6.3 spec. +# +# @none: None +# +# @direct: Direct Mapped +# +# @complex: Complex Cache Indexing (implementation specific) +# +# Since: 4.2 +## +{ 'enum': 'HmatCacheAssociativity', + 'data': [ 'none', 'direct', 'complex' ] } + +## +# @HmatCacheWritePolicy: +# +# Cache write policy in the Memory Side Cache +# Information Structure of HMAT +# +# For more information of @HmatCacheWritePolicy see +# the chapter 5.2.27.5: Table 5-143: Field "Cache Attributes" of ACPI 6.3 = spec. +# +# @none: None +# +# @write-back: Write Back (WB) +# +# @write-through: Write Through (WT) +# +# Since: 4.2 +## +{ 'enum': 'HmatCacheWritePolicy', + 'data': [ 'none', 'write-back', 'write-through' ] } + +## +# @NumaHmatCacheOptions: +# +# Set the memory side cache information for a given memory domain. +# +# For more information of @NumaHmatCacheOptions see +# the chapter 5.2.27.5: Table 5-143: Field "Cache Attributes" of ACPI 6.3 = spec. +# +# @node-id: the memory proximity domain to which the memory belongs. +# +# @size: the size of memory side cache in bytes. +# +# @total: the total cache levels for this memory proximity domain. +# +# @level: the cache level described in this structure. +# +# @assoc: the cache associativity, none/direct-mapped/complex(complex cach= e indexing). +# +# @policy: the write policy, none/write-back/write-through. +# +# @line: the cache Line size in bytes. +# +# Since: 4.2 +## +{ 'struct': 'NumaHmatCacheOptions', + 'data': { + 'node-id': 'uint32', + 'size': 'size', + 'total': 'uint8', + 'level': 'uint8', + 'assoc': 'HmatCacheAssociativity', + 'policy': 'HmatCacheWritePolicy', + 'line': 'uint16' }} + ## # @HostMemPolicy: # diff --git a/qemu-options.hx b/qemu-options.hx index 609ea40086..5f3b2fd234 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -165,7 +165,8 @@ DEF("numa", HAS_ARG, QEMU_OPTION_numa, "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode][= ,initiator=3Dnode]\n" "-numa dist,src=3Dsource,dst=3Ddestination,val=3Ddistance\n" "-numa cpu,node-id=3Dnode[,socket-id=3Dx][,core-id=3Dy][,thread-id=3Dz= ]\n" - "-numa hmat-lb,initiator=3Dnode,target=3Dnode,hierarchy=3Dmemory|first= -level|second-level|third-level,data-type=3Daccess-latency|read-latency|wri= te-latency[,base-lat=3Dblat][,base-bw=3Dbbw][,latency=3Dlat][,bandwidth=3Db= w]\n", + "-numa hmat-lb,initiator=3Dnode,target=3Dnode,hierarchy=3Dmemory|first= -level|second-level|third-level,data-type=3Daccess-latency|read-latency|wri= te-latency[,base-lat=3Dblat][,base-bw=3Dbbw][,latency=3Dlat][,bandwidth=3Db= w]\n" + "-numa hmat-cache,node-id=3Dnode,size=3Dsize,total=3Dtotal,level=3Dlev= el[,assoc=3Dnone|direct|complex][,policy=3Dnone|write-back|write-through][,= line=3Dsize]\n", QEMU_ARCH_ALL) STEXI @item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}][,initiator=3D@var{initiator}] @@ -173,6 +174,7 @@ STEXI @itemx -numa dist,src=3D@var{source},dst=3D@var{destination},val=3D@var{di= stance} @itemx -numa cpu,node-id=3D@var{node}[,socket-id=3D@var{x}][,core-id=3D@va= r{y}][,thread-id=3D@var{z}] @itemx -numa hmat-lb,initiator=3D@var{node},target=3D@var{node},hierarchy= =3D@var{str},data-type=3D@var{str}[,base-lat=3D@var{blat}][,base-bw=3D@var{= bbw}][,latency=3D@var{lat}][,bandwidth=3D@var{bw}] +@itemx -numa hmat-cache,node-id=3D@var{node},size=3D@var{size},total=3D@va= r{total},level=3D@var{level}[,assoc=3D@var{str}][,policy=3D@var{str}][,line= =3D@var{size}] @findex -numa Define a NUMA node and assign RAM and VCPUs to it. Set the NUMA distance from a source node to a destination node. @@ -275,11 +277,19 @@ Note: Due to the minimum matrix value entry value bei= ng 10, the base unit corres to a value of 10. And @var{blat} or @var{bbw} should be an integer. @var{l= at} or @var{bw} is the latency/bandwidth value. =20 +In @samp{hmat-cache} option, @var{node-id} is the NUMA-id of the memory be= longs. +@var{size} is the size of memory side cache in bytes. @var{total} is the t= otal cache levels. +@var{level} is the cache level described in this structure. @var{assoc} is= the cache associativity. +"none/direct-mapped/complex(complex cache indexing). @var{policy} is the w= rite policy. +@var{line} is the cache Line size in bytes. + For example, the following option assigns NUMA node 0 and 1. Node 0 has 2 = cpus and a ram, node 1 has only a ram. The processors in node 0 access memory in no= de 0 with access-latency 5 picoseconds(base latency is 10), access-bandwidth = 5 MB/s(base latency is 20); The processors in NUMA node 0 access memory in NUMA node 1 with access-lat= ency 10 picoseconds(base latency is 10), access-bandwidth 10 MB/s(base latency is = 20). +And for memory side cache information, NUMA node 0 and 1 both have 1 level= memory +cache, size is 0x20000 bytes, policy is write-back, the cache Line size is= 8 bytes: @example -m 2G \ -object memory-backend-ram,size=3D1024M,policy=3Dbind,host-nodes=3D0,id=3D= ram-node0 -numa node,nodeid=3D0,memdev=3Dram-node0 \ @@ -291,6 +301,8 @@ picoseconds(base latency is 10), access-bandwidth 10 MB= /s(base latency is 20). -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,base-bw=3D20,bandwidth=3D5 \ -numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-latency,base-lat=3D10,latency=3D10 \ -numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,base-bw=3D20,bandwidth=3D10 \ +-numa hmat-cache,node-id=3D0,size=3D0x20000,total=3D1,level=3D1,assoc=3Ddi= rect,policy=3Dwrite-back,line=3D8 \ +-numa hmat-cache,node-id=3D1,size=3D0x20000,total=3D1,level=3D1,assoc=3Ddi= rect,policy=3Dwrite-back,line=3D8 \ @end example =20 ETEXI --=20 2.20.1