From patchwork Tue Dec 11 01:03:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10722927 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 D721C17FE for ; Tue, 11 Dec 2018 01:06:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5FB32A0E6 for ; Tue, 11 Dec 2018 01:06:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA1482A50D; Tue, 11 Dec 2018 01:06:19 +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=ham 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 825462A0E6 for ; Tue, 11 Dec 2018 01:06:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA2F88E0075; Mon, 10 Dec 2018 20:05:57 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D27468E006F; Mon, 10 Dec 2018 20:05:57 -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 B839A8E0075; Mon, 10 Dec 2018 20:05:57 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 621308E006F for ; Mon, 10 Dec 2018 20:05:57 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id t10so5102313plo.13 for ; Mon, 10 Dec 2018 17:05:57 -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=7dxj5oE+aZuqwVWr8gkwKZXVLDGVBA8qvHAAYITam6c=; b=J9hTZewocwDpExdkwS+tVetxVxRqwlsvJXeXoG9eLQpyYAkj5tavWsAlzI5Gq/z/Ia Cpsc5AtP72MZo6e6s8Lze+y1MzpCA1g+2y9xFsGx6jjw6aB7cOReXZ75yGwYa0FcvLho 6qmX9OqowCAGUNAb8bpxV4VUjlWpFFFjbooAmPBpkHAbcMEBxQz5aCljQQFNJiwOgJmP m2RkG4wIrw67Qra2C/L8XD5ZFUBeLuzVC3XDxsJi54wzqCS3v9W78fQlwekHJ9UsfhRg MBATlEJJM9005JNQVb992ciyfe3e8pCKiVzySovdvDr+NZAKtlocknQAdIGSwJ2zpe19 Vbdg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.43 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: AA+aEWYmt3tMzMKICshP+Oar6lBERoARXjnIpl1TEE0fmzbBrP6ib0mF cafyejlLVO9dnVkb1CDIvKjRw4cjKo3zfiTnXoQhOvjl3+yOfihFMm+NPnPyrPLj0WvyHYH/FmX OboKmK8/DyNf2OkMSq+MpjyDqpuI1MXOwEP4Ap34UVc27HJBVWIauaDOdHkTGXyf57Q== X-Received: by 2002:a62:ca9c:: with SMTP id y28mr14330201pfk.236.1544490357042; Mon, 10 Dec 2018 17:05:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/XxTevs3+mmN6KNXN/ixwUVfj3xjokCQnTYvKFfCqzitfKFx8Hdr5NeszZsCf//wu8udBf+ X-Received: by 2002:a62:ca9c:: with SMTP id y28mr14330145pfk.236.1544490355903; Mon, 10 Dec 2018 17:05:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544490355; cv=none; d=google.com; s=arc-20160816; b=x+zvj93tOimrWMeLZERlxl82zS0HiydzPj93QgjRTG2NPzHPdfSUuVmYtZwx32nKZP lcKidkQPF/px18agZyhKsdGRmvh/fFZOiZr6wmMISH7045uteKMwEopGCQ8t/Y9Ch5uR ZZ7W81xVwMQzO7AdDIpGCmJHAaKswJ42UqkP/oi3xK6nGLcgI3FsLifpCKAFvAjyaTcZ EkxfQB/tPDAQpaqA8votZLE7q+Sm6eIGkplgpeBdMh1CB9xQVAYqDqki5UO5KswKsys9 YNhx3QfchXHzKTADjrO+vXZ+ioQqubuygGwx798eevNk57LIWGWe64/xOf1VYjXWYBtn oLEQ== 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=7dxj5oE+aZuqwVWr8gkwKZXVLDGVBA8qvHAAYITam6c=; b=yzpL7iv525qUey5SxEdck7HHbqP0Y1lege+9Z5NuqlmMbOv31PW5hMR6Knbx6qNA8R 3Ad3vUNhxaU7NdK9HgGy2k3tkbkn1VQiM2tBJ5+qeNqClxEly81ozJLFXZ3O6yfHzXBU fNq7rhpBdqlbScX0lJpzda5y5rEOSXvtLUz3C3S3QNcHlcI+lRzO9+fHk9Q6Iv7eAYvH jsECIXMb2KJ1VrV0syzwPlj9WD6kBzIEvPgoeX5XIGG9MIao/ZLDNWSExLM9Xm46DMPh USVP4G1yChVzajLiVzuZLP4z0AozdSmmIESKcFcfvQ6qc73pB10PO8sWSSRZVodaewVB I4NA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga05.intel.com (mga05.intel.com. [192.55.52.43]) by mx.google.com with ESMTPS id i1si11402278pfj.276.2018.12.10.17.05.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 17:05:55 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.43 as permitted sender) client-ip=192.55.52.43; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.43 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 orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2018 17:05:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,340,1539673200"; d="scan'208";a="117705221" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by orsmga001.jf.intel.com with ESMTP; 10 Dec 2018 17:05:54 -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: [PATCHv2 12/12] doc/mm: New documentation for memory performance Date: Mon, 10 Dec 2018 18:03:10 -0700 Message-Id: <20181211010310.8551-13-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20181211010310.8551-1-keith.busch@intel.com> References: <20181211010310.8551-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 performance and caching attributes the kernel provides for applications wishing to query this information. 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. + +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 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/ + +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/ + +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