Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1233184 > unrolled thread
| Started by | Tang Chen <tangchen@cn.fujitsu.com> |
|---|---|
| First post | 2015-09-26 12:00 +0200 |
| Last post | 2015-09-28 04:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [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-26 12:00 +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-26 20:00 +0200
Re: [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-28 04:00 +0200
| From | Tang Chen <tangchen@cn.fujitsu.com> |
|---|---|
| Date | 2015-09-26 12:00 +0200 |
| Subject | Re: [PATCH v2 5/7] x86, acpi, cpu-hotplug: Introduce apicid_to_cpuid[] array to store persistent cpuid <-> apicid mapping. |
| Message-ID | <qcUqR-4MN-7@gated-at.bofh.it> |
Hi tj,
On 09/11/2015 03:55 AM, Tejun Heo wrote:
> Hello,
>
> So, overall, I think this is the right way to go although I have no
> idea whether the acpi part is okay.
Thank you very much for reviewing. :)
>
>> +/*
>> + * 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?
OK.
>
>> +static int cpuid_to_apicid[] = {
>> + [0 ... NR_CPUS - 1] = -1,
>> +};
> And maybe mention how the two variables are synchronized?
User should call allocate_logical_cpuid() to get a new logical cpuid.
This allocator will ensure the synchronization.
Will mention it in the comment.
>
>> +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?
It is not different. Since max_logical_cpuid is new, this is ensure it
won't
go beyond NR_CPUS.
Thanks.
>
> Thanks.
>
--
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/
[toc] | [next] | [standalone]
| From | Tejun Heo <tj@kernel.org> |
|---|---|
| Date | 2015-09-26 20:00 +0200 |
| Subject | Re: [PATCH v2 5/7] x86, acpi, cpu-hotplug: Introduce apicid_to_cpuid[] array to store persistent cpuid <-> apicid mapping. |
| Message-ID | <qd1Vn-77B-17@gated-at.bofh.it> |
| In reply to | #1233184 |
On Sat, Sep 26, 2015 at 05:52:09PM +0800, Tang Chen wrote:
> >>+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?
>
> It is not different. Since max_logical_cpuid is new, this is ensure it won't
> go beyond NR_CPUS.
If the above condition can happen, the original code should have had a
similar check as above, right? Sure, max_logical_cpuid is a new thing
but that doesn't seem to change whether the above condition can happen
or not, no?
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/
[toc] | [prev] | [next] | [standalone]
| From | Tang Chen <tangchen@cn.fujitsu.com> |
|---|---|
| Date | 2015-09-28 04:00 +0200 |
| Message-ID | <qdvTr-8b5-5@gated-at.bofh.it> |
| In reply to | #1233252 |
On 09/27/2015 01:56 AM, Tejun Heo wrote:
> On Sat, Sep 26, 2015 at 05:52:09PM +0800, Tang Chen wrote:
>>>> +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?
>> It is not different. Since max_logical_cpuid is new, this is ensure it won't
>> go beyond NR_CPUS.
> If the above condition can happen, the original code should have had a
> similar check as above, right? Sure, max_logical_cpuid is a new thing
> but that doesn't seem to change whether the above condition can happen
> or not, no?
Right, indeed. It is in
generic_processor_info()
|--> if (num_processors >= nr_cpu_ids)
Will remove my new added check.
Thanks.
>
> Thanks.
>
--
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/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web