2.6.17-rc5 does not build for sparc
Hello,
I tried to build the 2.6.17-rc5 for sparc with SMP enabled. The kernel was not build due to a missing macro. Here is a patch which fixes this (I copied the macro from a sparc64 header).
Best wishes,
Krzysztof
----------------------------------------------------
John Malkovich w filmie KLIMT.
Kontrowersyjny. Dekadencki. Rozpasany. Genialny.
W kinach od 26 maja.
http://klik.wp.pl/?adr=http%3A%2F%2Fadv.reklama.wp.pl%2Fas%2Fklimt.html&sid=771
Only in linux-2.6.17smp/include/asm-sparc: asm-offsets.h
include/asm-sparc/spinlock.h +2 -0
@@ -154,6 +154,8 @@#define __raw_spin_lock_flags (lock, flags) __raw_spin_lock(lock)#define __raw_read_trylock (lock) generic__raw_read_trylock(lock) +#define __raw_write_can_lock (rw) (!(rw)->lock) +#endif /* !(__ASSEMBLY__) */ #endif /* __SPARC_SPINLOCK_H */
Quoted 6 lines · Krzysztof Helt
Hello,
I tried to build the 2.6.17-rc5 for sparc with SMP enabled. The kernel was not build due to a missing macro. Here is a patch which fixes this (I copied the macro from a sparc64 header).
That's not all that is broken. I think I have what could be 4 separate patches for smp here: (combined in the attached patch)
1. add topology_init - fixes a boot time crash
2. setup cpu_possible_map - actually boot the additional cpu's
3. fix smp related section mismatch warnings
4. add the missing *_can_lock macros
If you are running a local framebuffer, you may encounter a problem with vmalloc. Adding "migration_cost=10000" to the kernel command line should cover up the problem.
I haven't had the time to give it a thorough testing and see if it self-recompiles recently, but I was previously able to successfully rebuild the kernel with "make -j6" on a dual SuperSPARC II.
Bob
arch/sparc/kernel/setup.c +33 -1
@@ -31,6 +31,7 @@#include <linux/console.h> #include <linux/spinlock.h> #include <linux/root_dev.h> +#include <linux/cpu.h> #include <asm/system.h> #include <asm/io.h>
@@ -348,6 +349,8 @@ void __init setup_arch(char **cmdline_p) init_mm.context = (unsigned long )NO_CONTEXT ; init_task.thread.kregs = &fake_swapper_regs; +smp_setup_cpu_possible_map (); +paging_init (); }
@@ -389,6 +392,8 @@ console_initcall(set_preferred_console);extern char *sparc_cpu_type;extern char *sparc_fpu_type; +static int ncpus_probed; +static int show_cpuinfo (struct seq_file *m,void *__unused) { seq_printf(m,
@@ -411,7 +416,7 @@ static int show_cpuinfo(struct seq_file romvec->pv_printrev >>16 , romvec->pv_printrev &0xffff , &cputypval, -num_possible_cpus (), + ncpus_probed, num_online_cpus() #ifndef CONFIG_SMP , cpu_data(0).udelay_val/(500000/HZ),
@@ -471,3 +476,30 @@ void sun_do_break(void)int serial_console =-1 ;int stop_a_enabled =1 ; + +static int __init topology_init (void ) +{ +int i, ncpus, err; + +/* Count the number of physically present processors in +* the machine, even on uniprocessor, so that /proc/cpuinfo +* output is consistent with 2.4.x +*/ + ncpus =0 ; +while (!cpu_find_by_instance (ncpus,NULL ,NULL )) + ncpus++; + ncpus_probed = ncpus; + + err =0 ; +for_each_online_cpu (i) { +struct cpu *p =kzalloc (sizeof (*p),GFP_KERNEL ); +if (!p) + err = -ENOMEM ; +else +register_cpu (p, i,NULL ); + } + +return err; +} + +subsys_initcall (topology_init);
arch/sparc/kernel/smp.c +25 -11
@@ -58,7 +58,7 @@ cpumask_t smp_commenced_mask = CPU_MASK_/* Used to make bitops atomic */ unsigned char bitops_spinlock =0 ; -void __init smp_store_cpu_info (int id) +void __cpuinit smp_store_cpu_info (int id) {int cpu_node;
@@ -256,22 +256,18 @@ int setup_profiling_timer(unsigned int mvoid __init smp_prepare_cpus (unsigned int max_cpus) {extern void smp4m_boot_cpus (void ); -int i, cpuid, ncpus, extra; +int i, cpuid, extra;BUG_ON (sparc_cpu_model != sun4m);printk ("Entering SMP Mode...\n" ); - ncpus =1 ; extra =0 ;for (i =0 ; !cpu_find_by_instance (i,NULL , &cpuid); i++) { -if (cpuid == boot_cpu_id) -continue ; -if (cpuid <NR_CPUS && ncpus++ < max_cpus) -cpu_set (cpuid, phys_cpu_present_map); -else +if (cpuid >=NR_CPUS ) extra++; } -if (max_cpus >=NR_CPUS && extra) +/* i = number of cpus */ +if (extra && max_cpus > i - extra)printk ("Warning: NR_CPUS is too low to start all cpus\n" );smp_store_cpu_info (boot_cpu_id);
@@ -279,7 +275,25 @@ void __init smp_prepare_cpus(unsigned insmp4m_boot_cpus (); } -void __devinit smp_prepare_boot_cpu (void ) +/* Set this up early so that things like the scheduler can init +* properly. We use the same cpu mask for both the present and +* possible cpu map. +*/ +void __init smp_setup_cpu_possible_map (void ) +{ +int instance, mid; + + instance =0 ; +while (!cpu_find_by_instance (instance,NULL , &mid)) { +if (mid <NR_CPUS ) { +cpu_set (mid, phys_cpu_present_map); +cpu_set (mid, cpu_present_map); + } + instance++; + } +} + +void __init smp_prepare_boot_cpu (void ) {int cpuid =hard_smp_processor_id ();
@@ -295,7 +309,7 @@ void __devinit smp_prepare_boot_cpu(voidcpu_set (cpuid, phys_cpu_present_map); } -int __devinit __cpu_up (unsigned int cpu) +int __cpuinit __cpu_up (unsigned int cpu) {extern int smp4m_boot_one_cpu (int );int ret;
arch/sparc/kernel/sun4m_smp.c +2 -7
@@ -66,7 +66,7 @@ static inline unsigned long swap(volatilstatic void smp_setup_percpu_timer (void );extern void cpu_probe (void ); -void __init smp4m_callin (void ) +void __cpuinit smp4m_callin (void ) {int cpuid =hard_smp_processor_id ();
@@ -112,13 +112,8 @@ void __init smp4m_callin(void)local_irq_enable ();cpu_set (cpuid, cpu_online_map); -/* last one in gets all the interrupts (for testing) */ -set_irq_udt (boot_cpu_id); } -extern void init_IRQ (void ); -extern void cpu_panic (void ); -/* * Cycle through the processors asking the PROM to start each one. */
@@ -134,7 +129,7 @@ void __init smp4m_boot_cpus(void)local_flush_cache_all (); } -int smp4m_boot_one_cpu (int i) +int __cpuinit smp4m_boot_one_cpu (int i) {extern unsigned long sun4m_cpu_startup;unsigned long *entry = &sun4m_cpu_startup;
include/asm-sparc/smp.h +7 -1
@@ -146,6 +146,8 @@ static inline int hard_smp_processor_id(#define prof_multiplier (__cpu) cpu_data(__cpu).multiplier#define prof_counter (__cpu) cpu_data(__cpu).counter +void smp_setup_cpu_possible_map (void ); +#endif /* !(__ASSEMBLY__) */ /* Sparc specific messages. */
@@ -162,7 +164,11 @@ static inline int hard_smp_processor_id(#define MBOX_IDLECPU2 0xFD#define MBOX_STOPCPU2 0xFE -#endif /* SMP */ +#else /* SMP */ + +#define smp_setup_cpu_possible_map () do { } while (0) + +#endif /* !(SMP) */ #define NO_PROC_ID 0xFF
include/asm-sparc/spinlock.h +2 -0
@@ -149,6 +149,8 @@ static inline int __raw_write_trylock(rareturn (val ==0 ); } +#define __raw_read_can_lock (rw) (!((rw)->lock & 0xff)) +#define __raw_write_can_lock (rw) (!(rw)->lock)#define __raw_write_unlock (rw) do { (rw)->lock = 0; } while(0)#define __raw_spin_lock_flags (lock, flags) __raw_spin_lock(lock)
Quoted 17 lines · Bob Breuer
Quoted 6 lines · Krzysztof Helt
Hello,
I tried to build the 2.6.17-rc5 for sparc with SMP enabled. The kernel was not build due to a missing macro. Here is a patch which fixes this (I copied the macro from a sparc64 header).
That's not all that is broken. I think I have what could be 4 separate patches for smp here: (combined in the attached patch)
1. addtopology_init- fixes a boot time crash
2. setupcpu_possible_map- actually boot the additional cpu's
3. fix smp related section mismatch warnings
4. add the missing*_can_lockmacros
Quoted 7 lines
If you are running a local framebuffer, you may encounter a problem with vmalloc. Adding "migration_cost000" to the kernel command line should cover up the problem.
I haven't had the time to give it a thorough testing and see if it self-recompiles recently, but I was previously able to successfully rebuild the kernel with "make -j6" on a dual SuperSPARC II.
I have tried your patch too and I only can randomly use a SS20 with two
SSI/75 (448 MB). I have tested the last kernel proposed on the debian-sparc mailing list without any trouble but with only one SSII (SMP is broken but I haven't seen any DMA error).
Question : does somebody use a SS20 with four ROSS ? I have seens a
very strange trouble. I have a lot of RT626, SS20 and memory chips. With all configurations I have tested with more than two RT626, Solaris 9 returns "watchdog reset". All motherboards have been tested and work fine. Same observations for RT626 and memory. Thus, I don't know if the trouble I have seen with Linux 2.6 and 4*RT626 come from hardware incompatibility or software mistake. Any idea ? Currently, I retest a SS20 with Solaris 9 and 2*RT626 and I have built without any trouble gcc-4.1.0 and gcc-4.1.1.
Regards,
JKB
Quoted 31 lines · BERTRAND Joël
Quoted 17 lines · Bob Breuer
Quoted 6 lines · Krzysztof Helt
Hello,
I tried to build the 2.6.17-rc5 for sparc with SMP enabled. The kernel was not build due to a missing macro. Here is a patch which fixes this (I copied the macro from a sparc64 header).
That's not all that is broken. I think I have what could be 4 separate patches for smp here: (combined in the attached patch)
1. addtopology_init- fixes a boot time crash
2. setupcpu_possible_map- actually boot the additional cpu's
3. fix smp related section mismatch warnings
4. add the missing*_can_lockmacrosQuoted 7 lines
If you are running a local framebuffer, you may encounter a problem with vmalloc. Adding "migration_cost000" to the kernel command line should cover up the problem.
I haven't had the time to give it a thorough testing and see if it self-recompiles recently, but I was previously able to successfully rebuild the kernel with "make -j6" on a dual SuperSPARC II.
I have tried your patch too and I only can randomly use a SS20 with two
SSI/75 (448 MB). I have tested the last kernel proposed on the debian-sparc mailing list without any trouble but with only one SSII (SMP is broken but I haven't seen any DMA error).
Quoted 9 lines
Question : does somebody use a SS20 with four ROSS ? I have seens a
very strange trouble. I have a lot of RT626, SS20 and memory chips. With all configurations I have tested with more than two RT626, Solaris 9 returns "watchdog reset". All motherboards have been tested and work fine. Same observations for RT626 and memory. Thus, I don't know if the trouble I have seen with Linux 2.6 and 4*RT626 come from hardware incompatibility or software mistake. Any idea ? Currently, I retest a SS20 with Solaris 9 and 2*RT626 and I have built without any trouble gcc-4.1.0 and gcc-4.1.1.
sorry, I had one, quad 150 MHz, but I threw it away in january, 2.2 worked but not 2.4, and sparc32 smp is as far as I understand... well, dead in 2.6....
Signature · 3 lines
Cheers, /ChJ
Dnia 28-05-2006 o godz. 0:43 Bob Breuer napisa³:
Quoted 1 line
That's not all that is broken. I think I have what could be 4
separate
Quoted 7 lines
patches for smp here: (combined in the attached patch)
1. addtopology_init- fixes a boot time crash
2. setupcpu_possible_map- actually boot the additional cpu's
3. fix smp related section mismatch warnings
4. add the missing*_can_lockmacrosIf you are running a local framebuffer, you may encounter a
problem with
Quoted 3 lines
vmalloc. Adding "migration_cost000" to the kernel command line should cover up the problem.
Thank you for the patch. It's a pity you haven't post it earlier as I lost few hours fixing missing topology_init.
Anyway, it is a huge improvement other the current state of official kernel. Is this patch on its way to the kernel?
Quoted 4 lines
I haven't had the time to give it a thorough testing and see if it self-recompiles recently, but I was previously able to successfully rebuild the kernel with "make -j6" on a dual SuperSPARC II.
I was not so lucky. I was able to boot and two cpus were detected
(Supersparc II) but the machine opened PROM console after
mounting tmpfs filesystem (for the /tmp directory). The harddisk filesystems were mounted correctly. I will try to look into this problem.
Krzysztof
David Miller
maintainerFrom: "Krzysztof Helt" <[email protected]>
Date: Sat, 27 May 2006 23:09:17 +0200
Quoted 3 lines
I tried to build the 2.6.17-rc5 for sparc with SMP enabled. The kernel was not build due to a missing macro. Here is a patch which fixes this (I copied the macro from a sparc64 header).
I was going to apply this just to fix the build, but it's not correct.
Because we embed a spinlock in the rwlock_t, we have to spin waiting for the lock bits to be clear before we can trust the sample of the rest of the lock. We used to have to do this when we embedded a spinlock into the atomic_t's on sparc32.
Quoted 7 lines · David Miller
From: "Krzysztof Helt" <[email protected]>
Date: Sat, 27 May 2006 23:09:17 +0200Quoted 3 lines
I tried to build the 2.6.17-rc5 for sparc with SMP enabled. The kernel was not build due to a missing macro. Here is a patch which fixes this (I copied the macro from a sparc64 header).
Quoted 7 lines
I was going to apply this just to fix the build, but it's not correct.
Because we embed a spinlock in the
rwlock_t, we have to spin waiting for the lock bits to be clear before we can trust the sample of the rest of the lock. We used to have to do this when we embedded a spinlock into the atomic_t's on sparc32.
Correct me if I am wrong, but...
From asm-sparc/spinlock.h:
* ------------------------------------ * | 24-bit counter | wlock | raw_rwlock_t * ------------------------------------
* 31 8 7 0
*
* wlock signifies the one writer is in or somebody is updating
* counter. For a writer, if he successfully acquires the wlock,
* but counter is non-zero, he has to release the lock and wait,
* till both counter and wlock are zero.
rw->lock in this case is the full 32-bit raw_rwlock_t, so a value of 0x000000ff is locked by a writer, 0x00000100 would be locked by a reader, and 0x000001ff would be locked by a reader and updating the counter.
For __raw_write_can_lock(), we should be able to return true when the whole 32-bits is zero (i.e. no readers, no counter being updated, and no writers). rw->lock is the whole 32-bits, so a check of !(rw)->lock should be the right thing.
While we are at it, another one we are missing is __raw_read_can_lock(), and I think that a check of !((rw)->lock & 0xff) will work (i.e. no writers and no updating of the counter), or might it be better if the counter was negated and we checked rw->lock <= 0 ?
Bob
David Miller
maintainerFrom: Bob Breuer <[email protected]>
Date: Mon, 05 Jun 2006 23:59:29 -0500
Quoted 3 lines
rw->lockin this case is the full 32-bitraw_rwlock_t, so a value of0x000000ffis locked by a writer,0x00000100would be locked by a reader, and0x000001ffwould be locked by a reader and updating the counter.
For a moment I thought you were right, but the spinlock acts to atomicize the reader counter updates too.
That lock could be set transiently, while decrementing the reader counter down to zero.
So it really does matter, and in fact you have to be even more careful that I originally indicated. In fact I can't even see how you can implement this %100 correctly.
We simply can't tell if the spinlock is held because the writer is trying to get in, or because a reader is holding is just to increment or decrement the counter.
If the reader count is zero, for example, the spinlock could be held by a writer and we don't want to spin waiting for it to clear in that case. If, however, the reader count is zero but the spinlock is held so that a reader can increment the count, we would want to spin waiting for the spinlock to release in that case.
There is a way to fix this. Rewrite the rwlock stuff to use the atomic_t hashed spinlocks to update rwlock_t and just modify it as a 32-bit atomically updatable value just like platforms which have compare-and-swap primitives do.
Then we could implement the "can lock" primitives just like the other platforms do.
Quoted 9 lines · David Miller
From: Bob Breuer <[email protected]>
Date: Mon, 05 Jun 2006 23:59:29 -0500Quoted 3 lines
rw->lockin this case is the full 32-bitraw_rwlock_t, so a value of0x000000ffis locked by a writer,0x00000100would be locked by a reader, and0x000001ffwould be locked by a reader and updating the counter.For a moment I thought you were right, but the spinlock acts to atomicize the reader counter updates too.
Is it ok if the can_lock macros are conservative and maybe return a false failure?
Quoted 6 lines
That lock could be set transiently, while decrementing the reader counter down to zero.
So it really does matter, and in fact you have to be even more careful that I originally indicated. In fact I can't even see how you can implement this %100 correctly.
Even if can_lock() is 100% correct, there is no guarantee that the lock will still be available right after, only a trylock could give that kind of guarantee.
Quoted 3 lines
We simply can't tell if the spinlock is held because the writer is trying to get in, or because a reader is holding is just to increment or decrement the counter.
If we can't tell, then be conservative and return 0.
Quoted 5 lines
If the reader count is zero, for example, the spinlock could be held by a writer and we don't want to spin waiting for it to clear in that case. If, however, the reader count is zero but the spinlock is held so that a reader can increment the count, we would want to spin waiting for the spinlock to release in that case.
The can_lock macros never need to spin.
Ok, how about a truth table to cover all combinations:
reader count | wlock | lock value | write_can_lock | read_can_lock
-------------+-------+------------+----------------+--------------
1) 0 | 0 | 000000 00 | 1 | 1 2) 0 | not 0 | 000000 xx | 0 | 0 3) not 0 | 0 | xxxxxx 00 | 0 | 1 4) not 0 | not 0 | xxxxxx xx | 0 | 0
reader count and wlock are part the _same_ 32-bit value, therefore when we read the value we get a simultaneous snapshot of both and it must be in one of these 4 states.
State 2 is a questionable state and could be caused by either a reader or a writer, therefore neither one can be guaranteed to succeed.
State 4 would be a bigger concern because read_can_lock() could be expected to return true, but then again the caller must be expecting potential failure, or they wouldn't be checking with can_lock.
My two cents to this discussion.
I consider both of these macros (write_can_lock and read_can_lock) brain-damaged as they do not guarantee anything. That's why I haven't copied the read_can_lock macro - it is not used in the sparc kernel and let it be this way.
The write_can_lock is used in one place only - in ptrace.c file when it is used to add a little efficiency into a waiting for two spinlocks to be free. I suppose this call can be removed but I afraid changing it. A whole idea there is simple: obtain one lock, try to obtain another one and if it is not successful use the write_can_lock macro to wait before repeating former steps. I think that without this macro the waiting may become less efficient - more trials of obtaining lock will be made. See the code below:
repeat:
/*
* Nasty, nasty.
*
* We want to hold both the task-lock and the
* tasklist_lock for writing at the same time.
* But that's against the rules (tasklist_lock
* is taken for reading by interrupts on other
* cpu's that may have task_lock).
*/
task_lock(task);
local_irq_disable();
if (!write_trylock(&tasklist_lock)) {
local_irq_enable();
task_unlock(task);
do {
cpu_relax();
} while (!write_can_lock(&tasklist_lock));
goto repeat;
}There is no need for this macro to be 100% accurate. It is enough to be conservative as Bob Breuer suggested (it should not spin waiting either). The other way is to remove the call to write_can_lock from the code above.
I beg you (sparc32 maintainers) to start pushing smp patches (or even parts of them) into the kernel tree. I have another patch which clears sun4m_smp.c a little (replaced loops with for_each_online_cpu, removed one unused global variable) but this will stop Bob Breuer's patch from applying so I wait sitting on it.
I am able to boot a dual SM81 in SS20 with all the smp patches from this list, but the kernel hangs on first module load. It is something I will investigate.
Regards,
Krzysztof
----------------------------------------------------
Nowe serie superksi±¿ek o Czarodziejkach WITCH!
Poznaj ¶wiat bohaterek WITCH!
Will, Irma, Taranee, Cornelia i Hay-Lin zapraszaj± do ksiêgarni.
http://klik.wp.pl/?adr=http%3A%2F%2Fadv.reklama.wp.pl%2Fas%2Fwitch.html&sidx1