Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1222377

Re: [PATCH v2 5/7] x86, acpi, cpu-hotplug: Introduce apicid_to_cpuid[] array to store persistent cpuid <-> apicid mapping.

From Tejun Heo <tj@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2 5/7] x86, acpi, cpu-hotplug: Introduce apicid_to_cpuid[] array to store persistent cpuid <-> apicid mapping.
Date 2015-09-10 22:00 +0200
Message-ID <q7gaK-32N-15@gated-at.bofh.it> (permalink)
References <q71EK-7Fd-15@gated-at.bofh.it> <q71Op-7Qc-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello,

So, overall, I think this is the right way to go although I have no
idea whether the acpi part is okay.

> +/*
> + * Current allocated max logical CPU ID plus 1.
> + * All allocated CPU ID should be in [0, max_logical_cpuid),
> + * so the maximum of max_logical_cpuid is nr_cpu_ids.
> + *
> + * NOTE: Reserve 0 for BSP.
> + */
> +static int max_logical_cpuid = 1;

Rename it to nr_logical_cpuids and just mention that it's allocated
contiguously?

> +static int cpuid_to_apicid[] = {
> +	[0 ... NR_CPUS - 1] = -1,
> +};

And maybe mention how the two variables are synchronized?

> +static int allocate_logical_cpuid(int apicid)
> +{
> +	int i;
> +
> +	/*
> +	 * cpuid <-> apicid mapping is persistent, so when a cpu is up,
> +	 * check if the kernel has allocated a cpuid for it.
> +	 */
> +	for (i = 0; i < max_logical_cpuid; i++) {
> +		if (cpuid_to_apicid[i] == apicid)
> +			return i;
> +	}
> +
> +	/* Allocate a new cpuid. */
> +	if (max_logical_cpuid >= nr_cpu_ids) {
> +		WARN_ONCE(1, "Only %d processors supported."
> +			     "Processor %d/0x%x and the rest are ignored.\n",
> +			     nr_cpu_ids - 1, max_logical_cpuid, apicid);
> +		return -1;
> +	}

So, the original code didn't have this failure mode, why is this
different for the new code?

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/7] Make cpuid <-> nodeid mapping persistent. Tang Chen <tangchen@cn.fujitsu.com> - 2015-09-10 06:30 +0200
  [PATCH v2 6/7] x86, acpi, cpu-hotplug: Enable MADT APIs to return disabled apicid. Tang Chen <tangchen@cn.fujitsu.com> - 2015-09-10 06:40 +0200
  [PATCH v2 2/7] x86, numa: Introduce a node to node array to map a node to its best online node. Tang Chen <tangchen@cn.fujitsu.com> - 2015-09-10 06:40 +0200
  [PATCH v2 7/7] x86, acpi, cpu-hotplug: Set persistent cpuid <-> nodeid mapping when booting. Tang Chen <tangchen@cn.fujitsu.com> - 2015-09-10 06:40 +0200
  [PATCH v2 1/7] x86, numa: Move definition of find_near_online_node() forward. Tang Chen <tangchen@cn.fujitsu.com> - 2015-09-10 06:40 +0200
  [PATCH v2 5/7] x86, acpi, cpu-hotplug: Introduce apicid_to_cpuid[] array to store persistent cpuid <-> apicid mapping. Tang Chen <tangchen@cn.fujitsu.com> - 2015-09-10 06:40 +0200
    Re: [PATCH v2 5/7] x86, acpi, cpu-hotplug: Introduce  apicid_to_cpuid[] array to store persistent cpuid <-> apicid mapping. Tejun Heo <tj@kernel.org> - 2015-09-10 22:00 +0200
  [PATCH v2 3/7] x86, gfp: Cache best near node for memory allocation. Tang Chen <tangchen@cn.fujitsu.com> - 2015-09-10 06:40 +0200
    Re: [PATCH v2 3/7] x86, gfp: Cache best near node for memory  allocation. Tejun Heo <tj@kernel.org> - 2015-09-10 21:30 +0200
      Re: [PATCH v2 3/7] x86, gfp: Cache best near node for memory  allocation. Tejun Heo <tj@kernel.org> - 2015-09-10 21:40 +0200
        Re: [PATCH v2 3/7] x86, gfp: Cache best near node for memory  allocation. Christoph Lameter <cl@linux.com> - 2015-09-11 00:10 +0200
          Re: [PATCH v2 3/7] x86, gfp: Cache best near node for memory  allocation. Tejun Heo <tj@kernel.org> - 2015-09-11 00:10 +0200
        Re: [PATCH v2 3/7] x86, gfp: Cache best near node for memory  allocation. Christoph Lameter <cl@linux.com> - 2015-09-11 02:20 +0200
  [PATCH v2 4/7] x86, acpi, cpu-hotplug: Enable acpi to register all possible cpus at boot time. Tang Chen <tangchen@cn.fujitsu.com> - 2015-09-10 06:40 +0200
    Re: [PATCH v2 4/7] x86, acpi, cpu-hotplug: Enable acpi to register all possible cpus at boot time. "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-09-11 00:50 +0200

csiph-web