Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158325
b: refs/heads/master
c: e4aafea
h: refs/heads/master
i:
  158323: 7fd1349
v: v3
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Jul 18, 2009
1 parent 7417304 commit 58a1d81
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e09758fae8ccde97e026c704319eaa18d488dc86
refs/heads/master: e4aafea2d4bde8b44d6500c4ee7195bbfc51269e
6 changes: 3 additions & 3 deletions trunk/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ extern int _cond_resched(void);
#endif

#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
void __might_sleep(char *file, int line);
void __might_sleep(char *file, int line, int preempt_offset);
/**
* might_sleep - annotation for functions that can sleep
*
Expand All @@ -137,9 +137,9 @@ extern int _cond_resched(void);
* supposed to.
*/
# define might_sleep() \
do { __might_sleep(__FILE__, __LINE__); might_resched(); } while (0)
do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
#else
static inline void __might_sleep(char *file, int line) { }
static inline void __might_sleep(char *file, int line, int preempt_offset) { }
# define might_sleep() do { might_resched(); } while (0)
#endif

Expand Down
15 changes: 11 additions & 4 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -6610,7 +6610,7 @@ static inline int should_resched(void)

static void __cond_resched(void)
{
__might_sleep(__FILE__, __LINE__);
__might_sleep(__FILE__, __LINE__, 0);

add_preempt_count(PREEMPT_ACTIVE);
schedule();
Expand Down Expand Up @@ -9429,13 +9429,20 @@ void __init sched_init(void)
}

#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
void __might_sleep(char *file, int line)
static inline int preempt_count_equals(int preempt_offset)
{
int nested = preempt_count() & ~PREEMPT_ACTIVE;

return (nested == PREEMPT_INATOMIC_BASE + preempt_offset);
}

void __might_sleep(char *file, int line, int preempt_offset)
{
#ifdef in_atomic
static unsigned long prev_jiffy; /* ratelimiting */

if ((!in_atomic() && !irqs_disabled()) ||
system_state != SYSTEM_RUNNING || oops_in_progress)
if ((preempt_count_equals(preempt_offset) && !irqs_disabled()) ||
system_state != SYSTEM_RUNNING || oops_in_progress)
return;
if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
return;
Expand Down

0 comments on commit 58a1d81

Please sign in to comment.