linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hitoshi Mitake <h.mitake@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Roland Dreier <rdreier@cisco.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Robert P. J. Day" <rpjday@crashcourse.ca>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: arch/x86/Kconfig selects invalid HAVE_READQ, HAVE_WRITEQ vars
Date: Tue, 21 Apr 2009 17:33:44 +0900	[thread overview]
Message-ID: <a6b9f31a0904210133m29e68580w1fb7a8e6159b65d6@mail.gmail.com> (raw)
In-Reply-To: <20090420160332.GB9689@elte.hu>

On Tue, Apr 21, 2009 at 01:03, Ingo Molnar <mingo@elte.hu> wrote:
>
> * Hitoshi Mitake <h.mitake@gmail.com> wrote:
>
>> On Mon, Apr 20, 2009 at 19:53, Ingo Molnar <mingo@elte.hu> wrote:
>> >
>> > * H. Peter Anvin <hpa@zytor.com> wrote:
>> >
>> >> Roland Dreier wrote:
>> >> >
>> >> > Notice that it reads from addr+4 *before* it reads from addr, rather
>> >> > than after as in your example (and in fact your example depends on
>> >> > undefined compiler semantics, since there is no sequence point between
>> >> > the two operands of the | operator).  Now, I don't know that hardware,
>> >> > so I don't know if it makes a difference, but the niu example I gave in
>> >> > my original email shows that given hardware with clear-on-read
>> >> > registers, the order does very much matter.
>> >> >
>> >>
>> >> At least for x86, the order should be low-high, because that is the
>> >> order that those two transactions would be seen on a 32-bit bus
>> >> downstream from the CPU if the CPU issued a 64-bit transaction.
>> >>
>> >> The only sane way to handle this as something other than per-driver
>> >> hacks would be something like:
>> >>
>> >> #include <linux/io64.h>               /* Any 64-bit I/O OK */
>> >>
>> >> #include <linux/io64lh.h>     /* Low-high splitting OK */
>> >>
>> >> #include <linux/io64hl.h>     /* High-low splitting OK */
>> >>
>> >> #include <linux/io64atomic.h> /* 64-bit I/O must be atomic */
>> >>
>> >> ... i.e. letting the driver choose what fallback method it will accept.
>> >
>> > Yeah - with the default being the natural low-high order.
>> >
>> > The other argument is that if a driver really wants some rare, oddly
>> > different order it should better define its own method that is not
>> > named in the same (or in a similar) way as an existing generic API.
>> > Otherwise, confusion will ensue.
>> I think this is a good way.
>> readq/writeq are already in Linus's tree, removing these is not a good idea.
>>
>> And I've sent the patch to fix a little problem of Kconfig about
>> readq/writeq to you.
>> http://marc.info/?l=linux-kernel&m=123521109218008&w=2
>> Did you notice?
>>
>> Adding cautions about accessing order or non-atomic to Kconfig's help
>> part may be benefit.
>
> It's better to add add such non-interactive help text as Makefile
> comments:
>
> #
> # This option ...
> #
>
> and they should be invisible in make menuconfig. This is a facility
> provided by architectures.
I'll move the help text from Kconfig to Makefile.
(My original patch also doesn't make help text visible in make menuconfig.)

>
> Note, the whole patchset is still incomplete - readq/writeq wrappers
> should be provided on all 32-bit architectures. Are those in the
> works?

I'm not working on porting readq/writeq on all 32-bit architectures.
If I port these, HAVE_READQ will be needless. Because there's no reason
to judge that architecture provides readq/writeq.

Porting readq/writeq on all architectures is radical way to solve.
But the problem related to order of accessing and non-atomic still exists.

I think there are 3 ways to choose:

1) Removing readq/writeq from x86_32
This is the way Roland mentioned.
This way removes the bugs related to order of accessing and non-atomic forever.
But driver programmers must implement their own version of readq/writeq,
and Andrew Morton said such case is sucks.
http://marc.info/?l=linux-kernel&m=122625885124798&w=2

2) Adding HAVE_READQ and HAVE_WRITEQ to Kconfigs of architectures
which provides readq/writeq
   despite of 32/64bit
This is the nearest with current state of Linux.
But some day non-atomic or order of accessing which driver programmers
didn't expect may cause
subtle bugs.

3) Porting readq/writeq on all architectures despite of 32/64bit
This is a very radical way.
This frees us from the problem of "#ifdef readq <implement driver own
version> #endif"
or HAVE_READQ forever.
But the possibility of subtle bugs caused by non-atomic or order of
accessing still exists.

Which one should we choose?

I suggest 2) (or 3)).
Because there's no problem since ported readq/writeq on x86_32.
And as H. Peter Anvin mentioned non-atomic is generally fine.

  reply	other threads:[~2009-04-21  8:33 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-19 19:45 arch/x86/Kconfig selects invalid HAVE_READQ, HAVE_WRITEQ vars Robert P. J. Day
2009-04-19 21:12 ` Roland Dreier
2009-04-19 21:46   ` Ingo Molnar
2009-04-19 22:02     ` H. Peter Anvin
2009-04-19 22:35       ` Ingo Molnar
2009-04-20  0:56         ` Roland Dreier
2009-04-20  2:08           ` Robert Hancock
2009-04-20  0:53     ` Roland Dreier
2009-04-20  1:20       ` H. Peter Anvin
2009-04-20 10:53         ` Ingo Molnar
2009-04-20 14:47           ` Hitoshi Mitake
2009-04-20 16:03             ` Ingo Molnar
2009-04-21  8:33               ` Hitoshi Mitake [this message]
2009-04-21  8:45                 ` Ingo Molnar
2009-04-21  8:57                   ` Hitoshi Mitake
2009-04-21 15:44                 ` H. Peter Anvin
2009-04-21 17:07                   ` Roland Dreier
2009-04-21 17:19                     ` H. Peter Anvin
2009-04-21 17:23                       ` Roland Dreier
2009-04-21 19:09                         ` H. Peter Anvin
2009-04-21 21:11                           ` Roland Dreier
2009-04-21 21:16                             ` H. Peter Anvin
2009-04-22  0:31                               ` David Miller
2009-04-28 19:05                                 ` [PATCH] x86: Remove readq()/writeq() on 32-bit Roland Dreier
2009-04-29  5:12                                   ` David Miller
2009-04-29 11:56                                     ` Ingo Molnar
2009-04-29 12:10                                       ` Jeff Garzik
2009-04-29 17:25                                         ` Roland Dreier
2009-04-29 19:59                                           ` Jeff Garzik
2009-05-13  5:32                                             ` Hitoshi Mitake
2009-05-13 20:19                                               ` H. Peter Anvin
2009-05-13 22:39                                                 ` Jeff Garzik
2009-05-13 23:39                                                   ` H. Peter Anvin
2009-05-14  0:49                                                     ` Jeff Garzik
2009-05-14  7:19                                                       ` Hitoshi Mitake
2009-05-15 23:44                                                         ` Jeff Garzik
2009-05-17  7:12                                                           ` Hitoshi Mitake
2009-05-17  8:06                                                             ` Jeff Garzik
2009-05-21 11:35                                                               ` Hitoshi Mitake
2009-05-21 11:49                                                                 ` Hitoshi Mitake
2009-05-13 20:42                                               ` Jeff Garzik
2009-05-13 21:05                                                 ` H. Peter Anvin
2009-05-13 21:30                                                   ` Jeff Garzik
2009-05-13 21:31                                                     ` Jeff Garzik
2009-05-13 21:54                                                     ` H. Peter Anvin
2009-05-13 22:06                                                 ` Roland Dreier
2009-05-13 22:29                                                   ` Jeff Garzik
2009-04-29 17:21                                       ` Roland Dreier
2009-04-22  0:27                           ` arch/x86/Kconfig selects invalid HAVE_READQ, HAVE_WRITEQ vars David Miller
2009-04-22  0:25                     ` David Miller

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=a6b9f31a0904210133m29e68580w1fb7a8e6159b65d6@mail.gmail.com \
    --to=h.mitake@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rdreier@cisco.com \
    --cc=rpjday@crashcourse.ca \
    --cc=tglx@linutronix.de \
    /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 NNTP newsgroup(s).