Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288763
b: refs/heads/master
c: 3ccf3e8
h: refs/heads/master
i:
  288761: 74391b8
  288759: 96e0235
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Mar 12, 2012
1 parent cde8656 commit 569c3f9
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 6 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: 554cecaf733623b327eef9652b65965eb1081b81
refs/heads/master: 3ccf3e8306156a28213adc720aba807e9a901ad5
10 changes: 10 additions & 0 deletions trunk/include/linux/printk.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ int vprintk(const char *fmt, va_list args);
asmlinkage __printf(1, 2) __cold
int printk(const char *fmt, ...);

/*
* Special printk facility for scheduler use only, _DO_NOT_USE_ !
*/
__printf(1, 2) __cold int printk_sched(const char *fmt, ...);

/*
* Please don't use printk_ratelimit(), because it shares ratelimiting state
* with all other unrelated printk_ratelimit() callsites. Instead use
Expand Down Expand Up @@ -127,6 +132,11 @@ int printk(const char *s, ...)
{
return 0;
}
static inline __printf(1, 2) __cold
int printk_sched(const char *s, ...)
{
return 0;
}
static inline int printk_ratelimit(void)
{
return 0;
Expand Down
40 changes: 37 additions & 3 deletions trunk/kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,13 +1208,47 @@ int is_console_locked(void)
return console_locked;
}

/*
* Delayed printk facility, for scheduler-internal messages:
*/
#define PRINTK_BUF_SIZE 512

#define PRINTK_PENDING_WAKEUP 0x01
#define PRINTK_PENDING_SCHED 0x02

static DEFINE_PER_CPU(int, printk_pending);
static DEFINE_PER_CPU(char [PRINTK_BUF_SIZE], printk_sched_buf);

int printk_sched(const char *fmt, ...)
{
unsigned long flags;
va_list args;
char *buf;
int r;

local_irq_save(flags);
buf = __get_cpu_var(printk_sched_buf);

va_start(args, fmt);
r = vsnprintf(buf, PRINTK_BUF_SIZE, fmt, args);
va_end(args);

__this_cpu_or(printk_pending, PRINTK_PENDING_SCHED);
local_irq_restore(flags);

return r;
}

void printk_tick(void)
{
if (__this_cpu_read(printk_pending)) {
__this_cpu_write(printk_pending, 0);
wake_up_interruptible(&log_wait);
int pending = __this_cpu_xchg(printk_pending, 0);
if (pending & PRINTK_PENDING_SCHED) {
char *buf = __get_cpu_var(printk_sched_buf);
printk(KERN_WARNING "[sched_delayed] %s", buf);
}
if (pending & PRINTK_PENDING_WAKEUP)
wake_up_interruptible(&log_wait);
}
}

Expand All @@ -1228,7 +1262,7 @@ int printk_needs_cpu(int cpu)
void wake_up_klogd(void)
{
if (waitqueue_active(&log_wait))
this_cpu_write(printk_pending, 1);
this_cpu_or(printk_pending, PRINTK_PENDING_WAKEUP);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ static int select_fallback_rq(int cpu, struct task_struct *p)
* leave kernel.
*/
if (p->mm && printk_ratelimit()) {
printk(KERN_INFO "process %d (%s) no longer affine to cpu%d\n",
printk_sched("process %d (%s) no longer affine to cpu%d\n",
task_pid_nr(p), p->comm, cpu);
}

Expand Down
8 changes: 7 additions & 1 deletion trunk/kernel/sched/rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,14 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
* but accrue some time due to boosting.
*/
if (likely(rt_b->rt_runtime)) {
static bool once = false;

rt_rq->rt_throttled = 1;
printk_once(KERN_WARNING "sched: RT throttling activated\n");

if (!once) {
once = true;
printk_sched("sched: RT throttling activated\n");
}
} else {
/*
* In case we did anyway, make it go away,
Expand Down

0 comments on commit 569c3f9

Please sign in to comment.