[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250304125416.GA26141@redhat.com>
Date: Tue, 4 Mar 2025 13:54:17 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Mateusz Guzik <mjguzik@...il.com>,
K Prateek Nayak <kprateek.nayak@....com>,
"Sapkal, Swapnil" <swapnil.sapkal@....com>,
Manfred Spraul <manfred@...orfullife.com>,
Christian Brauner <brauner@...nel.org>,
David Howells <dhowells@...hat.com>,
WangYuli <wangyuli@...ontech.com>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
"Shenoy, Gautham Ranjal" <gautham.shenoy@....com>,
Neeraj.Upadhyay@....com, Ananth.narayan@....com
Subject: Re: [PATCH] pipe_read: don't wake up the writer if the pipe is still
full
On 03/03, Linus Torvalds wrote:
>
> ENTIRELY UNTESTED, but it seems to generate ok code. It might even
> generate better code than what we have now.
Reviewed-by: Oleg Nesterov <oleg@...hat.com>
but I have another question...
> static inline bool pipe_readable(const struct pipe_inode_info *pipe)
> {
> - unsigned int head = READ_ONCE(pipe->head);
> - unsigned int tail = READ_ONCE(pipe->tail);
> + union pipe_index idx = { READ_ONCE(pipe->head_tail) };
I thought this is wrong, but then I noticed that in your version
->head_tail is the 1st member in this union.
Still perhaps
union pipe_index idx = { .head_tail = READ_ONCE(pipe->head_tail) };
will look more clear?
> +/*
> + * Really only alpha needs 32-bit fields, but
> + * might as well do it for 64-bit architectures
> + * since that's what we've historically done,
> + * and it makes 'head_tail' always be a simple
> + * 'unsigned long'.
> + */
> +#ifdef CONFIG_64BIT
> + typedef unsigned int pipe_index_t;
> +#else
> + typedef unsigned short pipe_index_t;
> +#endif
I am just curious, why we can't use "unsigned short" unconditionally
and avoid #ifdef ?
Is "unsigned int" more efficient on 64-bit?
Oleg.
Powered by blists - more mailing lists