All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Liu Jingqi <jingqi.liu@intel.com>
Cc: pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com,
	imammedo@redhat.com, marcel.apfelbaum@gmail.com,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v1 1/7] hmat acpi: Build Memory Subsystem Address Range Structre(s) in ACPI HMAT
Date: Fri, 11 May 2018 11:40:59 -0300	[thread overview]
Message-ID: <20180511144059.GN25013@localhost.localdomain> (raw)
In-Reply-To: <1525854869-13975-1-git-send-email-jingqi.liu@intel.com>

On Wed, May 09, 2018 at 04:34:29PM +0800, Liu Jingqi wrote:
> HMAT is defined in ACPI 6.2: 5.2.27 Heterogeneous Memory Attribute Table (HMAT).
> The specification references below link:
> http://www.uefi.org/sites/default/files/resources/ACPI_6_2.pdf
> 
> It describes the memory attributes, such as memory side cache
> attributes and bandwidth and latency details, related to the
> System Physical Address (SPA) Memory Ranges. The software is
> expected to use this information as hint for optimization.
> 
> This structure describes the System Physical Address(SPA) range
> occupied by memory subsystem and its associativity with processor
> proximity domain as well as hint for memory usage.
> 
[...]
> +/*
> + * The Proximity Domain of System Physical Address ranges defined
> + * in the HMAT, NFIT and SRAT tables shall match each other.
> + */
> +static void hmat_build_spa(GArray *table_data, PCMachineState *pcms)
> +{
> +    GSList *device_list = NULL;
> +    AcpiHmatSpaRange *hmat_spa;
> +    uint64_t mem_base, next_base, mem_len;
> +    int node;
> +
> +    next_base = 0;
> +    for (node = 0; node < nb_numa_nodes; node++) {
> +        mem_len = numa_info[node].node_mem;
> +        if (!mem_len) {
> +            continue;
> +        }
> +
> +        mem_base = next_base;
> +        next_base = mem_base + mem_len;
> +
> +        /* Cut out the 640K hole */
> +        if (mem_base <= HOLE_640K_START &&
> +            next_base > HOLE_640K_START) {
> +            mem_len -= next_base - HOLE_640K_START;
> +            if (mem_len > 0) {
> +                hmat_spa = acpi_data_push(table_data, sizeof(*hmat_spa));
> +                hmat_build_spa_info(hmat_spa, mem_base, mem_len, node);
> +            }
> +
> +            /* Check for the rare case: 640K < RAM < 1M */
> +            if (next_base <= HOLE_640K_END) {
> +                next_base = HOLE_640K_END;
> +                continue;
> +            }
> +            mem_base = HOLE_640K_END;
> +            mem_len = next_base - HOLE_640K_END;
> +        }
> +
> +        /* Cut out the ACPI_PCI hole */
> +        if (mem_base <= pcms->below_4g_mem_size &&
> +            next_base > pcms->below_4g_mem_size) {
> +            mem_len -= next_base - pcms->below_4g_mem_size;
> +            if (mem_len > 0) {
> +                hmat_spa = acpi_data_push(table_data, sizeof(*hmat_spa));
> +                hmat_build_spa_info(hmat_spa, mem_base, mem_len, node);
> +            }
> +            mem_base = 1ULL << 32;
> +            mem_len = next_base - pcms->below_4g_mem_size;
> +            next_base = mem_base + mem_len;
> +        }

This duplicates very complex logic that already exists in
build_srat().  We need to make the existing logic reusable.


> +        hmat_spa = acpi_data_push(table_data, sizeof(*hmat_spa));
> +        hmat_build_spa_info(hmat_spa, mem_base, mem_len, node);
> +    }
> +
> +    /* Build HMAT SPA structures for PC-DIMM devices. */
> +    object_child_foreach(qdev_get_machine(), pc_dimm_device_list, &device_list);
> +
> +    for (; device_list; device_list = device_list->next) {
> +        PCDIMMDevice *dimm = device_list->data;
> +        mem_base = object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP,
> +                                            NULL);
> +        mem_len = object_property_get_uint(OBJECT(dimm), PC_DIMM_SIZE_PROP,
> +                                           NULL);
> +        node = object_property_get_uint(OBJECT(dimm), PC_DIMM_NODE_PROP, NULL);
> +
> +        hmat_spa = acpi_data_push(table_data, sizeof(*hmat_spa));
> +        hmat_build_spa_info(hmat_spa, mem_base, mem_len, node);
> +    }
> +}

-- 
Eduardo

  parent reply	other threads:[~2018-05-11 14:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09  8:34 [Qemu-devel] [PATCH v1 1/7] hmat acpi: Build Memory Subsystem Address Range Structre(s) in ACPI HMAT Liu Jingqi
2018-05-09 13:13 ` Eric Blake
2018-05-10  3:05   ` Liu, Jingqi
2018-05-11 14:40 ` Eduardo Habkost [this message]
2018-05-14  5:55   ` Liu, Jingqi
2018-05-15 14:35 ` Igor Mammedov
2018-05-16  6:28   ` Liu, Jingqi
2018-05-15 14:41 ` Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180511144059.GN25013@localhost.localdomain \
    --to=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=jingqi.liu@intel.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.