lkml.org 
[lkml]   [2019]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] pipe: wakeup writer only if pipe buffer is at least half empty
From
Date
On 27/10/2019 19.12, Linus Torvalds wrote:
> On Sun, Oct 27, 2019 at 11:46 AM Konstantin Khlebnikov
> <khlebnikov@yandex-team.ru> wrote:
>>
>> There is no reason to wakeup writer if pipe has only one empty page.
>> This means reader consumes data slower then writer produces it.
>>
>> This patch waits until buffer is at least half empty before waking writer.
>
> This is a bit dangerous, at least with David's other changes.
>
> In particular, there's now a "max_usage" in his series means that the
> writer might be blocked even if there's lots of free slots, because
> the writer is only allowed to use part of those slots.
>
> So I'd rather not see this logic particularly now that David is
> working on modifying the overall pipe logic.
>
> I do agree with the overall idea, but I'm not entirely happy about the
> "half full" logic, because it gets subtle with David's changes.
>
> Also, I'm a bit worried about cases where the readers and writers
> block on each other, and depend on "there's enough space in the pipe
> that we won't deadlock". Maybe the writer is blocked (because it
> filled the pipe), the reader reads just part of the pipe, and then the
> reader blocks on the writer doing something else, knowing that it just
> free'd up resources for the writer. But the writer is still blocked,
> and not woken up, because the pipe is still more than half full. See
> what I'm saying?
>
> I'm not sure anything like that exists, but it's an example of a "hmm"
> condition.
>

Ok. This breakage scenario is doubtful but such weird software really might exist.

What about making this thing tunable via fcntl like size of pipe buffer?

fcntl(fd, F_SETPIPE_WRITE_SZ, size)

\
 
 \ /
  Last update: 2019-10-28 10:09    [W:0.105 / U:0.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site