DM-Devel Archive mirror
 help / color / mirror / Atom feed
From: Matthew Sakai <msakai@redhat.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: dm-devel@lists.linux.dev, Ken Raeburn <raeburn@redhat.com>
Subject: Re: [PATCH] dm vdo: use kernel byteswapping routines instead of GCC ones
Date: Thu, 21 Mar 2024 10:25:42 -0400	[thread overview]
Message-ID: <7f0a1378-18ae-5f3e-0e2d-2c371e4dc7b5@redhat.com> (raw)
In-Reply-To: <20240321035203.GA2387@sol.localdomain>

On 3/20/24 23:52, Eric Biggers wrote:
> On Wed, Mar 20, 2024 at 05:44:05PM -0400, Matthew Sakai wrote:
>>   static __always_inline u64 getblock64(const u64 *p, int i)
>>   {
>> -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
>> -	return p[i];
>> -#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
>> -	return __builtin_bswap64(p[i]);
>> -#else
>> -#error "can't figure out byte order"
>> -#endif
>> +	return le64_to_cpup(&p[i]);
>>   }
>>   
>>   static __always_inline void putblock64(u64 *p, int i, u64 value)
>>   {
>> -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
>> -	p[i] = value;
>> -#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
>> -	p[i] = __builtin_bswap64(value);
>> -#else
>> -#error "can't figure out byte order"
>> -#endif
>> +	p[i] = cpu_to_le64(value);
>>   }
> 
> This is very broken.  What you're actually looking for is get_unaligned_le64()
> and put_unaligned_le64().  And they should be folded directly into the caller.
> 
> - Eric
> 

Thanks for the suggestion. We'll work on a v2 to include this.

Matt


      reply	other threads:[~2024-03-21 14:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 21:44 [PATCH] dm vdo: use kernel byteswapping routines instead of GCC ones Matthew Sakai
2024-03-21  2:41 ` Guenter Roeck
2024-03-21  3:52 ` Eric Biggers
2024-03-21 14:25   ` Matthew Sakai [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=7f0a1378-18ae-5f3e-0e2d-2c371e4dc7b5@redhat.com \
    --to=msakai@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=ebiggers@kernel.org \
    --cc=raeburn@redhat.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).