From patchwork Wed Jan 16 17:57:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766597 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 E5D5A13B4 for ; Wed, 16 Jan 2019 17:59:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D23A22F0EC for ; Wed, 16 Jan 2019 17:59:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5E192F0F2; Wed, 16 Jan 2019 17:59:45 +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 478732F0EC for ; Wed, 16 Jan 2019 17:59:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 125E68E0007; Wed, 16 Jan 2019 12:59:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 00E558E0002; Wed, 16 Jan 2019 12:59:39 -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 DF4318E0006; Wed, 16 Jan 2019 12:59:39 -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 88F438E0005 for ; Wed, 16 Jan 2019 12:59:39 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id b8so5211779pfe.10 for ; Wed, 16 Jan 2019 09:59:39 -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=0eF9WR08VMqIj8YZyWfc2aEXzScLwdPodq5KjbNOY+w=; b=K9jQQZYVllOHezsBgQ5YT6go8VbctTbGgCnpuPJWPzGX9sISj4GA/v7KPOnTV6b/zP eXmAF/g6/Fkw/jqSqiTueNEZQAnj4C8ME5IyvF4gE9BY+VnD/wnHZJ8yzS47PspuMr4B s4pHDIX715W1mP5W3gFRpMaUmOTiWrcRU+aeVkfmlU790vfZKaw7MklCAmz4sYWkPk+a 66XDtGfl4irNmPJl1XU8vixyjyIyRvzCXvN0LoK5lgxuTuoL8qUCY4gWmz/yeKChE4hU FA5RVDbON4XhqFJ8J6P6e1Gnd39OEb5CCQLyKwPgOmfrRMCxWjPYEli1bwBUZeN12hcL /mVw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukcMg1fLfSEi3c/GiqLcd/AXRN3OdNE14B4NdUsr0fpS5a/wwqZ1 3cx6LN3XT/g7PXoEb6R91xIFS0dAXZIos2vXETkCsOEcQZ4zXSgpRw2DxOoqK4vrHfRDNiUdPNM GowkoW3eiC8ltnZEOHLRwR047YFX3cI7Hr+4P7DIzEqqjCYYH6EBi5fQCpg1OdrGcpw== X-Received: by 2002:a62:509b:: with SMTP id g27mr11136540pfj.48.1547661579057; Wed, 16 Jan 2019 09:59:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN4HWXEzPbAFgcKuF/vDOvaC/eiO1uzSe/Xa74J5pkMSH/nLnUpu7hxwuANeDedOCC7qKXVZ X-Received: by 2002:a62:509b:: with SMTP id g27mr11136392pfj.48.1547661576911; Wed, 16 Jan 2019 09:59:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661576; cv=none; d=google.com; s=arc-20160816; b=uS8SZ1BEcEkEvqb5CpbzhhgxmF3ZeuHzB0Z5QTQ2hx0833afJiBgaHKQom/MXDiXPl ldH3v2iI6mHkESbyna1584yFUINVdghdLMA2NOm5ztnriG7RAYRHsDeC2L2kvrXPWQGJ UoNm4Rf/cmNdetlvpdxErE0lzC7K0vSxE3vtdcNZW4Uv7GejUg8gPQAExROcsB5awtSC YdYcYJxNlVup4VrMDQyJ2SN1kS2p82IoiW/zaD0b1XDxkw/4Y0Z2X1bN90Iq3goLwYM8 hCY8PLwxErQVmZOsE0pAlYoG3s+MJv4ZLmVNkXQ8KERSwznmHJGZiTRemtCOLkNmihFT jsoA== 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=0eF9WR08VMqIj8YZyWfc2aEXzScLwdPodq5KjbNOY+w=; b=PiFRmBIPaoypljgrRXDTxyPDlh1qliIT3MruB6q7U1N5szw9525kZnRDRKI5ZgNBXs hrFi0dQ4757nYb9zcKOIRR/JAiFkrckN30wJnzvoXHUHCEtbevAmFafHiSsxmZy06rTr 9Hq97OSFwTSIHG1TlUo0QV+LB8rY18ZwNh+Q5yoDh0igc34TF9z/feNn7G799lAdW47U H0a/ZjcgrcdYIZ/+uFuJSAY+xa4/rISGaxT5oBlPneyrZU2gMmsZH3wc8pD6R3IEHY6A KyYLzSOGnsbiNA6E9+y0sSdLSGBTG/kICqRrWtt1FDPLF9YBjF8VNUAcXH7Sr6a8dIMo MjQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id y8si6735247plr.92.2019.01.16.09.59.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:36 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227764" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:35 -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: [PATCHv4 01/13] acpi: Create subtable parsing infrastructure Date: Wed, 16 Jan 2019 10:57:52 -0700 Message-Id: <20190116175804.30196-2-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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 7bbbf8256a41..d6433b14864c 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 16 17:57:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766593 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 342AA1390 for ; Wed, 16 Jan 2019 17:59:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 252452F0EC for ; Wed, 16 Jan 2019 17:59:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 187482F0F2; Wed, 16 Jan 2019 17:59:42 +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 AB73B2F0EC for ; Wed, 16 Jan 2019 17:59:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 745758E0004; Wed, 16 Jan 2019 12:59:39 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6A16C8E0002; Wed, 16 Jan 2019 12:59:39 -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 541028E0004; Wed, 16 Jan 2019 12:59:39 -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 133568E0002 for ; Wed, 16 Jan 2019 12:59:39 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id 75so5207514pfq.8 for ; Wed, 16 Jan 2019 09:59:39 -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=lqRqlAUixHP/maDucUSoUigQ7wiAfswfBWQi2LO7g6Q=; b=OA5DqOzyQzql/ZDIJkcWp1BZbCDGe7CGyH5Xxwf1aPHuHJkBAJVwk/WpHBni2I/zu+ QSpRVSGmqZgsRq2SPkaxT3xypBZW9d/mOKJzIpAeM2Gp7a/JadgCRIiwVJkMgA7jddFY 52OtRl8c/YDJH0z6PANoKZKnJLmWonhzxonc6QEfNb8hN9uzTAzNnfxeM/YHRXV5xNAm UFCU0th5ywwHPoJdzeKoOceyMuiKK+zQtgvzpywYFEKVI4euicb3W8q0rAxJ7gMbO15q QTfjsdz1DtFFO0tNnNUZVVSuE72fHA8FCOrqGNBuNkXcZDA4k7/kmV1D7R6EnIMUedLo tsfA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukdWDhsnaJMArCQZuvwz0lj/wi8KoeIZq2ZLymNBVFDqrbVeVlaO xzDbzTyeD+IKItMlUg4JjeLzwPrHoKq1YFNir+5zOvwqH8Yyj0YISVcFAP/ihlTLKMqsjZOmxDt cJcOjntNRBFLcBcdPI8z2IHcmQ2JKlHPG1b1eJujBLcBYvCqdT0nIXdhL6+Haigwm5Q== X-Received: by 2002:a62:5444:: with SMTP id i65mr11316076pfb.193.1547661578570; Wed, 16 Jan 2019 09:59:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN7aQp3eJfKpGuLY3eYgTBNGI41GrY6TX8sSQpD6+5Rp5wK48lDQnJ93aGYimmFmie6WDoOI X-Received: by 2002:a62:5444:: with SMTP id i65mr11316000pfb.193.1547661577430; Wed, 16 Jan 2019 09:59:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661577; cv=none; d=google.com; s=arc-20160816; b=pBaGJkl+VlbX+xylVK3cJgk94aGrfvP58NtoEG6fhekfOkNHR+BgBNXtQwm1pZdNHY AGuEjHRwFllwp4dpD2v/d9vqc/TZaR1wFwYbwvs/BceSFlLRcQ3/6e8hLYwhEtTbuj/Z DpQd3lsbSI7SB5XvH7ba3ddRc7pF0tTl5pjIWZB4jLdya9zdEN7ul/MjePAs8sGZ64Eg Upvm5bFCBpB2N582xBhVb23Sw5RBvJ8XnlmAfb935wt/O+gPWU/yVrKaGQXrHUJuGmgq Lb3MVlhJG7B3DeBvv11x53+RHA7BHpS9LQm5uV2aehZ22GBkkkd8/zG7c9xwBItAO4kQ N+kQ== 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=lqRqlAUixHP/maDucUSoUigQ7wiAfswfBWQi2LO7g6Q=; b=sdWsTPdGgIptM8HAIKg8uTpssV3bcwrz3uWR2z8KXdhIzzV0waTHOtoON9h8d8MKML nDOJ5U1Z2tYbLIinheYA+6Qw5NZ+AVt5BsG0cc5mlg5fuWBnZVe4/IOxF9CsXi0kPH3K vjVdnuYEHL1U52zbZeaZ/+AfQWCl8arSKFlEIElk/PY/bxp1H5n2jckXgJYjExbs6Eba 7fIiGGG9HpNZZQqOVamiVPNJRRllvGJ9/BiaX5ZxUmBlyECmi69pLj50HJemL/fC+uOX Vj9ky3HMx/WWKkGLxRX3KmaZux06jRNSl5I5sPLSbCjn47KOPOQ5PlyEpy4hB/2Gz0O4 KB1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id y8si6735247plr.92.2019.01.16.09.59.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:37 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227768" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:36 -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: [PATCHv4 02/13] acpi: Add HMAT to generic parsing tables Date: Wed, 16 Jan 2019 10:57:53 -0700 Message-Id: <20190116175804.30196-3-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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 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 Reviewed-by: Rafael J. Wysocki Signed-off-by: Keith Busch --- 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 16 17:57:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766599 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 B3A0713B4 for ; Wed, 16 Jan 2019 17:59:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A28DE2F0EC for ; Wed, 16 Jan 2019 17:59:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 964242F0F2; Wed, 16 Jan 2019 17:59:47 +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 DC6372F0EC for ; Wed, 16 Jan 2019 17:59:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 343748E0002; Wed, 16 Jan 2019 12:59:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 122E78E0006; Wed, 16 Jan 2019 12:59:40 -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 EDCDD8E0005; Wed, 16 Jan 2019 12:59:39 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id A5E9F8E0002 for ; Wed, 16 Jan 2019 12:59:39 -0500 (EST) Received: by mail-pg1-f200.google.com with SMTP id g188so4310077pgc.22 for ; Wed, 16 Jan 2019 09:59:39 -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=C00vQ4YRfQjt4JFHxQY6u3FI0PBTuyG7tEsUz22jZu4=; b=L7zaBYAgmoICrvo+B0cTRL7BwVdQT3MZ8g+J7+1vEpN2VhSORcRtbFGx/KoNDEEqz9 RzVajnT4SS/ii2i2oIxDCt0Ae1B5EcTsICPGU63OCO9fZ0XUg4xa9sWc/IU8uXNSj184 eUXpQ/uTRKUTB36TgMjzAFg7jflYb4RoikhRSTREvuO9wruQt3pB9DF22myMlmz0DMU/ t1pFKMt3LPwM6nDhkKVEaivmZbIsJpNNEN1QoNvZ22fIjCyZbvSnXnGugC1Z7hqYM6dX aoGZ7PzoREuwdfFmSWgCpvqI7hmPoHcv2u6WcS6PRj7pSn0kAd+w/bzLAU1PEdr3CAJv fwuw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukfaOIqZyRZUcdsJpJRDIOPJDEiQaSqmP2Lbenz3RU6bTzRkIsYE hTOpX+xIb2TYu92+GmiR3c1E5tFulEHc3WDhqo+XS4twqH3AwvknQFHRicMmS4J8ZjIJRxMC1ry 3XetVO4aVVf8QEXBuE/hxAH+h9UwX6QQhTqEfpVIBUkHBP3sXWPNxATtKJu5ZYXLzpw== X-Received: by 2002:a62:c711:: with SMTP id w17mr11137680pfg.50.1547661579236; Wed, 16 Jan 2019 09:59:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN4JZ8iYk0iF5bqM+MkInu1CP4ImwlvTcEQ70gfl03X+1ESKuu5JcsM393bdRcey7ecblTR0 X-Received: by 2002:a62:c711:: with SMTP id w17mr11137599pfg.50.1547661578042; Wed, 16 Jan 2019 09:59:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661578; cv=none; d=google.com; s=arc-20160816; b=QeOolFRHVborWnkELdi4Laac4HrzjT/G0xHxGN9i1961q2JftdBpH9nPxPrGr/8zwE WOKF5XoFDNVGBfVHGc0Gf9B4MenNM6VZEyzdO1t1zPTdp8h3EdpyALAQ9JJ7OqBhd55V 0ocVfUKUaEG/7M+FFlHDVAatn3bhTA5KnXf8f2Sr1a2UTlM1DtlW9iP7AqQRLAywlrFC 1/i5zwu6QASdjWUe4aFAGWMgfc4P4ScLYnch1fLCk+3WeCtgcTsKxpvoqJuk9p7NOoeW BcdfLSStzlYqiJAB2vJgfSjB02kx+Q+ASUlnoDpw39/E2yT9sDRd2Ft7StowqcAaqRzU ElWw== 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=C00vQ4YRfQjt4JFHxQY6u3FI0PBTuyG7tEsUz22jZu4=; b=h8LlqNq1V2k3+NBOleicpn/x67MzmnAHL1AaQfDmhq/2m9s2WlTDxK9g4tz45sGZ2c 791rZCVLdeqDHOZ8CmGSM3EFtQwY+2/fy1kCi9PI27JiWrJPp6S7IkHcWPJRW1MjbrBt SUiN8hLQHjhnECK/YErxckLlEYbgnI/tVXnZrGFUgaTfUo/0PAoKoC5vi1ZTvJK6wwJ4 zhMn5KGjKnSq1fC83KVTMNKRN5/fP25gdPfudZgYhbuuF5ilh3um1CjvgNtADgdr9Emu C1amvQbXGc8J0JJf29DhrDvYq/e7B97LThkogzUqsoJ999mrGyYS/22+ShmeuYefZ/8Z LlxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id y8si6735247plr.92.2019.01.16.09.59.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:38 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227772" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:37 -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: [PATCHv4 03/13] acpi/hmat: Parse and report heterogeneous memory Date: Wed, 16 Jan 2019 10:57:54 -0700 Message-Id: <20190116175804.30196-4-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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 | 1 + drivers/acpi/Makefile | 1 + drivers/acpi/hmat/Kconfig | 8 ++ drivers/acpi/hmat/Makefile | 1 + drivers/acpi/hmat/hmat.c | 180 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 191 insertions(+) create mode 100644 drivers/acpi/hmat/Kconfig create mode 100644 drivers/acpi/hmat/Makefile create mode 100644 drivers/acpi/hmat/hmat.c diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 90ff0a47c12e..b377f970adfd 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -465,6 +465,7 @@ config ACPI_REDUCED_HARDWARE_ONLY If you are unsure what to do, do not enable this option. source "drivers/acpi/nfit/Kconfig" +source "drivers/acpi/hmat/Kconfig" source "drivers/acpi/apei/Kconfig" source "drivers/acpi/dptf/Kconfig" diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 7c6afc111d76..bff8fbe5a6ab 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -79,6 +79,7 @@ obj-$(CONFIG_ACPI_PROCESSOR) += processor.o obj-$(CONFIG_ACPI) += container.o obj-$(CONFIG_ACPI_THERMAL) += thermal.o obj-$(CONFIG_ACPI_NFIT) += nfit/ +obj-$(CONFIG_ACPI_HMAT) += hmat/ obj-$(CONFIG_ACPI) += acpi_memhotplug.o obj-$(CONFIG_ACPI_HOTPLUG_IOAPIC) += ioapic.o obj-$(CONFIG_ACPI_BATTERY) += battery.o diff --git a/drivers/acpi/hmat/Kconfig b/drivers/acpi/hmat/Kconfig new file mode 100644 index 000000000000..a4034d37a311 --- /dev/null +++ b/drivers/acpi/hmat/Kconfig @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +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. diff --git a/drivers/acpi/hmat/Makefile b/drivers/acpi/hmat/Makefile new file mode 100644 index 000000000000..e909051d3d00 --- /dev/null +++ b/drivers/acpi/hmat/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_ACPI_HMAT) := hmat.o diff --git a/drivers/acpi/hmat/hmat.c b/drivers/acpi/hmat/hmat.c new file mode 100644 index 000000000000..833a783868d5 --- /dev/null +++ b/drivers/acpi/hmat/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 16 17:57:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766603 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 0C0731390 for ; Wed, 16 Jan 2019 17:59:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE5162F0EC for ; Wed, 16 Jan 2019 17:59:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E23DB2F0F2; Wed, 16 Jan 2019 17:59:52 +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 2F6F32F0EC for ; Wed, 16 Jan 2019 17:59:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C7AF8E0005; Wed, 16 Jan 2019 12:59:42 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F2CBD8E0008; Wed, 16 Jan 2019 12:59:41 -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 CBFC68E0005; Wed, 16 Jan 2019 12:59:41 -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 81EE58E0006 for ; Wed, 16 Jan 2019 12:59:41 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id p15so5213196pfk.7 for ; Wed, 16 Jan 2019 09:59:41 -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=L7FJ5sgSKEoSzwTq3TWighJ5lFq6R/5JKxRAHS4jhyA=; b=ff9EZYo79E5bS2tdUYa4gU93/8svDuRxncZu4cRilFAlCSPbTMFtCYPQTWYuk5WaLD LPgy0euQVQ66oQoyBsPc2KJeOiUHtvivzX5D3yTIjPKQEbzvIYtqmFq4BskhiReZAuJn TbQGb6yX0pb5JyYlduakFTcKRQLAGjuIDuz8u5M9rZj9a/u/eV5rOKi/avibO/z549l7 1ynY6y23OyOf/1l34PEN8sg4c51CtC3w8FSAu/Sgchn74qmz+iOSm9f3WI8xDdweGnD1 crgG9lSW0ufGsiIc1JnZquMxnrEO/lOrl7G5stSN+NMEnNiIdQExCdIVYGL4HZYVFF2C wXYw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukePUV1TIXB0DEoY4xrrbhYvZhWt/u25ZYdoPDpBXssWcvF/YOtl HOrKoLCd6GptuTIm5W0x6Cf8ZbSs5GvluWFk8CbwwcDPqgrJvidfkkd6+1UkrlxBUK4pZ1G5WMj svfjWZf+2+XfYNMgHsG/N4hgFFK+zVZPah0gu3hkvhxMeS+pyPUWsg+wzyo7A5T8h9g== X-Received: by 2002:a62:3a04:: with SMTP id h4mr10938887pfa.119.1547661581140; Wed, 16 Jan 2019 09:59:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN5vRjHWs6BOegDJOY1NTcgryAfjDT7OF8PMxTlTvPaplpuBjyHgAceJPK/pk/C/kE1THO2l X-Received: by 2002:a62:3a04:: with SMTP id h4mr10938821pfa.119.1547661580019; Wed, 16 Jan 2019 09:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661580; cv=none; d=google.com; s=arc-20160816; b=JDCvggU5Pm5VTWoEJ/zQ9NVRpAP/MpjLjYvIPZmrvT3+vLiCXPR/HWG7iiiGQgQdG0 hgI7UYR11IRPHqy0U+kG4QeyeN2HzvBGB+rq0nZ9k9+HfQ8YrfXtzzrg9Q/q0uOru3MT qMiH6eIGyxGZONSOoOZznRRT3g2Ft7P+v4UwshpGq52bK3nENrjER3xs1inHsma+9HQn ARH27Wo1Cidc/+UuqnlwfUMi1cRhKqIVhlux9Y/xD7gsvjSQOcG8jbQJiM0JjXX6QSgq WGGS5seFMd1Z4PaScv9UYY9TDK+3w98VXZd8uce/DJ3cQqp/u77lrCkg+jzHRIX46rZ/ 9lQg== 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=L7FJ5sgSKEoSzwTq3TWighJ5lFq6R/5JKxRAHS4jhyA=; b=bxQW1Xu7blseAntSC/Oyr0JMYzU7rinUG0UNONvRZhju1/a3ZH6tYvJxEkqIgJDMYE bW4SFWgKX/AFxXHz7MOT7lScd+oGjN+JMHBD5Zp3Inb+x+hO3Vm/PmOT3gHxZsujGrwh aF+9wvZ8/FHpd56UObNhrlgruklIFoQQv/xhmur+uwWtQzd6la9KRftETB/8oOeIAkhe QX4WmuylUvD8X8GHuVkCBHAntwcJP/TpNArdyQb+hVAY76ddGWfgQJKeM6m78ykwQNfX FxVy9LOhHyvpFZZ97AS7VEQPgCayow3PC4kzs2i8a+1wMJy8qJmJiVvHXmL+gqgfQ1Hc FS7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id y8si6735247plr.92.2019.01.16.09.59.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:40 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227779" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:37 -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: [PATCHv4 04/13] node: Link memory nodes to their compute nodes Date: Wed, 16 Jan 2019 10:57:55 -0700 Message-Id: <20190116175804.30196-5-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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 nodes 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 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 16 17:57:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766601 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 D284B1390 for ; Wed, 16 Jan 2019 17:59:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C35352F0EC for ; Wed, 16 Jan 2019 17:59:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7D1F2F0F2; Wed, 16 Jan 2019 17:59: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 5601B2F0EC for ; Wed, 16 Jan 2019 17:59:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F30D88E0009; Wed, 16 Jan 2019 12:59:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DF4658E0006; Wed, 16 Jan 2019 12:59:41 -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 C1F598E0008; Wed, 16 Jan 2019 12:59:41 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 6828F8E0005 for ; Wed, 16 Jan 2019 12:59:41 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id o17so4332811pgi.14 for ; Wed, 16 Jan 2019 09:59:41 -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=U+z9noPMPaeCk0UPYga623RXIE+Nc9U1cmpwn4RnvsiGHC4HurTCIlRzZ1Q4rhQVaM DvvWryjQSgWU5ZDDox42r4xm3S1cX/Vedp7Lpq5tDi2v/JkZwPHRWWNZe0DIa67epDKd SzbFBIuXnODlAFf10StFCvm42QOZ5HQRE556Vm4NcVn/pty8GaVLQKGrqTFkFwkqjo8P SVa0MH8NxLuDB1lvd6tAI5yAFyxOnu7wK+cV7L62dlLdIJh8NFyJf+IWScU6XAPiJlT+ A+tvpdIAFgCyQqnR7AihFbv/1rz3+hTMyv37ynRCbuZGu2d6QaZTxFS2OUpU3QFTXzgl /JSw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukc2tNgcuqaCYAC/UulZiCeU+BH7r1jWOGszOg0LFxBBFcFgt5CP Av2ZmPFazSDD9f9seXcwR/SCxMmRIQOTkdeDcNK00apxVFQKnH5knUuUxZuO8HfkWmoDNhCS5Bu TzBNA/nkvs1AuZoOhV122FPcrURc79A9ZmuJdR4WxVdIzQQHyd6sU2cdMOQ6d+5VYBw== X-Received: by 2002:a63:f006:: with SMTP id k6mr9964196pgh.259.1547661581069; Wed, 16 Jan 2019 09:59:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN4/mk38wU1qJwATBXfs1f36MbaUz5uiz6L4N6R5+4u8TknlVwydClPF+ucKh2sADIUt+F0K X-Received: by 2002:a63:f006:: with SMTP id k6mr9964154pgh.259.1547661580314; Wed, 16 Jan 2019 09:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661580; cv=none; d=google.com; s=arc-20160816; b=Z9vzIGlmS2fiEzDqi6UrOaIqtPOsCM4tOcd1gRzHRziq/WyMkazg1Iq82HG4KgpYz3 ieCtXYCjvNGtt+ydq4VjqhH+ATnMAqixIBKhfp6dnaRcEAg+0lPOKjI9KBmucQa9nc3v Xkfi7TJpVtrDK4zSCgXOckHj0WsGZ4B4MyaOZOwYVD29TjIMbAFW9O8bZaQZuXwahoPB h6WcBCg+W0pBE/uIyC/9MSQCaP9zIHN+auIhjM6er+QuMMAeCNleXYvOxvRH4GlPZE2b GPnhlXsgOLMH0URdjWz+ewUJ4alLq0YvEJvTili+kGdWFexhCwO9WoptoxYECLUssl3l v6gg== 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=Fy8aiFYZogvvi5vNpHpu3vaw0RN5U20d9Jl42w+RxFcvJsa4BZyPHNp+i9TD/YfVSP fzaZSBizFrEHG43U4z8mU8BsJGaItnympPV+NigCE/AUksMJNWtdhxLNtFpe+NI/c1c7 haeqcS3oedW7x2n1wSD5eC1oJ6DWD84HcYXCbOEvNp8Wp3tV2fpfK6Qq+UU1haJcaFG+ rBoz6yV3PqFL8X3jclrNyjm7YmYXPb5oARWvb873QL0lwixvMU9khQCyb4xAb9XAxsCp WeEUXE7vNVUodCezOCScaI8fDxUKZDnTqACKX6gf4A3UArR9df7LY7QI2lH+oqStAwKa PUFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id e188si7088344pfa.16.2019.01.16.09.59.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:40 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227782" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:38 -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: [PATCHv4 05/13] Documentation/ABI: Add new node sysfs attributes Date: Wed, 16 Jan 2019 10:57:56 -0700 Message-Id: <20190116175804.30196-6-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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 16 17:57:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766605 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 E397713B4 for ; Wed, 16 Jan 2019 17:59:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2AFB2F0EF for ; Wed, 16 Jan 2019 17:59:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6A9F2F102; Wed, 16 Jan 2019 17:59:55 +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 2653D2F0EF for ; Wed, 16 Jan 2019 17:59:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB5A58E0008; Wed, 16 Jan 2019 12:59:42 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E705A8E0006; Wed, 16 Jan 2019 12:59:42 -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 C1E538E0008; Wed, 16 Jan 2019 12:59:42 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 750828E0006 for ; Wed, 16 Jan 2019 12:59:42 -0500 (EST) Received: by mail-pg1-f200.google.com with SMTP id 202so4339470pgb.6 for ; Wed, 16 Jan 2019 09:59:42 -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=Yca6fCvrHPEOciR9bJUbC7nCn8ZyQaAC2wLtcb2Lx6c=; b=dT3Hp+e5IHO5eryVh7JwPqlF7fVfgMoYK4n6hYH+wGyFP3pfyrd7YB/vwNd5ozp2s5 xr2MfYe0w+TUAAzkbycef/d4nkbOhGOQOyP+8oy4xHYve8B/kYsgqbmaa8aQ0Yj84ntb vr1TPepmMBOGqP70JxesNwUpZOu6qXWqtdiG1fDnZb18rB4qWizlCmTAIVSVGSBKqG8P MKSHn8x8RMd1NjGhO3rghpYHrXfIARFNaBI11v3GfQmnZFbL7TMflx9iqaParGwNSgVd Pb57iqq28SGDed4zBpL/PflzGcPoH6yLBPLpxqlDFEBH2EW0BNcDQnmv1btTrgkIgNeA XFGg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukcHv3Id44zZ4yUOZmJsV3tAjT1v2PWEqSlQiVA554nk0LUKBB3R M0TtOUXleFV5DjIDvXh27XHWxUSNEhjxS9UUhqlGHgfVXFGxXDl9YJYNEEcXvOcY2ZAkii5TAoI IAvhyRoiB+LAJdngc5pubkieI5hkAixuSxS2qgTaEZbkoQuKVMozaMQj1c7m1/PP6ow== X-Received: by 2002:a17:902:bd92:: with SMTP id q18mr11110632pls.167.1547661582107; Wed, 16 Jan 2019 09:59:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN6sXtLxsTcrlFm/j0ZcNlbofxhbeS+GBvlJaS/OmzlGCWhl9NE/s0o32xkLTwWg8oThJf43 X-Received: by 2002:a17:902:bd92:: with SMTP id q18mr11110574pls.167.1547661581229; Wed, 16 Jan 2019 09:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661581; cv=none; d=google.com; s=arc-20160816; b=Ur6W64wP8U//POBY1KQObCIXclst3y0DrScfZqivh8mQZSSXbob1V90GKPKRZvJ2J1 M2RsAGRnJa5edOUb69bNcxnhRvl0slHI8usqRY3K3mDTYYkeBluYw/qRDfSMXnUMB9ju Y2josRnASM1biflTtxCJP8zG9WxhYgwUqX0xPMBwEzoDizEVFHsaxzboso/DQ0gHqR8f 8VujEJ6RbraBxYlOyZOcP5OhMad8k7R8SgIiFD56Y3s+rksSCzzDHQqKpnbtapSM7Bpm QOV9eCF6kBwg1jp0V5WCXldCSKs1tVMG73Uo34wPblKhW58JftlQysg7EMM53TwsKFG6 Ofjw== 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=Yca6fCvrHPEOciR9bJUbC7nCn8ZyQaAC2wLtcb2Lx6c=; b=vHTZoimE3juIPj/RcdorNidBaTGugyVf9Z2KW4Yj2ORgBqHcYPDTqUV7BSv27SMH/6 IzI+upuuTFpaTJZ0zPapa3IEerZnZvDyKvLscgqSIIOaTegt6Itmixd9B0aPKMqdtOQo Zc7E2FCE5F6a2V06a8n+gxYNJ2oJGdZniJoL/v8NpWRBHv3wD+aSBkS0K8AoWf5jxRs2 CG1xB/w4/l4YX41C1J1uzHnCeE1JuPafgZLmTF8Jik7MvBD2riYyC75HC04pved6NaBa UJTXoYKsKzWS9qPR4Yow+/qF9sQSXWvybVudL+jLpjkcGFEg4E7yx3Za61LTvpwOHm31 q0lA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id d18si6701527pgm.212.2019.01.16.09.59.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:41 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227786" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:38 -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: [PATCHv4 06/13] acpi/hmat: Register processor domain to its memory Date: Wed, 16 Jan 2019 10:57:57 -0700 Message-Id: <20190116175804.30196-7-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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/hmat.c | 143 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 136 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/hmat/hmat.c b/drivers/acpi/hmat/hmat.c index 833a783868d5..efb33c74d1a3 100644 --- a/drivers/acpi/hmat/hmat.c +++ b/drivers/acpi/hmat/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 16 17:57:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766607 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 D938D13B4 for ; Wed, 16 Jan 2019 17:59:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7F622F0EC for ; Wed, 16 Jan 2019 17:59:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC6192F0F2; Wed, 16 Jan 2019 17:59:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=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 2C8732F0EC for ; Wed, 16 Jan 2019 17:59:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FF5F8E000B; Wed, 16 Jan 2019 12:59:43 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9AFF38E0006; Wed, 16 Jan 2019 12:59:43 -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 828AA8E000B; Wed, 16 Jan 2019 12:59:43 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 336458E0006 for ; Wed, 16 Jan 2019 12:59:43 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id d3so4309772pgv.23 for ; Wed, 16 Jan 2019 09:59: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=AYtf+RckJM8KVQDjGkv2FMQzQJ1RDITzHw0rToiBHM8=; b=WH2uTNJWcIoVgiMAGQDd4eIrfZ6PeOGjtg6BWP5AiktDb23iTifLYWq0VFNwMWYtIx USjD122E1/nDEQurAvO/p4WlKoFbRMHzvljnLeCsE6j6/YSjHeUjjt8IImMXBOCv7ykC vIJRvd4VENdX/yFfTWyaXnl6DaMJCjW3SLX41b7518D6LguinlpDB1sXcF6BJQXRZp8C qOWSqPMGbumdEs7rRzGljcgeS0+ThSaVNpHJwcLIgPaf8/J7YNsW2QzkgsfXnww00FYn 3FwNHLBYGOnI6VpSVtpvsXWfklbuzg7Fb4Hts3eK1KJS6euV0+ZBJ6+EraJ1amC+HFpG Z/Jw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukeSQUO8kgCv4ySx+3dC7Oo0dyaN9SZXuAiU6S5ikfhUwMWC7/Yn bgFYHOJl6kv9LbzW5Yjebj7XvMCYqn4zatHOl/beRtKFgXHo9o+cZhA9FbooU89z4ukPCa/yNlf beDI7QuQnS4hzvTtrEYUv0P52TPeJkecfNCMSa8TVg1ivSwjBMzHyeagbCX2Aq+ZEeQ== X-Received: by 2002:a63:235f:: with SMTP id u31mr9946777pgm.122.1547661582816; Wed, 16 Jan 2019 09:59:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN7KOHSjYcpfdETysYhFTYl/D8t9HxuCrXwNI9BC500GUnlbTFOJjXdXA8JemWifeTDMv8Ev X-Received: by 2002:a63:235f:: with SMTP id u31mr9946705pgm.122.1547661581547; Wed, 16 Jan 2019 09:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661581; cv=none; d=google.com; s=arc-20160816; b=NSqXwhzhXa4lAf4JKczfrFfQ4dDhSEPJguWRLhSDXK6+qsjaMvXQIhoHD1mMHqlda3 v/Vxzc4atZnFQPmU+hwxbTRdke5yMbLhs3kEJJaQudr71hy/gjNgTYYfgcKozCN+wevS YGxKcd9j5Z4OW7XRaqDFU8VjYXt3MdRC8/gTfVrjXt0PluO+3Im1CPHqhnOiYmyNPpaw Fa7384c0dyPLR65luyaQm1zyr9P7rqKyPA3KM+rvW2h2nFPllSQI+XAVdAiasNIpqQP4 PJCKopR987AALtaOBsebBcguC0goIbykxBuxfdN/hoey6XsB5D8iKrRh4AC/gYzm3UgV Sucw== 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=qUTOaImE8T+WDkcAIeZ3710kNxc4IKoXsgoV3LhqjSYivuMEMgt92SWq0Ys5JJ+QfV ODPla2kwmnCkWn9/WdqwVQylbWrvJAj4UhPclZjDv7yoBGQijsGQQMi8PBq4VYxHKQby 1m+VOC5n5E5U+3A7fWCK5T//FyiDW7yViGVn8mhJO3GhG/WyxCwmBS4HEUJg4d2Duh84 CX+BiRjJYlOgijXIyOn/KEu2xCtSZmZDjiiaACxjvbuq5JU6ULJdAWDDj9rkdcvWB9n0 lPc38BAvHn098qWjoP5ME5a9GXVbTs+ckU49O57hv2wyI609zLBbUJiLm04XMqCGCuio 3UCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id d18si6701527pgm.212.2019.01.16.09.59.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:41 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227791" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:39 -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: [PATCHv4 07/13] node: Add heterogenous memory access attributes Date: Wed, 16 Jan 2019 10:57:58 -0700 Message-Id: <20190116175804.30196-8-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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 16 17:57:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766625 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 F19C713BF for ; Wed, 16 Jan 2019 18:00:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E11D52F0EF for ; Wed, 16 Jan 2019 18:00:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D56732F102; Wed, 16 Jan 2019 18:00:20 +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 6AF082F0EF for ; Wed, 16 Jan 2019 18:00:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93C168E0010; Wed, 16 Jan 2019 12:59:49 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8C2458E000D; Wed, 16 Jan 2019 12:59:49 -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 7D7D68E0010; Wed, 16 Jan 2019 12:59:49 -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 3B5328E000D for ; Wed, 16 Jan 2019 12:59:49 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id c14so4255338pls.21 for ; Wed, 16 Jan 2019 09:59:49 -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=hxfGLurI+WG9FRkl229XH3oMqxxZ5BdsK6zqvROtKvs=; b=FHAD/icZUXr2smMHuwio5thPRJqC3BPV55PNotN2qCxPp6O2Tkv2OYUacnc9dhqSV1 kRYssPsj87yrkeE3WTth/ezbGP/BHaytr5OV/gjIhfHNugu3kXFiHEBOaIEHBU/voAhk mIZ3tzg3F2CLvzVLdJtsu5mNZgD0WCbzBZUheA0L5UB0QPCAFawgFqVDkk0a0U3louvI c769fbiOkl2WkL5mzk5ARwXd859MxExe6+mhrIpX1jhqk2vaEgurd8Ls+6lvB9ey8BJT U2DfxE3Su57hr3xgueB0KuC797Qzxnv4zfbij7Ne7G4qaZbsXpfhTyTEXSg3D7QZxqy0 UZag== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukdKXzjG3lrt7a7g6PNHhrz0HN5ltf0QHZYOOoORFbD2Q+JC8Rj0 rtCc0UssOafQqphKo+5No0s+NWoehLMYSBa4sjT5v7G39lHfEIBPf2EtK6pzhfCpRmn85kAiTmm OQ3fzWzftPEAwTPgyVbDTQiVRIq3gN1pQduhkWw9IxiqkoepO0yfSk2agLNd+3cJo/Q== X-Received: by 2002:a62:528e:: with SMTP id g136mr11447591pfb.111.1547661588873; Wed, 16 Jan 2019 09:59:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN7BAx0tWC5G9w7jlOUf2OJwotGaFQukUr7zMr69r9pzUlTImPAKVLphOPkIqeOFeGSHfiUY X-Received: by 2002:a62:528e:: with SMTP id g136mr11447125pfb.111.1547661581857; Wed, 16 Jan 2019 09:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661581; cv=none; d=google.com; s=arc-20160816; b=EgLoTZzzv9g1yTQcqsbM3mmVkau8inkMHmZb+vICzAodiHOh3btHUH974T6L0QHVSd AoaNyuM7gkCnxuYRn4sH3JunaSa97jzYB1p9JguQILizj1/CdVIxnqkbUoiasJMu8kDv jseg4e0ae7EbkgYwZfpJ5D28Bc3TvKah/EBsj7TBlSCUrS6XWQON4Mj0KkW8pqVUTr4p OhaxNglParhawNosx2sUybZdtyiomGqQKBjsZ/9Sj9bLyQtH+WDJYRzGoWtz8I0WFW5N xT/I53fjTpS3aWRZrS2Jk3qSSg+51wkARc9591dg8z2iKlVhx1VQ51nxmiOKchuxTnZp qnsg== 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=hxfGLurI+WG9FRkl229XH3oMqxxZ5BdsK6zqvROtKvs=; b=HxphpqqBkkFCFHV2q67y5C3YgET6C17GsAk2W3bFM4lJsM4CD0HQn5BekMmawMDNMy zLXhXdxXYeyOJxm53C7pvprZk6FsPd7D+1eWnzmSmJVm6qPNRCbJZzKHz2RGQEU1sQEV /zLX9pGevFgpYPTwVTgP9kBUxsstQMzRzCjrLQdb0m6zMJB/T99RITdOlZSkR0SAoiza 2iTSZaj7/4d1Q9I9QzsYQF5IRPCeZ3ETBTkboPDPIpt23qoF3Dvfxp0i606VRfQPkkms Zbf4lkUcJZhVO4MhhJa1mNYVInt9diQB1JNbgSz+1p7fDwPtZsgOeBzQ0tH3UF6dNyvc 4GnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id d18si6701527pgm.212.2019.01.16.09.59.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:41 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227794" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:39 -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: [PATCHv4 08/13] Documentation/ABI: Add node performance attributes Date: Wed, 16 Jan 2019 10:57:59 -0700 Message-Id: <20190116175804.30196-9-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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..2217557f29d3 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 nanoseconds 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 nanoseconds available to memory + initiators in nodes found in this class's initiators_nodelist. From patchwork Wed Jan 16 17:58:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766611 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 BEA2A1390 for ; Wed, 16 Jan 2019 18:00:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD1AE2F0EC for ; Wed, 16 Jan 2019 18:00:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F11B2F0F2; Wed, 16 Jan 2019 18:00: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=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 37BF82F0EC for ; Wed, 16 Jan 2019 18:00:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC5D98E0006; Wed, 16 Jan 2019 12:59:43 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C9B3A8E000D; Wed, 16 Jan 2019 12:59:43 -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 A52298E000A; Wed, 16 Jan 2019 12:59:43 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 5C6EC8E000A for ; Wed, 16 Jan 2019 12:59:43 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id d71so4363938pgc.1 for ; Wed, 16 Jan 2019 09:59: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=LDxe+yVu0lOGlnJY9yYDyXlJo/q3OIrUnN6/6s2AWNw=; b=RteJr1FvLqyidLh+ju1iM690PHNYFFD6i8ppKusRN/IM+pWM0FdVeEwXIji91nVfZ2 +5xa01BV1ptJ3QUiw9neQGqhm0ZCS7o5MZY2NYXVoXlgUsJNcQT7CDCE81ktyqqL8e/b trNN0M+1P6bBQCdmz1Cb6fl/Ph4Ou1s+IDPo4HORFDy+lC/Kiv8s6RHiQAKQqGiV0mPY bJNIO6k3Lxj9Xc8PWzh7azii8qISZkQFpjCXlC+ekcqZbuKUvZlzZ5MODxdnkFBHDbyD UnEYRegkrnCDPyZx03UyvRSzRXGl0U6saAo4C/jWx31toz95dIwka63wWWe6c7HKqUjz Qjng== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukcKX4elD7v7PUQQpYb0pytguYC/73YoamvrppXgTsFm1KoVjcRg Gaz/0mf1zqlvKn6pQwD/6Mra2AVXGtA9y/X9jBcdU/rhjZaCyLlLM3vaTUl6AMWhjhx5mTfxJDw Ww/tOnqsyqBvltu305kjP5ofcNfzY4PcFzcVurbrrCPXEh63980kF933BYUAoc7+NZQ== X-Received: by 2002:a63:8149:: with SMTP id t70mr10150078pgd.172.1547661583031; Wed, 16 Jan 2019 09:59:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN7r3X6btQ9rjI0ctXqqFYDV3bTZ/BfFrcJgZbBLBK0szYIAXIbSpKiBLICAtq6e6Pl6TRdB X-Received: by 2002:a63:8149:: with SMTP id t70mr10150023pgd.172.1547661582128; Wed, 16 Jan 2019 09:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661582; cv=none; d=google.com; s=arc-20160816; b=gH7utQt1OIW7zfxAzJylUE9SQrtJw//ahhA4xPgGBInOFSZn4doltoDJqlt2mvaEdE lFEPe7PhxnEEMUwqJtYdWzatB7b9d2//t6cSZlgfEwMi/ADdvDXiZOOIR/80j2/N1L8y ZLjjQhv1zFjs9X87p4lkA+2t5bPiy8/8c0RXcxX3uXQcTHvU3zayGPq4X2/mrq/h6LEe Rxx5qU49VzcgiOpN/TJhG9lPDlZu4yeAsZIbI8dJrU/hcjdc8eGnnDvlSp+bPIOrqCNC PI9Xu4STJXD3WRn7QPv8ClPcNDsaBEbQFbj3JC8YoOtPK2kcq2oUsxIOy8gjWvXQ+5ci XZIA== 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=LDxe+yVu0lOGlnJY9yYDyXlJo/q3OIrUnN6/6s2AWNw=; b=vPvC+ZkuOh1N67MWW2A4vGbjnVuxsLr8PXxXnyx5olxHZHR4fYAj0vWfZKP/xhfrl0 qg9NJK38SSYq2aYVfjGq4L9MY2YNxyIh1Q7KiWT564qudwuIC8TWcFFUJFzE5ngf+Va1 S0X6ui8WNDgWxQgAraE4zdeI8ZKfFEFX8S6yrgXcypqCThsQxb858/tO2KMTiPXt7UDD t7OJvJXych5U69Vg4pDRdVsrz3KaEMTGvpSCGYAeUOFZsaX9379yVhHXcj/RbSPioWTO zMvGmhnVtgGI+qkmu6Wq9F9GJqqZ+dmxF/fkmU3h9hYu1FXsDxVl3CzBo0BCI7AfqQ2N BxqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id d18si6701527pgm.212.2019.01.16.09.59.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:42 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227797" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59: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: [PATCHv4 09/13] acpi/hmat: Register performance attributes Date: Wed, 16 Jan 2019 10:58:00 -0700 Message-Id: <20190116175804.30196-10-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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/hmat/Kconfig | 1 + drivers/acpi/hmat/hmat.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/acpi/hmat/Kconfig b/drivers/acpi/hmat/Kconfig index a4034d37a311..20a0e96ba58a 100644 --- a/drivers/acpi/hmat/Kconfig +++ b/drivers/acpi/hmat/Kconfig @@ -2,6 +2,7 @@ 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/hmat.c b/drivers/acpi/hmat/hmat.c index efb33c74d1a3..45e20dc677f9 100644 --- a/drivers/acpi/hmat/hmat.c +++ b/drivers/acpi/hmat/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 16 17:58:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766617 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 9399C1580 for ; Wed, 16 Jan 2019 18:00:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82E062F0EC for ; Wed, 16 Jan 2019 18:00:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 767C22F0EF; Wed, 16 Jan 2019 18:00:09 +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 BB3CB2F0F2 for ; Wed, 16 Jan 2019 18:00:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9EEB8E000C; Wed, 16 Jan 2019 12:59:44 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9D9B98E000D; Wed, 16 Jan 2019 12:59: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 826AB8E000C; Wed, 16 Jan 2019 12:59:44 -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 39FAB8E000D for ; Wed, 16 Jan 2019 12:59:44 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id o23so4297516pll.0 for ; Wed, 16 Jan 2019 09:59:44 -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=MI59qDXgA/T+c2K6qovM9IqOR9ojwd/Tqb62GYmwONNYOKw/Q25MO8uP01kHfouE7t R0FbaENOChE0K5xhdSd1QQqWmslDSZsZqBTZmVNlNLvNHZTtvkUJTbGqLEOOHxn/c4QG uLB0FF098NfcxuhjxmrXxRA44SHPa0C4NhwytUZs0i9Fp1UeWlV1cFmqJHygveQ77kXW 3uc393wad6wItbQusuoLnfv57+x/SoKyCJXjJHkmb7GimPoC0cVl0UXbg3m5LEiNAeyA ZX1HrLimaSMJUTP36W+kD3E0p+YD50RalW73L0VT13OYgNq6YFPjfhvG7jJWbQe3nx1q i51Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukdXZJNJR8AvC4HqrGe2XDhj6z1AlEmv2+3KR1t0yxeeoUAQSfQw GvjBuAE4IRbCmYX7lf6QoVUJXBM6vqgKbF7p3akIriZFQwwVwnfkVO33IRfgeDu33cowX3oKVXu R/ZcW/cs6ffAAgpCKvNM3KWZZTkq82QhRf2ybCRfq3z7hC9qxJu2LBRCQ3fGwZWjZAw== X-Received: by 2002:a63:134f:: with SMTP id 15mr9925988pgt.19.1547661583766; Wed, 16 Jan 2019 09:59:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN72Hf0iFhOC/b6ntFiZKMi0/GGfR6DwyWCIX7laVIb2rTYC1DIHVffYQNpiQN5RGJMDHL42 X-Received: by 2002:a63:134f:: with SMTP id 15mr9925910pgt.19.1547661582480; Wed, 16 Jan 2019 09:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661582; cv=none; d=google.com; s=arc-20160816; b=oNX1S/LzMFaT9M806hVooHK6bYUn42vW9jVPJ4TU7yJAvc60GSQlAQQFQlJPPv0124 Hzv41MTVkS6VYwqAADazWSUWfZJ6xNdsjunOQsFZOww8hG0I62r0PCPDr1bub35BpM5A +5MbbsfNIOKQPrZ2HNR46NmSe32WELHup0S2X2uZoADNPdS1Mxu/AcoYomwF0pbamp5i iUKeWhLIFXrpsz4FLGAIB0buRsUAZAZqK2m+tXWdogKz6Q33h02gA8FsorAkAMUr01jw FLlCW31TRSmBvgngGHsVJCeKcYrXaM3TgsQbcPNIchwUiw+v7owUUu6K/kLc/IlhIz84 pCAw== 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=GRXwk4LH/QkwSk2wfjOV7Oob7DmenTRJEWDS5D0cHattJE6Cp3VpurQkj1zjpXOs8D pREzvrOpzVMzHVg1NCI42QZrTrPx5uKsnGChkf9sqlfkV1qkxU87AbR591Lh0WA9pPjY cTmwjEUyJSCqMlXryslHe4hFDJndLaCAFquZffRcSZTCw/Iz9YEOczTobi0FE01eJM4a 34DfcQUiiLVDOioI+85Q5Yv8yzLwJXUaBTs2Xd37Utp8w2GRX8ONyURN4/m3krYkE+tD Md80RLD8RY/uPbYTVZJ6lAAKdn5t79PbM4iGbHn/IP07BrpmSZHB+Iob4npdWHH/0Ew7 sihQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id v9si4151090pfl.45.2019.01.16.09.59.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:42 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227800" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:41 -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: [PATCHv4 10/13] node: Add memory caching attributes Date: Wed, 16 Jan 2019 10:58:01 -0700 Message-Id: <20190116175804.30196-11-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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 16 17:58:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766613 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 334ED1390 for ; Wed, 16 Jan 2019 18:00:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 205C42F0EC for ; Wed, 16 Jan 2019 18:00:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10EA32F0F2; Wed, 16 Jan 2019 18:00:05 +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 A1D6B2F0EC for ; Wed, 16 Jan 2019 18:00:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 260938E000A; Wed, 16 Jan 2019 12:59:44 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1C72F8E000C; Wed, 16 Jan 2019 12:59: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 F04C68E000A; Wed, 16 Jan 2019 12:59:43 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 9B27B8E000C for ; Wed, 16 Jan 2019 12:59:43 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id r13so4331123pgb.7 for ; Wed, 16 Jan 2019 09:59: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=rEvbGuuvxl/pTVCry03oC5Sm6yLKUT+sf3b9tNseCB4=; b=N9OfcC60XPS2VSY3uButjv/f8cWCicMA3ymHdQBqTRLpDfgAs6GxtLsxj8jAKm15I1 S0soO+PE6EWXOTOxT7G7UMknH2vr+572WvW5G9U/0bUySzxlR5z5j37XaVqcdVJ53kcG PBqkoS1zrdrdsQCSxr9kFzLPSvHLkvKfkhMKdvKOfOYXBGiJ16M5TBuL17fl8YE+j+Sq siJ6ULbl2tImTg3vdy69x78NuvPqgGhAn071t1KCKuXix2P6tt4/bYFZktBpz5/oUzF+ tYd7xlrlunHx2m90/wW+duJNzwYTuopS2B2UskGTWDUo5UBSj2CpEQY+/8O9EcHh96gM g8kw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukfNEJo1HtcveCE/rob5cIJGcTkPnlIywi0XZcJWsZ6pOLXQM2bZ CL+6XkT3geCFz4KfcfZiw4MTZoAK/SBTJ5eky0odnAfmZrCsDyqXEHIk1zoWtGdSs52vDLXWl3Y g/bEgtuQouNgtCpMIaM41gBZnqm80BqP/C63ky5Oxko154KFw/FjTviBHMISZZagCaw== X-Received: by 2002:a17:902:e10a:: with SMTP id cc10mr11207628plb.165.1547661583302; Wed, 16 Jan 2019 09:59:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN6755AP5g0iyb1dHe21ZqvG96x5Qo9LPkppIAnS+UGvYFXm2Z0b6dpZwkMcFG59xsvnL3qt X-Received: by 2002:a17:902:e10a:: with SMTP id cc10mr11207574plb.165.1547661582477; Wed, 16 Jan 2019 09:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661582; cv=none; d=google.com; s=arc-20160816; b=MZheoplEQyu/6UaA95AQyqXl6x6Mo22E9q5agpV1IZR7IjcUvDqZO1P78mD6Us04dt IlcaTINvPHm7KLlNXwD7eJOC9iopMhPBHKIUpobvvVle/COI10Glk9+hDXeZ2+0w9lMe mlkpCD1zOB3VXMi2mpxFYxi/XMIilmjBuUC7BJeEcY6594WHl8aL0Ks1Zbajvm7rvQJ9 qjfKbI+i0GUxqbxj60M1WOjoOfbW6qjV1yXGffDxicp4rYR9e85lL2wnkmTqGKVMZ/m5 xhARwrdjHW2h4Xv+W0QFKtY6A/MB//WP6EJNyoKZ52PbGY/I1h0yWcnmeanJuKgJaKVY VXSw== 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=rEvbGuuvxl/pTVCry03oC5Sm6yLKUT+sf3b9tNseCB4=; b=lS8I+U4xBoEwfgxmt25TRpqLNxz5K+2gMAhJEZCpZdvpJ1yoXn02d2x8JOZ1RWh/yv SUxQ88e3ZJKi3eJW3GAtU/9RoHyiD7/yx0drowYzv62QXxzDvZOdOLXbWn5w7y91uRtW lz8VX+VDubmzRA8PVS3f8LSv1qm0C/ZqRQ4ZM4dSZRooC5tZEbq6M1e/FSPelUzoKx3o +hwx1eIZ/vMJvfNK+xMsY87SxfjbX5Y33OrkS4d6dcUim/afwg86ryXAbHsb7v3mzQ1F tO93d1TUN9gdad3rIGzV3tDPyKgtbicj18buxH90DKLk1wOdXVY2dceDr6I717FG+xAh gbxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id d18si6701527pgm.212.2019.01.16.09.59.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:42 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227804" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:41 -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: [PATCHv4 11/13] Documentation/ABI: Add node cache attributes Date: Wed, 16 Jan 2019 10:58:02 -0700 Message-Id: <20190116175804.30196-12-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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 2217557f29d3..613d51fb52a3 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 nanoseconds 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 16 17:58:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766619 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 F1FE11390 for ; Wed, 16 Jan 2019 18:00:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD6E82F0EC for ; Wed, 16 Jan 2019 18:00:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D195F2F0F2; Wed, 16 Jan 2019 18:00:12 +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 680A02F0EC for ; Wed, 16 Jan 2019 18:00:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D7578E000E; Wed, 16 Jan 2019 12:59:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 985128E000D; Wed, 16 Jan 2019 12:59:45 -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 89F318E000E; Wed, 16 Jan 2019 12:59:45 -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 420438E000D for ; Wed, 16 Jan 2019 12:59:45 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id g12so4242468pll.22 for ; Wed, 16 Jan 2019 09:59:45 -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=LeA9O+aMUfw7chPbIMIltglPHbtnLkFZesIZULkNVzM=; b=n7CiimMhoxOdDsPcamwWBjkxJrbuUG89kGlNmm6M0/c9Jo54CWsKOCJLKFrcTjCfQM aoPQojc5BB1Kuqen+hLjRKY6sUuq2W3vgp4GHayRNdLG+fsfyUgBpcc9++nAWVxqGXXq YQfRLMHec3q3+mijipGhUBMc6DD5O8UwLOO4HWvjh72+HKmYn3ZHJBXIzEliBDHcRSYt cTijmWi+pRQU6NQEMSliAAx6aqcUSokzBmEo/VKDAJ4If31HwiUDE0X/+/pnXM3Iw6x4 Su1F8SgEmmtSo29EtYgPZeeuOsvwjJUO0QsjeqyGmMBHXJIfSFWIFgZsa+ZV5gGpoBmo QF/Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukf+9XfqnwSjDUdLS2nKz0jzjkoxJZvxMZhcDRBkZbWqTd3mUJ0W vG9aEOUDeeNpqHw/CUvEmHiTmrvMFUaBfMdQqfJ5P86+28CVoRNSQXA9lbHUyWZYyxhpB0NZLQN qdGgjup3jPwWw0sJXsdK/zE1wizghB1PtIF8JkpzwuJxAdmiD7KZK9u5xWdpSrnZiBA== X-Received: by 2002:a17:902:82c2:: with SMTP id u2mr11117577plz.110.1547661584934; Wed, 16 Jan 2019 09:59:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN5VWgm72Vt5/0mdOZX5bhi9f53+7KfUCodM2qeKG4vXalQWlxQM0wzvyua22FZvWS8L/UxJ X-Received: by 2002:a17:902:82c2:: with SMTP id u2mr11117542plz.110.1547661584187; Wed, 16 Jan 2019 09:59:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661584; cv=none; d=google.com; s=arc-20160816; b=gM2NmgmnE5z3JMlZbqOBMlqMM0jvoKdTP3NgpLoC+iLN/iHL79IYMG7DHL0HNoOL9q aM9sI2rlnc+N48Ao4hdvNsLtYRzkX0WukczfzhWQ+7NbdLixRE0imZZjqsdUh69fzuPQ Wuqb6C+jmPoDoHduO0Nmd6dsPbpkX9TNloaV66MB8+3SNtKGG+Mg8dUKpBbYk6ZWf3y+ N3bWqf7GIqOIWG3qNbAsCLv5b3cgTCeKW4yY0T2qpvhp7ss+j4T1SVxCxzUKSCEDroFM mdnLUlfI5dS184JxVNTTXUSTnrenD6sDCuTbAWpTOqW44mnN+r4JsTQc9X8gdVQTaIxY mcew== 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=LeA9O+aMUfw7chPbIMIltglPHbtnLkFZesIZULkNVzM=; b=ne1gmmdOUL97ihAIG8znJ0qOqYZW/BR8NMjn6/EA9JaL9xUq5ZuxONpRUdtqjpRtBu Gs9ced4+lIHxBtV9sY+OttJNN8bf4UguGzeyWnlSEo7Nd5DZuRTeVfB760VrsmjEYjBZ OK1e/t6AM7mOta7exMY8vSgpCNkqOj9e3J4KA+wgZ7OUr0hSxcfmPQB1NC2WvLoOoDdO RtU8LH9jllci2tYxPVPcZX1KlLT02Cyaxb595MDHYQ33qeuv1mVS55RBTkm17IqR6nsU fCMOwAlRq0bR+LkdCi/gjhecW41UmKmU28UZMUVem/havIw3g8AM0HUVEWG3o/8UcKHA Cadw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id 1si3509983plk.296.2019.01.16.09.59.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:44 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227809" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:42 -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: [PATCHv4 12/13] acpi/hmat: Register memory side cache attributes Date: Wed, 16 Jan 2019 10:58:03 -0700 Message-Id: <20190116175804.30196-13-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-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/hmat.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/acpi/hmat/hmat.c b/drivers/acpi/hmat/hmat.c index 45e20dc677f9..9efdd0a63a79 100644 --- a/drivers/acpi/hmat/hmat.c +++ b/drivers/acpi/hmat/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 16 17:58:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10766623 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 0A38013BF for ; Wed, 16 Jan 2019 18:00:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDCB82F0EC for ; Wed, 16 Jan 2019 18:00:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1A2E2F0F2; Wed, 16 Jan 2019 18:00:16 +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 362242F0EC for ; Wed, 16 Jan 2019 18:00:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE6808E000F; Wed, 16 Jan 2019 12:59:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A9FFB8E000D; Wed, 16 Jan 2019 12:59:46 -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 8270B8E000F; Wed, 16 Jan 2019 12:59:46 -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 425D78E000D for ; Wed, 16 Jan 2019 12:59:46 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id b17so5201236pfc.11 for ; Wed, 16 Jan 2019 09:59:46 -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=4kD6ZHyV2w+PBG7/eC9i2wK3AWeBk12p5dRzIBQMOTQ=; b=NIzdPMqTHSyJKImzjO+fLsgSajuGHQQaSIy15X9Qn1p7grfQx5rPo2lv/IHP3pgnY1 GHKB8CbvBd5BB9L1WOAUEWTVELM5Pj3rP0Y9p4NHABBWspjY2076w8dXWqbQxCn8wJ7m wSvMxTsF0eLXTc0DjCGEMX6tzDmcj45JaNdY9zPUQvQV2pDYaTV0FvRW95g2z62Addnh sqZxXSiIRbUtTVG6jif79KR7QiuI4ICnmXPHeIYIUG6WkChqHMyOIDE+i2JyR8fHvujM nNa2eWk3y1vbimVl0gjhygux376yAczo7Kriqq8+yKp0EWE5nZcM6pT1493kZjfjd4Dc 50Ew== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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: AJcUukdiPIcqMAuwsw35eLNpkH+nvFVFfxdmhJgTV3vKxaLsDMNxF/kH EsoE0dpHTxtHqXfmrLDq8MpZ9JG+5tPbSbTeOccLlikujj8OJHX0A45qg7pC1En6CUwoJQDj8cS ZqWiPLztjLjnkNQKkL7WND+0FBKJux9T+JiMsF2c6cUWTY2c2wPr64wqXF30xl+I2VQ== X-Received: by 2002:a17:902:8e8a:: with SMTP id bg10mr11096801plb.192.1547661585888; Wed, 16 Jan 2019 09:59:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN7MDGLrd387IRG/L4vY/YqEQYGqN+im85k21LafgSeDxexHIaSXNbIEMyGqUo81GvWvvi3d X-Received: by 2002:a17:902:8e8a:: with SMTP id bg10mr11096717plb.192.1547661584490; Wed, 16 Jan 2019 09:59:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661584; cv=none; d=google.com; s=arc-20160816; b=RP+KhhibzFDX/yiVLvRSdYXQKEDRvzmBXvat3bVLf6x0toKUh79+ltSJ2pXiOerEOQ dN4SyK3s8NE36lqo1CnNRPQea6pCguzKrFIgXuf92tV/d8uCEQTkU1eJFQqCMtfkwFps zbJoSTcNOK5+5Nws/QhdE4IFxTpCWkmnxz2NrdS+mKXzuj+Nba5EaFqT9rDNkXtmJerJ R7gkOAYtQY1sTp+Hi9Rq6m0VO41bdBYcKRgOgpxgU7vkvDKwP/aoX0vhvf7jD+y+KrKs +0an176SBEP0MbL5UPxc+huGup4Bg3boSKgNky43toOjpJ5uGLd87NaGvwX0yr36Jqzo Fz4A== 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=4kD6ZHyV2w+PBG7/eC9i2wK3AWeBk12p5dRzIBQMOTQ=; b=dzMX7181GdvljTIFlszmfGhH6N/j1LnFJAm6B88MOhtzI+aQdJVrbU+1QQ+naGoHlJ REVeC/wRYyXiRq3oHypJwZgBFJzAEZ1oIq+iAgqLbSRyCp1ISvfxGGCjZMqOBdtYGP/W hUZiPID3SmDRArpqmNtRMBVekZu1+keaDwUPvd3eP2KKTit/MfAMJv1PYj+3W9rWsnZ9 yGCpD4cM3cj1+p4DRz5CDZsOJ+EThymotPgI0oqFu/iAAzUxApLla8CDJ9BemoEchhtt exRhpfgslN9BnOzgg+4ZFlIHUOXTpBdD4/ua2u1D4ZJpGZS/8MF0JRlLzZFAbkYEOwPq UjHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=keith.busch@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id 1si3509983plk.296.2019.01.16.09.59.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 09:59:44 -0800 (PST) Received-SPF: pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of keith.busch@intel.com designates 192.55.52.88 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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 09:59:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="117227813" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by fmsmga008.fm.intel.com with ESMTP; 16 Jan 2019 09:59:42 -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: [PATCHv4 13/13] doc/mm: New documentation for memory performance Date: Wed, 16 Jan 2019 10:58:04 -0700 Message-Id: <20190116175804.30196-14-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190116175804.30196-1-keith.busch@intel.com> References: <20190116175804.30196-1-keith.busch@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Platforms may provide system memory where some physical address ranges perform differently than others, or is side cached by the system. Add documentation describing a high level overview of such systems and the perforamnce and caching attributes the kernel provides for applications wishing to query this information. Reviewed-by: Mike Rapoport Signed-off-by: Keith Busch --- Documentation/admin-guide/mm/numaperf.rst | 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..963fbd3004d3 --- /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 +nodes with local memory and a memory only node for each of compute node: + + +------------------+ +------------------+ + | Compute Node 0 +-----+ Compute Node 1 | + | Local Node0 Mem | | Local Node1 Mem | + +--------+---------+ +--------+---------+ + | | + +--------+---------+ +--------+---------+ + | Slower Node2 Mem | | Slower Node3 Mem | + +------------------+ +--------+---------+ + +A "memory initiator" is a node containing one or more devices such as +CPUs or separate memory I/O devices that can initiate memory requests. +A "memory target" is a node containing one or more physical address +ranges accessible from one or more memory initiators. + +When multiple memory initiators exist, they may not all have the same +performance when accessing a given memory target. Each initiator-target +pair may be organized into different ranked access classes to represent +this relationship. The highest performing initiator to a given target +is considered to be one of that target's local initiators, and given +the highest access class, 0. Any given target may have one or more +local initiators, and any given initiator may have multiple local +memory targets. + +To aid applications matching memory targets with their initiators, the +kernel provides symlinks to each other. The following example lists the +relationship for the class "0" memory initiators and targets, which is +the 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 +target and initiator nodelist 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 +are provided by the last memory level in the hierarchy. The system +meanwhile uses higher performing memory to transparently cache access +to progressively slower levels. + +The term "far memory" is used to denote the last level memory in the +hierarchy. Each increasing cache level provides higher performing +initiator access, and the term "near memory" represents the fastest +cache provided by the system. + +This numbering is different than CPU caches where the cache level (ex: +L1, L2, L3) uses a CPU centric view with each increased level is lower +performing. In contrast, the memory cache level is centric to the last +level memory, so the higher numbered cache level denotes memory nearer +to the CPU, and further from far memory. + +The memory side caches are not directly addressable by software. When +software accesses a system address, the system will return it from the +near memory cache if it is present. If it is not present, the system +accesses the next level of memory until there is either a hit in that +cache level, or it reaches far memory. + +An application does not need to know about caching attributes in order +to use the system. Software may optionally query the memory cache +attributes in order to maximize the performance out of such a setup. +If the system provides a way for the kernel to discover this information, +for example with ACPI HMAT (Heterogeneous Memory Attribute Table), +the kernel will append these attributes to the NUMA node memory target. + +When the kernel first registers a memory cache with a node, the kernel +will create the following directory:: + + /sys/devices/system/node/nodeX/side_cache/ + +If that directory is not present, the system either does not not provide +a memory side cache, or that information is not accessible to the kernel. + +The attributes for each level of cache is provided under its cache +level index:: + + /sys/devices/system/node/nodeX/side_cache/indexA/ + /sys/devices/system/node/nodeX/side_cache/indexB/ + /sys/devices/system/node/nodeX/side_cache/indexC/ + +Each cache level's directory provides its attributes. For example, the +following shows a single cache level and the attributes available for +software to query:: + + # tree sys/devices/system/node/node0/side_cache/ + /sys/devices/system/node/node0/side_cache/ + |-- index1 + | |-- associativity + | |-- level + | |-- line_size + | |-- size + | `-- write_policy + +The "associativity" will be 0 if it is a direct-mapped cache, and non-zero +for any other indexed based, multi-way associativity. + +The "level" is the distance from the far memory, and matches the number +appended to its "index" directory. + +The "line_size" is the number of bytes accessed on a cache miss. + +The "size" is the number of bytes provided by this cache level. + +The "write_policy" will be 0 for write-back, and non-zero for +write-through caching. + +======== +See Also +======== +.. [1] https://www.uefi.org/sites/default/files/resources/ACPI_6_2.pdf + Section 5.2.27