All of lore.kernel.org
 help / color / mirror / Atom feed
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: mm: define NET_IP_ALIGN to 0
Date: Thu, 8 Nov 2018 11:34:45 +0100	[thread overview]
Message-ID: <CAKv+Gu-rKC8mUrjLLooVSxcc6zncG5_Hpubx+3+xqwFqkske3A@mail.gmail.com> (raw)
In-Reply-To: <20181108100614.2otaqmz3hoe7wsax@salmiak>

On 8 November 2018 at 11:06, Mark Rutland <mark.rutland@arm.com> wrote:
> On Thu, Nov 08, 2018 at 12:18:33AM +0100, Ard Biesheuvel wrote:
>> (+ Arnd)
>>
>> On 7 November 2018 at 19:10, Mark Rutland <mark.rutland@arm.com> wrote:
>> > On Wed, Nov 07, 2018 at 06:10:38PM +0100, Ard Biesheuvel wrote:
>> >> On arm64, there is no need to add 2 bytes of padding to the start of
>> >> each network buffer just to make the IP header appear 32-bit aligned.
>> >>
>> >> Since this might actually adversely affect DMA performance some
>> >> platforms, let's override NET_IP_ALIGN to 0 to get rid of this
>> >> padding.
>> >>
>> >> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> >> ---
>> >>  arch/arm64/include/asm/processor.h | 8 ++++++++
>> >>  1 file changed, 8 insertions(+)
>> >>
>> >> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
>> >> index 3e2091708b8e..6b0d4dff5012 100644
>> >> --- a/arch/arm64/include/asm/processor.h
>> >> +++ b/arch/arm64/include/asm/processor.h
>> >> @@ -24,6 +24,14 @@
>> >>  #define KERNEL_DS    UL(-1)
>> >>  #define USER_DS              (TASK_SIZE_64 - 1)
>> >>
>> >> +/*
>> >> + * On arm64 systems, unaligned accesses by the CPU are cheap, and so there is
>> >> + * no point in shifting all network buffers by 2 bytes just to make some IP
>> >> + * header fields appear aligned in memory, potentially sacrificing some DMA
>> >> + * performance on some platforms.
>> >> + */
>> >> +#define NET_IP_ALIGN 0
>> >
>> > Might it be better for core code to do this based on
>> > CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS?
>>
>> In general, yes. But that will cause performance issues on ARMv6+,
>> since we will end up using ldrd instructions that require alignment
>> fixups.
>
> Ok.
>
>> In my opinion, CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS should signify
>> that unaligned accessors are cheap, not that they are not required at
>> all.
>
> I'm not sure I follow the distinction you're trying to make.
>

What would be better IMHO is if CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
means that you don't have to go out of your way (e.g., by shifting all
ethernet packets by 2 bytes) to avoid having to call get_unaligned_xxx

get_unaligned_xx() is essentially already a noop on most archs that
define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, and so there is no
overhead in using it in that case. On ARM, however, it makes all the
difference, since ldr+ldr tolerates any alignment while ldrd goes
through the alignment fixup handler.


> I do see that *certain* unaligned accesses may be cheap while others are not,
> so maybe that's worth addressing (e.g. HAVE_EFFICIENT_UNALIGNED_32BIT_ACCESS),
> but that is a more general thing.
>
> FWIW, for this as-is:
>
> Acked-by: Mark Rutland <mark.rutland@arm.com>
>
> Thanks,
> Mark.

  reply	other threads:[~2018-11-08 10:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-07 17:10 [PATCH] arm64: mm: define NET_IP_ALIGN to 0 Ard Biesheuvel
2018-11-07 18:10 ` Mark Rutland
2018-11-07 23:18   ` Ard Biesheuvel
2018-11-08 10:06     ` Mark Rutland
2018-11-08 10:34       ` Ard Biesheuvel [this message]
2018-11-07 21:14 ` Will Deacon
2018-11-08 12:22 ` Ilias Apalodimas
2018-11-08 17:51 ` Catalin Marinas
2018-11-28  6:02 ` Kunihiko Hayashi
2018-11-28 11:58   ` Ard Biesheuvel
2018-11-29  1:50     ` Kunihiko Hayashi
2018-11-28 12:04   ` Will Deacon
2018-11-29  1:51     ` Kunihiko Hayashi

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=CAKv+Gu-rKC8mUrjLLooVSxcc6zncG5_Hpubx+3+xqwFqkske3A@mail.gmail.com \
    --to=ard.biesheuvel@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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 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.