diff mbox

[V3,05/37] x86, PCI, ACPI: use kmalloc_node() to optimize for performance

Message ID 1401178092-1228-6-git-send-email-jiang.liu@linux.intel.com
State Not Applicable
Headers show

Commit Message

Jiang Liu May 27, 2014, 8:07 a.m. UTC
Use kmalloc_node() instead of kmalloc() when possible to optimize
for performance on NUMA platforms.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
---
 arch/x86/pci/acpi.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Bjorn Helgaas May 27, 2014, 1:50 p.m. UTC | #1
On Tue, May 27, 2014 at 2:07 AM, Jiang Liu <jiang.liu@linux.intel.com> wrote:
> Use kmalloc_node() instead of kmalloc() when possible to optimize
> for performance on NUMA platforms.
>
> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

I think this is micro-optimization, because I don't think these
structures are referenced often.  It might be nicer if we could
arrange to run this path on the local node, as we do in
pci_call_probe(), so all allocs would happen there.  But I'm OK with
this as-is.

> ---
>  arch/x86/pci/acpi.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
> index 01edac6c5e18..91bef49df228 100644
> --- a/arch/x86/pci/acpi.c
> +++ b/arch/x86/pci/acpi.c
> @@ -448,7 +448,7 @@ static void probe_pci_root_info(struct pci_root_info *info,
>                 return;
>
>         size = sizeof(*info->res) * info->res_num;
> -       info->res = kzalloc(size, GFP_KERNEL);
> +       info->res = kzalloc_node(size, GFP_KERNEL, info->sd.node);
>         if (!info->res) {
>                 info->res_num = 0;
>                 return;
> @@ -456,7 +456,7 @@ static void probe_pci_root_info(struct pci_root_info *info,
>
>         size = sizeof(*info->res_offset) * info->res_num;
>         info->res_num = 0;
> -       info->res_offset = kzalloc(size, GFP_KERNEL);
> +       info->res_offset = kzalloc_node(size, GFP_KERNEL, info->sd.node);
>         if (!info->res_offset) {
>                 kfree(info->res);
>                 info->res = NULL;
> @@ -495,7 +495,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>         if (node != NUMA_NO_NODE && !node_online(node))
>                 node = NUMA_NO_NODE;
>
> -       info = kzalloc(sizeof(*info), GFP_KERNEL);
> +       info = kzalloc_node(sizeof(*info), GFP_KERNEL, node);
>         if (!info) {
>                 printk(KERN_WARNING "pci_bus %04x:%02x: "
>                        "ignored (out of memory)\n", domain, busnum);
> --
> 1.7.10.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Rientjes May 27, 2014, 9:22 p.m. UTC | #2
On Tue, 27 May 2014, Jiang Liu wrote:

> Use kmalloc_node() instead of kmalloc() when possible to optimize
> for performance on NUMA platforms.
> 
> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>

Acked-by: David Rientjes <rientjes@google.com>

All the handling to make sure sd->node refers to either NUMA_NO_NODE 
(fallback to local allocation) or an online node looks to be handled 
properly.
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 01edac6c5e18..91bef49df228 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -448,7 +448,7 @@  static void probe_pci_root_info(struct pci_root_info *info,
 		return;
 
 	size = sizeof(*info->res) * info->res_num;
-	info->res = kzalloc(size, GFP_KERNEL);
+	info->res = kzalloc_node(size, GFP_KERNEL, info->sd.node);
 	if (!info->res) {
 		info->res_num = 0;
 		return;
@@ -456,7 +456,7 @@  static void probe_pci_root_info(struct pci_root_info *info,
 
 	size = sizeof(*info->res_offset) * info->res_num;
 	info->res_num = 0;
-	info->res_offset = kzalloc(size, GFP_KERNEL);
+	info->res_offset = kzalloc_node(size, GFP_KERNEL, info->sd.node);
 	if (!info->res_offset) {
 		kfree(info->res);
 		info->res = NULL;
@@ -495,7 +495,7 @@  struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	if (node != NUMA_NO_NODE && !node_online(node))
 		node = NUMA_NO_NODE;
 
-	info = kzalloc(sizeof(*info), GFP_KERNEL);
+	info = kzalloc_node(sizeof(*info), GFP_KERNEL, node);
 	if (!info) {
 		printk(KERN_WARNING "pci_bus %04x:%02x: "
 		       "ignored (out of memory)\n", domain, busnum);