Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1450357imu; Tue, 11 Dec 2018 20:57:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/WH+MS0ljBCbCApevGKCW4RDQHSuJnEh8C6O+jkAbPfi+Tm5iLemYVdqbpeyDenqs1cU3DG X-Received: by 2002:a63:3858:: with SMTP id h24mr16485604pgn.300.1544590665569; Tue, 11 Dec 2018 20:57:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544590665; cv=none; d=google.com; s=arc-20160816; b=zZREZsobugL7OcPlKiFiU501Yu1a8cRbXU3eT1Gw/xJ9EW4vnHlt2qaqB6yb6ZD2Z2 mEruxMO4JglnM6cJ5ha4bvGIbpJrlmVnaH9VjNDNQr7KLh5gn227GZZCmVpY9KqGAdMr A4sMvSX8jvL7BZx/kB2L3qa+6rN8Va9D4HVDcuiJmJBWd00f1UDq/qhFaz9erU2p6J8x zOLLBapBBxkXfnrPAgatkkii98hgIPTgLahcu3Dxmi1GfXWhvp7AfBTHRmgoP1+xQM6h 4iYzCK2UEIQ3g9i4n0AlBBAYSYI4Oo3odhGGLjEu4ValR2nzMA7Vz3hQrlokdClJFNNP rDIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject; bh=DjN45IdZ4wNzkinbxbQ+rBdcD8zD54gsy+K6RFfZ2m8=; b=yKMLSA/hAZ2ARF21qEnPDVzP1cBt017osJszpM+jbIGApIPavz1mgDFGTnp7vF6CqQ gPuOZgz2kSe6CCOhFQSynecdH9pvM+ofO1yp+glEj9y81sMz9OAoMRYI3jJEp6m8pdn8 oQQdNs1Ghekpb9XmAONLai+KeBvBECYncXFiz0hSmWh/HVpm9gJ7Lg/W0/BZkGOIlxTD VQIUraz3mR3iyDuHYPYfi92JdQLwmxBq6piQXztjzF4sn9rXvi7i6+s5nXiUjdhFjfmq HEXWKa/yW+5NpZH2n7ee65EGEltTTBeF0KoVBsK/Hz2Y+Kp8LCy09cF2+5x9TZVT1TYL 5q3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si13798059pgi.89.2018.12.11.20.57.28; Tue, 11 Dec 2018 20:57:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726263AbeLLE4e (ORCPT + 99 others); Tue, 11 Dec 2018 23:56:34 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51054 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbeLLE4e (ORCPT ); Tue, 11 Dec 2018 23:56:34 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wBC4uToI051409 for ; Tue, 11 Dec 2018 23:56:33 -0500 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2par2q7xg2-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 11 Dec 2018 23:56:31 -0500 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Dec 2018 04:53:32 -0000 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Dec 2018 04:53:29 -0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wBC4rSTp23658522 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Dec 2018 04:53:28 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1FB63AE05C; Wed, 12 Dec 2018 04:53:28 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED725AE05F; Wed, 12 Dec 2018 04:53:25 +0000 (GMT) Received: from [9.85.73.10] (unknown [9.85.73.10]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 12 Dec 2018 04:53:25 +0000 (GMT) Subject: Re: [PATCHv2 12/12] doc/mm: New documentation for memory performance To: Keith Busch , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org Cc: Greg Kroah-Hartman , Rafael Wysocki , Dave Hansen , Dan Williams References: <20181211010310.8551-1-keith.busch@intel.com> <20181211010310.8551-13-keith.busch@intel.com> From: "Aneesh Kumar K.V" Date: Wed, 12 Dec 2018 10:23:24 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <20181211010310.8551-13-keith.busch@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18121204-0060-0000-0000-000002E2AE1A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010214; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000270; SDB=6.01130525; UDB=6.00587459; IPR=6.00910658; MB=3.00024660; MTD=3.00000008; XFM=3.00000015; UTC=2018-12-12 04:53:31 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18121204-0061-0000-0000-00004781D05C Message-Id: <681f14eb-def4-bf40-fdfd-b5fb89045132@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-12-12_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812120041 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/11/18 6:33 AM, Keith Busch wrote: > Platforms may provide system memory where some physical address ranges > perform differently than others, or is side cached by the system. > > Add documentation describing a high level overview of such systems and the > performance and caching attributes the kernel provides for applications > wishing to query this information. > The series looks good with the examples in the commit messages > Signed-off-by: Keith Busch > --- > Documentation/admin-guide/mm/numaperf.rst | 171 ++++++++++++++++++++++++++++++ > 1 file changed, 171 insertions(+) > create mode 100644 Documentation/admin-guide/mm/numaperf.rst > > diff --git a/Documentation/admin-guide/mm/numaperf.rst b/Documentation/admin-guide/mm/numaperf.rst > new file mode 100644 > index 000000000000..846b3f991e7f > --- /dev/null > +++ b/Documentation/admin-guide/mm/numaperf.rst > @@ -0,0 +1,171 @@ > +.. _numaperf: > + > +============= > +NUMA Locality > +============= > + > +Some platforms may have multiple types of memory attached to a single > +CPU. These disparate memory ranges share some characteristics, such as > +CPU cache coherence, but may have different performance. For example, > +different media types and buses affect bandwidth and latency. > + > +A system supporting such heterogeneous memory by grouping each memory > +type under different "nodes" based on similar CPU locality and performance > +characteristics. Some memory may share the same node as a CPU, and others > +are provided as memory only nodes. While memory only nodes do not provide > +CPUs, they may still be directly accessible, or local, to one or more > +compute nodes. The following diagram shows one such example of two compute > +noes with local memory and a memory only node for each of compute node: > + > + +------------------+ +------------------+ > + | Compute Node 0 +-----+ Compute Node 1 | > + | Local Node0 Mem | | Local Node1 Mem | > + +--------+---------+ +--------+---------+ > + | | > + +--------+---------+ +--------+---------+ > + | Slower Node2 Mem | | Slower Node3 Mem | > + +------------------+ +--------+---------+ > + > +A "memory initiator" is a node containing one or more devices such as > +CPUs or separate memory I/O devices that can initiate memory requests. A > +"memory target" is a node containing one or more accessible physical > +address ranges from one or more memory initiators. > + > +When multiple memory initiators exist, they may not all have the same > +performance when accessing a given memory target. The highest performing > +initiator to a given target is considered to be one of that target's > +local initiators. Any given target may have one or more local initiators, > +and any given initiator may have multiple local memory targets. > + Can you also add summary here suggesting node X is compute and Node y is memory target > +To aid applications matching memory targets with their initiators, > +the kernel provide symlinks to each other like the following example:: > + > + # ls -l /sys/devices/system/node/nodeX/local_target* > + /sys/devices/system/node/nodeX/local_targetY -> ../nodeY > + > + # ls -l /sys/devices/system/node/nodeY/local_initiator* > + /sys/devices/system/node/nodeY/local_initiatorX -> ../nodeX > + the patch series had primary_target and primary_initiator > +The linked nodes will also have their node number set in the local_mem > +and local_cpu node list and maps. > + > +An example showing how this may be used to run a particular task on CPUs > +and memory that are both local to a particular PCI device can be done > +using existing 'numactl' as follows:: > + > + # NODE=$(cat /sys/devices/pci:0000:00/.../numa_node) > + # numactl --membind=$(cat /sys/devices/node/node${NODE}/local_mem_nodelist) \ > + --cpunodebind=$(cat /sys/devices/node/node${NODE}/local_cpu_nodelist) \ > + -- > + > +================ > +NUMA Performance > +================ > + > +Applications may wish to consider which node they want their memory to > +be allocated from based on the node's performance characteristics. If the > +system provides these attributes, the kernel exports them under the node > +sysfs hierarchy by appending the local_initiator_access directory under > +the memory node as follows:: > + > + /sys/devices/system/node/nodeY/local_initiator_access/ > + Same here s/local/primary? > +The kernel does not provide performance attributes for non-local memory > +initiators. These attributes apply only to the memory initiator nodes that > +have a local_initiatorX link, or are set in the local_cpu_nodelist. A > +memory initiator node is considered local to itself if it also is > +a memory target and will be set it its node list and map, but won't > +contain a symlink to itself. > + > +The performance characteristics the kernel provides for the local initiators > +are exported are as follows:: > + > + # tree /sys/devices/system/node/nodeY/local_initiator_access > + /sys/devices/system/node/nodeY/local_initiator_access > + |-- read_bandwidth > + |-- read_latency > + |-- write_bandwidth > + `-- write_latency > + > +The bandwidth attributes are provided in MiB/second. > + > +The latency attributes are provided in nanoseconds. > + > +========== > +NUMA Cache > +========== > + > +System memory may be constructed in a hierarchy of elements with various > +performance characteristics in order to provide large address space > +of slower performing memory side-cached by a smaller higher performing > +memory. The system physical addresses that initiators are aware of is > +provided by the last memory level in the hierarchy, while the system uses > +higher performing memory to transparently cache access to progressively > +slower levels. > + > +The term "far memory" is used to denote the last level memory in the > +hierarchy. Each increasing cache level provides higher performing > +initiator access, and the term "near memory" represents the fastest > +cache provided by the system. > + > +This numbering is different than CPU caches where the cache level (ex: > +L1, L2, L3) uses a CPU centric view with each increased level is lower > +performing. In contrast, the memory cache level is centric to the last > +level memory, so the higher numbered cache level denotes memory nearer > +to the CPU, and further from far memory. > + > +The memory side caches are not directly addressable by software. When > +software accesses a system address, the system will return it from the > +near memory cache if it is present. If it is not present, the system > +accesses the next level of memory until there is either a hit in that > +cache level, or it reaches far memory. > + > +An application does not need to know about caching attributes in order > +to use the system, software may optionally query the memory cache > +attributes in order to maximize the performance out of such a setup. > +If the system provides a way for the kernel to discover this information, > +for example with ACPI HMAT (Heterogeneous Memory Attribute Table), > +the kernel will append these attributes to the NUMA node memory target. > + > +When the kernel first registers a memory cache with a node, the kernel > +will create the following directory:: > + > + /sys/devices/system/node/nodeX/side_cache/ > + This is something even the patch commit message didn't explain we create side_cache directory in memory target nodes or initiator nodes? I assume it is part of memory target nodes. If so to be consistent can you use nodeY? > +If that directory is not present, the system either does not not provide > +a memory side cache, or that information is not accessible to the kernel. > + > +The attributes for each level of cache is provided under its cache > +level index:: > + > + /sys/devices/system/node/nodeX/side_cache/indexA/ > + /sys/devices/system/node/nodeX/side_cache/indexB/ > + /sys/devices/system/node/nodeX/side_cache/indexC/ > + > +Each cache level's directory provides its attributes. For example, > +the following is a single cache level and the attributes available for > +software to query:: > + > + # tree sys/devices/system/node/node0/side_cache/ > + /sys/devices/system/node/node0/side_cache/ > + |-- index1 > + | |-- associativity > + | |-- level > + | |-- line_size > + | |-- size > + | `-- write_policy > + > +The "associativity" will be 0 if it is a direct-mapped cache, and non-zero > +for any other indexed based, multi-way associativity. > + > +The "level" is the distance from the far memory, and matches the number > +appended to its "index" directory. > + > +The "line_size" is the number of bytes accessed on a cache miss. > + > +The "size" is the number of bytes provided by this cache level. > + > +The "write_policy" will be 0 for write-back, and non-zero for > +write-through caching. > + > +See also: https://www.uefi.org/sites/default/files/resources/ACPI_6_2.pdf >