From: Konrad Rzeszutek Wilk <konrad@kernel.org>
To: Andy Lutomirski <luto@amacapital.net>, stefan.bader@canonical.com
Cc: linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: WT memory type on x86_64?
Date: Wed, 8 May 2013 10:35:08 -0400 [thread overview]
Message-ID: <20130508143505.GA8599@phenom.dumpdata.com> (raw)
In-Reply-To: <CALCETrVBor6fKwxP=+0mtJ4SjKn2YrFczSdXhazw3m8E5Sxx6A@mail.gmail.com>
On Wed, Apr 24, 2013 at 12:33:33PM -0700, Andy Lutomirski wrote:
> For an upcoming (and, sadly, NDA'd [1]) project, I may need to use
> write-through memory. I'd like to gauge how unpleasant this will be.
>
> AFAICT, modern CPUs allow the WT type to be set using MTRR or a PAT
> entry. Sadly, MTRRs are in short supply, and the four fully-usable
> PAT slots are used for UC, UC-, WB, and WC. I can keep my fingers
> crossed and hope that there are enough free MTRRs, or I could try to
> free up a PAT entry.
>
> How nasty will the latter be? I just looked at two rather different
> modern Sandy Bridge machines, and BIOS doesn't appear to set up any
> MTRRs in the WC or WP states. As long as those MTRR types aren't
> used, I think the UC- PAT entry is useless -- it behaves identically
> to UC. Lots of DRM drivers, though, seen to add a WC MTRR to cover
> video memory. Is there any need for this on modern machines? That
> is, are there any drivers that actually need the mtrr_add call to
> succeed on a machine that has a working PAT?
>
> If not, then here's a proposal: At startup, if there are no WC or WP
> MTRRs and the CPU is new enough, then set a flag for an alternative
> PAT. In alternative PAT mode, UC- is replaced with WT in the PAT and
> mtrr_add fails when attempting to add a WC or WP entry. Add
> set_memory_wt, etc. They fail in non-alternative-PAT mode. This gets
> a bit unpleasant, since _PAGE_CACHE_UC_MINUS will have a different
> meaning depending on the mode.
>
> A less conservative proposal would be to stop using UC- in the PAT
> entirely. The memtype code could learn to emulate UC- when there's an
> overlapping WC or WP MTRR.
>
> Any thoughts? Are there known errata here? Is there a good reason
> why the kernel needs UC-? Will this be such a big can of worms that I
> should just hope there's an available MTRR?
Stefan Bader (CC-ed here) was looking in making a "black-box" type
code wherein for any types but WC it would lookup in the PAT index
the right bit and provide that for the page_attr_set functions.
If I recall he had run in a bit of issue with of the hard-coded values
set by the macros.
>
> --Andy
>
> [1] I hope to be able to upstream all kernel code related to this
> project. It will be neat -- I promise. It will depend on convincing
> the people on the other end of the NDA that they should let me.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
next prev parent reply other threads:[~2013-05-08 14:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-24 19:33 WT memory type on x86_64? Andy Lutomirski
2013-04-27 0:37 ` Andy Lutomirski
2013-04-27 1:00 ` Dave Airlie
2013-04-27 1:01 ` Dave Airlie
2013-04-30 18:55 ` Andy Lutomirski
2013-05-08 14:35 ` Konrad Rzeszutek Wilk [this message]
2013-05-08 15:14 ` Stefan Bader
2013-05-08 16:37 ` Andy Lutomirski
2013-05-08 22:49 ` H. Peter Anvin
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=20130508143505.GA8599@phenom.dumpdata.com \
--to=konrad@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=stefan.bader@canonical.com \
--cc=x86@kernel.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