Re: 2.6.0-test7-mm1

From: Anton Blanchard (anton_at_samba.org)
Date: 10/16/03

  • Next message: iain d broadfoot: "pcmcia working again in -test7!"
    Date:	Fri, 17 Oct 2003 00:04:00 +1000
    To: Ben Collins <bcollins@debian.org>
    
    

    > > Anton had a ppc64 patch which implemented the preempt_count beancounting
    > > without actually implementing premption. So might_sleep() does the right
    > > thing.
    >
    > I might have to dig that out and try to make use of it. Thanks for the
    > pointer.

    Here is the patch with the ppc64 bits in it. (I already have
    might_sleep() littered in asm-ppc64/semaphore.h and asm-ppc64/uaccess.h)

    Its a bit old but it seems to dump valid warnings.

    Anton

    Sleep with spinlock debugging.

     foo-anton/arch/ppc64/Kconfig | 7 +++++++
     foo-anton/include/asm-ppc64/hardirq.h | 2 +-
     foo-anton/include/linux/preempt.h | 17 +++++++++++------
     foo-anton/kernel/fork.c | 2 +-
     foo-anton/kernel/sched.c | 2 +-
     5 files changed, 21 insertions(+), 9 deletions(-)

    diff -puN arch/ppc64/Kconfig~spinlock_sleep arch/ppc64/Kconfig
    --- foo/arch/ppc64/Kconfig~spinlock_sleep 2003-10-10 00:23:32.000000000 -0500
    +++ foo-anton/arch/ppc64/Kconfig 2003-10-10 00:23:32.000000000 -0500
    @@ -385,6 +385,13 @@ config DEBUG_PAGEALLOC
               This results in a large slowdown, but helps to find certain types
               of memory corruptions.
     
    +config DEBUG_SPINLOCK_SLEEP
    + bool "Sleep-inside-spinlock checking"
    + depends on DEBUG_KERNEL
    + help
    + If you say Y here, various routines which may sleep will become very
    + noisy if they are called with a spinlock held.
    +
     endmenu
     
     source "security/Kconfig"
    diff -puN include/asm-ppc64/hardirq.h~spinlock_sleep include/asm-ppc64/hardirq.h
    --- foo/include/asm-ppc64/hardirq.h~spinlock_sleep 2003-10-10 00:23:32.000000000 -0500
    +++ foo-anton/include/asm-ppc64/hardirq.h 2003-10-10 00:23:32.000000000 -0500
    @@ -82,7 +82,7 @@ typedef struct {
     
     #define irq_enter() (preempt_count() += HARDIRQ_OFFSET)
     
    -#ifdef CONFIG_PREEMPT
    +#if defined(CONFIG_PREEMPT) || defined(CONFIG_DEBUG_SPINLOCK_SLEEP)
     # define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
     # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
     #else
    diff -puN include/linux/preempt.h~spinlock_sleep include/linux/preempt.h
    --- foo/include/linux/preempt.h~spinlock_sleep 2003-10-10 00:23:32.000000000 -0500
    +++ foo-anton/include/linux/preempt.h 2003-10-10 00:23:32.000000000 -0500
    @@ -24,6 +24,17 @@ do { \
     
     extern void preempt_schedule(void);
     
    +#define preempt_check_resched() \
    +do { \
    + if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \
    + preempt_schedule(); \
    +} while (0)
    +#else
    +#define preempt_check_resched() do { } while (0)
    +#endif
    +
    +#if defined(CONFIG_PREEMPT) || defined(CONFIG_DEBUG_SPINLOCK_SLEEP)
    +
     #define preempt_disable() \
     do { \
             inc_preempt_count(); \
    @@ -36,12 +47,6 @@ do { \
             barrier(); \
     } while (0)
     
    -#define preempt_check_resched() \
    -do { \
    - if (unlikely(test_thread_flag(TIF_NEED_RESCHED))) \
    - preempt_schedule(); \
    -} while (0)
    -
     #define preempt_enable() \
     do { \
             preempt_enable_no_resched(); \
    diff -puN kernel/fork.c~spinlock_sleep kernel/fork.c
    --- foo/kernel/fork.c~spinlock_sleep 2003-10-10 00:23:32.000000000 -0500
    +++ foo-anton/kernel/fork.c 2003-10-10 00:23:32.000000000 -0500
    @@ -850,7 +850,7 @@ struct task_struct *copy_process(unsigne
             if (p->binfmt && !try_module_get(p->binfmt->module))
                     goto bad_fork_cleanup_put_domain;
     
    -#ifdef CONFIG_PREEMPT
    +#if defined(CONFIG_PREEMPT) || defined(CONFIG_DEBUG_SPINLOCK_SLEEP)
             /*
              * schedule_tail drops this_rq()->lock so we compensate with a count
              * of 1. Also, we want to start with kernel preemption disabled.
    diff -puN kernel/sched.c~spinlock_sleep kernel/sched.c
    --- foo/kernel/sched.c~spinlock_sleep 2003-10-10 00:23:32.000000000 -0500
    +++ foo-anton/kernel/sched.c 2003-10-10 00:23:32.000000000 -0500
    @@ -2533,7 +2533,7 @@ void __init init_idle(task_t *idle, int
             local_irq_restore(flags);
     
             /* Set the preempt count _outside_ the spinlocks! */
    -#ifdef CONFIG_PREEMPT
    +#if defined(CONFIG_PREEMPT) || defined(CONFIG_DEBUG_SPINLOCK_SLEEP)
             idle->thread_info->preempt_count = (idle->lock_depth >= 0);
     #else
             idle->thread_info->preempt_count = 0;

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


  • Next message: iain d broadfoot: "pcmcia working again in -test7!"

    Relevant Pages

    • Re: XFS: inode with st_mode == 0
      ... with current oss.sgi.com CVS (or the patch below). ... retrieving revision 1.175 ... diff -u -p -r1.175 xfs_ialloc.c ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [ACPI] Call for help: list of machines with working S3
      ... but a diff of what? ... BlueZ patch -mh4 ... this laptop works very well! ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH 2.6] Altix updates
      ... bogus, please decide whether you want to pass a pointer to the pcibr_soft ... Also while the pic.h changes look okay they will conflict with a patch ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: diff command line?
      ... >> What are the options normally used to generate a diff for public ... >so the resulting patch can be applied with patch -p1. ... Copyright 2005 by Maurice Eugene Heskett, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [PATCH] 1-Wire Dallas in bigendian machines
      ... provided patch. ... (inline at the end of the message). ... diff -urP linux-2.6.10/drivers/w1/w1.c ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)