All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'michael@michaelkloos.com'" <michael@michaelkloos.com>,
	"paul.walmsley@sifive.com" <paul.walmsley@sifive.com>,
	"palmer@dabbelt.com" <palmer@dabbelt.com>,
	"aou@eecs.berkeley.edu" <aou@eecs.berkeley.edu>
Cc: "linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2] Fixed: Misaligned memory access. Fixed pointer comparison.
Date: Mon, 24 Jan 2022 22:28:23 +0000	[thread overview]
Message-ID: <394ff54c0b574484a4656e52c3c7e244@AcuMS.aculab.com> (raw)
In-Reply-To: <fdbf6e1c-6ed1-bb82-1a56-f7188de7f83f@michaelkloos.com>

From: michael@michaelkloos.com
> Sent: 24 January 2022 19:19

Re-instating the bit I commented on ..
> > ... Additionally, hardware support may not exist and would likely
> > still run slower than aligned accesses even if it did.
> 
> > That may not be true.
> > On x86 the cost of misaligned accesses only just measurable.
> > It isn't even one clock per cache line for reads (eg ipcsum).

> I know that the Intel manuals still recommend alignment on x86.  I
> haven't tried to measure performance differences yet.

IIRC they recommend aligned writes in particular.
(And don't do misaligned locked accesses that cross page boundaries.)

I've done some measurements for reads and the cost really was minimal.
You'd need to be doing a high proportion of multi-kb misaligned transfers
to cover the cost of any conditional test on aligned tranfsers.

> I think the issue here is that RISC-V is designed as a modular
> architecture.  Unlike x86, we don't know that misaligned accesses
> will or will not be supported.  I will grant you that if they are
> supported by hardware, it will probably be faster to let the hardware
> natively take care of it.  However, if the hardware doesn't support
> it, the kernel won't be compatible with that hardware.

Indeed you really don't want to be fixing up alignment faults - ever.
I've no idea why that ever became acceptable.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: David Laight <David.Laight@ACULAB.COM>
To: "'michael@michaelkloos.com'" <michael@michaelkloos.com>,
	"paul.walmsley@sifive.com" <paul.walmsley@sifive.com>,
	"palmer@dabbelt.com" <palmer@dabbelt.com>,
	"aou@eecs.berkeley.edu" <aou@eecs.berkeley.edu>
Cc: "linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2] Fixed: Misaligned memory access. Fixed pointer comparison.
Date: Mon, 24 Jan 2022 22:28:23 +0000	[thread overview]
Message-ID: <394ff54c0b574484a4656e52c3c7e244@AcuMS.aculab.com> (raw)
In-Reply-To: <fdbf6e1c-6ed1-bb82-1a56-f7188de7f83f@michaelkloos.com>

From: michael@michaelkloos.com
> Sent: 24 January 2022 19:19

Re-instating the bit I commented on ..
> > ... Additionally, hardware support may not exist and would likely
> > still run slower than aligned accesses even if it did.
> 
> > That may not be true.
> > On x86 the cost of misaligned accesses only just measurable.
> > It isn't even one clock per cache line for reads (eg ipcsum).

> I know that the Intel manuals still recommend alignment on x86.  I
> haven't tried to measure performance differences yet.

IIRC they recommend aligned writes in particular.
(And don't do misaligned locked accesses that cross page boundaries.)

I've done some measurements for reads and the cost really was minimal.
You'd need to be doing a high proportion of multi-kb misaligned transfers
to cover the cost of any conditional test on aligned tranfsers.

> I think the issue here is that RISC-V is designed as a modular
> architecture.  Unlike x86, we don't know that misaligned accesses
> will or will not be supported.  I will grant you that if they are
> supported by hardware, it will probably be faster to let the hardware
> natively take care of it.  However, if the hardware doesn't support
> it, the kernel won't be compatible with that hardware.

Indeed you really don't want to be fixing up alignment faults - ever.
I've no idea why that ever became acceptable.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2022-01-24 22:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-23  3:45 [PATCH v2] Fixed: Misaligned memory access. Fixed pointer comparison Michael T. Kloos
2022-01-23  3:45 ` Michael T. Kloos
2022-01-23 13:31 ` David Laight
2022-01-23 13:31   ` David Laight
2022-01-23 16:53   ` Michael T. Kloos
2022-01-23 16:53     ` Michael T. Kloos
2022-01-23 22:35     ` David Laight
2022-01-23 22:35       ` David Laight
2022-01-23 23:03       ` Michael T. Kloos
2022-01-23 23:03         ` Michael T. Kloos
2022-01-23 15:44 ` Jessica Clarke
2022-01-23 15:44   ` Jessica Clarke
2022-01-23 17:15   ` Michael T. Kloos
2022-01-23 17:15     ` Michael T. Kloos
2022-01-24  9:21 ` David Laight
2022-01-24  9:21   ` David Laight
2022-01-24 19:19   ` Michael T. Kloos
2022-01-24 19:19     ` Michael T. Kloos
2022-01-24 22:28     ` David Laight [this message]
2022-01-24 22:28       ` David Laight
2022-01-24 13:38 ` kernel test robot

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=394ff54c0b574484a4656e52c3c7e244@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=michael@michaelkloos.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.