From patchwork Wed Jan 9 17:43:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754625 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 9A5396C5 for ; Wed, 9 Jan 2019 17:47:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83C2128972 for ; Wed, 9 Jan 2019 17:47:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 773FE28DC6; Wed, 9 Jan 2019 17:47:46 +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 EF4BE28972 for ; Wed, 9 Jan 2019 17:47:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B9738E009E; Wed, 9 Jan 2019 12:47:44 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 116FB8E0038; Wed, 9 Jan 2019 12:47:44 -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 ED3938E009E; Wed, 9 Jan 2019 12:47:43 -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 96FB88E0038 for ; Wed, 9 Jan 2019 12:47:43 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id g13so2384548plo.10 for ; Wed, 09 Jan 2019 09:47:43 -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=3vhVRV8ArwmTfFX5XTTZQlHuTocJlhEC3/XA+6xQsDY=; b=c1ipGz0c34wXRF6aYVlxrIu6Mwr0z6SeyAfqPpT/PyjL9/s0yzagJu+SeyichYnRPd vq88/c1vk+HevP3V+IRIRw333Jj593H8e9jAhXdtKVV0DmEux2aEuv85WTwPkxqfyNyI YwWkRl7vu6FAEX6vJRvwd9Pv63fdoXJ6jfy6k7XPLWKHls0lGBfxJmrppTvIvnjhn/lL Ec5R08hl9Q31CCPVJcCXcAyqbTA2OIist8Ig0oBjvE7NUjXWRHWebC+RL/ewMivQzYz2 QN1ZAb+6LVBDYYo7aLbtXh2zJllkk/ZSM8WqTa8vfdNObi7kXPnKzwdms6GP5zVlwQQ6 c1yw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.20 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: AJcUukdN3H/LgrtYS8A/IYa9gUk9z58u4FVG9G9MOTFZzSnrrnStyFdl BboiYgCt8V0wTp1vIrtELImLTT7STE7a1hjRCPvE0iM7mSfakvkueT+4KRleyPLtQz54NGQYNVm GIfb3LetpnMArAy/A8MJja6j3pYiCy3LPEHBU6q69ai7UCwn1V3GmQDdcVSKn6lJ4DA== X-Received: by 2002:a63:5346:: with SMTP id t6mr6405918pgl.40.1547056063225; Wed, 09 Jan 2019 09:47:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Z36W6Y+PhgzrrS8MEjM+1xczr5l7Y2WIzqkGovfU9EZSwTa56SQ8yPfcWqwPo5FrmQqKU X-Received: by 2002:a63:5346:: with SMTP id t6mr6405837pgl.40.1547056061258; Wed, 09 Jan 2019 09:47:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056061; cv=none; d=google.com; s=arc-20160816; b=NHGEZkKKrwO/e24BK6qmuI3YS+q0fCZlsvesD6+OG4I6FrcDJEltZu9zzImSJ7O4Dz khx0PNa32G6IaX9dHbHyFLwQYorNU3pf3no8OJ6ZzPpYedMqXvYy+zlmYU+ZYD3hf5pw sXdP771DHfLPrC3p4RDyQx+k2Fr5OEQyuvQoRq1AJVEnLDHEbn0dzcsdl2ALStocAgVQ lvnDK8vT9G+KG9eYee8wYt3zqrsGLSCMVvD5ictJqV3yZVogOuEOFVyIML7W/o9Nd0zQ Yc93e4+CmIyjWNHqumSJUnzzmxYAEO+/sCQb7i25vjagRXTQahWPvdsvmrVQl7YuzGuH G3sA== 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=3vhVRV8ArwmTfFX5XTTZQlHuTocJlhEC3/XA+6xQsDY=; b=pI3eHEY5vUZ2HzhhalrLOdhfhIatqijFWzNTRRl+ONTa0OMacrWaXSb5CVPQbiwDAI 8Z5MLaN2oGFest7ZHZ18JX7IoDgJSpHM1o8VjT9WISyq3aVqt8e0Z3l95CR9CUwA5GLn 4jhHeO6ub1BeNKY6h3mIArJlTOgy/0tMdr9YQzo/J88y4EMEu+vcU8fuXYaU/YNL9R6H C2+o6hZDGw40tEgsBA4xg34kZOE/sb6cUKCOkPE+oka/SSeb6F1g+qPVstQSUjxHSauC 7aSaZ7iNbaTUAasxlMt6swDWZuG1p1w1X1ZoeY1STRWaMd4ZbhYk/f3aLu5H4PfK/oaz Q2bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga02.intel.com (mga02.intel.com. [134.134.136.20]) by mx.google.com with ESMTPS id i5si7092908pfo.189.2019.01.09.09.47.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:47:41 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.20 as permitted sender) client-ip=134.134.136.20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.20 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:47:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485553" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:47:40 -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: [PATCHv3 01/13] acpi: Create subtable parsing infrastructure Date: Wed, 9 Jan 2019 10:43:29 -0700 Message-Id: <20190109174341.19818-2-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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 Parsing entries in an ACPI table had assumed a generic header structure. There is no standard ACPI header, though, so less common layouts with different field sizes required custom parsers to go through their subtable entry list. Create the infrastructure for adding different table types so parsing the entries array may be more reused for all ACPI system tables and the common code doesn't need to be duplicated. Reviewed-by: Rafael J. Wysocki Cc: Dan Williams Signed-off-by: Keith Busch --- arch/arm64/kernel/acpi_numa.c | 2 +- arch/arm64/kernel/smp.c | 4 +- arch/ia64/kernel/acpi.c | 12 ++--- arch/x86/kernel/acpi/boot.c | 36 +++++++------- drivers/acpi/numa.c | 16 +++---- drivers/acpi/scan.c | 4 +- drivers/acpi/tables.c | 67 +++++++++++++++++++++++---- drivers/irqchip/irq-gic-v2m.c | 2 +- drivers/irqchip/irq-gic-v3-its-pci-msi.c | 2 +- drivers/irqchip/irq-gic-v3-its-platform-msi.c | 2 +- drivers/irqchip/irq-gic-v3-its.c | 6 +-- drivers/irqchip/irq-gic-v3.c | 10 ++-- drivers/irqchip/irq-gic.c | 4 +- drivers/mailbox/pcc.c | 2 +- include/linux/acpi.h | 5 +- 15 files changed, 112 insertions(+), 62 deletions(-) diff --git a/arch/arm64/kernel/acpi_numa.c b/arch/arm64/kernel/acpi_numa.c index eac1d0cc595c..7ff800045434 100644 --- a/arch/arm64/kernel/acpi_numa.c +++ b/arch/arm64/kernel/acpi_numa.c @@ -45,7 +45,7 @@ static inline int get_cpu_for_acpi_id(u32 uid) return -EINVAL; } -static int __init acpi_parse_gicc_pxm(struct acpi_subtable_header *header, +static int __init acpi_parse_gicc_pxm(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_srat_gicc_affinity *pa; diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 1598d6f7200a..e6a148604dcc 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -553,7 +553,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor) } static int __init -acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header, +acpi_parse_gic_cpu_interface(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_generic_interrupt *processor; @@ -562,7 +562,7 @@ acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header, if (BAD_MADT_GICC_ENTRY(processor, end)) return -EINVAL; - acpi_table_print_madt_entry(header); + acpi_table_print_madt_entry(&header->common); acpi_map_gic_cpu_interface(processor); diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index 41eb281709da..3973d2c2a9b0 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c @@ -177,7 +177,7 @@ struct acpi_table_madt *acpi_madt __initdata; static u8 has_8259; static int __init -acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, +acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_local_apic_override *lapic; @@ -216,7 +216,7 @@ acpi_parse_lsapic(struct acpi_subtable_header * header, const unsigned long end) } static int __init -acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end) +acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_local_apic_nmi *lacpi_nmi; @@ -230,7 +230,7 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e } static int __init -acpi_parse_iosapic(struct acpi_subtable_header * header, const unsigned long end) +acpi_parse_iosapic(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_io_sapic *iosapic; @@ -245,7 +245,7 @@ acpi_parse_iosapic(struct acpi_subtable_header * header, const unsigned long end static unsigned int __initdata acpi_madt_rev; static int __init -acpi_parse_plat_int_src(struct acpi_subtable_header * header, +acpi_parse_plat_int_src(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_interrupt_source *plintsrc; @@ -329,7 +329,7 @@ unsigned int get_cpei_target_cpu(void) } static int __init -acpi_parse_int_src_ovr(struct acpi_subtable_header * header, +acpi_parse_int_src_ovr(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_interrupt_override *p; @@ -350,7 +350,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header, } static int __init -acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end) +acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_nmi_source *nmi_src; diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 2624de16cd7a..b694a32f95d4 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -197,7 +197,7 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled) } static int __init -acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) +acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_local_x2apic *processor = NULL; #ifdef CONFIG_X86_X2APIC @@ -210,7 +210,7 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) if (BAD_MADT_ENTRY(processor, end)) return -EINVAL; - acpi_table_print_madt_entry(header); + acpi_table_print_madt_entry(&header->common); #ifdef CONFIG_X86_X2APIC apic_id = processor->local_apic_id; @@ -242,7 +242,7 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, const unsigned long end) } static int __init -acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end) +acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_local_apic *processor = NULL; @@ -251,7 +251,7 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end) if (BAD_MADT_ENTRY(processor, end)) return -EINVAL; - acpi_table_print_madt_entry(header); + acpi_table_print_madt_entry(&header->common); /* Ignore invalid ID */ if (processor->id == 0xff) @@ -272,7 +272,7 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end) } static int __init -acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end) +acpi_parse_sapic(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_local_sapic *processor = NULL; @@ -281,7 +281,7 @@ acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end) if (BAD_MADT_ENTRY(processor, end)) return -EINVAL; - acpi_table_print_madt_entry(header); + acpi_table_print_madt_entry(&header->common); acpi_register_lapic((processor->id << 8) | processor->eid,/* APIC ID */ processor->processor_id, /* ACPI ID */ @@ -291,7 +291,7 @@ acpi_parse_sapic(struct acpi_subtable_header *header, const unsigned long end) } static int __init -acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, +acpi_parse_lapic_addr_ovr(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_local_apic_override *lapic_addr_ovr = NULL; @@ -301,7 +301,7 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, if (BAD_MADT_ENTRY(lapic_addr_ovr, end)) return -EINVAL; - acpi_table_print_madt_entry(header); + acpi_table_print_madt_entry(&header->common); acpi_lapic_addr = lapic_addr_ovr->address; @@ -309,7 +309,7 @@ acpi_parse_lapic_addr_ovr(struct acpi_subtable_header * header, } static int __init -acpi_parse_x2apic_nmi(struct acpi_subtable_header *header, +acpi_parse_x2apic_nmi(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_local_x2apic_nmi *x2apic_nmi = NULL; @@ -319,7 +319,7 @@ acpi_parse_x2apic_nmi(struct acpi_subtable_header *header, if (BAD_MADT_ENTRY(x2apic_nmi, end)) return -EINVAL; - acpi_table_print_madt_entry(header); + acpi_table_print_madt_entry(&header->common); if (x2apic_nmi->lint != 1) printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n"); @@ -328,7 +328,7 @@ acpi_parse_x2apic_nmi(struct acpi_subtable_header *header, } static int __init -acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long end) +acpi_parse_lapic_nmi(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_local_apic_nmi *lapic_nmi = NULL; @@ -337,7 +337,7 @@ acpi_parse_lapic_nmi(struct acpi_subtable_header * header, const unsigned long e if (BAD_MADT_ENTRY(lapic_nmi, end)) return -EINVAL; - acpi_table_print_madt_entry(header); + acpi_table_print_madt_entry(&header->common); if (lapic_nmi->lint != 1) printk(KERN_WARNING PREFIX "NMI not connected to LINT 1!\n"); @@ -449,7 +449,7 @@ static int __init mp_register_ioapic_irq(u8 bus_irq, u8 polarity, } static int __init -acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end) +acpi_parse_ioapic(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_io_apic *ioapic = NULL; struct ioapic_domain_cfg cfg = { @@ -462,7 +462,7 @@ acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end) if (BAD_MADT_ENTRY(ioapic, end)) return -EINVAL; - acpi_table_print_madt_entry(header); + acpi_table_print_madt_entry(&header->common); /* Statically assign IRQ numbers for IOAPICs hosting legacy IRQs */ if (ioapic->global_irq_base < nr_legacy_irqs()) @@ -508,7 +508,7 @@ static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger, } static int __init -acpi_parse_int_src_ovr(struct acpi_subtable_header * header, +acpi_parse_int_src_ovr(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_interrupt_override *intsrc = NULL; @@ -518,7 +518,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header, if (BAD_MADT_ENTRY(intsrc, end)) return -EINVAL; - acpi_table_print_madt_entry(header); + acpi_table_print_madt_entry(&header->common); if (intsrc->source_irq == acpi_gbl_FADT.sci_interrupt) { acpi_sci_ioapic_setup(intsrc->source_irq, @@ -550,7 +550,7 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header, } static int __init -acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end) +acpi_parse_nmi_src(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_madt_nmi_source *nmi_src = NULL; @@ -559,7 +559,7 @@ acpi_parse_nmi_src(struct acpi_subtable_header * header, const unsigned long end if (BAD_MADT_ENTRY(nmi_src, end)) return -EINVAL; - acpi_table_print_madt_entry(header); + acpi_table_print_madt_entry(&header->common); /* TBD: Support nimsrc entries? */ diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index 274699463b4f..f5e09c39ff22 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -338,7 +338,7 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa) } static int __init -acpi_parse_x2apic_affinity(struct acpi_subtable_header *header, +acpi_parse_x2apic_affinity(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_srat_x2apic_cpu_affinity *processor_affinity; @@ -347,7 +347,7 @@ acpi_parse_x2apic_affinity(struct acpi_subtable_header *header, if (!processor_affinity) return -EINVAL; - acpi_table_print_srat_entry(header); + acpi_table_print_srat_entry(&header->common); /* let architecture-dependent part to do it */ acpi_numa_x2apic_affinity_init(processor_affinity); @@ -356,7 +356,7 @@ acpi_parse_x2apic_affinity(struct acpi_subtable_header *header, } static int __init -acpi_parse_processor_affinity(struct acpi_subtable_header *header, +acpi_parse_processor_affinity(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_srat_cpu_affinity *processor_affinity; @@ -365,7 +365,7 @@ acpi_parse_processor_affinity(struct acpi_subtable_header *header, if (!processor_affinity) return -EINVAL; - acpi_table_print_srat_entry(header); + acpi_table_print_srat_entry(&header->common); /* let architecture-dependent part to do it */ acpi_numa_processor_affinity_init(processor_affinity); @@ -374,7 +374,7 @@ acpi_parse_processor_affinity(struct acpi_subtable_header *header, } static int __init -acpi_parse_gicc_affinity(struct acpi_subtable_header *header, +acpi_parse_gicc_affinity(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_srat_gicc_affinity *processor_affinity; @@ -383,7 +383,7 @@ acpi_parse_gicc_affinity(struct acpi_subtable_header *header, if (!processor_affinity) return -EINVAL; - acpi_table_print_srat_entry(header); + acpi_table_print_srat_entry(&header->common); /* let architecture-dependent part to do it */ acpi_numa_gicc_affinity_init(processor_affinity); @@ -394,7 +394,7 @@ acpi_parse_gicc_affinity(struct acpi_subtable_header *header, static int __initdata parsed_numa_memblks; static int __init -acpi_parse_memory_affinity(struct acpi_subtable_header * header, +acpi_parse_memory_affinity(union acpi_subtable_headers * header, const unsigned long end) { struct acpi_srat_mem_affinity *memory_affinity; @@ -403,7 +403,7 @@ acpi_parse_memory_affinity(struct acpi_subtable_header * header, if (!memory_affinity) return -EINVAL; - acpi_table_print_srat_entry(header); + acpi_table_print_srat_entry(&header->common); /* let architecture-dependent part to do it */ if (!acpi_numa_memory_affinity_init(memory_affinity)) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 5efd4219f112..a894ce3556f2 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2240,10 +2240,10 @@ static struct acpi_probe_entry *ape; static int acpi_probe_count; static DEFINE_MUTEX(acpi_probe_mutex); -static int __init acpi_match_madt(struct acpi_subtable_header *header, +static int __init acpi_match_madt(union acpi_subtable_headers *header, const unsigned long end) { - if (!ape->subtable_valid || ape->subtable_valid(header, ape)) + if (!ape->subtable_valid || ape->subtable_valid(&header->common, ape)) if (!ape->probe_subtbl(header, end)) acpi_probe_count++; diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 48eabb6c2d4f..967e1168becf 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -49,6 +49,15 @@ static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata; static int acpi_apic_instance __initdata; +enum acpi_subtable_type { + ACPI_SUBTABLE_COMMON, +}; + +struct acpi_subtable_entry { + union acpi_subtable_headers *hdr; + enum acpi_subtable_type type; +}; + /* * Disable table checksum verification for the early stage due to the size * limitation of the current x86 early mapping implementation. @@ -217,6 +226,42 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) } } +static unsigned long __init +acpi_get_entry_type(struct acpi_subtable_entry *entry) +{ + switch (entry->type) { + case ACPI_SUBTABLE_COMMON: + return entry->hdr->common.type; + } + return 0; +} + +static unsigned long __init +acpi_get_entry_length(struct acpi_subtable_entry *entry) +{ + switch (entry->type) { + case ACPI_SUBTABLE_COMMON: + return entry->hdr->common.length; + } + return 0; +} + +static unsigned long __init +acpi_get_subtable_header_length(struct acpi_subtable_entry *entry) +{ + switch (entry->type) { + case ACPI_SUBTABLE_COMMON: + return sizeof(entry->hdr->common); + } + return 0; +} + +static enum acpi_subtable_type __init +acpi_get_subtable_type(char *id) +{ + return ACPI_SUBTABLE_COMMON; +} + /** * acpi_parse_entries_array - for each proc_num find a suitable subtable * @@ -246,8 +291,8 @@ acpi_parse_entries_array(char *id, unsigned long table_size, struct acpi_subtable_proc *proc, int proc_num, unsigned int max_entries) { - struct acpi_subtable_header *entry; - unsigned long table_end; + struct acpi_subtable_entry entry; + unsigned long table_end, subtable_len, entry_len; int count = 0; int errs = 0; int i; @@ -270,19 +315,20 @@ acpi_parse_entries_array(char *id, unsigned long table_size, /* Parse all entries looking for a match. */ - entry = (struct acpi_subtable_header *) + entry.type = acpi_get_subtable_type(id); + entry.hdr = (union acpi_subtable_headers *) ((unsigned long)table_header + table_size); + subtable_len = acpi_get_subtable_header_length(&entry); - while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < - table_end) { + while (((unsigned long)entry.hdr) + subtable_len < table_end) { if (max_entries && count >= max_entries) break; for (i = 0; i < proc_num; i++) { - if (entry->type != proc[i].id) + if (acpi_get_entry_type(&entry) != proc[i].id) continue; if (!proc[i].handler || - (!errs && proc[i].handler(entry, table_end))) { + (!errs && proc[i].handler(entry.hdr, table_end))) { errs++; continue; } @@ -297,13 +343,14 @@ acpi_parse_entries_array(char *id, unsigned long table_size, * If entry->length is 0, break from this loop to avoid * infinite loop. */ - if (entry->length == 0) { + entry_len = acpi_get_entry_length(&entry); + if (entry_len == 0) { pr_err("[%4.4s:0x%02x] Invalid zero length\n", id, proc->id); return -EINVAL; } - entry = (struct acpi_subtable_header *) - ((unsigned long)entry + entry->length); + entry.hdr = (union acpi_subtable_headers *) + ((unsigned long)entry.hdr + entry_len); } if (max_entries && count > max_entries) { diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index f5fe0100f9ff..de14e06fd9ec 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -446,7 +446,7 @@ static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev) } static int __init -acpi_parse_madt_msi(struct acpi_subtable_header *header, +acpi_parse_madt_msi(union acpi_subtable_headers *header, const unsigned long end) { int ret; diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c index 8d6d009d1d58..c81d5b81da56 100644 --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c @@ -159,7 +159,7 @@ static int __init its_pci_of_msi_init(void) #ifdef CONFIG_ACPI static int __init -its_pci_msi_parse_madt(struct acpi_subtable_header *header, +its_pci_msi_parse_madt(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_generic_translator *its_entry; diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c index 7b8e87b493fe..9cdcda5bb3bd 100644 --- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c +++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c @@ -117,7 +117,7 @@ static int __init its_pmsi_init_one(struct fwnode_handle *fwnode, #ifdef CONFIG_ACPI static int __init -its_pmsi_parse_madt(struct acpi_subtable_header *header, +its_pmsi_parse_madt(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_generic_translator *its_entry; diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index db20e992a40f..d6677075d68f 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -3764,13 +3764,13 @@ static int __init acpi_get_its_numa_node(u32 its_id) return NUMA_NO_NODE; } -static int __init gic_acpi_match_srat_its(struct acpi_subtable_header *header, +static int __init gic_acpi_match_srat_its(union acpi_subtable_headers *header, const unsigned long end) { return 0; } -static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, +static int __init gic_acpi_parse_srat_its(union acpi_subtable_headers *header, const unsigned long end) { int node; @@ -3837,7 +3837,7 @@ static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; } static void __init acpi_its_srat_maps_free(void) { } #endif -static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header, +static int __init gic_acpi_parse_madt_its(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_generic_translator *its_entry; diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 0868a9d81c3c..44db6b809c52 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -1392,7 +1392,7 @@ gic_acpi_register_redist(phys_addr_t phys_base, void __iomem *redist_base) } static int __init -gic_acpi_parse_madt_redist(struct acpi_subtable_header *header, +gic_acpi_parse_madt_redist(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_generic_redistributor *redist = @@ -1410,7 +1410,7 @@ gic_acpi_parse_madt_redist(struct acpi_subtable_header *header, } static int __init -gic_acpi_parse_madt_gicc(struct acpi_subtable_header *header, +gic_acpi_parse_madt_gicc(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_generic_interrupt *gicc = @@ -1452,14 +1452,14 @@ static int __init gic_acpi_collect_gicr_base(void) return -ENODEV; } -static int __init gic_acpi_match_gicr(struct acpi_subtable_header *header, +static int __init gic_acpi_match_gicr(union acpi_subtable_headers *header, const unsigned long end) { /* Subtable presence means that redist exists, that's it */ return 0; } -static int __init gic_acpi_match_gicc(struct acpi_subtable_header *header, +static int __init gic_acpi_match_gicc(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_generic_interrupt *gicc = @@ -1525,7 +1525,7 @@ static bool __init acpi_validate_gic_table(struct acpi_subtable_header *header, return true; } -static int __init gic_acpi_parse_virt_madt_gicc(struct acpi_subtable_header *header, +static int __init gic_acpi_parse_virt_madt_gicc(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_generic_interrupt *gicc = diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index ba2a37a27a54..a749d73f8337 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -1508,7 +1508,7 @@ static struct } acpi_data __initdata; static int __init -gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header, +gic_acpi_parse_madt_cpu(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_madt_generic_interrupt *processor; @@ -1540,7 +1540,7 @@ gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header, } /* The things you have to do to just *count* something... */ -static int __init acpi_dummy_func(struct acpi_subtable_header *header, +static int __init acpi_dummy_func(union acpi_subtable_headers *header, const unsigned long end) { return 0; diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 256f18b67e8a..08a0a3517138 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -382,7 +382,7 @@ static const struct mbox_chan_ops pcc_chan_ops = { * * This gets called for each entry in the PCC table. */ -static int parse_pcc_subspace(struct acpi_subtable_header *header, +static int parse_pcc_subspace(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_pcct_subspace *ss = (struct acpi_pcct_subspace *) header; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 87715f20b69a..7c3c4ebaded6 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -141,10 +141,13 @@ enum acpi_address_range_id { /* Table Handlers */ +union acpi_subtable_headers { + struct acpi_subtable_header common; +}; typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table); -typedef int (*acpi_tbl_entry_handler)(struct acpi_subtable_header *header, +typedef int (*acpi_tbl_entry_handler)(union acpi_subtable_headers *header, const unsigned long end); /* Debugger support */ From patchwork Wed Jan 9 17:43:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754627 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 F31F713B4 for ; Wed, 9 Jan 2019 17:47:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2CDD28A2E for ; Wed, 9 Jan 2019 17:47:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D66E728DC6; Wed, 9 Jan 2019 17:47:49 +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 67FCF28A2E for ; Wed, 9 Jan 2019 17:47:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6BF2D8E009F; Wed, 9 Jan 2019 12:47:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 645ED8E0038; Wed, 9 Jan 2019 12:47:48 -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 4EA768E009F; Wed, 9 Jan 2019 12:47:48 -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 0CC158E0038 for ; Wed, 9 Jan 2019 12:47:48 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id v2so4568806plg.6 for ; Wed, 09 Jan 2019 09:47:48 -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=ExGNvcoKEZ/xzPwWGckO8sjrAYh7haWWgBU2TSXU3/0=; b=EZXCGp3LhvTcqp/3WIVF2w4E4JuOB291t8XN39seB7KLSNJwZMp/tEEmNe99lc67gO hIb9hIvzQA0a4c6DJARE3abAX3KdCuZM8R5I/331w/vvQI7WpMKvzh792jMYBfZLW56J G5SdBbJ/r/1EPywB4i6dWvNag19576lJVByxbUMa9m/NHKt7r+GQctMiYxwLAlh2tIqj OYy7YY7sJgNHVFJm31QL+aoeFRIhRq5OnkJUi7lu+W4Yzgkb95wCper6uygR5FgGpRNa ePl9Czju9eG/lPvNqGokCkLobCqIV5VqOPASTp465vkVCtI9jkEXOWJkpJBEDH11B8Gr Dvog== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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: AJcUukcy/tRme7s+p15LeDTPgbF8ePyy00MuCXjMHQ54N83fpqDBP75k DND2IcGTiJsedFOXYMv1ybn9nPNNA8TFnzu9QhJoVZKXphO/wN8fgjSzN4eOaEJpQn5AgT56N6l 6g1OtPTM9pe/oemqiXi44eEgXmOTj27zTcPPJgiR/z6RftHQx9izfiGcILXRtbOTOrQ== X-Received: by 2002:a62:db41:: with SMTP id f62mr6995589pfg.123.1547056067704; Wed, 09 Jan 2019 09:47:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN4FQS05btPY6lNTCDYdBz3LvYJ9qT36vUGkf9yyzdubpe9bIBLR24ijW477KBN/rsZxYP8E X-Received: by 2002:a62:db41:: with SMTP id f62mr6995549pfg.123.1547056067052; Wed, 09 Jan 2019 09:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056067; cv=none; d=google.com; s=arc-20160816; b=qON6vLcATQqRzbbNruSZQNIq8KQCs89gVs2S9+8qsocDFttNpbdWNGz1CTqvbXCiV9 6bcCDd6tXqrgbWYEFvfOEniXPXrkBZHXA4yJQfKKjozLWtx0QoEq7ahxgifbDjAam7/f CM4lQ7cMPAT7tIPdF13GI3kDKqHL+A/e9gPBS+nCfshdXxqhR+EnEjhAfSBP8xTXn0eK nBcGCDxeBdYLgv836mizy8kc4A0kZ/pf3WX2aIDKuMaGHFfNkrCtGO3FQzSMcEbUhbKM 4LrrlZ5Ho2nS5mS03qqMBZl5pFgDiMJPv3EChqNVUAwOigKihVxEe07OEY/OTJh4jbj6 YKOQ== 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=ExGNvcoKEZ/xzPwWGckO8sjrAYh7haWWgBU2TSXU3/0=; b=DviaqUD2w8G4Spkl9JOyGLTIFi9SebOHrX+IkrL6WwLvRf0th1su5WX5Si6BYJYdHq dBQ0owBEsEWEBLr/ZP8/klwQPeuuH4Fy1M9dojBp+vh/GWzvQQQfL+oXge7wMeRH49Rf Fp9SN4nCN7rdKzaByJqdjNkv2dcybXbNz8XhsKXB3pq0cNotQ7eBuswHa3Jma98SkbC0 KTz4Ehmu2LtS7tr/hoEBKXP1ynt9TbwR/werTTWqpFYCnc80rzKMbeXntMltry4jHatk ct+kKFho8ORBhKTdgC7zwTpLvBCckoybPsFwO0xDUuqOxx5VMxpWt6P+mamEZhONRPLH JCGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id f75si4647455pff.131.2019.01.09.09.47.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:47:47 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:47:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485579" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:47:45 -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: [PATCHv3 02/13] acpi: Add HMAT to generic parsing tables Date: Wed, 9 Jan 2019 10:43:30 -0700 Message-Id: <20190109174341.19818-3-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-1-keith.busch@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 The Heterogeneous Memory Attribute Table (HMAT) header has different field lengths than the existing parsing uses. Add the HMAT type to the parsing rules so it may be generically parsed. Cc: Dan Williams Signed-off-by: Keith Busch Reviewed-by: Rafael J. Wysocki --- drivers/acpi/tables.c | 9 +++++++++ include/linux/acpi.h | 1 + 2 files changed, 10 insertions(+) diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 967e1168becf..d9911cd55edc 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -51,6 +51,7 @@ static int acpi_apic_instance __initdata; enum acpi_subtable_type { ACPI_SUBTABLE_COMMON, + ACPI_SUBTABLE_HMAT, }; struct acpi_subtable_entry { @@ -232,6 +233,8 @@ acpi_get_entry_type(struct acpi_subtable_entry *entry) switch (entry->type) { case ACPI_SUBTABLE_COMMON: return entry->hdr->common.type; + case ACPI_SUBTABLE_HMAT: + return entry->hdr->hmat.type; } return 0; } @@ -242,6 +245,8 @@ acpi_get_entry_length(struct acpi_subtable_entry *entry) switch (entry->type) { case ACPI_SUBTABLE_COMMON: return entry->hdr->common.length; + case ACPI_SUBTABLE_HMAT: + return entry->hdr->hmat.length; } return 0; } @@ -252,6 +257,8 @@ acpi_get_subtable_header_length(struct acpi_subtable_entry *entry) switch (entry->type) { case ACPI_SUBTABLE_COMMON: return sizeof(entry->hdr->common); + case ACPI_SUBTABLE_HMAT: + return sizeof(entry->hdr->hmat); } return 0; } @@ -259,6 +266,8 @@ acpi_get_subtable_header_length(struct acpi_subtable_entry *entry) static enum acpi_subtable_type __init acpi_get_subtable_type(char *id) { + if (strncmp(id, ACPI_SIG_HMAT, 4) == 0) + return ACPI_SUBTABLE_HMAT; return ACPI_SUBTABLE_COMMON; } diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 7c3c4ebaded6..53f93dff171c 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -143,6 +143,7 @@ enum acpi_address_range_id { /* Table Handlers */ union acpi_subtable_headers { struct acpi_subtable_header common; + struct acpi_hmat_structure hmat; }; typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table); From patchwork Wed Jan 9 17:43:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754631 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 A3C3A6C5 for ; Wed, 9 Jan 2019 17:47:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90D1728972 for ; Wed, 9 Jan 2019 17:47:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8109328D6D; Wed, 9 Jan 2019 17:47:57 +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 8888528972 for ; Wed, 9 Jan 2019 17:47:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A6438E00A0; Wed, 9 Jan 2019 12:47:54 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 92CB08E0038; Wed, 9 Jan 2019 12:47:54 -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 7CFB38E00A0; Wed, 9 Jan 2019 12:47:54 -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 39AD18E0038 for ; Wed, 9 Jan 2019 12:47:54 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id t72so5722275pfi.21 for ; Wed, 09 Jan 2019 09:47:54 -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=qoiyh1VaxNuHsP1v6Afq2FT7Jqi62YmJ/KMR69fZP8o=; b=bFHNEl4ff4ZLqPQmVl5gDbl/5OPpm6cMNxvSa4Rmv9g9rZIXA89jA+VgLw/qdNZgXa YkSk5VPvSpugMT2VgiKGn0EGCCX+ITy17XcS743jXQ1etpGaQlA5lgalqebeCgtn52C3 j+afY3xHlcnq3VvsPXWJklleQT2kqjSXH9IP+M4jvtCaxOoV+d7so1m6/JK2TbZNusQB JxVKM4fCU5eBYR4osnqQ9rWCXn8GG4Hc0DeR2bP7T+esRBAmHHbgjTgRcZ4j5nyVAown vXRYfQx3CZjLCLL821HEaovAyqn2vPm2M0SV6yZ6X89G8ZcAqiwLz76fdgVE7Giehf/v GcQQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.93 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: AJcUukfdNpt7RxXn2IyjEl1cC4QVj00cBt8JQBnSplymGQ8PRqxZJqrH HG0LR/4XpqjfR6POIeJ33zXh5a5n+wRBarftib1nWTct3/LxfxBti48LhkCqxZM2KiM9Ysm+MS2 S4RSvTQ951XWspXRql8k+PbthMDi/fjV6ic1eNv+K1nXEylBezDHggbbLJk2MLdzOCQ== X-Received: by 2002:a63:6cc8:: with SMTP id h191mr6033490pgc.366.1547056073878; Wed, 09 Jan 2019 09:47:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN5rInHxK3DVfHgnHs01VRqeW5M8szdkSVok6axEcfXeAvFx1I/Ay/VbRDkmYMojLzZWzr5L X-Received: by 2002:a63:6cc8:: with SMTP id h191mr6033454pgc.366.1547056072892; Wed, 09 Jan 2019 09:47:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056072; cv=none; d=google.com; s=arc-20160816; b=qkigJXvf9xpfGDWXWrxuo4ivV9KETZy+ccQKOKUvFvS2DFMHatRPqV5rWSyG551aT0 BSUZHVUjS2kLWrKmB+HpWlLssjWD8T46Ei/WuTI9BVanByOZaQgS7myAMJBnPrNAYHRn yHEAHKafWp8uwAgmDFv74eYtkh05p3vzvcC9MbI6MtdEU+72MD13L9ZgunCStPNfV7bJ 0e5caF1th9VyErSJjZQuI8rvhcyh7WqDz6lRi2z3ZcjcKr2OwNG1ffxBEl6jHixJN1ut TzOPEkkjkuvXV0B1BmIpsI7WPfaQ0fX7jCvpUf4rR9dwMuHkRpHCicUsTkzo9eokSMeC bwfg== 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=qoiyh1VaxNuHsP1v6Afq2FT7Jqi62YmJ/KMR69fZP8o=; b=OEALSosCrk5m+4WuMirBcZyWd+A4fs2hvS/2DFlsbcwap+oRGsq93PMf3iJLv/t0H5 GfJVLZqx1Qzkpcy6u52BygONFlvX8CZFExb7CqLWFe8Ogpz8gtSmTUvwmrHTsHkA5BhZ 3uIEXIC7gdd5Vjujw12BZvuR+FxetC6CLijf7Cj5T8pCe6ZQ7tim6Ar2kkw5AKpSFtNb PMp2e/p71bggsXsAbmg+ph3s7u6c6LKW61Cfc6k1zwk1zRsc9CQxHHdt2sENN3/9+M4L bbOjgIh6dHzu8dSupIjVrgc70/HeQcNTG4+r0YYXm20qweBjcBKGqUJ/QK2WirDLblvp eW2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga11.intel.com (mga11.intel.com. [192.55.52.93]) by mx.google.com with ESMTPS id t136si28153535pfc.262.2019.01.09.09.47.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:47:52 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.93 as permitted sender) client-ip=192.55.52.93; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.93 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 fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:47:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485602" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:47:51 -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: [PATCHv3 03/13] acpi/hmat: Parse and report heterogeneous memory Date: Wed, 9 Jan 2019 10:43:31 -0700 Message-Id: <20190109174341.19818-4-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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 Systems may provide different memory types and export this information in the ACPI Heterogeneous Memory Attribute Table (HMAT). Parse these tables provided by the platform and report the memory access and caching attributes. Signed-off-by: Keith Busch --- drivers/acpi/Kconfig | 8 +++ drivers/acpi/Makefile | 1 + drivers/acpi/hmat.c | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 drivers/acpi/hmat.c diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 7b65a807b3dd..b102d9f544ee 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -326,6 +326,14 @@ config ACPI_NUMA depends on (X86 || IA64 || ARM64) default y if IA64_GENERIC || IA64_SGI_SN2 || ARM64 +config ACPI_HMAT + bool "ACPI Heterogeneous Memory Attribute Table Support" + depends on ACPI_NUMA + help + Parses representation of the ACPI Heterogeneous Memory Attributes + Table (HMAT) and set the memory node relationships and access + attributes. + config ACPI_CUSTOM_DSDT_FILE string "Custom DSDT Table file to include" default "" diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 7c6afc111d76..2a435dcfaa9c 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -55,6 +55,7 @@ acpi-$(CONFIG_X86) += x86/apple.o acpi-$(CONFIG_X86) += x86/utils.o acpi-$(CONFIG_DEBUG_FS) += debugfs.o acpi-$(CONFIG_ACPI_NUMA) += numa.o +acpi-$(CONFIG_ACPI_HMAT) += hmat.o acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o acpi-y += acpi_lpat.o acpi-$(CONFIG_ACPI_LPIT) += acpi_lpit.o diff --git a/drivers/acpi/hmat.c b/drivers/acpi/hmat.c new file mode 100644 index 000000000000..833a783868d5 --- /dev/null +++ b/drivers/acpi/hmat.c @@ -0,0 +1,180 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Heterogeneous Memory Attributes Table (HMAT) representation + * + * Copyright (c) 2018, Intel Corporation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static __init const char *hmat_data_type(u8 type) +{ + switch (type) { + case ACPI_HMAT_ACCESS_LATENCY: + return "Access Latency"; + case ACPI_HMAT_READ_LATENCY: + return "Read Latency"; + case ACPI_HMAT_WRITE_LATENCY: + return "Write Latency"; + case ACPI_HMAT_ACCESS_BANDWIDTH: + return "Access Bandwidth"; + case ACPI_HMAT_READ_BANDWIDTH: + return "Read Bandwidth"; + case ACPI_HMAT_WRITE_BANDWIDTH: + return "Write Bandwidth"; + default: + return "Reserved"; + }; +} + +static __init const char *hmat_data_type_suffix(u8 type) +{ + switch (type) { + case ACPI_HMAT_ACCESS_LATENCY: + case ACPI_HMAT_READ_LATENCY: + case ACPI_HMAT_WRITE_LATENCY: + return " nsec"; + case ACPI_HMAT_ACCESS_BANDWIDTH: + case ACPI_HMAT_READ_BANDWIDTH: + case ACPI_HMAT_WRITE_BANDWIDTH: + return " MB/s"; + default: + return ""; + }; +} + +static __init int hmat_parse_locality(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_hmat_locality *loc = (void *)header; + unsigned int init, targ, total_size, ipds, tpds; + u32 *inits, *targs, value; + u16 *entries; + u8 type; + + if (loc->header.length < sizeof(*loc)) { + pr_err("HMAT: Unexpected locality header length: %d\n", + loc->header.length); + return -EINVAL; + } + + type = loc->data_type; + ipds = loc->number_of_initiator_Pds; + tpds = loc->number_of_target_Pds; + total_size = sizeof(*loc) + sizeof(*entries) * ipds * tpds + + sizeof(*inits) * ipds + sizeof(*targs) * tpds; + if (loc->header.length < total_size) { + pr_err("HMAT: Unexpected locality header length:%d, minimum required:%d\n", + loc->header.length, total_size); + return -EINVAL; + } + + pr_info("HMAT: Locality: Flags:%02x Type:%s Initiator Domains:%d Target Domains:%d Base:%lld\n", + loc->flags, hmat_data_type(type), ipds, tpds, + loc->entry_base_unit); + + inits = (u32 *)(loc + 1); + targs = &inits[ipds]; + entries = (u16 *)(&targs[tpds]); + for (targ = 0; targ < tpds; targ++) { + for (init = 0; init < ipds; init++) { + value = entries[init * tpds + targ]; + value = (value * loc->entry_base_unit) / 10; + pr_info(" Initiator-Target[%d-%d]:%d%s\n", + inits[init], targs[targ], value, + hmat_data_type_suffix(type)); + } + } + return 0; +} + +static __init int hmat_parse_cache(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_hmat_cache *cache = (void *)header; + u32 attrs; + + if (cache->header.length < sizeof(*cache)) { + pr_err("HMAT: Unexpected cache header length: %d\n", + cache->header.length); + return -EINVAL; + } + + attrs = cache->cache_attributes; + pr_info("HMAT: Cache: Domain:%d Size:%llu Attrs:%08x SMBIOS Handles:%d\n", + cache->memory_PD, cache->cache_size, attrs, + cache->number_of_SMBIOShandles); + + return 0; +} + +static int __init hmat_parse_address_range(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_hmat_address_range *spa = (void *)header; + + if (spa->header.length != sizeof(*spa)) { + pr_err("HMAT: Unexpected address range header length: %d\n", + spa->header.length); + return -EINVAL; + } + pr_info("HMAT: Memory (%#llx length %#llx) Flags:%04x Processor Domain:%d Memory Domain:%d\n", + spa->physical_address_base, spa->physical_address_length, + spa->flags, spa->processor_PD, spa->memory_PD); + return 0; +} + +static int __init hmat_parse_subtable(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_hmat_structure *hdr = (void *)header; + + if (!hdr) + return -EINVAL; + + switch (hdr->type) { + case ACPI_HMAT_TYPE_ADDRESS_RANGE: + return hmat_parse_address_range(header, end); + case ACPI_HMAT_TYPE_LOCALITY: + return hmat_parse_locality(header, end); + case ACPI_HMAT_TYPE_CACHE: + return hmat_parse_cache(header, end); + default: + return -EINVAL; + } +} + +static __init int hmat_init(void) +{ + struct acpi_table_header *tbl; + enum acpi_hmat_type i; + acpi_status status; + + if (srat_disabled()) + return 0; + + status = acpi_get_table(ACPI_SIG_HMAT, 0, &tbl); + if (ACPI_FAILURE(status)) + return 0; + + for (i = ACPI_HMAT_TYPE_ADDRESS_RANGE; i < ACPI_HMAT_TYPE_RESERVED; i++) { + if (acpi_table_parse_entries(ACPI_SIG_HMAT, + sizeof(struct acpi_table_hmat), i, + hmat_parse_subtable, 0) < 0) + goto out_put; + } +out_put: + acpi_put_table(tbl); + return 0; +} +subsys_initcall(hmat_init); From patchwork Wed Jan 9 17:43:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754637 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 5F5D16C5 for ; Wed, 9 Jan 2019 17:48:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F8AD28A2E for ; Wed, 9 Jan 2019 17:48:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4241928DC6; Wed, 9 Jan 2019 17:48:04 +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 801BC28A2E for ; Wed, 9 Jan 2019 17:48:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 366FA8E00A1; Wed, 9 Jan 2019 12:48:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2EB5D8E0038; Wed, 9 Jan 2019 12:48:00 -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 144E68E00A3; Wed, 9 Jan 2019 12:48:00 -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 AB4118E00A1 for ; Wed, 9 Jan 2019 12:47:59 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id o23so4583458pll.0 for ; Wed, 09 Jan 2019 09:47:59 -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=WkxRbXsyJx+8YU8EFkbpOgmcfouDZAhdnb/RTxBK8HA=; b=lhdNrGl6auwoyowN0zVo9XnU995b/KA1QeJ5Jaw6hxvyM04zAaXQ4bOj+hxM+cWDIl 00EMCBy0UGPNGVbyvRsZRQPpHUce2Yu1ATCwDv0m761N469ZBAyvVJt8ckXUw6DetIWc H9tudgmZfARSleJqA76u4bFYBDtbGnhneGI3S2SMVBFn0zcNCi6dJy5s32zu/wVro+G0 9CrwOu1ixj/aVP/TJHPki7IizsZMyDFPaiJavaz62dpsES2vVVUZfsnw0yHKq6IfxLVh SZPCQ2dWPuMcafUj5ZiQ0jTPp05upHz2zsTp5tfkUDk/vAErbCjxo9GW3f+uYKajI5ir SwCA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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: AJcUukd157escfTcVYtqRIqBi8WnRy0TrnhQwP3FXQ9lAAvw5VG9xKXA 2+c+x1I/22+FqACt86toE/nsiZkMxNIufXeobfOYnT6NQBqpB2+rgTU8NMZAHD2C67VCw6woYkJ 2bm8Nqx6bcQ7BIbEbmYwyqDmu8aqyledUmr0UidH3iJj13f5qg5e77ANRw4jIlgASvQ== X-Received: by 2002:a63:eb0e:: with SMTP id t14mr6347119pgh.445.1547056079268; Wed, 09 Jan 2019 09:47:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN64CjBexLU6CW72jJJqg5rfdZNLO5R0yucMUo7FDSUJRvUvi3Vs4CHu73/G5ZDjRaDbahg0 X-Received: by 2002:a63:eb0e:: with SMTP id t14mr6347078pgh.445.1547056078228; Wed, 09 Jan 2019 09:47:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056078; cv=none; d=google.com; s=arc-20160816; b=uZeUji1exPQXCrhy9aT1y2pg3l8k26Cxhex7gM1zT4M8eX9pKgCy63Mt7pf22AmWhh 9LNO/a5g4HvTwyRuz2BdGpNNIn9SQq+0IWsNuYVvvvD23/LEhijN/R052mRUGCiGgbmq yfJDVkyht4H/fySTghziDuIDWkGe/H+RDEmI2ti25D+mzrUYfdQdFnrUT9btIGs3DIy3 oeudyQM9Nf+F1Rltp/DYbz0gUgdfGInSNU1dog8CmJCMA72Sa6D8xFlX5FbKiF02vE/Y ncOD+zfcYICnXxxGj9eH1DTeP1sN+XhDhVw71amFoUOW+H3OdH1Q84dQQbzVTMnDffgQ +tzA== 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=WkxRbXsyJx+8YU8EFkbpOgmcfouDZAhdnb/RTxBK8HA=; b=fK2iSIkMEDo3cfhsJ4CXQf2x3AjvqxsrdFfKSVDyvfL65CI6DypnDb+Ku1NWKK6knk Ty2FoQeZocW3BFSwM5jgyfNzzXjiNPWhqUO7aZTAMgB100HDxTrlbrr7tUxTbMEVNZDd MFsqUkputJtoNJHZTuoRoQ273FqdKr7tRTsyDJvSB38svDmXNDnqvbMj5xlVHxjUi4WZ 1emI6KeNJQXChZn5G8uVtjH8m9XdZyMuwiMScIMjxKJchMX1+5dGhnpG7h+wO+n0/UUi VyJWHVBb3J/cLDQAol6ZlM5z/7QYwKw2HX5jB+bSd80mK+04V5KHA5uGa4sAzpWUXPK+ frkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id c10si25675731pla.173.2019.01.09.09.47.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:47:58 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:47:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485615" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:47:57 -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: [PATCHv3 04/13] node: Link memory nodes to their compute nodes Date: Wed, 9 Jan 2019 10:43:32 -0700 Message-Id: <20190109174341.19818-5-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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 Systems may be constructed with various specialized nodes. Some nodes may provide memory, some provide compute devices that access and use that memory, and others may provide both. Nodes that provide memory are referred to as memory targets, and nodes that can initiate memory access are referred to as memory initiators. Memory targets will often have varying access characteristics from different initiators, and platforms may have ways to express those relationships. In preparation for these systems, provide interfaces for the kernel to export the memory relationship among different node's memory targets and their initiators with symlinks to each other's nodes, and export node lists showing the same relationship. If a system provides access locality for each initiator-target pair, nodes may be grouped into ranked access classes relative to other nodes. The new interface allows a subsystem to register relationships of varying classes if available and desired to be exported. A lower class number indicates a higher performing tier, with 0 being the best performing class. A memory initiator may have multiple memory targets in the same access class. The initiator's memory targets in given class indicate the node's access characteristics perform better relative to other initiator nodes either unreported or in lower class numbers. The targets within an initiator's class, though, do not necessarily perform the same as each other. A memory target node may have multiple memory initiators. All linked initiators in a target's class have the same access characteristics as each other to that target. The following example show the nodes' new sysfs hierarchy for a memory target node 'Y' with class 0 access from initiator node 'X': # symlinks -v /sys/devices/system/node/nodeX/class0/ relative: /sys/devices/system/node/nodeX/class0/targetY -> ../../nodeY # symlinks -v /sys/devices/system/node/nodeY/class0/ relative: /sys/devices/system/node/nodeY/class0/initiatorX -> ../../nodeX And the same information is reflected in the nodelist: # cat /sys/devices/system/node/nodeX/class0/target_nodelist Y # cat /sys/devices/system/node/nodeY/class0/initiator_nodelist X Signed-off-by: Keith Busch --- drivers/base/node.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++- include/linux/node.h | 6 ++- 2 files changed, 131 insertions(+), 2 deletions(-) diff --git a/drivers/base/node.c b/drivers/base/node.c index 86d6cd92ce3d..1da5072116ab 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -59,6 +60,91 @@ static inline ssize_t node_read_cpulist(struct device *dev, static DEVICE_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL); static DEVICE_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL); +struct node_class_nodes { + struct device dev; + struct list_head list_node; + unsigned class; + nodemask_t initiator_nodes; + nodemask_t target_nodes; +}; +#define to_class_nodes(dev) container_of(dev, struct node_class_nodes, dev) + +static ssize_t initiator_nodelist_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct node_class_nodes *c = to_class_nodes(dev); + return scnprintf(buf, PAGE_SIZE - 1, "%*pbl\n", + nodemask_pr_args(&c->initiator_nodes)); +} +static DEVICE_ATTR_RO(initiator_nodelist); + +static ssize_t target_nodelist_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct node_class_nodes *c = to_class_nodes(dev); + return scnprintf(buf, PAGE_SIZE - 1, "%*pbl\n", + nodemask_pr_args(&c->target_nodes)); +} +static DEVICE_ATTR_RO(target_nodelist); + +static struct attribute *node_class_node_attrs[] = { + &dev_attr_initiator_nodelist.attr, + &dev_attr_target_nodelist.attr, + NULL, +}; +ATTRIBUTE_GROUPS(node_class_node); + +static void node_remove_classes(struct node *node) +{ + struct node_class_nodes *c, *cnext; + + list_for_each_entry_safe(c, cnext, &node->class_list, list_node) { + list_del(&c->list_node); + device_unregister(&c->dev); + } +} + +static void node_class_release(struct device *dev) +{ + kfree(to_class_nodes(dev)); +} + +static struct node_class_nodes *node_init_node_class(struct device *parent, + struct list_head *list, + unsigned class) +{ + struct node_class_nodes *class_node; + struct device *dev; + + list_for_each_entry(class_node, list, list_node) + if (class_node->class == class) + return class_node; + + class_node = kzalloc(sizeof(*class_node), GFP_KERNEL); + if (!class_node) + return NULL; + + class_node->class = class; + dev = &class_node->dev; + dev->parent = parent; + dev->release = node_class_release; + dev->groups = node_class_node_groups; + if (dev_set_name(dev, "class%u", class)) + goto free; + + if (device_register(dev)) + goto free_name; + + pm_runtime_no_callbacks(dev); + list_add_tail(&class_node->list_node, list); + return class_node; +free_name: + kfree_const(dev->kobj.name); +free: + kfree(class_node); + return NULL; +} + #define K(x) ((x) << (PAGE_SHIFT - 10)) static ssize_t node_read_meminfo(struct device *dev, struct device_attribute *attr, char *buf) @@ -340,7 +426,7 @@ static int register_node(struct node *node, int num) void unregister_node(struct node *node) { hugetlb_unregister_node(node); /* no-op, if memoryless node */ - + node_remove_classes(node); device_unregister(&node->dev); } @@ -372,6 +458,44 @@ int register_cpu_under_node(unsigned int cpu, unsigned int nid) kobject_name(&node_devices[nid]->dev.kobj)); } +int register_memory_node_under_compute_node(unsigned int m, unsigned int p, + unsigned class) +{ + struct node *init, *targ; + struct node_class_nodes *i, *t; + char initiator[20]; /* "initiator4294967295\0" */ + char target[17]; /* "target4294967295\0" */ + int ret; + + if (!node_online(p) || !node_online(m)) + return -ENODEV; + + init = node_devices[p]; + targ = node_devices[m]; + i = node_init_node_class(&init->dev, &init->class_list, class); + t = node_init_node_class(&targ->dev, &targ->class_list, class); + if (!i || !t) + return -ENOMEM; + + snprintf(initiator, sizeof(initiator), "initiator%u", p); + snprintf(target, sizeof(target), "target%u", m); + ret = sysfs_create_link(&i->dev.kobj, &targ->dev.kobj, target); + if (ret) + return ret; + + ret = sysfs_create_link(&t->dev.kobj, &init->dev.kobj, initiator); + if (ret) + goto err; + + node_set(m, i->target_nodes); + node_set(p, t->initiator_nodes); + return 0; + err: + sysfs_remove_link(&node_devices[p]->dev.kobj, + kobject_name(&node_devices[m]->dev.kobj)); + return ret; +} + int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) { struct device *obj; @@ -580,6 +704,7 @@ int __register_one_node(int nid) register_cpu_under_node(cpu, nid); } + INIT_LIST_HEAD(&node_devices[nid]->class_list); /* initialize work queue for memory hot plug */ init_node_hugetlb_work(nid); diff --git a/include/linux/node.h b/include/linux/node.h index 257bb3d6d014..8e3666c12ef2 100644 --- a/include/linux/node.h +++ b/include/linux/node.h @@ -17,11 +17,12 @@ #include #include +#include #include struct node { struct device dev; - + struct list_head class_list; #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS) struct work_struct node_work; #endif @@ -75,6 +76,9 @@ extern int register_mem_sect_under_node(struct memory_block *mem_blk, extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, unsigned long phys_index); +extern int register_memory_node_under_compute_node(unsigned int m, unsigned int p, + unsigned class); + #ifdef CONFIG_HUGETLBFS extern void register_hugetlbfs_with_node(node_registration_func_t doregister, node_registration_func_t unregister); From patchwork Wed Jan 9 17:43:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754635 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 7DB7013B4 for ; Wed, 9 Jan 2019 17:48:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D63528972 for ; Wed, 9 Jan 2019 17:48:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6134D28D6D; Wed, 9 Jan 2019 17:48:01 +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 F16B328972 for ; Wed, 9 Jan 2019 17:48:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF9978E00A2; Wed, 9 Jan 2019 12:47:59 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E846D8E0038; Wed, 9 Jan 2019 12:47:59 -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 CFF598E00A2; Wed, 9 Jan 2019 12:47:59 -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 8C97C8E0038 for ; Wed, 9 Jan 2019 12:47:59 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id c14so4552196pls.21 for ; Wed, 09 Jan 2019 09:47:59 -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=a4EoclMwVDF3lBeKs4444RhLdcW6NN/PLzr4cZY+WqQ=; b=kW655aAwpTl0QMWd0hMGSQeEX0T7ixyq+IjWMg95ZVYbAKo+Vl6LgtzQ5QdGUymSJ/ ZHwzUp50PkFBidlo3f3miSOyvgsXDE10LZD08qwxEoGu/mXAlE2rji8l+qdQpUpRPKDo onMNNNBEK7Sp+K6R+nPhisVzNGN95HWqgWBY+t72I5smjdStqRNopXaO2S9xxUXgGeJ9 44DSsUVwzwvhLCzHvL9Lp/yLL6CWVURX9jAq5XJyy/Au6V68VHeNkI1oQLCOlJsKCmJD iTsaWkJ6DTNgHQdY9nbJbjlWfFy067nkRgIJbKNusREmEZLJM8DZcdxq/4AfZL6ecJ/n rLuw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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: AJcUukdCjoa+ikimndACQdTAZrSt3MmynaaAdcsmC79uCAeDBwn5Nyq9 GMC7sKThVPSdiaQnDrZLqrF/0RYiNF2bqBRZZmaMU17R7+esj5Fk3/cNA2VU6oza5Ho8hI45mnn ndW+V6b7XZ0cTQk9MPnP2yYNkPGz4a2OWUhAYtgb1GpCx2Os6PSGQJgOPeGHpemGN6A== X-Received: by 2002:a62:da5a:: with SMTP id w26mr6899461pfl.106.1547056079240; Wed, 09 Jan 2019 09:47:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN5IpGpUNTh30WzALxHWAcdp/vxvesT4qzyxmfG28gOOxrKwdq/X7DtArRF4zqN+/2HltAAB X-Received: by 2002:a62:da5a:: with SMTP id w26mr6899433pfl.106.1547056078540; Wed, 09 Jan 2019 09:47:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056078; cv=none; d=google.com; s=arc-20160816; b=cRl0HoSYlFcLu2HU6PD7DkkChCy7t305zzX0FjEcQlbszJCPNBpyVaPPdNDNFeV5B5 ppcvwRZ11TwuohdgflGLxGl3sGAQjMFtnlOFM5TUgHZzVqRn+w3OccVj6uhcIwtrNyva f+Th2DPGCWkdefrA9oJa9dMqHvl5097HLe82kuGbCnfyo2fCs3p2L97d4+OEjpLavpe3 Edc/ZMqai+aE1+DzORoaD3+Bd4Catvkg7NAJJYznZYJAYo0njpkQgkNaQRacv5UqLIoT xdTKTJXI+17DZEnr8uycV9ZjsgAlCuWXP7nl/kXozFQiR9V7ZeoqoyaFp5tKVCt9+YKv hSOw== 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=a4EoclMwVDF3lBeKs4444RhLdcW6NN/PLzr4cZY+WqQ=; b=MFTaAZiRx5K8mEQUPOH/J8OzycyEVwsbgksAcAQiMSZcQooh3sh/vkzX6YCzCmVo9t 0l2DfSl9kjl8YF4JnnEo1aRj84I3lts+Fy3Vw0SeeScL2nKwdEvGsveOS6gGVSkjtd/n STOYAa/x4iGR1rhgi4jqTH+wHVcKlsBxpHGzx/VTlKdtH6tNEtGkWBKaplVdFoMJtLEj zf3M55Q9HPQmMw1Sl0x9TRnBq9FPcxx20CyJfUJ4SsXgBbQgyjIdC55V2ppsG+9+0vd9 /terKRSO+1BVLalWoKVu86aerGHiSVYn2cZp6W9XJpFPtv/kZ62LetoHvQgcSR+9l7e8 fA/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id c10si25675731pla.173.2019.01.09.09.47.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:47:58 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:47:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485618" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:47:57 -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: [PATCHv3 05/13] Documentation/ABI: Add new node sysfs attributes Date: Wed, 9 Jan 2019 10:43:33 -0700 Message-Id: <20190109174341.19818-6-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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 Add entries for memory initiator and target node class attributes. Signed-off-by: Keith Busch --- Documentation/ABI/stable/sysfs-devices-node | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/stable/sysfs-devices-node b/Documentation/ABI/stable/sysfs-devices-node index 3e90e1f3bf0a..a9c47b4b0eee 100644 --- a/Documentation/ABI/stable/sysfs-devices-node +++ b/Documentation/ABI/stable/sysfs-devices-node @@ -90,4 +90,27 @@ Date: December 2009 Contact: Lee Schermerhorn Description: The node's huge page size control/query attributes. - See Documentation/admin-guide/mm/hugetlbpage.rst \ No newline at end of file + See Documentation/admin-guide/mm/hugetlbpage.rst + +What: /sys/devices/system/node/nodeX/classY/ +Date: December 2018 +Contact: Keith Busch +Description: + The node's relationship to other nodes for access class "Y". + +What: /sys/devices/system/node/nodeX/classY/initiator_nodelist +Date: December 2018 +Contact: Keith Busch +Description: + The node list of memory initiators that have class "Y" access + to this node's memory. CPUs and other memory initiators in + nodes not in the list accessing this node's memory may have + different performance. + +What: /sys/devices/system/node/nodeX/classY/target_nodelist +Date: December 2018 +Contact: Keith Busch +Description: + The node list of memory targets that this initiator node has + class "Y" access. Memory accesses from this node to nodes not + in this list may have differet performance. From patchwork Wed Jan 9 17:43:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754639 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 A76C56C5 for ; Wed, 9 Jan 2019 17:48:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96E8228972 for ; Wed, 9 Jan 2019 17:48:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AF8F28D6D; Wed, 9 Jan 2019 17:48:06 +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 E14BF28972 for ; Wed, 9 Jan 2019 17:48:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D754D8E00A3; Wed, 9 Jan 2019 12:48:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D04018E0038; Wed, 9 Jan 2019 12:48:00 -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 A919A8E00A3; Wed, 9 Jan 2019 12:48:00 -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 5E52A8E0038 for ; Wed, 9 Jan 2019 12:48:00 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id o23so4583476pll.0 for ; Wed, 09 Jan 2019 09:48:00 -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=DA4r5XVbZMv6R0RlwA+K66wymHGZ2fnHYP815/v8iSI=; b=G47tmAFWoozM1v+0m1x6czLQHapXlUWwSej0S+wzJDix8LDxjW8+NehNDS7c+sl4TP KBVrs1LhvwgiU0qCYsmKGLfpZlxzjBaCQgKIdzgoYmZ+RJr4I+wmmDry4vIWOlhjrNf8 YFCOkK2JOz8GeEVKjSvzEYJVwVbGwloD7AziS0FarXePnfxcRJTh5mnoKw8L5+w4qiF2 ay3qmgks4yqHm0lw+aTtPt/ilYu5hCOWAC6g02TlRywNCw8kGF+LfoEXR780DRAbouf5 FoafTOeK1+4/+RjjAWe/byUtho6/TBJ9XuXgidY4IwJpiS9548AyEJ97EbD/8DwEkMz5 JhJw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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: AJcUukeEX3Bhuy0YaHwkCOPgzQ4T63K0AhEecb/RmJhaHQT7o1XXqikH YGVfQ+Wb2piwvRWT7AiQ4TrHdQtsYjoYBMHqMHCirO5pbvoLrDBldW+ooL3QPk7RAzWkCXBOnDe LY1k/01oczRMDSjKQwXvSFczoZU5MIrzYXSsQC5LH8H/21if6e1QMx+6RE8EZfkrBnA== X-Received: by 2002:a63:bc02:: with SMTP id q2mr6312603pge.116.1547056080031; Wed, 09 Jan 2019 09:48:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN4pOfdFUFaRdpq6BdeOGZq8zkMPv6JbviJqUXTmuBaMDcuslfv//9ODqGsXHoFlO+cv7TX+ X-Received: by 2002:a63:bc02:: with SMTP id q2mr6312574pge.116.1547056079128; Wed, 09 Jan 2019 09:47:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056079; cv=none; d=google.com; s=arc-20160816; b=WXo1WBnnZUCE93Vhd96nTMQi+1xN/fFl7AEl6Fj6YUI2pHcAGXT6DvkuKvHvldFQ5z gSYMT7Fz5d6WesTp2M6qhTxRcbXMbd9BruR8Qnvlreg5mGNakkk+3N37nhg7j5f/zwij YJS77XsLTxAOjcR8kfMR46r4MEJw0MIBM6fdOU6vRUC/cqPAYc7Q247+nS+cMSLIa/So EvrmMEsh/o1BWX1PN1nmnrS/9Pha0IbzoosfzmyeM8YhWXe1Xqg4q8KSgHRyJezXQXHk fhssfzxM8+Qu0PxYqY0tX3tgvGp3bcwI0ZLnk0LiiGm+vkolUOJ2zoBsr5NUf71YtkXb 8PbA== 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=DA4r5XVbZMv6R0RlwA+K66wymHGZ2fnHYP815/v8iSI=; b=ycKXGmtUzCqrU0+r8KqiUcALwT03xBeHCAPBoHxZJ9OJd5AnbFRROoJPq3ChGkUbsn JYp5khznwCv75xEepzgdHsdgvRZqMfCtpyTWELpjH2Zaz7zMZiLBKyH+6MceFFabPSBG qoHKrS19duRungiTFlGpgnPws9YlD+rFuJv1qMmdiQNCjAnobgZggsZ6zL01LHb+1/4/ /Qr45IAmZdkOx8guYeQnelkE9d32ifeKa/8zPjYJygSmPerRgc6SfWYvIIwYlUsNv/cV onEfyf987TJ6WaCS7FCWbtkwsrvKCb1mK3WLqeR4IRJKeqNVg+MTzk8DiRKRsx3xK6P1 jVTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id c10si25675731pla.173.2019.01.09.09.47.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:47:59 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:47:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485622" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:47:58 -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: [PATCHv3 06/13] acpi/hmat: Register processor domain to its memory Date: Wed, 9 Jan 2019 10:43:34 -0700 Message-Id: <20190109174341.19818-7-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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 If the HMAT Subsystem Address Range provides a valid processor proximity domain for a memory domain, or a processor domain with the highest performing access exists, register the memory target with that initiator so this relationship will be visible under the node's sysfs directory. Since HMAT requires valid address ranges have an equivalent SRAT entry, verify each memory target satisfies this requirement. Signed-off-by: Keith Busch --- drivers/acpi/hmat.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 136 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/hmat.c b/drivers/acpi/hmat.c index 833a783868d5..efb33c74d1a3 100644 --- a/drivers/acpi/hmat.c +++ b/drivers/acpi/hmat.c @@ -17,6 +17,43 @@ #include #include +static LIST_HEAD(targets); + +struct memory_target { + struct list_head node; + unsigned int memory_pxm; + unsigned long p_nodes[BITS_TO_LONGS(MAX_NUMNODES)]; +}; + +static __init struct memory_target *find_mem_target(unsigned int m) +{ + struct memory_target *t; + + list_for_each_entry(t, &targets, node) + if (t->memory_pxm == m) + return t; + return NULL; +} + +static __init void alloc_memory_target(unsigned int mem_pxm) +{ + struct memory_target *t; + + if (pxm_to_node(mem_pxm) == NUMA_NO_NODE) + return; + + t = find_mem_target(mem_pxm); + if (t) + return; + + t = kzalloc(sizeof(*t), GFP_KERNEL); + if (!t) + return; + + t->memory_pxm = mem_pxm; + list_add_tail(&t->node, &targets); +} + static __init const char *hmat_data_type(u8 type) { switch (type) { @@ -53,11 +90,30 @@ static __init const char *hmat_data_type_suffix(u8 type) }; } +static __init void hmat_update_access(u8 type, u32 value, u32 *best) +{ + switch (type) { + case ACPI_HMAT_ACCESS_LATENCY: + case ACPI_HMAT_READ_LATENCY: + case ACPI_HMAT_WRITE_LATENCY: + if (!*best || *best > value) + *best = value; + break; + case ACPI_HMAT_ACCESS_BANDWIDTH: + case ACPI_HMAT_READ_BANDWIDTH: + case ACPI_HMAT_WRITE_BANDWIDTH: + if (!*best || *best < value) + *best = value; + break; + } +} + static __init int hmat_parse_locality(union acpi_subtable_headers *header, const unsigned long end) { + struct memory_target *t; struct acpi_hmat_locality *loc = (void *)header; - unsigned int init, targ, total_size, ipds, tpds; + unsigned int init, targ, pass, p_node, total_size, ipds, tpds; u32 *inits, *targs, value; u16 *entries; u8 type; @@ -87,12 +143,28 @@ static __init int hmat_parse_locality(union acpi_subtable_headers *header, targs = &inits[ipds]; entries = (u16 *)(&targs[tpds]); for (targ = 0; targ < tpds; targ++) { - for (init = 0; init < ipds; init++) { - value = entries[init * tpds + targ]; - value = (value * loc->entry_base_unit) / 10; - pr_info(" Initiator-Target[%d-%d]:%d%s\n", - inits[init], targs[targ], value, - hmat_data_type_suffix(type)); + u32 best = 0; + + t = find_mem_target(targs[targ]); + for (pass = 0; pass < 2; pass++) { + for (init = 0; init < ipds; init++) { + value = entries[init * tpds + targ]; + value = (value * loc->entry_base_unit) / 10; + + if (!pass) { + hmat_update_access(type, value, &best); + pr_info(" Initiator-Target[%d-%d]:%d%s\n", + inits[init], targs[targ], value, + hmat_data_type_suffix(type)); + continue; + } + + if (!t) + continue; + p_node = pxm_to_node(inits[init]); + if (p_node != NUMA_NO_NODE && value == best) + set_bit(p_node, t->p_nodes); + } } } return 0; @@ -122,6 +194,7 @@ static int __init hmat_parse_address_range(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_hmat_address_range *spa = (void *)header; + struct memory_target *t = NULL; if (spa->header.length != sizeof(*spa)) { pr_err("HMAT: Unexpected address range header length: %d\n", @@ -131,6 +204,23 @@ static int __init hmat_parse_address_range(union acpi_subtable_headers *header, pr_info("HMAT: Memory (%#llx length %#llx) Flags:%04x Processor Domain:%d Memory Domain:%d\n", spa->physical_address_base, spa->physical_address_length, spa->flags, spa->processor_PD, spa->memory_PD); + + if (spa->flags & ACPI_HMAT_MEMORY_PD_VALID) { + t = find_mem_target(spa->memory_PD); + if (!t) { + pr_warn("HMAT: Memory Domain missing from SRAT\n"); + return -EINVAL; + } + } + if (t && spa->flags & ACPI_HMAT_PROCESSOR_PD_VALID) { + int p_node = pxm_to_node(spa->processor_PD); + + if (p_node == NUMA_NO_NODE) { + pr_warn("HMAT: Invalid Processor Domain\n"); + return -EINVAL; + } + set_bit(p_node, t->p_nodes); + } return 0; } @@ -154,6 +244,33 @@ static int __init hmat_parse_subtable(union acpi_subtable_headers *header, } } +static __init int srat_parse_mem_affinity(union acpi_subtable_headers *header, + const unsigned long end) +{ + struct acpi_srat_mem_affinity *ma = (void *)header; + + if (!ma) + return -EINVAL; + if (!(ma->flags & ACPI_SRAT_MEM_ENABLED)) + return 0; + alloc_memory_target(ma->proximity_domain); + return 0; +} + +static __init void hmat_register_targets(void) +{ + struct memory_target *t, *next; + unsigned m, p; + + list_for_each_entry_safe(t, next, &targets, node) { + list_del(&t->node); + m = pxm_to_node(t->memory_pxm); + for_each_set_bit(p, t->p_nodes, MAX_NUMNODES) + register_memory_node_under_compute_node(m, p, 0); + kfree(t); + } +} + static __init int hmat_init(void) { struct acpi_table_header *tbl; @@ -163,6 +280,17 @@ static __init int hmat_init(void) if (srat_disabled()) return 0; + status = acpi_get_table(ACPI_SIG_SRAT, 0, &tbl); + if (ACPI_FAILURE(status)) + return 0; + + if (acpi_table_parse_entries(ACPI_SIG_SRAT, + sizeof(struct acpi_table_srat), + ACPI_SRAT_TYPE_MEMORY_AFFINITY, + srat_parse_mem_affinity, 0) < 0) + goto out_put; + acpi_put_table(tbl); + status = acpi_get_table(ACPI_SIG_HMAT, 0, &tbl); if (ACPI_FAILURE(status)) return 0; @@ -173,6 +301,7 @@ static __init int hmat_init(void) hmat_parse_subtable, 0) < 0) goto out_put; } + hmat_register_targets(); out_put: acpi_put_table(tbl); return 0; From patchwork Wed Jan 9 17:43:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754641 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 ED77C13B4 for ; Wed, 9 Jan 2019 17:48:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDEF128972 for ; Wed, 9 Jan 2019 17:48:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1FC228EC7; Wed, 9 Jan 2019 17:48:08 +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 40DD328A2E for ; Wed, 9 Jan 2019 17:48:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B02CB8E00A5; Wed, 9 Jan 2019 12:48:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A8BAD8E0038; Wed, 9 Jan 2019 12:48:01 -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 84FE78E00A5; Wed, 9 Jan 2019 12:48:01 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 309C08E0038 for ; Wed, 9 Jan 2019 12:48:01 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id y88so5738512pfi.9 for ; Wed, 09 Jan 2019 09:48:01 -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=AYtf+RckJM8KVQDjGkv2FMQzQJ1RDITzHw0rToiBHM8=; b=nI3/TCePaP1admEqfknO47Z8dkfyxchFSqX/glmQRLbcQt3ddR2FWBcv2LpXxF5pzd xSvKbE54hTrcp2ki+r5RGsqwvBS5F0kz+wptyxSJ7D2UpON2se+xgV2iOwJkHVw0orI5 BT9z6pminGU9gqwcbq2uxXOSqF6FDU2IdRmtX4mDgvU1QTy8f0Kly6ssllVVnr7zycCX aQGg4jCazLoyMsbSMSY1KsOT9Bhv9ZLIuKNe+JhUO6herBqEEErjGmTc/tm0HsVwu0On coJhzwTB/b8SFGN+g5qgczd5Z1XckOCFFH7OLKGYFLS61LPMGeEVLmbRLHgFjRiQxlUf 8EYw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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: AJcUukdA2pr6TF9V5ZJ1A0ssbjSjAqNGzaXG7KsGNazExMsJCLpGuN1h LSEeTGlYauYZ8B9ixy7oEExMkt3jLMrw4Kjn4rcVxS2INGuBhi/KJAnAFuCihIL3BtnUYFpVXLP 08V5sztYk1hrP1CWrvvqeKmRHisIKJ0au2cqtzThM5P2nPyUHcw+zeaSFUynMpj7DAw== X-Received: by 2002:a63:1a4b:: with SMTP id a11mr6319998pgm.254.1547056080850; Wed, 09 Jan 2019 09:48:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN4J9wgpuf1oBsLXOXUmYZKN0zl44pj47cwW51QUoINt7/qjMtuRyQ7w4RDZP+N/P2xlaovd X-Received: by 2002:a63:1a4b:: with SMTP id a11mr6319950pgm.254.1547056079753; Wed, 09 Jan 2019 09:47:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056079; cv=none; d=google.com; s=arc-20160816; b=vEmAwOFFN5nixOVCUp/FARLYsg+wzQnjQrcR7JqfIPC+v8BwLbEZUQVtuxoNrno6fl VhN+JMAfszSlnP6wCgIcQsMCozXgo+PCe0rmi8ixBOD5fz62oT9QkIlcl8it3e4Y5ekP 91KMq6HsyTkkBwPmgC99B2KROp91Ewv+mputuTxRewz1yBsWax2Gp6TthnaQ3tS67ZCJ EGWIcz5Ybwu0bKi925YJ0Xdc8DZKZIJQ5uP0qyGarVBvorUk0Srhn7ENsD+v8/Of7YET GKAsR8EQTlrsjQCzFYOxBDLPcPrtTToZYfEMPqDHhj1REhJAAvmr3xGlVMcOKBl6pkrR +djA== 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=AYtf+RckJM8KVQDjGkv2FMQzQJ1RDITzHw0rToiBHM8=; b=Nh+QYCj4MQ7CTnFtJM9d6heFiOoy3sqXM5wuZZELkbKYyNSjo32Fj7ai/kZR70imlZ Z7CZdDqUnq2UQD2rzfMivxehahqyLkO2P0+vms1e7m5cL5zEgxdBiOSwSPFTmoHiv0vo hrvuSIF9Z3Xnk7kZt3fgxxzlEHeOChIKVeKnfdTJo/1Jc0JsTinq0NmJNvS483O+fsEj GQMPe63H2NatX0Fp2S9WI1PsomSbN1SnKW7K3DI4mcrHZjYbfy2WqPT/HJULqlWYqCrB rr40wzJRw2sxRRWf+sMbM42QHyZ2ZCoRhHYEQDkiPqX7Tcppk2ZKBcw65sLSeIzQcQ76 VPpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id c10si25675731pla.173.2019.01.09.09.47.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:47:59 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:47:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485626" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:47:58 -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: [PATCHv3 07/13] node: Add heterogenous memory access attributes Date: Wed, 9 Jan 2019 10:43:35 -0700 Message-Id: <20190109174341.19818-8-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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 Heterogeneous memory systems provide memory nodes with different latency and bandwidth performance attributes. Provide a new kernel interface for subsystems to register the attributes under the memory target node's initiator access class. If the system provides this information, applications may query these attributes when deciding which node to request memory. The following example shows the new sysfs hierarchy for a node exporting performance attributes: # tree -P "read*|write*" /sys/devices/system/node/nodeY/classZ/ /sys/devices/system/node/nodeY/classZ/ |-- read_bandwidth |-- read_latency |-- write_bandwidth `-- write_latency The bandwidth is exported as MB/s and latency is reported in nanoseconds. Memory accesses from an initiator node that is not one of the memory's class "Z" initiator nodes may encounter different performance than reported here. When a subsystem makes use of this interface, initiators of a lower class number, "Z", have better performance relative to higher class numbers. When provided, class 0 is the highest performing access class. Signed-off-by: Keith Busch --- drivers/base/Kconfig | 8 ++++++++ drivers/base/node.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/node.h | 25 +++++++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 3e63a900b330..6014980238e8 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -149,6 +149,14 @@ config DEBUG_TEST_DRIVER_REMOVE unusable. You should say N here unless you are explicitly looking to test this functionality. +config HMEM_REPORTING + bool + default y + depends on NUMA + help + Enable reporting for heterogenous memory access attributes under + their non-uniform memory nodes. + source "drivers/base/test/Kconfig" config SYS_HYPERVISOR diff --git a/drivers/base/node.c b/drivers/base/node.c index 1da5072116ab..1e909f61e8b1 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -66,6 +66,9 @@ struct node_class_nodes { unsigned class; nodemask_t initiator_nodes; nodemask_t target_nodes; +#ifdef CONFIG_HMEM_REPORTING + struct node_hmem_attrs hmem_attrs; +#endif }; #define to_class_nodes(dev) container_of(dev, struct node_class_nodes, dev) @@ -145,6 +148,51 @@ static struct node_class_nodes *node_init_node_class(struct device *parent, return NULL; } +#ifdef CONFIG_HMEM_REPORTING +#define ACCESS_ATTR(name) \ +static ssize_t name##_show(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + return sprintf(buf, "%u\n", to_class_nodes(dev)->hmem_attrs.name); \ +} \ +static DEVICE_ATTR_RO(name); + +ACCESS_ATTR(read_bandwidth) +ACCESS_ATTR(read_latency) +ACCESS_ATTR(write_bandwidth) +ACCESS_ATTR(write_latency) + +static struct attribute *access_attrs[] = { + &dev_attr_read_bandwidth.attr, + &dev_attr_read_latency.attr, + &dev_attr_write_bandwidth.attr, + &dev_attr_write_latency.attr, + NULL, +}; +ATTRIBUTE_GROUPS(access); + +void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs, + unsigned class) +{ + struct node_class_nodes *c; + struct node *node; + + if (WARN_ON_ONCE(!node_online(nid))) + return; + + node = node_devices[nid]; + c = node_init_node_class(&node->dev, &node->class_list, class); + if (!c) + return; + + c->hmem_attrs = *hmem_attrs; + if (sysfs_create_groups(&c->dev.kobj, access_groups)) + pr_info("failed to add performance attribute group to node %d\n", + nid); +} +#endif + #define K(x) ((x) << (PAGE_SHIFT - 10)) static ssize_t node_read_meminfo(struct device *dev, struct device_attribute *attr, char *buf) diff --git a/include/linux/node.h b/include/linux/node.h index 8e3666c12ef2..e22940a593c2 100644 --- a/include/linux/node.h +++ b/include/linux/node.h @@ -20,6 +20,31 @@ #include #include +#ifdef CONFIG_HMEM_REPORTING +/** + * struct node_hmem_attrs - heterogeneous memory performance attributes + * + * @read_bandwidth: Read bandwidth in MB/s + * @write_bandwidth: Write bandwidth in MB/s + * @read_latency: Read latency in nanoseconds + * @write_latency: Write latency in nanoseconds + */ +struct node_hmem_attrs { + unsigned int read_bandwidth; + unsigned int write_bandwidth; + unsigned int read_latency; + unsigned int write_latency; +}; +void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs, + unsigned class); +#else +static inline void node_set_perf_attrs(unsigned int nid, + struct node_hmem_attrs *hmem_attrs, + unsigned class) +{ +} +#endif + struct node { struct device dev; struct list_head class_list; From patchwork Wed Jan 9 17:43:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754645 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 4922E6C5 for ; Wed, 9 Jan 2019 17:48:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3253628972 for ; Wed, 9 Jan 2019 17:48:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26A0928D6D; Wed, 9 Jan 2019 17:48:11 +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 BD82928972 for ; Wed, 9 Jan 2019 17:48:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F8DB8E00A4; Wed, 9 Jan 2019 12:48:02 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 00BB88E0038; Wed, 9 Jan 2019 12:48:01 -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 AFFE98E00A4; Wed, 9 Jan 2019 12:48:01 -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 3EB628E00A4 for ; Wed, 9 Jan 2019 12:48:01 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id n17so5711860pfk.23 for ; Wed, 09 Jan 2019 09:48:01 -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=wBtTheXbL4R1uAeXtTtFTc8TW8IlrYmOF4We5vmciwM=; b=phtxgd7D8PrvSM+OiuoMTiPkiIfvoCIqPwncTyKdKwVlkadX0KWLzGKmFlnDclNjwX PyN9SBr5VOc/9oOHJHp45hKt0SkxGzb/3a/67a03+b4JzRq+34rHfrg7jLOxKq34PsmO m+63Femms5LV9W9MYdx6BVjlBGYyg+GYFdbzhpYTOzJVPXkT0XY4hR4sYiX8pLa1Mccm JzOphxVFQlg3NqE2nfBwaXt8IUFb0G1IcLHBeLs9WG5bcxI19omBFDnXCAGx/y2jNdop GbFk/jo/v3Pq4eJhTjYkeOIblf4RnLgumVfabPqqHKNsrXxfYmX+BHb+QsN2F1usWJVs 8JKA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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: AJcUukfowN6cYFJRP5DbLzLcLbkIY73ZI78m+3gSwyWZcAAELXOvV2ys 6oSm4Gs6J55a6xZaIqyWzHY3wWGkK/ed0eXaUUv9LFlJQpkBrwv7QSGsKDTL6NJ/Km3HcUPDCjB hc3soIoN9ua053T52T+EUgJq3Vo69pTMTQQpkyIIxfugGKMR2y1Sfmu1jHnkdu85CAQ== X-Received: by 2002:a62:6dc7:: with SMTP id i190mr6891148pfc.166.1547056080923; Wed, 09 Jan 2019 09:48:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN6bdInH4Thk5nNRJ8Qs9arfp1D8edFRN6JiNOPwLhZLXXVJP4zAgBzCG7EEUFgB7nWplSax X-Received: by 2002:a62:6dc7:: with SMTP id i190mr6891126pfc.166.1547056080275; Wed, 09 Jan 2019 09:48:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056080; cv=none; d=google.com; s=arc-20160816; b=nHmQA0XUpdqtw0QKGOnwPtwjtRszY+IsZfV7nWS53le7il4McAKezVuhxg1H0xjeIN yIGNIOr08LBtPH5Ic6SMP/usrmJ5q7QTQ1GXOX21u5YWXwlFdj2jaiUIKb9mLqHwGR4l fLUpZPDb9iqAiA/+5SqxVAxsrIV+MyhLGRyZ6QewxV5l/wEZ6PJdclxCtIgPZLhcqhV0 5apkXSnUsH/aZZI+dMiT0jDT5aR2tBtDbLBiEzsIM1oLDO4MMHduHSfDXugpyC77/34a Nj83dkl95p0SqboplPRQGN7RcDdCxcnkcS5VdsKD4Ofmz6Auvuth5mWa9AyVawkCTBt7 U83Q== 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=wBtTheXbL4R1uAeXtTtFTc8TW8IlrYmOF4We5vmciwM=; b=kyN0nPJBfXlDlFm45DP7MjB66KAyIiYD3ZGdvkz2uIRvOMv+11muALFMEuH6sRXy7c MpJfURztD12CbDZ5CW6jpniqo9WVEStGe2/kect6DFST+mPGxQO3WHQjtwt53kTn3bhl lDMRfew0hLhxsWGkpwZsYLrf1CO4H+Oy+k9FBahaR9cJ13LCWCSTxKC0BLPoTyE8YNHu iAXNpG7F5N8SLzcQegwqje0gRzs7A+9vNLIW8OdCcvQM8JSO0Qp2t5X5dEmd8GVy+1p6 4BWsP2D3Irqw6ksvEGXmAE5EpaLtpewiFosbLzTf75jNruiNwddRzugNMAloX6Kp2CTg 8DmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id c10si25675731pla.173.2019.01.09.09.48.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:48:00 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:47:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485629" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:47:59 -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: [PATCHv3 08/13] Documentation/ABI: Add node performance attributes Date: Wed, 9 Jan 2019 10:43:36 -0700 Message-Id: <20190109174341.19818-9-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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 Add descriptions for memory class initiator performance access attributes. Signed-off-by: Keith Busch --- Documentation/ABI/stable/sysfs-devices-node | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Documentation/ABI/stable/sysfs-devices-node b/Documentation/ABI/stable/sysfs-devices-node index a9c47b4b0eee..74cfc80cabf6 100644 --- a/Documentation/ABI/stable/sysfs-devices-node +++ b/Documentation/ABI/stable/sysfs-devices-node @@ -114,3 +114,31 @@ Description: The node list of memory targets that this initiator node has class "Y" access. Memory accesses from this node to nodes not in this list may have differet performance. + +What: /sys/devices/system/node/nodeX/classY/read_bandwidth +Date: December 2018 +Contact: Keith Busch +Description: + This node's read bandwidth in MB/s available to memory + initiators in nodes found in this class's initiators_nodelist. + +What: /sys/devices/system/node/nodeX/classY/read_latency +Date: December 2018 +Contact: Keith Busch +Description: + This node's read latency in nanosecondss available to memory + initiators in nodes found in this class's initiators_nodelist. + +What: /sys/devices/system/node/nodeX/classY/write_bandwidth +Date: December 2018 +Contact: Keith Busch +Description: + This node's write bandwidth in MB/s available to memory + initiators in nodes found in this class's initiators_nodelist. + +What: /sys/devices/system/node/nodeX/classY/write_latency +Date: December 2018 +Contact: Keith Busch +Description: + This node's write latency in nanosecondss available to memory + initiators in nodes found in this class's initiators_nodelist. From patchwork Wed Jan 9 17:43:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754649 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 1F5EC13B4 for ; Wed, 9 Jan 2019 17:48:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 102D128972 for ; Wed, 9 Jan 2019 17:48:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0487928D6D; Wed, 9 Jan 2019 17:48:14 +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 8E97B28972 for ; Wed, 9 Jan 2019 17:48:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75B748E0038; Wed, 9 Jan 2019 12:48:02 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6BD708E00A6; Wed, 9 Jan 2019 12:48:02 -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 4CD628E0038; Wed, 9 Jan 2019 12:48:02 -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 CF98C8E00A6 for ; Wed, 9 Jan 2019 12:48:01 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id 82so5732792pfs.20 for ; Wed, 09 Jan 2019 09:48:01 -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=4cS41mm0645F0oPGt+z1xoyu71BBSxW7i0CzyIKciN0=; b=ZQq4SHwODfhq7WN2mkp9sLJ2w9dP82hGvG0JDTlI6p/YCmsGLUqZelIkBtucOh0iq5 rqlCO7QnkvD1IZbHjCm4tqT7pTD51Q6T1fQDdDgS8b49YWmGrpiQDkw/TnlW1DJ3Frk5 mgl9qNXjY4FBkG9IUiYuUE23yA3h8cjkDH7oNsyvlFXvn6PJ10/Sfu9R1IccuFXLQurP lFtYv9JSTqawfZkTXPA6KA+YJ48h9Syo/gJw1FV2d5AgLLwRcU8JznVfG54s864WVj6J mstft+jAvAVQJj/NXEd7usLmOmzNXYh4mKZQVtQpDaV37jwa9L8QhJWWNS5xv/L+6ilE YdyA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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: AJcUuke2GTaOzTFq2KkCyh55EXhPU0dGMk63GK/C8GWoh4BGdG6W1AWE hBV07P8jKUJLS97Fb4OJDJifETltsnaLyYW9kIc6qKje9zLhNDZdKPzOYv5ktLgNhodyK+1w0iH kIgbwhdBF01da0jBhXC8Nu1WiTyezjN2jrMUWz5gIeZcr86im0PvtcjrenKxra0bEcA== X-Received: by 2002:a17:902:714c:: with SMTP id u12mr6904731plm.234.1547056081525; Wed, 09 Jan 2019 09:48:01 -0800 (PST) X-Google-Smtp-Source: ALg8bN6GjSvh4Q8M4+E/+1LbH22eO1CnT4DsQUQS3gJhQU6m5i2SsCxHYBnH8qbTBon8XPtjaRjA X-Received: by 2002:a17:902:714c:: with SMTP id u12mr6904696plm.234.1547056080838; Wed, 09 Jan 2019 09:48:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056080; cv=none; d=google.com; s=arc-20160816; b=FpuM9SAd9cbVN+LFTeFrNWCsNxqJ0Wn/d0baJ0ArC4NOKS35qjxj1R26duDt5xmNTw rZwe685Ou854VwLDXkgLd0DXhtS+9dng3XYknR67wNXM8xiyAcVpjn3AGDzUMn67Ashs mJn+ixwbHV6c5+XeY8GczkCX2Z4KikjDTK3vj/PhtyBwi28EcX7Uk0l7FQz43TqnLEw3 J0ZrhPTHHvfFr6Rqkuth0py1w9w6k+0uKfxrVNWK/DFnVan3247Vrklg9uR9oeR5sWg+ 0HM1Y5Ye9oLNZgj7buTz16cVl8X7qv00GJobDNELMwc5YH1kb4LDhgn5CDU3fHQNa/6J i5eg== 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=4cS41mm0645F0oPGt+z1xoyu71BBSxW7i0CzyIKciN0=; b=oo8P3//YJ3NWrTfR6gQ6feZG5Hxy8XUw3AQ9xAVkvIMV7ZEDCeoYmc7DUOXtZ2LGc0 U1LlKUo3zoyzN/LFVq5i59I9D5MTcOEAOmnTtAkEDQZgLi4Ikmsz+yrFoEPyiwflZIdi AQA2Wnt7yTVEoiPetxHWenwOHrLzB9OFBrCgNZoHdEl6VsCkXmQmh6Y3j4kMSEeR/GU0 KRXk9NvstDg5oavjDjYb32BRKNeADK3N1zrsB5BJQadDvCYiIC+omr7Zl2zkBVUzXLKW ugewkdCmKxtchRtTFw4ziwEmOt7nxC57qIxDs7lxcBFQ3685O5JqBEIVC1ObMzZtuZfq qKYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id c10si25675731pla.173.2019.01.09.09.48.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:48:00 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:48:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485636" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:47:59 -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: [PATCHv3 09/13] acpi/hmat: Register performance attributes Date: Wed, 9 Jan 2019 10:43:37 -0700 Message-Id: <20190109174341.19818-10-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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 Save the best performace access attributes and register these with the memory's node if HMAT provides the locality table. While HMAT does make it possible to know performance for all possible initiator-target pairings, we export only the best pairings at this time. Signed-off-by: Keith Busch --- drivers/acpi/Kconfig | 1 + drivers/acpi/hmat.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index b102d9f544ee..ac6c38b50916 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -329,6 +329,7 @@ config ACPI_NUMA config ACPI_HMAT bool "ACPI Heterogeneous Memory Attribute Table Support" depends on ACPI_NUMA + select HMEM_REPORTING help Parses representation of the ACPI Heterogeneous Memory Attributes Table (HMAT) and set the memory node relationships and access diff --git a/drivers/acpi/hmat.c b/drivers/acpi/hmat.c index efb33c74d1a3..45e20dc677f9 100644 --- a/drivers/acpi/hmat.c +++ b/drivers/acpi/hmat.c @@ -23,6 +23,8 @@ struct memory_target { struct list_head node; unsigned int memory_pxm; unsigned long p_nodes[BITS_TO_LONGS(MAX_NUMNODES)]; + bool hmem_valid; + struct node_hmem_attrs hmem; }; static __init struct memory_target *find_mem_target(unsigned int m) @@ -108,6 +110,34 @@ static __init void hmat_update_access(u8 type, u32 value, u32 *best) } } +static __init void hmat_update_target(struct memory_target *t, u8 type, + u32 value) +{ + switch (type) { + case ACPI_HMAT_ACCESS_LATENCY: + t->hmem.read_latency = value; + t->hmem.write_latency = value; + break; + case ACPI_HMAT_READ_LATENCY: + t->hmem.read_latency = value; + break; + case ACPI_HMAT_WRITE_LATENCY: + t->hmem.write_latency = value; + break; + case ACPI_HMAT_ACCESS_BANDWIDTH: + t->hmem.read_bandwidth = value; + t->hmem.write_bandwidth = value; + break; + case ACPI_HMAT_READ_BANDWIDTH: + t->hmem.read_bandwidth = value; + break; + case ACPI_HMAT_WRITE_BANDWIDTH: + t->hmem.write_bandwidth = value; + break; + } + t->hmem_valid = true; +} + static __init int hmat_parse_locality(union acpi_subtable_headers *header, const unsigned long end) { @@ -166,6 +196,8 @@ static __init int hmat_parse_locality(union acpi_subtable_headers *header, set_bit(p_node, t->p_nodes); } } + if (t && best) + hmat_update_target(t, type, best); } return 0; } @@ -267,6 +299,8 @@ static __init void hmat_register_targets(void) m = pxm_to_node(t->memory_pxm); for_each_set_bit(p, t->p_nodes, MAX_NUMNODES) register_memory_node_under_compute_node(m, p, 0); + if (t->hmem_valid) + node_set_perf_attrs(m, &t->hmem, 0); kfree(t); } } From patchwork Wed Jan 9 17:43:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754651 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 35EDF6C5 for ; Wed, 9 Jan 2019 17:48:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 261CD28972 for ; Wed, 9 Jan 2019 17:48:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A9A328D6D; Wed, 9 Jan 2019 17:48:17 +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 69E4B28972 for ; Wed, 9 Jan 2019 17:48:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4746E8E00A8; Wed, 9 Jan 2019 12:48:03 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3FF068E00A6; Wed, 9 Jan 2019 12:48:03 -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 27AFB8E00A8; Wed, 9 Jan 2019 12:48:03 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id CF7468E00A6 for ; Wed, 9 Jan 2019 12:48:02 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id t72so5722495pfi.21 for ; Wed, 09 Jan 2019 09:48:02 -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=t2b6xpOyb2bVHTLZNAWW/AEy+vaE5WGzHQgBNhAcNp8=; b=euDabePwFImV9tSXUt2funcCGZjFWRG/Wq1z8EVBWr5Kt40Cldy7EDPszgq/qDlqGn +XnyE3U4r+KIRUANLCjsunOR+TUnITn/FI63xHmiYjCQ/V5Z4xMDfBpMUwjFgSh1QthL jVhUnmY1FAhG6cOxN8eYqIWrb0pHqjvv//a5vL2SdgS7IUFmoScrXZAwRfg8N9TssWF9 L5ND8Woc7+E+nun5AMkQDiY5v2hyiALJaNkV6fGa/I4V2/dVoZzYdZCVayXqH6rTczSC RfP5vC9mveQnzDwq/Ln+QQTtbOUKYyhiabtmgUbZdZdwDbSQlj7oW7hheU6ZJ6GkY9F9 nMEA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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: AJcUukcIcvXXiqEpKtQpxNkk0f40QVqN03UjkKgit8LglB8u039KmpY5 CT4PYGn1uqZBD/LOVXY1qWFKnbTPiXgn4aIz9wPPM9OAGnh31Dd+Qv5ZzddYK595wXD19qOuMcD iofwvKm7SlswhpXGkOaGrFyq02ULCq6vPyPTA9ZMABGQVSTXgGu4N4wnkmm/cakk/Wg== X-Received: by 2002:a62:1a91:: with SMTP id a139mr7125823pfa.64.1547056082470; Wed, 09 Jan 2019 09:48:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7FUWBQYWqbkEuXIhFN1qT3i7KJX/3pN2FlNZswaDTIiG7pG+HFnueXenAE+ABTg4gOKZDN X-Received: by 2002:a62:1a91:: with SMTP id a139mr7125771pfa.64.1547056081502; Wed, 09 Jan 2019 09:48:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056081; cv=none; d=google.com; s=arc-20160816; b=Ui8M8DlHEcXx3M0oKewvhhUjWZddTtwT/SKlkPuIqNBH+PPlKgj7PHd1CVLFmIluld DDMBFesyjWICMFtUspYok7fivKxr6yfSLtrN1kwcy3Msd5stLq5H1h3uBAlxK5ynR9Ex ybhxhHRmkWQKZ03UCj1gu8ltJQgipnWDso3r9rHR0VTuwHI5U30xGqoVDLpTOkdqeyBI +HGXCllOIRQr0EUdegqqCu32HnvIn4ROet8LW4ojP7wcLpztOBu8R5qkEgLJDbCgtwfF yiF+25+cGlcQFhZe5JH1xCIwvdSHQOJBdfEeI/QzBUm34rwhZfpN0Glqy3u0wjEawZvR tKvQ== 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=t2b6xpOyb2bVHTLZNAWW/AEy+vaE5WGzHQgBNhAcNp8=; b=ZZqiT5VvfMmHNACANlpJhZtj/9h/CYH4aViL2eqTFgF0+m1qwPDj2wGmjb3EZc0NUo MEW9ML4z+mPyIuVppUAD/0uEEbMTIixD1dxprltSWdUVp6YFxWt+tRmzdefKncY3gUVl AL/JW8jGwJFEDnJ7hynKyfjueBMuy184bwtKQK7uv6g6Uh7p9ZvQnccdwuERMUUOYrKV K1ndFLvLndtg2PiqUUSnX3HDGhj8XOc9h8rcbhUAlbdm5+hlNQgax+aXAIeSDb2dcKUp Ai7nvAa8uBJe6vjhXssQslNZ53AWi883Gh3TSgevOTmbaMtk62u5+ta7jYkpZkpc/gUO VhoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id c10si25675731pla.173.2019.01.09.09.48.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:48:01 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:48:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485642" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:48:00 -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: [PATCHv3 10/13] node: Add memory caching attributes Date: Wed, 9 Jan 2019 10:43:38 -0700 Message-Id: <20190109174341.19818-11-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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 System memory may have side caches to help improve access speed to frequently requested address ranges. While the system provided cache is transparent to the software accessing these memory ranges, applications can optimize their own access based on cache attributes. Provide a new API for the kernel to register these memory side caches under the memory node that provides it. The new sysfs representation is modeled from the existing cpu cacheinfo attributes, as seen from /sys/devices/system/cpu/cpuX/side_cache/. Unlike CPU cacheinfo, though, the node cache level is reported from the view of the memory. A higher number is nearer to the CPU, while lower levels are closer to the backing memory. Also unlike CPU cache, it is assumed the system will handle flushing any dirty cached memory to the last level on a power failure if the range is persistent memory. The attributes we export are the cache size, the line size, associativity, and write back policy. Signed-off-by: Keith Busch --- drivers/base/node.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/node.h | 39 ++++++++++++++ 2 files changed, 181 insertions(+) diff --git a/drivers/base/node.c b/drivers/base/node.c index 1e909f61e8b1..7ff3ed566d7d 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -191,6 +191,146 @@ void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs, pr_info("failed to add performance attribute group to node %d\n", nid); } + +struct node_cache_info { + struct device dev; + struct list_head node; + struct node_cache_attrs cache_attrs; +}; +#define to_cache_info(device) container_of(device, struct node_cache_info, dev) + +#define CACHE_ATTR(name, fmt) \ +static ssize_t name##_show(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ +{ \ + return sprintf(buf, fmt "\n", to_cache_info(dev)->cache_attrs.name);\ +} \ +DEVICE_ATTR_RO(name); + +CACHE_ATTR(size, "%llu") +CACHE_ATTR(level, "%u") +CACHE_ATTR(line_size, "%u") +CACHE_ATTR(associativity, "%u") +CACHE_ATTR(write_policy, "%u") + +static struct attribute *cache_attrs[] = { + &dev_attr_level.attr, + &dev_attr_associativity.attr, + &dev_attr_size.attr, + &dev_attr_line_size.attr, + &dev_attr_write_policy.attr, + NULL, +}; +ATTRIBUTE_GROUPS(cache); + +static void node_cache_release(struct device *dev) +{ + kfree(dev); +} + +static void node_cacheinfo_release(struct device *dev) +{ + struct node_cache_info *info = to_cache_info(dev); + kfree(info); +} + +static void node_init_cache_dev(struct node *node) +{ + struct device *dev; + + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + return; + + dev->parent = &node->dev; + dev->release = node_cache_release; + if (dev_set_name(dev, "side_cache")) + goto free_dev; + + if (device_register(dev)) + goto free_name; + + pm_runtime_no_callbacks(dev); + node->cache_dev = dev; + return; +free_name: + kfree_const(dev->kobj.name); +free_dev: + kfree(dev); +} + +void node_add_cache(unsigned int nid, struct node_cache_attrs *cache_attrs) +{ + struct node_cache_info *info; + struct device *dev; + struct node *node; + + if (!node_online(nid) || !node_devices[nid]) + return; + + node = node_devices[nid]; + list_for_each_entry(info, &node->cache_attrs, node) { + if (info->cache_attrs.level == cache_attrs->level) { + dev_warn(&node->dev, + "attempt to add duplicate cache level:%d\n", + cache_attrs->level); + return; + } + } + + if (!node->cache_dev) + node_init_cache_dev(node); + if (!node->cache_dev) + return; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return; + + dev = &info->dev; + dev->parent = node->cache_dev; + dev->release = node_cacheinfo_release; + dev->groups = cache_groups; + if (dev_set_name(dev, "index%d", cache_attrs->level)) + goto free_cache; + + info->cache_attrs = *cache_attrs; + if (device_register(dev)) { + dev_warn(&node->dev, "failed to add cache level:%d\n", + cache_attrs->level); + goto free_name; + } + pm_runtime_no_callbacks(dev); + list_add_tail(&info->node, &node->cache_attrs); + return; +free_name: + kfree_const(dev->kobj.name); +free_cache: + kfree(info); +} + +static void node_remove_caches(struct node *node) +{ + struct node_cache_info *info, *next; + + if (!node->cache_dev) + return; + + list_for_each_entry_safe(info, next, &node->cache_attrs, node) { + list_del(&info->node); + device_unregister(&info->dev); + } + device_unregister(node->cache_dev); +} + +static void node_init_caches(unsigned int nid) +{ + INIT_LIST_HEAD(&node_devices[nid]->cache_attrs); +} +#else +static void node_init_caches(unsigned int nid) { } +static void node_remove_caches(struct node *node) { } #endif #define K(x) ((x) << (PAGE_SHIFT - 10)) @@ -475,6 +615,7 @@ void unregister_node(struct node *node) { hugetlb_unregister_node(node); /* no-op, if memoryless node */ node_remove_classes(node); + node_remove_caches(node); device_unregister(&node->dev); } @@ -755,6 +896,7 @@ int __register_one_node(int nid) INIT_LIST_HEAD(&node_devices[nid]->class_list); /* initialize work queue for memory hot plug */ init_node_hugetlb_work(nid); + node_init_caches(nid); return error; } diff --git a/include/linux/node.h b/include/linux/node.h index e22940a593c2..8cdf2b2808e4 100644 --- a/include/linux/node.h +++ b/include/linux/node.h @@ -37,12 +37,47 @@ struct node_hmem_attrs { }; void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs, unsigned class); + +enum cache_associativity { + NODE_CACHE_DIRECT_MAP, + NODE_CACHE_INDEXED, + NODE_CACHE_OTHER, +}; + +enum cache_write_policy { + NODE_CACHE_WRITE_BACK, + NODE_CACHE_WRITE_THROUGH, + NODE_CACHE_WRITE_OTHER, +}; + +/** + * struct node_cache_attrs - system memory caching attributes + * + * @associativity: The ways memory blocks may be placed in cache + * @write_policy: Write back or write through policy + * @size: Total size of cache in bytes + * @line_size: Number of bytes fetched on a cache miss + * @level: Represents the cache hierarchy level + */ +struct node_cache_attrs { + enum cache_associativity associativity; + enum cache_write_policy write_policy; + u64 size; + u16 line_size; + u8 level; +}; +void node_add_cache(unsigned int nid, struct node_cache_attrs *cache_attrs); #else static inline void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs, unsigned class) { } + +static inline void node_add_cache(unsigned int nid, + struct node_cache_attrs *cache_attrs) +{ +} #endif struct node { @@ -51,6 +86,10 @@ struct node { #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS) struct work_struct node_work; #endif +#ifdef CONFIG_HMEM_REPORTING + struct list_head cache_attrs; + struct device *cache_dev; +#endif }; struct memory_block; From patchwork Wed Jan 9 17:43:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754653 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 D5D0D13B4 for ; Wed, 9 Jan 2019 17:48:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C551F28972 for ; Wed, 9 Jan 2019 17:48:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B93BA28D6D; Wed, 9 Jan 2019 17:48: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 4DA0D28972 for ; Wed, 9 Jan 2019 17:48:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8956A8E00A7; Wed, 9 Jan 2019 12:48:03 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7A9338E00A6; Wed, 9 Jan 2019 12:48:03 -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 586088E00A9; Wed, 9 Jan 2019 12:48:03 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 003488E00A7 for ; Wed, 9 Jan 2019 12:48:03 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id l9so4558189plt.7 for ; Wed, 09 Jan 2019 09:48:02 -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=XRzaa5h+gNb8Jm8KkLlBBbsLRuLWb5Ki0XiuGLOtJU4=; b=OGWAHe4NDrWJsVd9q7tOArgbGG2vQ2W6vc3JeTI6WIAjxWrB8BBSVhBLi3DV5aauJ8 z/q/E3EJ/YioLQwFHKwed8ER6pNmOEV/jN5GZQF95AB7uuWkCpRLeHwjt3epEc/FbKRb PUJJdLYRKfSKLLg1OlbxH75FYeoBnRbYSor63oRkqDL6YySbkzoVnXLrjlihgtcmPb7E l3pQfwvBliVA4zzhYuwkI87m+/PO4netkyVrArfU9ux3inq1ykahqb7prnCjHuyPyXFN 0jhG2A8JNwR5XuAnZa47UX6i3HDlTNRsFnaQ9k9YGG5KLmv/tzOSehH8vBjGftNO/y3N mmZQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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: AJcUukc1GnZSoa1uv+nkowrHg95SMlM9CS9a6oFw2dmrXe/Hg6HMegEy ovRsyyh30bv+rhPYQFvMR3uws13I5SUwEOhO6gC0pKs+IVbl36D87kKjjJc+S/X3AUVNuC/ftKf INK1sRF/RRa6/OnGorAvfsRnOc7XDRzHv9CNdhLw/DrFHoj0mW3G4JGYxkRamtjAqgA== X-Received: by 2002:a17:902:ba89:: with SMTP id k9mr7059177pls.189.1547056082677; Wed, 09 Jan 2019 09:48:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7XJkFHe9hkTCZ/psIG8tqQRx+ZI8EvqwTK8O1sxxKoPWh3mkY7lVN6naYNY51p+0XguNnL X-Received: by 2002:a17:902:ba89:: with SMTP id k9mr7059143pls.189.1547056082033; Wed, 09 Jan 2019 09:48:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056082; cv=none; d=google.com; s=arc-20160816; b=ULmw3skAMFgU1aus23ZpUiFiKcL/mSTbJ+Z1VmRiyB++GVv+wLh2xWYP9h7P8Uw7K3 qK1T6fbgPF/a/nG37J5sr9Ffva7YFHcSHAkdAM+UivrIqj3y5cwlhcGTaNiPwOaDmb2L +98l0wHdKBLLBIuzDFbbgq8jW02PhgF/UJGcvwSSJpEg8rSlANYBE4gRAjscaLF7pih/ EKJF0/pSJ5z3TNIDl1rwTVAYYUKRy6boAA+guCB1foQIqRmtLaBETQt693cWMvGHfUN2 Ma2GSpXW8CjY5xs5sZUzYCU1YpyzqDH4nqWCNwKprXUM8NKuUZO2gRZQqZNu2hy5eOJO fYSA== 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=XRzaa5h+gNb8Jm8KkLlBBbsLRuLWb5Ki0XiuGLOtJU4=; b=1IwSIraHtKnwr5L+OzgPz+1GAgwu3cCX2j+xII6hKbRJsbFO+VnwEQt7R3MAuTpt1S zkULyb1pWBgI39f6BCTLgy+gebRsOLnkZB88VIxyoJgf0IelfSiebOsNel4to0QNyPlp gpnWNo84V2KOz+8yvVEMs5trBkoiRuTp4lfgJukOuadJvX/cim+PRWNKhGTBrCC8xmee ovr3viLDkow/m4Auda1ptB6SqpUkp/UU+DtTLb9YQlsE/E/7/kUTj70WPVWxBO4IdPi7 +lN+iMbeVuz8JUikk9lUHipQ5mFJyi9g1BTUSwvLZfGqP+2HbpSE5q92fWhqoyfF0cv4 twYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id c10si25675731pla.173.2019.01.09.09.48.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:48:02 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:48:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485647" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:48:01 -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: [PATCHv3 11/13] Documentation/ABI: Add node cache attributes Date: Wed, 9 Jan 2019 10:43:39 -0700 Message-Id: <20190109174341.19818-12-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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 Add the attributes for the system memory side caches. Signed-off-by: Keith Busch --- Documentation/ABI/stable/sysfs-devices-node | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Documentation/ABI/stable/sysfs-devices-node b/Documentation/ABI/stable/sysfs-devices-node index 74cfc80cabf6..e128464691f0 100644 --- a/Documentation/ABI/stable/sysfs-devices-node +++ b/Documentation/ABI/stable/sysfs-devices-node @@ -142,3 +142,37 @@ Contact: Keith Busch Description: This node's write latency in nanosecondss available to memory initiators in nodes found in this class's initiators_nodelist. + +What: /sys/devices/system/node/nodeX/side_cache/indexY/associativity +Date: December 2018 +Contact: Keith Busch +Description: + The caches associativity: 0 for direct mapped, non-zero if + indexed. + +What: /sys/devices/system/node/nodeX/side_cache/indexY/level +Date: December 2018 +Contact: Keith Busch +Description: + This cache's level in the memory hierarchy. Matches 'Y' in the + directory name. + +What: /sys/devices/system/node/nodeX/side_cache/indexY/line_size +Date: December 2018 +Contact: Keith Busch +Description: + The number of bytes accessed from the next cache level on a + cache miss. + +What: /sys/devices/system/node/nodeX/side_cache/indexY/size +Date: December 2018 +Contact: Keith Busch +Description: + The size of this memory side cache in bytes. + +What: /sys/devices/system/node/nodeX/side_cache/indexY/write_policy +Date: December 2018 +Contact: Keith Busch +Description: + The cache write policy: 0 for write-back, 1 for write-through, + 2 for other or unknown. From patchwork Wed Jan 9 17:43:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754655 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 A076913B4 for ; Wed, 9 Jan 2019 17:48:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 914B228972 for ; Wed, 9 Jan 2019 17:48:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 858D128D6D; Wed, 9 Jan 2019 17:48:22 +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 1B11928972 for ; Wed, 9 Jan 2019 17:48:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18D318E00A6; Wed, 9 Jan 2019 12:48:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 11A518E00A9; Wed, 9 Jan 2019 12:48:04 -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 E89D78E00A6; Wed, 9 Jan 2019 12:48:03 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 92BF28E00A9 for ; Wed, 9 Jan 2019 12:48:03 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id d18so5759162pfe.0 for ; Wed, 09 Jan 2019 09:48:03 -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=0VPC3GD1Za6SFyz5PfakW307GYFxc2o6iQzURNqoiEs=; b=cMPtgOLeC2+lkSsiz2XDOjmdqFGCRHWugidMneZM5MAbxvs7l2dIDOEeB4Asvjolcc B89EXKqiJp/WDVGNAb3QxIwMjs6y+K8y8DzDMIJk/qVvFuhekAuTuapMdoj0p+lPnfsY VTsBmdjpAcuiP/wvof/ZpB3WtbpzcP4QPDnQaGWrC+xVCCgoYjGGC2WKKu3cu8RzkoLz vKDeMKzzhDejbqNeCh1U9+xyHMCG0I40QXi7gvo9gNGI/GRbScI7UErrAalTxUcs8zUh Uauyjgy99MwfFhqvAjDwCCEJDoIxismHQNna7F5Bb42mh8rPVaLHUgZCWLIAGFc3pwoC oAYg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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: AJcUukcw1VHuAT0ZeBpGx24wYK+ocviGtWKdn7V2V+7e+71pPoWEQUBV i5wwy8B0Kjilo4wwYTEOX89P8VvYecGxe97KqdGvwy4ybNMI8dmS84fsTXLC+iQHTdX+xu+jNHG 04SSNo0z3eDgpTMEHjWU5jDBKUAC4V7jptUAi6AQKVJGC/u8yjROsvGe3f/pwFmhiKg== X-Received: by 2002:a63:ac1a:: with SMTP id v26mr6354502pge.293.1547056083242; Wed, 09 Jan 2019 09:48:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN6AN15kaxbwJkRRqtdEYEngwcW136uQKWCLGb1iltFHH4OK/BchMJL/FKCxiDT1U0r1JaVa X-Received: by 2002:a63:ac1a:: with SMTP id v26mr6354475pge.293.1547056082637; Wed, 09 Jan 2019 09:48:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056082; cv=none; d=google.com; s=arc-20160816; b=FiYm+mKdyBW9oSab7k+Ph4KDsBEb24myjyhWZdSEe6/JFPgIKo/DHWKmrw1dHiBsrp XLSQTwxfwicdSnwBJZTOAl/CD67VitGLkri+OgR6H+NxSba3U9NyUI6evkiE+xuoA/WZ op/f5c+8OnZgUCupy9m35qiDZLuQP8oc3j6usA0AMUxIkvq+4wl+/KVQDgIT9ZFHtEfi h6q/C7AwfqKbXyoXPNrxvA7Eda9jADkkiaKwDwLeDhP3VoWUb5DrAjsmewVfkSFf5F0u D1IgqQdIMJnL9OiJ5vk8jbQn9sQWh0iqqtaA1BMfUriYan4A4vIJc7mNeeAiTS1K1Lbx kG4g== 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=0VPC3GD1Za6SFyz5PfakW307GYFxc2o6iQzURNqoiEs=; b=esqK4dPB63u3FKRd/QxNMKcoaPmP6CzaQS5D7z0yX5i2FRkSMOSNwrvBwqd5o6CE1y YwMuOhzR/4D8X/0Je3K8z/p8+27XFJgUvkJweLuZXovubLnKy89X1dVxzS+qkCrPEHz7 CPFLn2upPgJiv84qdLr81tNlD7nH7Qj0m+iZftetci1WDciZxBnQmdRV3ZOvikgZQ3I9 lk5TmsoRttKbOSwRJBlEp72ccnF87igoTx+hnSOtB07OhKjxZJppQZLeqN7B5e0rAgML sfM1nAjn/4Vc/4s6B/Dfj9+BFuGm6qy0fl5O/2Ckvn2Sv9rlMGHSi0dXK1ELSXXhXWEy pZrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id c10si25675731pla.173.2019.01.09.09.48.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:48:02 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:48:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485651" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:48:01 -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: [PATCHv3 12/13] acpi/hmat: Register memory side cache attributes Date: Wed, 9 Jan 2019 10:43:40 -0700 Message-Id: <20190109174341.19818-13-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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 Register memory side cache attributes with the memory's node if HMAT provides the side cache iniformation table. Signed-off-by: Keith Busch --- drivers/acpi/hmat.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/acpi/hmat.c b/drivers/acpi/hmat.c index 45e20dc677f9..9efdd0a63a79 100644 --- a/drivers/acpi/hmat.c +++ b/drivers/acpi/hmat.c @@ -206,6 +206,7 @@ static __init int hmat_parse_cache(union acpi_subtable_headers *header, const unsigned long end) { struct acpi_hmat_cache *cache = (void *)header; + struct node_cache_attrs cache_attrs; u32 attrs; if (cache->header.length < sizeof(*cache)) { @@ -219,6 +220,37 @@ static __init int hmat_parse_cache(union acpi_subtable_headers *header, cache->memory_PD, cache->cache_size, attrs, cache->number_of_SMBIOShandles); + cache_attrs.size = cache->cache_size; + cache_attrs.level = (attrs & ACPI_HMAT_CACHE_LEVEL) >> 4; + cache_attrs.line_size = (attrs & ACPI_HMAT_CACHE_LINE_SIZE) >> 16; + + switch ((attrs & ACPI_HMAT_CACHE_ASSOCIATIVITY) >> 8) { + case ACPI_HMAT_CA_DIRECT_MAPPED: + cache_attrs.associativity = NODE_CACHE_DIRECT_MAP; + break; + case ACPI_HMAT_CA_COMPLEX_CACHE_INDEXING: + cache_attrs.associativity = NODE_CACHE_INDEXED; + break; + case ACPI_HMAT_CA_NONE: + default: + cache_attrs.associativity = NODE_CACHE_OTHER; + break; + } + + switch ((attrs & ACPI_HMAT_WRITE_POLICY) >> 12) { + case ACPI_HMAT_CP_WB: + cache_attrs.write_policy = NODE_CACHE_WRITE_BACK; + break; + case ACPI_HMAT_CP_WT: + cache_attrs.write_policy = NODE_CACHE_WRITE_THROUGH; + break; + case ACPI_HMAT_CP_NONE: + default: + cache_attrs.write_policy = NODE_CACHE_WRITE_OTHER; + break; + } + + node_add_cache(pxm_to_node(cache->memory_PD), &cache_attrs); return 0; } From patchwork Wed Jan 9 17:43:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10754657 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 DC6C36C5 for ; Wed, 9 Jan 2019 17:48:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE12128972 for ; Wed, 9 Jan 2019 17:48:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C23C828D6D; Wed, 9 Jan 2019 17:48:25 +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 1418D28972 for ; Wed, 9 Jan 2019 17:48:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 36A258E00AA; Wed, 9 Jan 2019 12:48:05 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2C9368E00A9; Wed, 9 Jan 2019 12:48:05 -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 11E3A8E00AA; Wed, 9 Jan 2019 12:48:05 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id AE3348E00A9 for ; Wed, 9 Jan 2019 12:48:04 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id i3so5754847pfj.4 for ; Wed, 09 Jan 2019 09:48:04 -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=094J5uJpEt34iRFRDY9Pq29GKYEa91v33BwLKlqByyo=; b=UKdMrdPYTo2rXLiCYoOjz6kqsTlh4+KflbQS0HLWxAvzxFbpn/e4jSOE9sp+oDlkpr KYn9YKYuPztLLp+QlU+qACqvFfROClhqvyH5HX+Jz9hSHcOV8pw4gNezijmiv4vUxF+V CPzqKJd4ReKNHc18DpG+FqRDByE/dErlXgRTynbBNJfj9dyzPJg8Dim7tVX0SELbKPb2 PTYVOIu3WRXxKwiJ3qYBQVYsUw8kgIKHdSZY7DhjIUoSTDZQR8ZAxfah8edY4rDPZ4AJ 2Dnk0ASA/ovfis/dtwL0+5On1UxuJUz99Nqo4nbkZAzeDsyx5psLDiB0JdQ6qL15+7BX BPZg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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: AJcUukel0IAwW/YVDUZJCq+66gRyjv36Y2VnQNbEL89pC0++xstvqrPL ychwcY9Q9TC3UMZqIFtiY/L5cM0RGQqBJDdCBMlWSOXqFrWvvizCRBoR+frNeOHmPo8hyGWpN04 tjYlNMDEMlYim38XvXYApXGqN2vtVaIniZOZS0al+5A1qnzhtav1omhKw41hxXBex3A== X-Received: by 2002:a17:902:bb86:: with SMTP id m6mr7048832pls.315.1547056084320; Wed, 09 Jan 2019 09:48:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN6l0GGImXDfunfWP9kvDTGCJRihox4TtyKtfiXOnJ1Nv6Qpy6LRm6fkffU6HDanOUe8hOMz X-Received: by 2002:a17:902:bb86:: with SMTP id m6mr7048797pls.315.1547056083262; Wed, 09 Jan 2019 09:48:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547056083; cv=none; d=google.com; s=arc-20160816; b=zt3gqWeAP1FNmZMDF1yfa51UOKcSptRxflbjO3yJ11HiLIiOwIF7bHb65EyLWB11m4 aSMLU4bvqlbPVH3LUcJOFOLR+Vy7Nh3g1CarbUs5myppcILdQVB6o8N6cCs8r+B0u3ah PsoQBobhBBPwjpS4TrWsw6l3+owQu33tGwKdfZRGeB0qWmBnj6by8CR1W5bTg3YRfa+a DsEFfz1nH3IdoScpTvlSl+jxIZd+vd63b2eHzzGXhIXFTTC1govOyeLNgXN7fwdtius1 1HI0lNYtkTw1USiQwUTC2+N/qELziCQBCDd1S4SidLg2QM8e0E1GkIfNEoYcU6y1mSWq WsoQ== 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=094J5uJpEt34iRFRDY9Pq29GKYEa91v33BwLKlqByyo=; b=AX0YTo4yikZbbLxtVa9uEAbRibw6uGPFfuHXRxEYAJU5UJkf/5C/T9q/q9FXiPlct4 9rFeDpYb9+HCB6r8HLgwVxQYEw8c5bTjaAXtcOMVe8OcV6MRQrsQoAmC8EW1d/gY6ETF NSP12jI7rtIYG8HvyP+f5m3Nw5ubixlEcDUPcbl/JBmkXvKaAGMaC2I11N2/rqYRybVd hV/c9z4fKt5M+pSVPh0SELPz8futxkbNglYgSZbWoazIGNakhrjPQukUdiX2aHH6CMEK 3mLzaGlhRQQlkQc7dvccleBb5EBZmUWIZgJ0W2Dxti0X27q8AerYSXJFyxbYn+uy/3Wj JwcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id c10si25675731pla.173.2019.01.09.09.48.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jan 2019 09:48:03 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 134.134.136.100 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 09:48:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,458,1539673200"; d="scan'208";a="115485663" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2019 09:48:02 -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: [PATCHv3 13/13] doc/mm: New documentation for memory performance Date: Wed, 9 Jan 2019 10:43:41 -0700 Message-Id: <20190109174341.19818-14-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190109174341.19818-1-keith.busch@intel.com> References: <20190109174341.19818-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. Signed-off-by: Keith Busch Reviewed-by: Mike Rapoport --- Documentation/admin-guide/mm/numaperf.rst | 184 ++++++++++++++++++++++++++++++ 1 file changed, 184 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..b6d99d7e0f57 --- /dev/null +++ b/Documentation/admin-guide/mm/numaperf.rst @@ -0,0 +1,184 @@ +.. _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. 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 provide symlinks to each other. The following example lists the +relationship for the class "0" memory intiators and targets, which is +are the class of nodes with the highest performing access relationship:: + + # symlinks -v /sys/devices/system/node/nodeX/class0/ + relative: /sys/devices/system/node/nodeX/class0/targetY -> ../../nodeY + + # symlinks -v /sys/devices/system/node/nodeY/class0/ + relative: /sys/devices/system/node/nodeY/class0/initiatorX -> ../../nodeX + +The linked nodes will also have their node numbers set in the class's +mem_target and mem_initiator nodelist and nodemap entries. Following +the same example as above may look like the following:: + + # cat /sys/devices/system/node/nodeX/class0/target_nodelist + Y + + # cat /sys/devices/system/node/nodeY/class0/initiator_nodelist + X + +An example showing how this may be used to run a particular task on CPUs +and memory using best class nodes for 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}/class0/target_nodelist) \ + --cpunodebind=$(cat /sys/devices/node/node${NODE}/class0/initiator_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 attributes directory under the +memory node's class 0 initiators as follows:: + + /sys/devices/system/node/nodeY/class0/ + +These attributes apply only to the memory initiator nodes that have the +same class access and are symlink under the class, and are set in the +initiators' nodelist. + +The performance characteristics the kernel provides for the local initiators +are exported are as follows:: + + # tree -P "read*|write*" /sys/devices/system/node/nodeY/class0/ + /sys/devices/system/node/nodeY/class0/ + |-- 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. 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