Page MenuHomeFreeBSD

Reallocate pcpu area on the correct domain.

Authored by jeff on Aug 13 2019, 1:49 AM.



This patch simply allocates various per-cpu data-structures on the correct domain. The actual pcpu area is reallocated and we waste a page. Recovering the page is likely more costly than the benefit as it will increase the size of the page array.

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jeff created this revision.Aug 13 2019, 1:49 AM
jeff retitled this revision from Reallocate pcpu area on the correct domain if it is not already. Parts of this diff were originally from kib. to Reallocate pcpu area on the correct domain..Aug 13 2019, 1:52 AM
jeff edited the summary of this revision. (Show Details)
jeff added reviewers: markj, kib, gallatin, jhb, glebius.
kib added inline comments.Aug 13 2019, 7:28 AM
406 ↗(On Diff #60707)

You are remapping a page in the kernel .bss section, I think that pmap_enter() works there only by a chance for now. I am sure that we do not want to support such use of pmap_enter().

Ideally we would use something like pmap_qenter(), but .bss might be mapped with superpage.

jeff added inline comments.Aug 13 2019, 7:31 AM
406 ↗(On Diff #60707)

What might break it? Why do we not want to support this?

kib added inline comments.Aug 13 2019, 11:07 AM
406 ↗(On Diff #60707)

For instance, vm_page_array elements backing pages of kernel text/data/bss were not initialized until very recently. We never faulted on kernel segments, and pmap_enter() was correspondingly never needed there.

jeff added inline comments.Aug 13 2019, 5:09 PM
406 ↗(On Diff #60707)

Ok but I still don't see a reason not to do this. It is simple and it works. Anything I do will just be a more long winded replacement of the same code.

kib added inline comments.Aug 13 2019, 5:35 PM
406 ↗(On Diff #60707)

I do not object (strongly), just pointing out that the code introduces a new requirement.

Also, this causes demotion of the superpage mapping the data (.data + .bss), I believe.

jeff added a reviewer: mmacy.Aug 15 2019, 7:29 PM
jeff added a comment.Aug 18 2019, 8:36 AM

If there is no strong objection I will commit this tomorrow.

kib accepted this revision.Aug 18 2019, 6:25 PM
This revision is now accepted and ready to land.Aug 18 2019, 6:25 PM
gallatin requested changes to this revision.Aug 18 2019, 7:52 PM
gallatin added inline comments.
470 ↗(On Diff #60707)

I'm getting a panic here on AMD rome configured in non-numa mode. I think we need to avoid acpi_pxm_get_cpu_locality() when we're not on a numa machine. The following patch seems to fix it:

        /* start each AP */
-       for (cpu = 1; cpu < mp_ncpus; cpu++) {
+       for (domain = 0, cpu = 1; cpu < mp_ncpus; cpu++) {
                apic_id = cpu_apic_ids[cpu];
-               domain = acpi_pxm_get_cpu_locality(apic_id);
+#ifdef NUMA
+               if (vm_ndomains > 1)
+                       domain = acpi_pxm_get_cpu_locality(apic_id);
                /* allocate and set up an idle stack data page */
                bootstacks[cpu] = (void *)kmem_malloc_domainset(
This revision now requires changes to proceed.Aug 18 2019, 7:52 PM
This revision was not accepted when it landed; it landed in state Needs Revision.Aug 18 2019, 11:44 PM
This revision was automatically updated to reflect the committed changes.