mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Martin Wilck <mwilck@suse.com>,
	linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] scsi: Let scsi_execute_cmd() mark args->sshdr as invalid
Date: Thu, 11 May 2023 15:32:33 +0200	[thread overview]
Message-ID: <45d127c4-71e9-2959-b69c-d31c46ec721e@suse.com> (raw)
In-Reply-To: <e7c5f4334ab6ff897547c68ea216fbcba22d4929.camel@suse.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 1030 bytes --]

On 11.05.23 15:23, Martin Wilck wrote:
> On Thu, 2023-05-11 at 15:17 +0200, Juergen Gross wrote:
>>>
>>> We know for certain that sizeof(*sshdr) is 8 bytes, and will most
>>> probably remain so. Thus
>>>
>>>       memset(sshdr, 0, sizeof(*sshdr))
>>>
>>> would result in more efficient code.
>>
>> I fail to see why zeroing a single byte would be less efficient than
>> zeroing
>> a possibly unaligned 8-byte area.
> 
> I don't think it can be unaligned. gcc seems to think the same. It
> compiles the memset(sshdr, ...) in scsi_normalize_sense() into a single
> instruction on x86_64.
> 
> 0xffffffff8177e9d0 <scsi_normalize_sense>:      nopl   0x0(%rax,%rax,1) [FTRACE NOP]
> 0xffffffff8177e9d5 <scsi_normalize_sense+5>:    test   %rdi,%rdi
> 0xffffffff8177e9d8 <scsi_normalize_sense+8>:    movq   $0x0,(%rdx)

A struct with 8 "u8" fields can be unaligned.

x86_64 can do unaligned 8-byte stores.

Other architectures can't (e.g. MIPS). And 32-bit architectures might need
2 stores.


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  reply	other threads:[~2023-05-11 13:34 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11 12:34 Juergen Gross
2023-05-11 12:49 ` Bart Van Assche
2023-05-11 12:54   ` Juergen Gross
2023-05-11 13:10 ` Martin Wilck
2023-05-11 13:17   ` Juergen Gross
2023-05-11 13:23     ` Martin Wilck
2023-05-11 13:32       ` Juergen Gross [this message]
2023-05-11 15:59         ` Martin Wilck
2023-05-11 16:00 ` Martin Wilck
2023-05-17  2:06 ` Martin K. Petersen
2023-05-17  4:54   ` Juergen Gross
2023-05-17 15:05     ` John Garry
2023-05-18  4:53       ` Juergen Gross
2023-05-18 10:57         ` John Garry
2023-05-18 19:54           ` Bart Van Assche
2023-05-19 16:06             ` John Garry
2023-05-19 16:54               ` Bart Van Assche
2023-05-19 17:12                 ` John Garry
2023-05-19 17:39                   ` Bart Van Assche
2023-05-22  9:55                     ` John Garry
2023-05-22 13:31                       ` Bart Van Assche
2023-05-22 15:54                         ` John Garry
2023-05-22 22:48                           ` michael.christie
2023-05-21  1:19           ` Martin K. Petersen
2023-05-21  5:23             ` Juergen Gross
2023-05-22 22:26               ` Martin K. Petersen
2023-05-23 15:04             ` Mike Christie
2023-05-21  0:46     ` Martin K. Petersen

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=45d127c4-71e9-2959-b69c-d31c46ec721e@suse.com \
    --to=jgross@suse.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mwilck@suse.com \
    --cc=stable@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

all inboxes | Powered by JetHome®