Re: [PATCH v5 1/2] printk: Add console owner and waiter logic to load balance console writes

From: Byungchul Park
Date: Wed Jan 17 2018 - 20:57:23 EST


On 1/18/2018 10:53 AM, Byungchul Park wrote:
Hello,

This is a thing simulating a wait for an event e.g.
wait_for_completion() doing spinning instead of sleep, rather
than a spinlock. I mean:

ÂÂ This context
ÂÂ ------------
ÂÂ while (READ_ONCE(console_waiter)) /* Wait for the event */
ÂÂÂÂÂ cpu_relax();

ÂÂ Another context
ÂÂ ---------------
ÂÂ WRITE_ONCE(console_waiter, false); /* Event */

That's why I said this's the exact case of cross-release. Anyway
without cross-release, we usually use typical acquire/release
pairs to cover a wait for an event in the following way:

ÂÂ A context
ÂÂ ---------
ÂÂ lock_map_acquire(wait); /* Or lock_map_acquire_read(wait) */
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ /* Read one is better though..ÂÂÂ */

ÂÂ /* A section, we suspect, a wait for an event might happen. */
ÂÂ ...
ÂÂ lock_map_release(wait);


ÂÂ The place actually doing the wait
ÂÂ ---------------------------------
ÂÂ lock_map_acquire(wait);
ÂÂ lock_map_acquire(wait);
^
lock_map_release(wait);

--
Thanks,
Byungchul