On Mon, Jan 28, 2019 at 12:03 PM Linus Torvalds <torva...@linux-foundation.org> wrote: > > That's harder to do for reads - because incoming characters happen in > interrupt context, but shouldn't be all that hard to do for writes.
Side note: the reason I mention this part is that "harder" may not mean "impossible". In particular, I wonder if we could do the tty buffer flipping in the reader context too. Currently, what happens is that when we receive characters, we schedule things for flipping with the workqueues. *BUT* we could also just wake up any pending readers directly, and maybe have the *readers* do the flip if they wake up before the workqueue. And that would allow you to do real-time serial work simply by marking the process *you* care about as RT, and not worry so much about the workqueue threads at all. The workqueue threads would be fallbacks for when there isn't an active reader at all. I dunno. A bit handwavy, I know, but it sounds like if you care about the read latency, that would be a better model entirely (skipping the technically unnecessary kernel workqueue entirely). Linus