[patch] alpha updates 2.3.30pre3+alpha-1

Andrea Arcangeli (andrea@suse.de)
Thu, 2 Dec 1999 00:23:59 +0100 (CET)


These are my latest alpha updates. They should go fine on the top of your
current tree.

o fixed mm activation on ev4 cpus (fixed by from Thorsten Kranzkowski)

o removed variable udelay while waiting irqs to complete and removed
a noop mb (the udelay could be removed completly for stability,
but I am not 100% sure that the CPU has the time to deliver the
irq in the middle of the __cli(); __sti();) So for now a udelay(1)
is still there.

o more detailed memory report at boot (like in i386).

o fixed the SMP idle task creation to avoid rescheduling the
child.

o some minor cleanup in the smp boot, btw now I free the unused idle
task if the CPU fails to boot (could be done on i386 too I think).

o removed initialize_secondary.

diff -urN alpha-linus/arch/alpha/kernel/irq.c 2.3.30pre3-alpha/arch/alpha/kernel/irq.c
--- alpha-linus/arch/alpha/kernel/irq.c Sun Nov 28 01:53:25 1999
+++ 2.3.30pre3-alpha/arch/alpha/kernel/irq.c Thu Dec 2 00:11:53 1999
@@ -392,8 +392,6 @@

static void show(char * str, void *where);

-#define SYNC_OTHER_CPUS(x) udelay((x)+1);
-
static inline void
wait_on_irq(int cpu, void *where)
{
@@ -414,7 +412,6 @@

/* Duh, we have to loop. Release the lock to avoid deadlocks */
spin_unlock(&global_irq_lock);
- mb();

for (;;) {
if (!--count) {
@@ -422,7 +419,7 @@
count = MAXCOUNT;
}
__sti();
- SYNC_OTHER_CPUS(cpu);
+ udelay(1); /* make sure to run pending irqs */
__cli();

if (atomic_read(&global_irq_count))
diff -urN alpha-linus/arch/alpha/kernel/setup.c 2.3.30pre3-alpha/arch/alpha/kernel/setup.c
--- alpha-linus/arch/alpha/kernel/setup.c Sun Nov 28 01:53:25 1999
+++ 2.3.30pre3-alpha/arch/alpha/kernel/setup.c Mon Nov 29 01:52:56 1999
@@ -327,6 +327,28 @@
}
#endif /* CONFIG_BLK_DEV_INITRD */
}
+
+int __init page_is_ram(unsigned long pfn)
+{
+ struct memclust_struct * cluster;
+ struct memdesc_struct * memdesc;
+ int i;
+
+ memdesc = (struct memdesc_struct *) (hwrpb->mddt_offset + (unsigned long) hwrpb);
+ for_each_mem_cluster(memdesc, cluster, i)
+ {
+ if (pfn >= cluster->start_pfn &&
+ pfn < cluster->start_pfn + cluster->numpages)
+ {
+ if (cluster->usage & 3)
+ return 0;
+ else
+ return 1;
+ }
+ }
+
+ return 0;
+}
#undef PFN_UP
#undef PFN_DOWN
#undef PFN_PHYS
diff -urN alpha-linus/arch/alpha/kernel/smp.c 2.3.30pre3-alpha/arch/alpha/kernel/smp.c
--- alpha-linus/arch/alpha/kernel/smp.c Wed Nov 24 18:22:03 1999
+++ 2.3.30pre3-alpha/arch/alpha/kernel/smp.c Mon Nov 29 20:48:13 1999
@@ -396,6 +396,16 @@
return 0;
}

+static int __init fork_by_hand(void)
+{
+ struct pt_regs regs;
+ /*
+ * don't care about the regs settings since
+ * we'll never reschedule the forked task.
+ */
+ return do_fork(CLONE_VM|CLONE_PID, 0, &regs);
+}
+
/*
* Bring one cpu online.
*/
@@ -409,18 +419,25 @@
to kernel_thread is irrelevant -- it's going to start where
HWRPB.CPU_restart says to start. But this gets all the other
task-y sort of data structures set up like we wish. */
- kernel_thread((void *)__smp_callin, NULL, CLONE_PID|CLONE_VM);
+ /*
+ * We can't use kernel_thread since we must avoid to
+ * reschedule the child.
+ */
+ if (fork_by_hand() < 0)
+ panic("failed fork for CPU %d", cpuid);

idle = init_task.prev_task;
if (!idle)
- panic("No idle process for CPU %d", cpunum);
- del_from_runqueue(idle);
- init_tasks[cpunum] = idle;
- idle->processor = cpuid;
-
- /* Schedule the first task manually. */
- /* ??? Ingo, what is this? */
- idle->has_cpu = 1;
+ panic("No idle process for CPU %d", cpuid);
+
+ idle->processor = cpuid;
+ __cpu_logical_map[cpunum] = cpuid;
+ cpu_number_map[cpuid] = cpunum;
+ idle->has_cpu = 1; /* we schedule the first task manually */
+
+ del_from_runqueue(idle);
+ unhash_process(idle);
+ init_tasks[cpunum] = idle;

DBGS(("smp_boot_one_cpu: CPU %d state 0x%lx flags 0x%lx\n",
cpuid, idle->state, idle->flags));
@@ -442,13 +459,18 @@
barrier();
}

+ /* we must invalidate our stuff as we failed to boot the CPU */
+ __cpu_logical_map[cpunum] = -1;
+ cpu_number_map[cpuid] = -1;
+
+ /* the idle task is local to us so free it as we don't use it */
+ free_task_struct(idle);
+
printk(KERN_ERR "SMP: Processor %d is stuck.\n", cpuid);
return -1;

alive:
/* Another "Red Snapper". */
- cpu_number_map[cpuid] = cpunum;
- __cpu_logical_map[cpunum] = cpuid;
return 0;
}

@@ -579,16 +601,6 @@
{
/* smp_init sets smp_threads_ready -- that's enough. */
mb();
-}
-
-/*
- * Only broken Intel needs this, thus it should not even be
- * referenced globally.
- */
-
-void __init
-initialize_secondary(void)
-{
}


diff -urN alpha-linus/arch/alpha/mm/init.c 2.3.30pre3-alpha/arch/alpha/mm/init.c
--- alpha-linus/arch/alpha/mm/init.c Sun Nov 28 01:53:25 1999
+++ 2.3.30pre3-alpha/arch/alpha/mm/init.c Mon Nov 29 02:15:25 1999
@@ -273,12 +273,42 @@
}
#endif

+static void printk_memory_info(void)
+{
+ unsigned long codesize, reservedpages, datasize, initsize, tmp;
+ extern int page_is_ram(unsigned long) __init;
+ extern char _text, _etext, _data, _edata;
+ extern char __init_begin, __init_end;
+
+ /* printk all informations */
+ reservedpages = 0;
+ for (tmp = 0; tmp < max_low_pfn; tmp++)
+ /*
+ * Only count reserved RAM pages
+ */
+ if (page_is_ram(tmp) && PageReserved(mem_map+tmp))
+ reservedpages++;
+
+ codesize = (unsigned long) &_etext - (unsigned long) &_text;
+ datasize = (unsigned long) &_edata - (unsigned long) &_data;
+ initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
+
+ printk("Memory: %luk/%luk available (%luk kernel code, %luk reserved, %luk data, %luk init)\n",
+ (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
+ max_mapnr << (PAGE_SHIFT-10),
+ codesize >> 10,
+ reservedpages << (PAGE_SHIFT-10),
+ datasize >> 10,
+ initsize >> 10);
+}
+
void
mem_init(void)
{
max_mapnr = num_physpages = max_low_pfn;
totalram_pages += free_all_bootmem();
- printk("Memory: %luk available\n", totalram_pages << (PAGE_SHIFT-10));
+
+ printk_memory_info();
}

void
diff -urN alpha-linus/include/asm-alpha/mmu_context.h 2.3.30pre3-alpha/include/asm-alpha/mmu_context.h
--- alpha-linus/include/asm-alpha/mmu_context.h Wed Dec 1 03:35:41 1999
+++ 2.3.30pre3-alpha/include/asm-alpha/mmu_context.h Wed Dec 1 23:55:22 1999
@@ -160,6 +160,8 @@

current->thread.ptbr
= ((unsigned long) next_mm->pgd - IDENT_ADDR) >> PAGE_SHIFT;
+
+ __reload_thread(&current->thread);
}

__EXTERN_INLINE void

Andrea

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