[lkml]   [2004]   [Sep]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    SubjectRe: [linux-audio-dev] Re: [announce] [patch] Voluntary Kernel Preemption Patch
    Hi Ingo,

    On Mon, Jul 19, 2004 at 01:59:52PM +0200, Ingo Molnar wrote:
    > yes. Btw., i'm not sure whether you've noticed but last week i've also
    > created a 'clean' variant of the patch. The latest version against -mm
    > is:
    > this one doesnt have any of the debugging/development helpers and
    > switches. I have still made it a .config option. Note how minimal the
    > patch became this way.

    as said in a part of a previous email might_sleep() just like BUG() can
    be defined to noop.

    cond_resched() is the API to use.

    if you're scared that there are too many cond_resched (I'm not scared
    and people should enable them anyways if they make a difference, they
    still should be less than the number of spin_unlocks with preempt
    enabled), then you should add a cond_resched_costly and add a config
    option that turns it off. I think you don't even need to add the config
    option, you can define cond_resched_costly as cond_resched, and to just
    use it to mark the places that might be expensive.

    Then you should change cond_resched to call might_sleep in the else
    branch (as I discussed with Andrew last month).

    this was the core of the patch I was playing with last month which
    should be still valid and it solves the preprocessor issues with
    cond_resched (and I hope the bug was not in the below code ;)

    could you modify your patch accordingly? thanks!

    Index: linux-2.5/include/linux/kernel.h
    RCS file: /home/andrea/crypto/cvs/linux-2.5/include/linux/kernel.h,v
    retrieving revision 1.53
    diff -u -p -r1.53 kernel.h
    --- linux-2.5/include/linux/kernel.h 27 Jun 2004 17:55:19 -0000 1.53
    +++ linux-2.5/include/linux/kernel.h 13 Jul 2004 02:19:43 -0000
    @@ -48,12 +48,23 @@ struct completion;
    void __might_sleep(char *file, int line);
    #define might_sleep() __might_sleep(__FILE__, __LINE__)
    -#define might_sleep_if(cond) do { if (unlikely(cond)) might_sleep(); } while (0)
    #define might_sleep() do {} while(0)
    -#define might_sleep_if(cond) do {} while (0)

    +#define need_resched() unlikely(test_thread_flag(TIF_NEED_RESCHED))
    +extern void __cond_resched(void);
    +#define cond_resched() \
    +do { \
    + if (need_resched()) \
    + __cond_resched(); \
    + else \
    + might_sleep(); \
    +} while (0)
    +#define cond_resched_if(cond) do { if (unlikely(cond)) cond_resched(); } while (0)
    #define abs(x) ({ \
    int __x = (x); \
    (__x < 0) ? -__x : __x; \
    Index: linux-2.5/include/linux/sched.h
    RCS file: /home/andrea/crypto/cvs/linux-2.5/include/linux/sched.h,v
    retrieving revision 1.245
    diff -u -p -r1.245 sched.h
    --- linux-2.5/include/linux/sched.h 2 Jul 2004 17:31:23 -0000 1.245
    +++ linux-2.5/include/linux/sched.h 13 Jul 2004 02:33:12 -0000
    @@ -1012,18 +1013,6 @@ static inline int signal_pending(struct
    return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
    -static inline int need_resched(void)
    - return unlikely(test_thread_flag(TIF_NEED_RESCHED));
    -extern void __cond_resched(void);
    -static inline void cond_resched(void)
    - if (need_resched())
    - __cond_resched();

    * cond_resched_lock() - if a reschedule is pending, drop the given lock,
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at
     \ /
      Last update: 2005-03-22 14:05    [W:0.025 / U:25.780 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site