* [PATCH] fs/pipe.c: merge if statements with identical conditions
@ 2025-03-07 22:25 Rasmus Villemoes
2025-03-07 22:40 ` Mateusz Guzik
2025-03-07 22:54 ` Oleg Nesterov
0 siblings, 2 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2025-03-07 22:25 UTC (permalink / raw)
To: Linus Torvalds
Cc: David Howells, Oleg Nesterov, Rasmus Villemoes, Jan Kara,
linux-fsdevel, linux-kernel
As 'head' is not updated after head+1 is assigned to pipe->head, the
condition being tested here is exactly the same as in the big if
statement just above. Merge the two bodies.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
fs/pipe.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/fs/pipe.c b/fs/pipe.c
index 097400cce241..27385e3e5417 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -547,10 +547,8 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
if (!iov_iter_count(from))
break;
- }
-
- if (!pipe_full(head, pipe->tail, pipe->max_usage))
continue;
+ }
/* Wait for buffer space to become available. */
if ((filp->f_flags & O_NONBLOCK) ||
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] fs/pipe.c: merge if statements with identical conditions
2025-03-07 22:25 [PATCH] fs/pipe.c: merge if statements with identical conditions Rasmus Villemoes
@ 2025-03-07 22:40 ` Mateusz Guzik
2025-03-07 22:51 ` Rasmus Villemoes
2025-03-07 22:54 ` Oleg Nesterov
1 sibling, 1 reply; 4+ messages in thread
From: Mateusz Guzik @ 2025-03-07 22:40 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Linus Torvalds, David Howells, Oleg Nesterov, Jan Kara,
linux-fsdevel, linux-kernel
On Fri, Mar 07, 2025 at 11:25:00PM +0100, Rasmus Villemoes wrote:
> As 'head' is not updated after head+1 is assigned to pipe->head, the
> condition being tested here is exactly the same as in the big if
> statement just above. Merge the two bodies.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> fs/pipe.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/fs/pipe.c b/fs/pipe.c
> index 097400cce241..27385e3e5417 100644
> --- a/fs/pipe.c
> +++ b/fs/pipe.c
> @@ -547,10 +547,8 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
>
> if (!iov_iter_count(from))
> break;
> - }
> -
> - if (!pipe_full(head, pipe->tail, pipe->max_usage))
> continue;
> + }
>
> /* Wait for buffer space to become available. */
> if ((filp->f_flags & O_NONBLOCK) ||
I already posted this :)
It is hanging out in the vfs trees (and -next), see
https://lore.kernel.org/linux-fsdevel/20250303230409.452687-2-mjguzik@gmail.com/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs/pipe.c: merge if statements with identical conditions
2025-03-07 22:40 ` Mateusz Guzik
@ 2025-03-07 22:51 ` Rasmus Villemoes
0 siblings, 0 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2025-03-07 22:51 UTC (permalink / raw)
To: Mateusz Guzik
Cc: Linus Torvalds, David Howells, Oleg Nesterov, Jan Kara,
linux-fsdevel, linux-kernel
On Fri, Mar 07 2025, Mateusz Guzik <mjguzik@gmail.com> wrote:
> On Fri, Mar 07, 2025 at 11:25:00PM +0100, Rasmus Villemoes wrote:
>> As 'head' is not updated after head+1 is assigned to pipe->head, the
>> condition being tested here is exactly the same as in the big if
>> statement just above. Merge the two bodies.
>>
>> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
>> ---
>> fs/pipe.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/fs/pipe.c b/fs/pipe.c
>> index 097400cce241..27385e3e5417 100644
>> --- a/fs/pipe.c
>> +++ b/fs/pipe.c
>> @@ -547,10 +547,8 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
>>
>> if (!iov_iter_count(from))
>> break;
>> - }
>> -
>> - if (!pipe_full(head, pipe->tail, pipe->max_usage))
>> continue;
>> + }
>>
>> /* Wait for buffer space to become available. */
>> if ((filp->f_flags & O_NONBLOCK) ||
>
> I already posted this :)
>
Ah, never mind then, also for that other patch I just sent. Just
stumbled on those while trying to proof-read the pipe code.
Rasmus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs/pipe.c: merge if statements with identical conditions
2025-03-07 22:25 [PATCH] fs/pipe.c: merge if statements with identical conditions Rasmus Villemoes
2025-03-07 22:40 ` Mateusz Guzik
@ 2025-03-07 22:54 ` Oleg Nesterov
1 sibling, 0 replies; 4+ messages in thread
From: Oleg Nesterov @ 2025-03-07 22:54 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Linus Torvalds, David Howells, Jan Kara, linux-fsdevel,
linux-kernel
On 03/07, Rasmus Villemoes wrote:
>
> As 'head' is not updated after head+1 is assigned to pipe->head, the
> condition being tested here is exactly the same as in the big if
> statement just above. Merge the two bodies.
Yes.
But Mateusz has already sent the same patch, please see
[PATCH 1/3] pipe: drop an always true check in anon_pipe_write()
https://lore.kernel.org/all/20250303230409.452687-2-mjguzik@gmail.com/
Oleg.
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> fs/pipe.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/fs/pipe.c b/fs/pipe.c
> index 097400cce241..27385e3e5417 100644
> --- a/fs/pipe.c
> +++ b/fs/pipe.c
> @@ -547,10 +547,8 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
>
> if (!iov_iter_count(from))
> break;
> - }
> -
> - if (!pipe_full(head, pipe->tail, pipe->max_usage))
> continue;
> + }
>
> /* Wait for buffer space to become available. */
> if ((filp->f_flags & O_NONBLOCK) ||
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-07 22:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-07 22:25 [PATCH] fs/pipe.c: merge if statements with identical conditions Rasmus Villemoes
2025-03-07 22:40 ` Mateusz Guzik
2025-03-07 22:51 ` Rasmus Villemoes
2025-03-07 22:54 ` Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox