From patchwork Thu Jan 24 23:07:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10780263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D9161399 for ; Thu, 24 Jan 2019 23:08:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 193302F914 for ; Thu, 24 Jan 2019 23:08:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D23B2F91B; Thu, 24 Jan 2019 23:08:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A28F2F91C for ; Thu, 24 Jan 2019 23:08:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BC148E00AA; Thu, 24 Jan 2019 18:08:31 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 22EFF8E00A6; Thu, 24 Jan 2019 18:08:31 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0847D8E00AA; Thu, 24 Jan 2019 18:08:31 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id B470A8E00A6 for ; Thu, 24 Jan 2019 18:08:30 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id q63so5903833pfi.19 for ; Thu, 24 Jan 2019 15:08:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=rBye8AplufPCz6aFFpxzb4fm0i0takBt9HLlXY44oRs=; b=nKEUZfcrxN7+AMabReIP5jASM2azo1Zcsj9Cn41IHOH99WoKtjPuLZfBolchBEikzc bslQa83idLU5JGUCWBGHtrcj5iYQ+Aa3Ecokw39BLfrGzlzANrhxbnwUwAPwtm8q//EH aBNd8JiOcmUgUioBcAfi5E9u06Tbtpx9JZM6zLnqTv9mCoYmCtQGnW36oMNAoUC5iNoY yZENz+pPOZJ8AVAaRH4D1oDRaD/L7AEOnZuAJxRQrrjOc0BR++sm1SfKbMSt2C84uNnE YjcTagjtqVrAlkWB65+0ytckQhFsS/tzyYM8f1RB82Ng4PQ08MdS8WjAk0Yj0s2a9MaX 7fdg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AJcUukc3I3Upxo5grr10m0UFFWeoYdI2+DhDmYhlCvLWsPTbDuaaSjRP s6UpfiS5kiSBDFjQs6HoHcZtD7+mbv0KzSmZ5aQiByO2WCTqngCudxkNrTUVt+cqnfKM9R+2uQo UMpdBNwlwumTC3eOgmrEGm4p4S/IoN/HVBVYqFHDHdKXKxIpzhawCM/RzMGwhX7DaCw== X-Received: by 2002:a63:1a4b:: with SMTP id a11mr7764011pgm.254.1548371310356; Thu, 24 Jan 2019 15:08:30 -0800 (PST) X-Google-Smtp-Source: ALg8bN4VS2dTjOWEAH6qDG4ocWzWc0gdPGEJz+xVYK+BNyW4nQaL/WxjGfY7IVqUbMPfplXSVIlh X-Received: by 2002:a63:1a4b:: with SMTP id a11mr7763951pgm.254.1548371309240; Thu, 24 Jan 2019 15:08:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548371309; cv=none; d=google.com; s=arc-20160816; b=I7Y1ry/gXpPFX6pvJ14Gb41+PlRpcVCforiIryfOJIJU0Wt/cq0cKMQsF/Y8RCuNtq 3EsurhcNZD9mSbT0nuPCxrHy16nBrMDS10gDCTzJzk6z2GHKqn7uFxm38ieRsjvDVZP3 qs7ekxyCfOY4V/UlrAPSP0eK/DxleJAqJ0b1x/TkKZBHxeOnHafubY2NgPx7De5SqaFT pr4cpFz7NkHeOVikanqcZ0Oj7NJlOG46SW45AWndsNuRpOgBLXrvhOmJSNcuM0tnbmLs NBT9gsFOlZCVcfx9x74myFlbEqXMSsZuFZFsPXWHXOpATkoOgJMXwU8kvfTvdkwfOsqX ZluA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=rBye8AplufPCz6aFFpxzb4fm0i0takBt9HLlXY44oRs=; b=P1m9WGWZb/pVW/ddJv3lzy4hcua5CpktIrahaLDZgB/RsfR/yh+7UlckcgkPlPHcTz G5Rtmb+DdH+5WbRW4ntm2M+b+PLUNiYpNHewllqFSrhXoO6x4wkcGiQXnrfs+3fDmuvm nSgn919kAX7o4A+A+kVobxlxK3TTsK3jyg5fwrurwfUP8g9ZmAh0dLi4HVjHbrghV786 FXQgDikTUzHSk2/UcJChkkJQXYQyJbLnDhxoNCFWZnq5GgINPszYLhqpgpE4Exh0PbsZ cePR2x2J4KGVNH/SpurQrB36T8IZkDBOkcFlWPMNimgTbhgRjdIGPqMSjftRVL5kDFMX h3Ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga12.intel.com (mga12.intel.com. [192.55.52.136]) by mx.google.com with ESMTPS id bj11si23263112plb.21.2019.01.24.15.08.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 15:08:29 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.136 as permitted sender) client-ip=192.55.52.136; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2019 15:08:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,518,1539673200"; d="scan'208";a="313295786" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga006.fm.intel.com with ESMTP; 24 Jan 2019 15:08:28 -0800 From: Keith Busch To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org Cc: Greg Kroah-Hartman , Rafael Wysocki , Dave Hansen , Dan Williams , Keith Busch Subject: [PATCHv5 10/10] doc/mm: New documentation for memory performance Date: Thu, 24 Jan 2019 16:07:24 -0700 Message-Id: <20190124230724.10022-11-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190124230724.10022-1-keith.busch@intel.com> References: <20190124230724.10022-1-keith.busch@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 perforamnce and caching attributes the kernel provides for applications wishing to query this information. Reviewed-by: Mike Rapoport Signed-off-by: Keith Busch --- Documentation/admin-guide/mm/numaperf.rst | 167 ++++++++++++++++++++++++++++++ 1 file changed, 167 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..52999336a8ed --- /dev/null +++ b/Documentation/admin-guide/mm/numaperf.rst @@ -0,0 +1,167 @@ +.. _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 +nodes 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 physical address +ranges accessible 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. Each initiator-target +pair may be organized into different ranked access classes to represent +this relationship. The highest performing initiator to a given target +is considered to be one of that target's local initiators, and given +the highest access class, 0. Any given target may have one or more +local initiators, and any given initiator may have multiple local +memory targets. + +To aid applications matching memory targets with their initiators, the +kernel provides symlinks to each other. The following example lists the +relationship for the access class "0" memory initiators and targets, which is +the of nodes with the highest performing access relationship:: + + # symlinks -v /sys/devices/system/node/nodeX/access0/targets/ + relative: /sys/devices/system/node/nodeX/access0/targets/nodeY -> ../../nodeY + + # symlinks -v /sys/devices/system/node/nodeY/access0/initiators/ + relative: /sys/devices/system/node/nodeY/access0/initiators/nodeX -> ../../nodeX + +================ +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 attributes directory under the +memory node's access class 0 initiators as follows:: + + /sys/devices/system/node/nodeY/access0/initiators/ + +These attributes apply only when accessed from nodes that have the +are linked under the this access's inititiators. + +The performance characteristics the kernel provides for the local initiators +are exported are as follows:: + + # tree -P "read*|write*" /sys/devices/system/node/nodeY/access0/ + /sys/devices/system/node/nodeY/access0/ + |-- read_bandwidth + |-- read_latency + |-- write_bandwidth + `-- write_latency + +The bandwidth attributes are provided in MiB/second. + +The latency attributes are provided in nanoseconds. + +The values reported here correspond to the rated latency and bandwidth +for the platform. + +========== +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 +are provided by the last memory level in the hierarchy. The system +meanwhile 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/ + +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 shows 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 +======== +.. [1] https://www.uefi.org/sites/default/files/resources/ACPI_6_2.pdf + Section 5.2.27