All of lore.kernel.org
 help / color / mirror / Atom feed
From: avanbrunt@nvidia.com (Alexander Van Brunt)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/3] Revert arm64 cache geometry
Date: Thu, 29 Oct 2015 23:06:36 +0000	[thread overview]
Message-ID: <1446160085730.52481@nvidia.com> (raw)
In-Reply-To: <5A68E2B9-2254-42CA-8781-E2FA737C366C@linaro.org>

>> On 29 okt. 2015, at 16:43, Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
>> 
>>> On Thu, Oct 29, 2015 at 12:22:51PM +0900, Ard Biesheuvel wrote:
>>> Fair enough. It is a bit disappointing that we cannot trust these
>>> values, but if the architecture does not mandate their accuracy, we
>>> obviously should not be using them in the way that we are.
>>> 
>>> I think we have similar code in the ARM tree, so we should probably
>>> make some changes there as well.
>> 
>> I've opposed exporting the cache dimensions to userspace for several
>> reasons:
>> 
>
>I agree with the arguments below. However, what I refer to here is kernel code that infers whether a certain VIPT cache is non-aliasing based on the way size, which is calculated from values that are exposed to software for the sole purpose of enumerating cachelines by set/way.

No, CCSIDR_EL1 is for the sole purpose of indicating how to clean / invalidate
caches by set and way. The documentation explicitly says it is not for
enumerating the cache geometry.
________________________________________
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Sent: Thursday, October 29, 2015 9:28 AM
To: Russell King - ARM Linux
Cc: Alexander Van Brunt; linux-arm-kernel at lists.infradead.org; Will Deacon; Sudeep Holla; Catalin Marinas
Subject: Re: [PATCH 0/3] Revert arm64 cache geometry

> On 29 okt. 2015, at 16:43, Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
>
>> On Thu, Oct 29, 2015 at 12:22:51PM +0900, Ard Biesheuvel wrote:
>> Fair enough. It is a bit disappointing that we cannot trust these
>> values, but if the architecture does not mandate their accuracy, we
>> obviously should not be using them in the way that we are.
>>
>> I think we have similar code in the ARM tree, so we should probably
>> make some changes there as well.
>
> I've opposed exporting the cache dimensions to userspace for several
> reasons:
>

I agree with the arguments below. However, what I refer to here is kernel code that infers whether a certain VIPT cache is non-aliasing based on the way size, which is calculated from values that are exposed to software for the sole purpose of enumerating cachelines by set/way.


> * it will become a nightmare with the various different register formats
>  to properly decode these values
> * older CPUs don't have the cache ID registers, so we'd need to augment
>  any export with additional static configuration somehow
> * I don't trust userland with this information to make the right choices,
>  especially when faced with further levels of caches.
>
> The main reason for people wanting the cache dimensions has been "so we
> can select the optimal code for the CPU".  Given all the combinations
> of caches out there, I've always said selecting code based on one level
> of cache is totally insane, and userspace is better off doing some
> performance measurement of its implementations and selecting the most
> appropriate version.
>
> There's many things that affect the performance of code paths with CPUs.
> It's not just about cache line size, but instruction latencies, write
> delays, branch prediction and so forth.  You can't _say_ "because this
> CPU has a 32K L1 cache, if I optimise my code as X it'll perform
> better everywhere with a 32K L1 cache than optimised Y."
>
> Selecting code based on cache parameters is just wrong.
>
> There may be cases where userspace would like to know the cache line
> size, so it can appropriately align data structures - but that again
> depends on what you're trying to achieve, and what if the L1 cache
> line size is different from the L2 cache line size...
>
> It's a minefield, one which IMHO userspace shouldn't be trusted with.
> Userspace should assume the worst case cache line size seen in ARM
> CPUs and be done with it.
>
> --
> FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
> according to speedtest.net.

  reply	other threads:[~2015-10-29 23:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-28 21:43 [PATCH 0/3] Revert arm64 cache geometry Alex Van Brunt
2015-10-28 21:43 ` [PATCH 1/3] Revert "arm64: kernel: add support for cpu cache information" Alex Van Brunt
2015-10-28 21:43 ` [PATCH 2/3] Revert "arm64: don't flag non-aliasing VIPT I-caches as aliasing" Alex Van Brunt
2015-10-28 21:43 ` [PATCH 3/3] Revert "arm64: add helper functions to read I-cache attributes" Alex Van Brunt
2015-10-29  3:22 ` [PATCH 0/3] Revert arm64 cache geometry Ard Biesheuvel
2015-10-29 11:20   ` Mark Rutland
2015-10-29 12:26     ` Ard Biesheuvel
2015-10-29 15:43   ` Russell King - ARM Linux
2015-10-29 16:28     ` Ard Biesheuvel
2015-10-29 23:06       ` Alexander Van Brunt [this message]
2015-10-29 22:54   ` Alexander Van Brunt
2015-10-30 11:18     ` Will Deacon
2015-10-29 11:29 ` Mark Rutland
2015-10-29 11:43   ` Sudeep Holla
2015-10-29 11:40 ` Will Deacon
2015-10-29 23:03   ` Alexander Van Brunt
2015-10-30 11:00     ` Catalin Marinas
2015-10-30 11:10       ` Sudeep Holla
2015-10-30 11:57         ` Catalin Marinas
2015-10-30 12:27           ` Sudeep Holla

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=1446160085730.52481@nvidia.com \
    --to=avanbrunt@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.