From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: Implement cache_line_size() based on CTR_EL0.CWG
Date: Fri, 2 May 2014 19:10:17 +0100 [thread overview]
Message-ID: <20140502181017.GC14645@arm.com> (raw)
In-Reply-To: <20140502173121.GB5341@arm.com>
On Fri, May 02, 2014 at 06:31:21PM +0100, Catalin Marinas wrote:
> On Fri, May 02, 2014 at 06:12:47PM +0100, Will Deacon wrote:
> > On Fri, May 02, 2014 at 04:55:32PM +0100, Catalin Marinas wrote:
> > > The hardware provides the maximum cache line size in the system via the
> > > CTR_EL0.CWG bits. This patch implements the cache_line_size() function
> > > to read such information, together with a sanity check if the statically
> > > defined L1_CACHE_BYTES is smaller than the hardware value.
[...]
> > > +static inline int cache_line_size(void)
> > > +{
> > > + u32 cwg = cache_type_cwg();
> > > + return cwg ? 4 << cwg : L1_CACHE_BYTES;
> > > +}
> >
> > Hmmm, but the CWG is not the same thing as the L1 cache line size, so
> > something is amiss here. If I have an L2 cache with bigger lines, then
> > reporting L1_CACHE_BYTES is wrong here.
>
> L1 is usually DMinSize while CWG is the maximum in the system. If a
> system has a system cache, it should be covered by CWG (especially those
> semi-transparent system caches).
I wouldn't bet on that, but it should at least define the maximum line size
of your inner caches.
> Using this macro is misleading indeed but Linux has lots of assumptions
> about the cache line size and only using L1_CACHE_BYTES, including cache
> line aligned sections. I consider L1 in this context to actually mean
> any cache line flushed by the standard DC instructions.
Yes, Linux uses L1_CACHE_BYTES and __cacheline_aligned etc for all sorts of
cases. Some of these are performance improvements, and should be as small as
possible (since they probably just refer to the L1 size for coherent CPUs)
but others are critical for correct operation, and should be large enough to
get things right (like early boot synchronisation).
I suppose that means we always use CWG and should loudly if it's bogus...
which is exactly what your patch does!
Acked-by: Will Deacon <will.deacon@arm.com>
Will
prev parent reply other threads:[~2014-05-02 18:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-02 15:55 [PATCH] arm64: Implement cache_line_size() based on CTR_EL0.CWG Catalin Marinas
2014-05-02 17:12 ` Will Deacon
2014-05-02 17:31 ` Catalin Marinas
2014-05-02 18:10 ` Will Deacon [this message]
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=20140502181017.GC14645@arm.com \
--to=will.deacon@arm.com \
--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 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).