mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: "John A. Gregor" <john.gregor@qlogic.com>
Cc: ralph.campbell@qlogic.com, linux-kernel@vger.kernel.org,
	johng@diamond.mv.qlogic.com
Subject: Re: [PATCH] x86_64/__iowrite32_copy: don't use string move for PIO writes
Date: Mon, 06 Jul 2009 15:47:00 -0700	[thread overview]
Message-ID: <4A527EE4.1080102@zytor.com> (raw)
In-Reply-To: <4a526e77.IPiyTZWRWfll2+00%john.gregor@qlogic.com>

John A. Gregor wrote:
> "H. Peter Anvin" <hpa@zytor.com> wrote:
> 
>> John Gregor wrote:
>>> From: John Gregor <johng@diamond.mv.qlogic.com>
>>>
>>> Some processors can write the same word more than once if the movs
>>> instruction is used. This version uses normal memory move instructions
>>> and gets the same performance since the speed is limited by PCIe and
>>> write combining.
>>>
>> Which processors do that *when addressing I/O memory*?
> 
> Nehalem.
> 

Thanks.  That should go into the patch header with a reference to the
erratum, rather than saying "some processors".  Additionally, there
should be a comment in the code to that effect.  Otherwise when 5-10
years from now we're trying to figure out what is going on, there is
absolutely no hope, and we'll either re-trigger the bug or end up being
stuck with cargo-cult programming.

It's probably also worth nothing that with this change, there probably
is little point in writing this in assembly at all.  This is especially
so since your implementation is buggy: by definition, __iowrite32_copy()
does the I/O operations 32 bits at a time, but you are using 64-bit
operations.

This gets even more ironic when you look at the erratum, which states
that this happens only when crossing from WB/WC memory into UC/WP/WT
memory, and in the case of UC memory (the only one of those types which
is used in Linux):

	* UC the data size of each write will now always be 8 bytes, as
	  opposed to the original data size.

A workaround is also described, which is to avoid page-crossing copies.
 No mention of doubled stores or anything like that.

Note the irony in that your patch actually takes the problem described
in the erratum and implementing it in software -- with your change,
*all* stores would be 8 bytes, which of course violates the definition
entirely.

Note how critical detailed information of the erratum was to being able
to make an actual analysis of the patch, too.  Again, this is not just a
case immediately, but possibly down the line.

Hence:

- your patch is wrong and actually introduces the problem it is supposed
  to solve;
- your description of the problem was both incomplete and incorrect (it
  might be correct if there is another erratum, but if so please
  describe it, it is not Nehalem AAK6);
- the current code is fine as long as it doesn't cross from cached to
  uncached memory, which it never should in any kind of sensible driver;
- if you are worried about that, introduce code which breaks the string
  copy at page boundaries.

Thanks,

	-hpa


  reply	other threads:[~2009-07-06 22:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-06 19:07 John Gregor
2009-07-06 21:30 ` H. Peter Anvin
2009-07-06 21:36   ` John A. Gregor
2009-07-06 22:47     ` H. Peter Anvin [this message]
2009-07-06 23:44       ` John A. Gregor
2009-07-07  0:03         ` H. Peter Anvin
2009-07-07 16:06           ` John A. Gregor
2009-07-08  0:46             ` H. Peter Anvin
2009-07-09 23:19       ` Pavel Machek
2009-07-10 15:07         ` H. Peter Anvin
2009-07-10 16:02           ` Lu, Hongjiu
2009-07-06 21:41   ` John A. Gregor

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=4A527EE4.1080102@zytor.com \
    --to=hpa@zytor.com \
    --cc=john.gregor@qlogic.com \
    --cc=johng@diamond.mv.qlogic.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ralph.campbell@qlogic.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome