mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org,
	"Russell King - ARM Linux" <linux@arm.linux.org.uk>,
	Peter Maydell <peter.maydell@linaro.org>,
	gcc@gcc.gnu.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Subject: Re: ARM unaligned MMIO access with attribute((packed))
Date: Wed, 02 Feb 2011 11:14:45 -0800	[thread overview]
Message-ID: <mcrpqrafdui.fsf@google.com> (raw)
In-Reply-To: <201102021839.17223.arnd@arndb.de> (Arnd Bergmann's message of "Wed, 2 Feb 2011 18:39:17 +0100")

Arnd Bergmann <arnd@arndb.de> writes:

> On Wednesday 02 February 2011 17:37:02 Russell King - ARM Linux wrote:
>> We used to use inline assembly at one point, but that got chucked out.
>> The problem is that using asm() for this causes GCC to generate horrid
>> code.
>> 
>> 1. there's no way to tell GCC that the inline assembly is a load
>>    instruction and therefore it needs to schedule the following
>>    instructions appropriately.
>> 
>> 2. GCC will needlessly reload pointers from structures and other such
>>    behaviour because it can't be told clearly what the inline assembly
>>    is doing, so the inline asm needs to have a "memory" clobber.
>> 
>> 3. It seems to misses out using the pre-index addressing, prefering to
>>    create add/sub instructions prior to each inline assembly load/store.
>> 
>> 4. There are no (documented) constraints in GCC to allow you to represent
>>    the offset format for the half-word instructions.
>> 
>> Overall, it means greater register pressure, more instructions, larger
>> functions, greater instruction cache pressure, etc.
>
> Another solution would be to declare the readl function extern and define
> it out of line, but I assume that this would be at least as bad as an
> inline assembly for all the points you brought up, right?
>
> Would it be possible to add the proper constraints for defining readl
> in an efficient way to a future version of gcc? That wouldn't help us
> in the near future, but we could at some points use those in a number
> of places.

I think it would be quite difficult to implement item 1 above in a way
that was actually usable.  It would require some way to describe the
scheduling requirements of an asm.  But the details of scheduling are
backend specific.  Internally there are define_insn_reservation
structures which have names, but the names are processor specific which
is not what you want in source code (by processor specific I mean
specific to particular CPUs within a family).  There are define_cpu_unit
structures which also have names, but are again processor specific.
What you want here is some non-processor-specific way to describe the
characteristics of an instruction.  gcc does not have that today.

Even if somebody implemented all that, most inline asms are not a single
instructions and thus would find it difficult to take advantage of it.
I don't see this as paying off in the long run.

A more likely payoff would be to develop builtin functions for whatever
functionality is required that can not expressed in source code.

Item 2 above can be done.  It is possible to describe precisely which
areas of memory are clobbered.

Item 3 above seems impossible to me.  There is no way to combine
compiler generated instructions with user written inline asm such that
pre-index addressing can be used.  Perhaps I misunderstand.

Item 4 can be implemented; please consider opening a feature request in
bugzilla.

Ian

  reply	other threads:[~2011-02-02 19:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-02 16:00 Arnd Bergmann
2011-02-02 16:37 ` Russell King - ARM Linux
2011-02-02 17:39   ` Arnd Bergmann
2011-02-02 19:14     ` Ian Lance Taylor [this message]
2011-02-02 21:38   ` David Miller
2011-02-02 21:45     ` Russell King - ARM Linux
2011-02-02 21:59       ` David Miller
2011-02-02 23:08     ` Måns Rullgård
2011-02-02 23:23       ` David Miller
2011-02-03  9:26       ` Arnd Bergmann
2011-02-03 15:03   ` Arnd Bergmann
2011-02-02 16:51 ` Richard Guenther
2011-02-02 17:09   ` Russell King - ARM Linux
2011-02-02 17:39   ` Joseph S. Myers
2011-04-26 15:00 ` Rabin Vincent
2011-04-26 18:51   ` Alan Stern
2011-04-27 14:06     ` Rabin Vincent
2011-04-27 16:25       ` Alan Stern
2011-04-27 16:37         ` Arnd Bergmann
2011-04-28 13:35           ` Alan Stern
2011-04-28 14:16             ` Arnd Bergmann

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=mcrpqrafdui.fsf@google.com \
    --to=iant@google.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=arnd@arndb.de \
    --cc=gcc@gcc.gnu.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=peter.maydell@linaro.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

Powered by JetHome