[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Y9L+O4V5uJIWFnmI@ZenIV>
Date: Thu, 26 Jan 2023 22:27:07 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: David Howells <dhowells@...hat.com>
Cc: David Hildenbrand <david@...hat.com>,
Christoph Hellwig <hch@...radead.org>,
Matthew Wilcox <willy@...radead.org>,
Jens Axboe <axboe@...nel.dk>, Jan Kara <jack@...e.cz>,
Jeff Layton <jlayton@...nel.org>,
Jason Gunthorpe <jgg@...dia.com>,
Logan Gunthorpe <logang@...tatee.com>,
linux-fsdevel@...r.kernel.org, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Christoph Hellwig <hch@....de>,
John Hubbard <jhubbard@...dia.com>
Subject: Re: [PATCH] iov_iter: Use __bitwise with the extraction_flags
On Thu, Jan 26, 2023 at 10:33:50AM +0000, David Howells wrote:
> X-Mailer: MH-E 8.6+git; nmh 1.7.1; GNU Emacs 28.2
> --------
> David Hildenbrand <david@...hat.com> wrote:
>
> > >> Just a note that the usage of new __bitwise types instead of "unsigned" is
> > >> encouraged for flags.
>
> Something like the attached?
>
> > $ git grep "typedef int" | grep __bitwise | wc -l
> > 27
> > $ git grep "typedef unsigned" | grep __bitwise | wc -l
> > 23
>
> git grep __bitwise | grep typedef | grep __u | wc -l
> 62
>
> *shrug*
>
> Interestingly, things like __be32 are __bitwise. I wonder if that actually
> makes sense or if it was just convenient so stop people doing arithmetic on
> them. I guess doing AND/OR/XOR on them isn't a problem provided both
> arguments are appropriately byte-swapped.
Forget the words "byte-swapped". There are several data types.
With different memory representations. Bitwise operations are
valid between the values of the same type and yield the result
of that same type.
The fact that mapping between those representations happens to
be an involution is an accident; keeping track of the number of
times you've done a byteswap to the value currently in this
variable is asking for trouble. It's really easy to fuck up.
"Am I trying to store the value of type X in variable of type Y
(presumably having forgotten that I need to use X_to_Y(...)
to convert)" is much easier to keep track of.
Powered by blists - more mailing lists