Skip to content
Snippets Groups Projects
Select Git revision
  • 9f5d1c336a10c0d24e83e40b4c1b9539f7dba627
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

futex.c

Blame
    • Mike Galbraith's avatar
      9f5d1c33
      futex: Handle transient "ownerless" rtmutex state correctly · 9f5d1c33
      Mike Galbraith authored
      
      Gratian managed to trigger the BUG_ON(!newowner) in fixup_pi_state_owner().
      This is one possible chain of events leading to this:
      
      Task Prio       Operation
      T1   120	lock(F)
      T2   120	lock(F)   -> blocks (top waiter)
      T3   50 (RT)	lock(F)   -> boosts T1 and blocks (new top waiter)
      XX   		timeout/  -> wakes T2
      		signal
      T1   50		unlock(F) -> wakes T3 (rtmutex->owner == NULL, waiter bit is set)
      T2   120	cleanup   -> try_to_take_mutex() fails because T3 is the top waiter
           			     and the lower priority T2 cannot steal the lock.
           			  -> fixup_pi_state_owner() sees newowner == NULL -> BUG_ON()
      
      The comment states that this is invalid and rt_mutex_real_owner() must
      return a non NULL owner when the trylock failed, but in case of a queued
      and woken up waiter rt_mutex_real_owner() == NULL is a valid transient
      state. The higher priority waiter has simply not yet managed to take over
      the rtmutex.
      
      The BUG_ON() is therefore wrong and this is just another retry condition in
      fixup_pi_state_owner().
      
      Drop the locks, so that T3 can make progress, and then try the fixup again.
      
      Gratian provided a great analysis, traces and a reproducer. The analysis is
      to the point, but it confused the hell out of that tglx dude who had to
      page in all the futex horrors again. Condensed version is above.
      
      [ tglx: Wrote comment and changelog ]
      
      Fixes: c1e2f0ea ("futex: Avoid violating the 10th rule of futex")
      Reported-by: default avatarGratian Crisan <gratian.crisan@ni.com>
      Signed-off-by: default avatarMike Galbraith <efault@gmx.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/87a6w6x7bb.fsf@ni.com
      Link: https://lore.kernel.org/r/87sg9pkvf7.fsf@nanos.tec.linutronix.de
      9f5d1c33
      History
      futex: Handle transient "ownerless" rtmutex state correctly
      Mike Galbraith authored
      
      Gratian managed to trigger the BUG_ON(!newowner) in fixup_pi_state_owner().
      This is one possible chain of events leading to this:
      
      Task Prio       Operation
      T1   120	lock(F)
      T2   120	lock(F)   -> blocks (top waiter)
      T3   50 (RT)	lock(F)   -> boosts T1 and blocks (new top waiter)
      XX   		timeout/  -> wakes T2
      		signal
      T1   50		unlock(F) -> wakes T3 (rtmutex->owner == NULL, waiter bit is set)
      T2   120	cleanup   -> try_to_take_mutex() fails because T3 is the top waiter
           			     and the lower priority T2 cannot steal the lock.
           			  -> fixup_pi_state_owner() sees newowner == NULL -> BUG_ON()
      
      The comment states that this is invalid and rt_mutex_real_owner() must
      return a non NULL owner when the trylock failed, but in case of a queued
      and woken up waiter rt_mutex_real_owner() == NULL is a valid transient
      state. The higher priority waiter has simply not yet managed to take over
      the rtmutex.
      
      The BUG_ON() is therefore wrong and this is just another retry condition in
      fixup_pi_state_owner().
      
      Drop the locks, so that T3 can make progress, and then try the fixup again.
      
      Gratian provided a great analysis, traces and a reproducer. The analysis is
      to the point, but it confused the hell out of that tglx dude who had to
      page in all the futex horrors again. Condensed version is above.
      
      [ tglx: Wrote comment and changelog ]
      
      Fixes: c1e2f0ea ("futex: Avoid violating the 10th rule of futex")
      Reported-by: default avatarGratian Crisan <gratian.crisan@ni.com>
      Signed-off-by: default avatarMike Galbraith <efault@gmx.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/87a6w6x7bb.fsf@ni.com
      Link: https://lore.kernel.org/r/87sg9pkvf7.fsf@nanos.tec.linutronix.de
    cache.h 1.08 KiB
    #ifndef _ASM_POWERPC_CACHE_H
    #define _ASM_POWERPC_CACHE_H
    
    #ifdef __KERNEL__
    
    
    /* bytes per L1 cache line */
    #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
    #define L1_CACHE_SHIFT		4
    #define MAX_COPY_PREFETCH	1
    #elif defined(CONFIG_PPC_E500MC)
    #define L1_CACHE_SHIFT		6
    #define MAX_COPY_PREFETCH	4
    #elif defined(CONFIG_PPC32)
    #define L1_CACHE_SHIFT		5
    #define MAX_COPY_PREFETCH	4
    #else /* CONFIG_PPC64 */
    #define L1_CACHE_SHIFT		7
    #endif
    
    #define	L1_CACHE_BYTES		(1 << L1_CACHE_SHIFT)
    
    #define	SMP_CACHE_BYTES		L1_CACHE_BYTES
    
    #if defined(__powerpc64__) && !defined(__ASSEMBLY__)
    struct ppc64_caches {
    	u32	dsize;			/* L1 d-cache size */
    	u32	dline_size;		/* L1 d-cache line size	*/
    	u32	log_dline_size;
    	u32	dlines_per_page;
    	u32	isize;			/* L1 i-cache size */
    	u32	iline_size;		/* L1 i-cache line size	*/
    	u32	log_iline_size;
    	u32	ilines_per_page;
    };
    
    extern struct ppc64_caches ppc64_caches;
    #endif /* __powerpc64__ && ! __ASSEMBLY__ */
    
    #if !defined(__ASSEMBLY__)
    #define __read_mostly __attribute__((__section__(".data.read_mostly")))
    #endif
    
    #endif /* __KERNEL__ */
    #endif /* _ASM_POWERPC_CACHE_H */