parisc: Re: Best parisc kernel?
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 parisc: Re: Best parisc kernel?
Quoted 65 lines · Helge Deller
Quoted 57 lines · John David Anglin
Quoted 56 lines · John David Anglin
Quoted 55 lines · John David Anglin
Quoted 44 lines · Helge Deller
Quoted 43 lines · John David Anglin
Quoted 42 lines · John David Anglin
diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md
index f124c301b7a..e8cc81511aa 100644
--- a/gcc/config/pa/pa.md
+++ b/gcc/config/pa/pa.md
@@ -10366,10 +10366,11 @@ add,l %2,%3,%3\;bv,n %%r0(%3)"
{
if (TARGET_SYNC_LIBCALL)
{
- rtx mem = operands[0];
- rtx val = operands[1];
- if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val)) - DONE;
+ rtx libfunc = optab_libfunc (sync_lock_test_and_set_optab, QImode); + emit_library_call (libfunc, LCT_NORMAL, VOIDmode,
+ XEXP (operands[0], 0), Pmode,
+ operands[1], QImode);
+ DONE;
}
FAIL;
})However, doing this causes soft lockups in glibc testsuite:
Message from syslogd@atlas at Nov 25 23:03:01 ...
kernel:watchdog: BUG: soft lockup - CPU#0 stuck for 354s! [ld.so.1:22095]Message from syslogd@atlas at Nov 25 23:03:01 ...
kernel:watchdog: BUG: soft lockup - CPU#1 stuck for 361s! [ld.so.1:22093]Message from syslogd@atlas at Nov 25 23:08:30 ...
kernel:watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [ld.so.1:16025]
Message from syslogd@atlas at Nov 25 23:10:28 ...
kernel:watchdog: BUG: soft lockup - CPU#3 stuck for 23s! [ld.so.1:22086]Message from syslogd@atlas at Nov 25 23:10:30 ...
kernel:watchdog: BUG: soft lockup - CPU#0 stuck for 21s! [ld.so.1:16025]This happens both with and without lws_atomic_xchg. The lockups aren't permanent but they clearly impact performance. Maybe we need to call sched_yield() if we spin too many times? I think scheduling is blocked when we spend too much time on gateway page.
Quoted 6 lines
Quoted 4 lines
The above soft lockups are not caused by the above change to pa.md.
They all occur on gateway page in thread related tests. They are not real lockups but I would guess scheduling is not optimal when we spend a lot of time on gateway page.
Or maybe calling
cond_resched()from inside the kernel (in the locking functions):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2a8bc5316adc998951e8f726c31e231a6021eae2I think the problem is related to COW breaks and the lock hashing which is shared between multiple processes/threads. This can leave ldcw lock in the held state for an extended period. There's probably a hole in the logic preventing processes from being scheduled on gateway page.
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
The problem was probably aggravated by the patch to leave interrupts enabled when we try to take lock.
A COW break can occur on the store instruction in the CAS operation.
I wonder if we should deprecate LWS implementation and use a full syscall? See
sys_atomic_cmpxchg_32()inarch/m68k/kernel/sys_m68k.cfor m68k implementation. I believe arm has one too.interesting.
Quoted 7 lines
Quoted 3 lines
The big concern about the current implementation is whether or not an IRQ or page fault can cause another thread/process to be scheduled in the middle of the critical sequences. So far, I haven't seen this but it would take a lot of testing to be sure.
True.
Quoted 1 line
Can process be killed if it sleeps in a critical region?
Don't know.
The attached patch against v5.14.21 fixes the LWS CAS behavior. COW breaks no longer occur in the critical region. The COW break now occurs on the stbys,e instruction. It magically does a store without writing anything 😁
Don't know if something similar is needed in the futex code.
Now need to extract the new stuff so it applies against mainline. Maybe add a "depi_safe" macro to clean up the code a bit.
With the whole patch v5.14.21 seems good and I haven't seen any random faults in some time. Doing some userspace testing.
Let me know if you have any suggestions.
Dave
Signature · 1 line
John David Anglin [email protected]
arch/parisc/Makefile +1 -1
@@ -83,7 +83,7 @@ endif # Currently we save and restore fpregs on all kernel entry/interruption paths. # If that gets optimized, we might need to disable the use of fpregs in the # kernel. -cflags-y += -mdisable-fpregs +# cflags-y += -mdisable-fpregs # Use long jumps instead of long branches (needed if your linker fails to # link a too big vmlinux executable). Not enabled for building modules.
arch/parisc/boot/compressed/Makefile +2 -1
@@ -18,7 +18,8 @@ KBUILD_CFLAGS := -D__KERNEL__ -O2 -DBOOTLOADER KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING KBUILD_CFLAGS += -fno-strict-aliasing KBUILD_CFLAGS += $(cflags-y) -fno-delete-null-pointer-checks -fno-builtin-printf -KBUILD_CFLAGS += -fno-PIE -mno-space-regs -mdisable-fpregs -Os +# KBUILD_CFLAGS += -fno-PIE -mno-space-regs -mdisable-fpregs -Os +KBUILD_CFLAGS += -fno-PIE -mno-space-regs -Os ifndef CONFIG_64BIT KBUILD_CFLAGS += -mfast-indirect-calls endif
arch/parisc/include/asm/assembly.h +10 -0
@@ -135,6 +135,16 @@ extrd,u \r, 63-(\sa), 64-(\sa), \t .endm + /* The extru instruction leaves the most significant 32 bits of the + * target register in an undefined state on PA 2.0 systems. */ + .macro extru_safe r, p, len, t +#ifdef CONFIG_64BIT + extrd,u \r, 32+(\p), \len, \t +#else + extru \r, \p, \len, \t +#endif + .endm +/* load 32-bit 'value' into 'reg' compensating for the ldil * sign-extension when running in wide mode. * WARNING!! neither 'value' nor 'reg' can be expressions
arch/parisc/include/asm/futex.h +26 -14
@@ -10,23 +10,28 @@#include <asm/errno.h> /* The following has to match the LWS code in syscall.S. We have -sixteen four-word locks. */ +256 four-word locks. We xor three 8-bit hunks of the futex physical +address to create the hash index. */ + +static unsigned long +_futex_hash_index (unsigned long pa) +{ +return ((pa >>6 ) ^ (pa >>14 ) ^ (pa >>22 )) &0x3fc ; +}static inline void -_futex_spin_lock_irqsave (u32 __user *uaddr,unsigned long int *flags) +_futex_spin_lock_irqsave (unsigned long index,unsigned long int *flags) {extern u32 lws_lock_start[]; -long index = ((long )uaddr &0x3f8 ) >>1 ;arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];local_irq_save (*flags);arch_spin_lock (s); }static inline void -_futex_spin_unlock_irqrestore (u32 __user *uaddr,unsigned long int *flags) +_futex_spin_unlock_irqrestore (unsigned long index,unsigned long int *flags) {extern u32 lws_lock_start[]; -long index = ((long )uaddr &0x3f8 ) >>1 ;arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];arch_spin_unlock (s);local_irq_restore (*flags);
@@ -35,11 +40,14 @@ _futex_spin_unlock_irqrestore(u32 __user *uaddr, unsigned long int *flags)static inline int arch_futex_atomic_op_inuser (int op,int oparg,int *oval,u32 __user *uaddr) { +unsigned long ua = (unsigned long )uaddr; +unsigned long index;unsigned long int flags;int oldval, ret;u32 tmp; -_futex_spin_lock_irqsave (uaddr, &flags); + index =_futex_hash_index (ua); +_futex_spin_lock_irqsave (index, &flags); ret = -EFAULT ;if (unlikely (get_user (oldval, uaddr) !=0 ))
@@ -72,7 +80,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) ret = -EFAULT ; out_pagefault_enable: -_futex_spin_unlock_irqrestore (uaddr, &flags); +_futex_spin_unlock_irqrestore (index, &flags);if (!ret) *oval = oldval;
@@ -84,10 +92,12 @@ static inline intfutex_atomic_cmpxchg_inatomic (u32 *uval, u32__user *uaddr, u32 oldval, u32 newval) { +unsigned long ua = (unsigned long )uaddr; +unsigned long index;u32 val;unsigned long flags; -/* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is +/* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is * our gateway page, and causes no end of trouble... */ if (uaccess_kernel () && !uaddr)
@@ -98,23 +108,25 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,/* HPPA has no cmpxchg in hardware and therefore the * best we can do here is use an array of locks. The -* lock selected is based on a hash of the userspace -* address. This should scale to a couple of CPUs. +* lock selected is based on a hash of the virtual +* address of the futex. This should scale to a couple +* of CPUs. */ -_futex_spin_lock_irqsave (uaddr, &flags); + index =_futex_hash_index (ua); +_futex_spin_lock_irqsave (index, &flags);if (unlikely (get_user (val, uaddr) !=0 )) { -_futex_spin_unlock_irqrestore (uaddr, &flags); +_futex_spin_unlock_irqrestore (index, &flags);return -EFAULT ; }if (val == oldval &&unlikely (put_user (newval, uaddr) !=0 )) { -_futex_spin_unlock_irqrestore (uaddr, &flags); +_futex_spin_unlock_irqrestore (index, &flags);return -EFAULT ; } *uval = val; -_futex_spin_unlock_irqrestore (uaddr, &flags); +_futex_spin_unlock_irqrestore (index, &flags);return 0 ; }
arch/parisc/include/asm/pgtable.h +2 -0
@@ -65,6 +65,8 @@ extern int pa_serialize_tlb_flushes;* are slow on SMP machines since the purge must be broadcast to all CPUs. */ +extern void __update_cache (pte_t pte); +static inline void purge_tlb_entries (struct mm_struct *mm,unsigned long addr) {unsigned long flags;
arch/parisc/include/asm/special_insns.h +22 -18
@@ -2,26 +2,30 @@#ifndef __PARISC_SPECIAL_INSNS_H#define __PARISC_SPECIAL_INSNS_H -#define lpa (va) ({ \ - unsigned long pa; \ - __asm__ __volatile__( \ - "copy %%r0,%0\n\t" \ - "lpa %%r0(%1),%0" \ - : "=r" (pa) \ - : "r" (va) \ - : "memory" \ - ); \ - pa; \ +#define lpa (va) ({ \ + unsigned long pa; \ + __asm__ __volatile__( \ + "copy %%r0,%0\n" \ + "9998:\tlpa %%r0(%1),%0\n" \ + "9999:\n" \ + ASM_EXCEPTIONTABLE_ENTRY(9998b, 9999b) \ + : "=&r" (pa) \ + : "r" (va) \ + : "memory" \ + ); \ + pa; \ }) -#define lpa_user (va) ({ \ - unsigned long pa; \ - __asm__ __volatile__( \ - "copy %%r0,%0\n\t" \ - "lpa %%r0(%%sr3,%1),%0" \ - : "=r" (pa) \ - : "r" (va) \ - : "memory" \ +#define lpa_user (va) ({ \ + unsigned long pa; \ + __asm__ __volatile__( \ + "copy %%r0,%0\n" \ + "9998:\tlpa %%r0(%%sr3,%1),%0\n" \ + "9999:\n" \ + ASM_EXCEPTIONTABLE_ENTRY(9998b, 9999b) \ + : "=&r" (pa) \ + : "r" (va) \ + : "memory" \ ); \ pa; \ })
arch/parisc/install.sh +1 -0
@@ -39,6 +39,7 @@ verify "$3" if [ -n "${INSTALLKERNEL}" ]; then if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi + if [ -x /usr/sbin/${INSTALLKERNEL} ]; then exec /usr/sbin/${INSTALLKERNEL} "$@"; fi fi # Default install
arch/parisc/kernel/cache.c +6 -0
@@ -559,6 +559,7 @@ void flush_cache_mm(struct mm_struct *mm)return ; } +preempt_disable ();if (mm->context ==mfsp (3 )) {for (vma = mm->mmap; vma; vma = vma->vm_next) {flush_user_dcache_range_asm (vma->vm_start, vma->vm_end);
@@ -566,8 +567,10 @@ void flush_cache_mm(struct mm_struct *mm)flush_user_icache_range_asm (vma->vm_start, vma->vm_end);flush_tlb_range (vma, vma->vm_start, vma->vm_end); } +preempt_enable ();return ; } +preempt_enable (); pgd = mm->pgd;for (vma = mm->mmap; vma; vma = vma->vm_next) {
@@ -606,13 +609,16 @@ void flush_cache_range(struct vm_area_struct *vma,return ; } +preempt_disable ();if (vma->vm_mm->context ==mfsp (3 )) {flush_user_dcache_range_asm (start, end);if (vma->vm_flags &VM_EXEC )flush_user_icache_range_asm (start, end);flush_tlb_range (vma, start, end); +preempt_enable ();return ; } +preempt_enable (); pgd = vma->vm_mm->pgd;for (addr = vma->vm_start; addr < vma->vm_end; addr +=PAGE_SIZE ) {
arch/parisc/kernel/entry.S +5 -13
@@ -393,17 +393,9 @@ */ .macro L2_ptep pmd,pte,index,va,fault #if CONFIG_PGTABLE_LEVELS == 3 - extru \va,31-ASM_PMD_SHIFT,ASM_BITS_PER_PMD,\index + extru_safe \va,31-ASM_PMD_SHIFT,ASM_BITS_PER_PMD,\index #else -# if defined(CONFIG_64BIT) - extrd,u \va,63-ASM_PGDIR_SHIFT,ASM_BITS_PER_PGD,\index - #else - # if PAGE_SIZE > 4096 - extru \va,31-ASM_PGDIR_SHIFT,32-ASM_PGDIR_SHIFT,\index - # else - extru \va,31-ASM_PGDIR_SHIFT,ASM_BITS_PER_PGD,\index - # endif -# endif + extru_safe \va,31-ASM_PGDIR_SHIFT,ASM_BITS_PER_PGD,\index #endif dep %r0,31,PAGE_SHIFT,\pmd /* clear offset */ #if CONFIG_PGTABLE_LEVELS < 3
@@ -413,7 +405,7 @@ bb,>=,n \pmd,_PxD_PRESENT_BIT,\fault dep %r0,31,PxD_FLAG_SHIFT,\pmd /* clear flags */ SHLREG \pmd,PxD_VALUE_SHIFT,\pmd - extru \va,31-PAGE_SHIFT,ASM_BITS_PER_PTE,\index + extru_safe \va,31-PAGE_SHIFT,ASM_BITS_PER_PTE,\index dep %r0,31,PAGE_SHIFT,\pmd /* clear offset */ shladd \index,BITS_PER_PTE_ENTRY,\pmd,\pmd /* pmd is now pte */ .endm
@@ -974,8 +966,8 @@ intr_do_preempt: /* current_thread_info()->preempt_count */ mfctl %cr30, %r1 - LDREG TI_PRE_COUNT(%r1), %r19 - cmpib,COND(<>) 0, %r19, intr_restore /* if preempt_count > 0 */ + ldw TI_PRE_COUNT(%r1), %r19 + cmpib,<> 0, %r19, intr_restore /* if preempt_count > 0 */ nop /* prev insn branched backwards */ /* check if we interrupted a critical path */
arch/parisc/kernel/patch.c +1 -2
@@ -67,8 +67,8 @@ void __kprobes __patch_text_multiple(void *addr, u32 *insn, unsigned int len)int mapped;/* Make sure we don't have any aliases in cache */ -flush_kernel_vmap_range (addr, len);flush_icache_range (start, end); +flush_tlb_kernel_range (start, end); p = fixmap =patch_map (addr,FIX_TEXT_POKE0 , &flags, &mapped);
@@ -93,7 +93,6 @@ void __kprobes __patch_text_multiple(void *addr, u32 *insn, unsigned int len)flush_kernel_vmap_range ((void *)fixmap, (p-fixmap) *sizeof (*p));if (mapped)patch_unmap (FIX_TEXT_POKE0 , &flags); -flush_icache_range (start, end); }void __kprobes __patch_text (void *addr,u32 insn)
arch/parisc/kernel/smp.c +3 -1
@@ -228,11 +228,13 @@ static inline void send_IPI_allbutself(enum ipi_message_type op) {int i; - + +preempt_disable ();for_each_online_cpu (i) {if (i !=smp_processor_id ())send_IPI_single (i, op); } +preempt_enable (); }#ifdef CONFIG_KGDB
arch/parisc/kernel/syscall.S +412 -21
511 lines not on this page · raw message
arch/parisc/kernel/time.c +8 -19
@@ -249,27 +249,16 @@ void __init time_init(void)static int __init init_cr16_clocksource (void ) {/* -* The cr16 interval timers are not syncronized across CPUs on -* different sockets, so mark them unstable and lower rating on -* multi-socket SMP systems. +* The cr16 interval timers are not syncronized across CPUs, even if +* they share the same socket. */ if (num_online_cpus () >1 && !running_on_qemu) { -int cpu; -unsigned long cpu0_loc; - cpu0_loc =per_cpu (cpu_data,0 ).cpu_loc; - -for_each_online_cpu (cpu) { -if (cpu ==0 ) -continue ; -if ((cpu0_loc !=0 ) && - (cpu0_loc ==per_cpu (cpu_data, cpu).cpu_loc)) -continue ; - - clocksource_cr16.name ="cr16_unstable" ; - clocksource_cr16.flags =CLOCK_SOURCE_UNSTABLE ; - clocksource_cr16.rating =0 ; -break ; - } +/* mark sched_clock unstable */ +clear_sched_clock_stable (); + + clocksource_cr16.name ="cr16_unstable" ; + clocksource_cr16.flags =CLOCK_SOURCE_UNSTABLE ; + clocksource_cr16.rating =0 ; }/* XXX: We may want to mark sched_clock stable here if cr16 clocks are
arch/parisc/kernel/traps.c +7 -5
@@ -479,9 +479,9 @@ void notrace handle_interruption(int code, struct pt_regs *regs)int si_code;if (code ==1 ) -pdc_console_restart ();/* switch back to pdc if HPMC */ -else -local_irq_enable (); +pdc_console_restart ();/* switch back to pdc if HPMC */ +else if (!irqs_disabled_flags (regs->gr[0 ])) +local_irq_enable ();/* Security check: * If the priority level is still user, and the
@@ -729,6 +729,8 @@ void notrace handle_interruption(int code, struct pt_regs *regs) }mmap_read_unlock (current->mm); } +/* CPU could not fetch instruction, so clear IIR stale value. */ + regs->iir =0xbaadf00d ; fallthrough;case 27 :/* Data memory protection ID trap */
@@ -782,13 +784,13 @@ void notrace handle_interruption(int code, struct pt_regs *regs)* unless pagefault_disable() was called before. */ -if (fault_space ==0 && !faulthandler_disabled ()) +if (faulthandler_disabled () || fault_space ==0 ) {/* Clean up and return if in exception table. */ if (fixup_exception (regs))return ;pdc_chassis_send_status (PDC_CHASSIS_DIRECT_PANIC ); -parisc_terminate ("Kernel Fault" , regs, code, fault_address); +parisc_terminate ("Kernel Fault" , regs, code,0 ); } }
arch/parisc/kernel/unwind.c +2 -1
@@ -309,7 +309,8 @@ static void unwind_frame_regs(struct unwind_frame_info *info)break ; } -if (get_user (tmp, (unsigned long *)(info->prev_sp -RP_OFFSET ))) +if (copy_from_kernel_nofault (&tmp, + (void *)info->prev_sp -RP_OFFSET ,sizeof (tmp)))break ; info->prev_ip = tmp; sp = info->prev_sp;
arch/parisc/kernel/vmlinux.lds.S +1 -2
@@ -57,8 +57,6 @@ SECTIONS { . = KERNEL_BINARY_TEXT_START; - _stext = .; /* start of kernel text, includes init code & data */ - __init_begin = .; HEAD_TEXT_SECTION MLONGCALL_DISCARD(INIT_TEXT_SECTION(8))
@@ -82,6 +80,7 @@ SECTIONS /* freed after init ends here */ _text = .; /* Text and read-only data */ + _stext = .; MLONGCALL_KEEP(INIT_TEXT_SECTION(8)) .text ALIGN(PAGE_SIZE) : { TEXT_TEXT
arch/parisc/mm/init.c +1 -1
@@ -341,7 +341,7 @@ static void __init setup_bootmem(void)static bool kernel_set_to_readonly; -static void __init map_pages (unsigned long start_vaddr, +static void map_pages (unsigned long start_vaddr,unsigned long start_paddr,unsigned long size,pgprot_t pgprot,int force) {
drivers/char/agp/parisc-agp.c +3 -3
@@ -281,7 +281,7 @@ agp_ioc_init(void __iomem *ioc_regs)return 0 ; } -static int +static int __init lba_find_capability (int cap) {struct _parisc_agp_info *info = &parisc_agp_info;
@@ -366,7 +366,7 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)return error; } -static int +static int __init find_quicksilver (struct device *dev,void *data) {struct parisc_device **lba = data;
@@ -378,7 +378,7 @@ find_quicksilver(struct device *dev, void *data)return 0 ; } -static int +static int __init parisc_agp_init (void ) {extern struct sba_device *sba_list;