• P
    relay: Use irq_work instead of plain timer for deferred wakeup · 26b5679e
    Peter Zijlstra 提交于
    Relay avoids calling wake_up_interruptible() for doing the wakeup of
    readers/consumers, waiting for the generation of new data, from the
    context of a process which produced the data.  This is apparently done to
    prevent the possibility of a deadlock in case Scheduler itself is is
    generating data for the relay, after acquiring rq->lock.
    
    The following patch used a timer (to be scheduled at next jiffy), for
    delegating the wakeup to another context.
    	commit 7c9cb383
    	Author: Tom Zanussi <zanussi@comcast.net>
    	Date:   Wed May 9 02:34:01 2007 -0700
    
    	relay: use plain timer instead of delayed work
    
    	relay doesn't need to use schedule_delayed_work() for waking readers
    	when a simple timer will do.
    
    Scheduling a plain timer, at next jiffies boundary, to do the wakeup
    causes a significant wakeup latency for the Userspace client, which makes
    relay less suitable for the high-frequency low-payload use cases where the
    data gets generated at a very high rate, like multiple sub buffers getting
    filled within a milli second.  Moreover the timer is re-scheduled on every
    newly produced sub buffer so the timer keeps getting pushed out if sub
    buffers are filled in a very quick succession (less than a jiffy gap
    between filling of 2 sub buffers).  As a result relay runs out of sub
    buffers to store the new data.
    
    By using irq_work it is ensured that wakeup of userspace client, blocked
    in the poll call, is done at earliest (through self IPI or next timer
    tick) enabling it to always consume the data in time.  Also this makes
    relay consistent with printk & ring buffers (trace), as they too use
    irq_work for deferred wake up of readers.
    
    [arnd@arndb.de: select CONFIG_IRQ_WORK]
     Link: http://lkml.kernel.org/r/20160912154035.3222156-1-arnd@arndb.de
    [akpm@linux-foundation.org: coding-style fixes]
    Link: http://lkml.kernel.org/r/1472906487-1559-1-git-send-email-akash.goel@intel.comSigned-off-by: NPeter Zijlstra <peterz@infradead.org>
    Signed-off-by: NAkash Goel <akash.goel@intel.com>
    Cc: Tom Zanussi <tzanussi@gmail.com>
    Cc: Chris Wilson <chris@chris-wilson.co.uk>
    Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Signed-off-by: NArnd Bergmann <arnd@arndb.de>
    Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    26b5679e
relay.c 32.1 KB