@@ -310,16 +310,13 @@ static struct rchan_callbacks default_channel_callbacks = {
310
310
311
311
/**
312
312
* wakeup_readers - wake up readers waiting on a channel
313
- * @work: work struct that contains the the channel buffer
313
+ * @data: contains the the channel buffer
314
314
*
315
- * This is the work function used to defer reader waking. The
316
- * reason waking is deferred is that calling directly from write
317
- * causes problems if you're writing from say the scheduler.
315
+ * This is the timer function used to defer reader waking.
318
316
*/
319
- static void wakeup_readers (struct work_struct * work )
317
+ static void wakeup_readers (unsigned long data )
320
318
{
321
- struct rchan_buf * buf =
322
- container_of (work , struct rchan_buf , wake_readers .work );
319
+ struct rchan_buf * buf = (struct rchan_buf * )data ;
323
320
wake_up_interruptible (& buf -> read_wait );
324
321
}
325
322
@@ -337,11 +334,9 @@ static void __relay_reset(struct rchan_buf *buf, unsigned int init)
337
334
if (init ) {
338
335
init_waitqueue_head (& buf -> read_wait );
339
336
kref_init (& buf -> kref );
340
- INIT_DELAYED_WORK (& buf -> wake_readers , NULL );
341
- } else {
342
- cancel_delayed_work (& buf -> wake_readers );
343
- flush_scheduled_work ();
344
- }
337
+ setup_timer (& buf -> timer , wakeup_readers , (unsigned long )buf );
338
+ } else
339
+ del_timer_sync (& buf -> timer );
345
340
346
341
buf -> subbufs_produced = 0 ;
347
342
buf -> subbufs_consumed = 0 ;
@@ -447,8 +442,7 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)
447
442
static void relay_close_buf (struct rchan_buf * buf )
448
443
{
449
444
buf -> finalized = 1 ;
450
- cancel_delayed_work (& buf -> wake_readers );
451
- flush_scheduled_work ();
445
+ del_timer_sync (& buf -> timer );
452
446
kref_put (& buf -> kref , relay_remove_buf );
453
447
}
454
448
@@ -608,11 +602,14 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
608
602
buf -> dentry -> d_inode -> i_size += buf -> chan -> subbuf_size -
609
603
buf -> padding [old_subbuf ];
610
604
smp_mb ();
611
- if (waitqueue_active (& buf -> read_wait )) {
612
- PREPARE_DELAYED_WORK (& buf -> wake_readers ,
613
- wakeup_readers );
614
- schedule_delayed_work (& buf -> wake_readers , 1 );
615
- }
605
+ if (waitqueue_active (& buf -> read_wait ))
606
+ /*
607
+ * Calling wake_up_interruptible() from here
608
+ * will deadlock if we happen to be logging
609
+ * from the scheduler (trying to re-grab
610
+ * rq->lock), so defer it.
611
+ */
612
+ __mod_timer (& buf -> timer , jiffies + 1 );
616
613
}
617
614
618
615
old = buf -> data ;
0 commit comments