Re: [PATCH] pipe_read: don't wake up the writer if the pipe is still full
From: Oleg Nesterov
Date: Mon Mar 03 2025 - 15:29:38 EST
On 03/03, Linus Torvalds wrote:
>
> There's currently a fair number of open-coded assignments:
>
> git grep -E 'pipe->((tail)|(head)).*=' fs/
>
> and some of those are under specific locking rules together with other
> updates (ie the watch-queue 'note_loss' thing.
Stupid question... but do we really need to change the code which update
tail/head if we pack them into a single word?
I mean,
- unsigned int head;
- unsigned int tail;
+ union {
+ struct {
+ u16 head, tail;
+ }
+
+ __u32 head_tail;
+ }
Now pipe_writebale() can read do READ_ONCE(pipe->head_tail) "atomically"
without preemption and this is all we need, no?
Yes, pipe_writable() should take endianess into account, but this is
simple...
Oleg