RE: [PATCH] long format VHPT

Chen, Kenneth W
2003-09-28T23:44:02Z

[-- Attachment #1: Type: text/plain, Size: 649 bytes --]

Arun Sharma wrote:
> - Can we avoid allocating VHPTs for non-existent CPUs ?
> - How about calling alloc_bootmem on cpu0 and __get_free_pages
> on secondary cpus ?

> I noticed that when we hit ia64_mmu_init() on a secondary
> processor, cpu0 has already made successful calls to
> __get_free_pages(). But calls from the secondary cpus fail.
> Does anyone know why ?

I did some hacking over the weekend. VHPT allocation can be done
from boot processor in function do_boot_cpu() before waking up
secondary CPUs. Allocation can be easily made numa friendly by
calling alloc_pages_node (didn't bother to do that for now).

- Ken

[-- Attachment #2: lvhpt_init.patch --]
[-- Type: application/octet-stream, Size: 2484 bytes --]

diff -Nurp 2.6.0-test5.v/arch/ia64/kernel/smpboot.c 2.6.0-test5.ken/arch/ia64/kernel/smpboot.c
--- 2.6.0-test5.v/arch/ia64/kernel/smpboot.c Sun Sep 28 16:28:16 2003
+++ 2.6.0-test5.ken/arch/ia64/kernel/smpboot.c Sun Sep 28 16:32:24 2003
@@ -358,11 +358,16 @@ fork_by_hand (void)
return copy_process(CLONE_VM|CLONE_IDLETASK, 0, 0, 0, NULL, NULL);
}

+#ifdef CONFIG_IA64_LONG_FORMAT_VHPT
+extern unsigned long vhpt_base[NR_CPUS];
+#endif
+
static int __init
do_boot_cpu (int sapicid, int cpu)
{
struct task_struct *idle;
int timeout;
+ struct page * vhpt_page;

/*
* We can't use kernel_thread since we must avoid to reschedule the child.
@@ -382,6 +387,16 @@ do_boot_cpu (int sapicid, int cpu)

task_for_booting_cpu = idle;

+#ifdef CONFIG_IA64_LONG_FORMAT_VHPT
+ vhpt_page = alloc_pages(__GFP_HIGHMEM, LONG_VHPT_BITS - PAGE_SHIFT);
+ if (vhpt_page)
+ vhpt_base[cpu] = (unsigned long) page_address(vhpt_page);
+ else
+ return -EINVAL;
+ printk(KERN_INFO "CPU %d: Long format VHPT initialised at base address:"
+ " 0x%lx\n", cpu, vhpt_base[cpu]);
+#endif
+
Dprintk("Sending wakeup vector %lu to AP 0x%x/0x%x.\n", ap_wakeup_vector, cpu, sapicid);

platform_send_ipi(cpu, ap_wakeup_vector, IA64_IPI_DM_INT, 0);
@@ -404,6 +419,7 @@ do_boot_cpu (int sapicid, int cpu)
printk(KERN_ERR "Processor 0x%x/0x%x is stuck.\n", cpu, sapicid);
ia64_cpu_to_sapicid[cpu] = -1;
cpu_clear(cpu, cpu_online_map); /* was set in smp_callin() */
+ __free_pages(vhpt_page, LONG_VHPT_BITS - PAGE_SHIFT);
return -EINVAL;
}
return 0;
diff -Nurp 2.6.0-test5.v/arch/ia64/mm/init.c 2.6.0-test5.ken/arch/ia64/mm/init.c
--- 2.6.0-test5.v/arch/ia64/mm/init.c Sun Sep 28 16:28:22 2003
+++ 2.6.0-test5.ken/arch/ia64/mm/init.c Sun Sep 28 16:32:25 2003
@@ -344,11 +344,8 @@ ia64_mmu_init (void *my_cpu_data)
if (cpu == 0)
{
/* We allocate all VHPTs here as we may not have enough contiguous memory later */
- /* Also, we cannot use __get_free_pages on the target processor (until after init_cpu) */
- for (i = 0; i < NR_CPUS; i++){
- vhpt_base[i] = (unsigned long)__alloc_bootmem(LONG_VHPT_SIZE, LONG_VHPT_SIZE, __pa(MAX_DMA_ADDRESS));
- printk(KERN_INFO "CPU %d: Long format VHPT initialised at base address: 0x%lx\n", i, vhpt_base[i]);
- }
+ vhpt_base[0] = (unsigned long)__alloc_bootmem(LONG_VHPT_SIZE, LONG_VHPT_SIZE, __pa(MAX_DMA_ADDRESS));
+ printk(KERN_INFO "CPU 0: Long format VHPT initialised at base address: 0x%lx\n", vhpt_base[0]);
}
#endif