linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, axboe@kernel.dk, kvalo@codeaurora.org,
	john.johansen@canonical.com, linux-arch@vger.kernel.org
Subject: Re: [PATCH] unaligned: delete 1-byte accessors
Date: Mon, 22 Jul 2019 15:20:43 +0900	[thread overview]
Message-ID: <1563776443.3223.8.camel@HansenPartnership.com> (raw)
In-Reply-To: <20190722060744.GA24253@avx2>

On Mon, 2019-07-22 at 09:07 +0300, Alexey Dobriyan wrote:
> On Mon, Jul 22, 2019 at 02:48:46PM +0900, James Bottomley wrote:
> > On Mon, 2019-07-22 at 08:22 +0300, Alexey Dobriyan wrote:
> > > On Mon, Jul 22, 2019 at 08:08:33AM +0900, James Bottomley wrote:
> > > > On Mon, 2019-07-22 at 00:52 +0300, Alexey Dobriyan wrote:
> > > > > Each and every 1-byte access is aligned!
> > > > 
> > > > The design idea of this is for parsing descriptors.  We simply
> > > > chunk up the describing structure using get_unaligned for
> > > > everything.  The reason is because a lot of these structures
> > > > come
> > > > with reserved areas which we may make use of later.  If we're
> > > > using
> > > > get_unaligned for everything we can simply change a u8 to a u16
> > > > in
> > > > the structure absorbing the reserved padding.  With your change
> > > > now
> > > > I'd have to chase down every byte access and replace it with
> > > > get_unaligned instead of simply changing the structure.
> > > > 
> > > > What's the significant advantage of this change that
> > > > compensates
> > > > for the problems the above causes?
> > > 
> > > HW descriptors have fixed endianness, you're supposed to use
> > > get_unaligned_be32() and friends.
> > 
> > Not if this is an internal descriptor format, which is what this is
> > mostly used for.
> 
> Maybe, but developer is supposed to look at all struct member usages
> while changing types, right?
> 
> > > For that matter, drivers/scsi/ has exactly 2 get_unaligned()
> > > calls
> > > one of which can be changed to get_unaligned_be32().
> > 
> > You haven't answered the "what is the benefit of this change"
> > question.
> >  I mean sure we can do it, but it won't make anything more
> > efficient
> > and it does help with the descriptor format to treat every
> > structure
> > field the same.
> 
> The benefit is less code, come on.
> 
> Another benefit is that typoing
> 
> 	get_unaligned((u16*)p)
> 
> for
> 	get_unaligned((u8*)p)
> 
> will get detected.

Well, that's not the way it's supposed to be used.  It's supposed to be
used as

struct desc {
u8 something;
u8 pad 1;
u16 another;
} __packed;

something = get_unaligned[_le/be](&struct.something);

So that the sizes are encoded in the descriptor structure.  If you
think it's badly documented, then please update that, I just don't see
a benefit to a coding change that removes the u8 version of this
because it makes our descriptor structure handling inconsistent.

Even if we allow people are hard coding the typedef, then making u8 not
work just looks inconsistent ... you could easily have typoed u32 for
u16 in the example above and there would be no detection.

James


      reply	other threads:[~2019-07-22  6:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-21 21:52 [PATCH] unaligned: delete 1-byte accessors Alexey Dobriyan
2019-07-21 23:08 ` James Bottomley
2019-07-22  5:22   ` Alexey Dobriyan
2019-07-22  5:48     ` James Bottomley
2019-07-22  6:07       ` Alexey Dobriyan
2019-07-22  6:20         ` James Bottomley [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1563776443.3223.8.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=john.johansen@canonical.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).