Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3709279ybb; Mon, 23 Mar 2020 06:18:23 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvecU2KIHpeCQqJFOMiYial0+5T4YNpBKLzyNNxTRuespNWEu35SaPHrsLdXKcwFy0Uo19K X-Received: by 2002:aca:4082:: with SMTP id n124mr237817oia.112.1584969503312; Mon, 23 Mar 2020 06:18:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584969503; cv=none; d=google.com; s=arc-20160816; b=htW9bq5e+alqhelsSH51Acngrc0TeofiImtqe3GsyyBev79UpTIZe8Tp6TKUuurYOt 7DzI1+No0n4xY9udjJ4kaiBfprNRF5E71mW2mHd8ghNjZWDIjXktLbkIi4mGJ7CRwiZH +l/iPCIv/F6l/mOtMqbXhgcZmCRF8fz4BS5BTCbEeJQCqv3kP1hWVkX+dk/xZlmwxy1v 11UWLd1YJRR6DPh8OBxzgwvVpaiFom2YZPTdUC8EWf6H73gTRCCbxLxXhGQuJoGb9JPD tQkqDc/cCxkC6I4wnFG+xEIuTnFgWhAY1NH7tCjtaWEsDlowwmz+nrdj3e4yHjO9Ce8n Huzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=0ZdmPHLHuZnhEaYpv0u610HaSK//dDLNpw+GkGMwCno=; b=imqpv+VHAk9SGyW7R8iS96QnQ3xVmSF6lRcwEuantlFKmKISjHCM1Pjova3szxxIGQ LMypacvetIgvmMJ2qW1fao7TciL2F3tINeoJTZ4+U+GPTcsK+z9cj/0ZHX7nzPyla+Bz a1IZhoYdOLNvGxXtN3TB+W0TQxBpIMQEPTnjnblemNu4MMGEEGM1gaKmkFPOaoHPGfQ4 UU5y6/AQPcdwbN0F6mEOfoth0nRXvnEtwZ2i2lMM5Oc2oIEg0mz1mFee1jzAQGO5OZu8 fpi4cMBTUFT34m+rV3voncKxRBNHRBSCAswh+1LZH1807prsd8hGmofJblYjQK9clR7t I+qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si163721oop.51.2020.03.23.06.18.09; Mon, 23 Mar 2020 06:18:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728506AbgCWNRZ (ORCPT + 99 others); Mon, 23 Mar 2020 09:17:25 -0400 Received: from foss.arm.com ([217.140.110.172]:48836 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728393AbgCWNRZ (ORCPT ); Mon, 23 Mar 2020 09:17:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D028A1FB; Mon, 23 Mar 2020 06:17:24 -0700 (PDT) Received: from C02TD0UTHF1T.local (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C864F3F52E; Mon, 23 Mar 2020 06:17:23 -0700 (PDT) Date: Mon, 23 Mar 2020 13:17:20 +0000 From: Mark Rutland To: Changbin Du Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: Two questions about cache coherency on arm platforms Message-ID: <20200323131720.GE2597@C02TD0UTHF1T.local> References: <20200323123524.w67fici6oxzdo665@mail.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200323123524.w67fici6oxzdo665@mail.google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 23, 2020 at 08:35:26PM +0800, Changbin Du wrote: > Hi, All, > I am not very familiar with ARM processors. I have two questions about > cache coherency. Could anyone help me? > > 1. How is cache coherency maintenanced on ARMv8 big.LITTLE system? > As far as I know, big cores and little cores are in seperate clusters on > big.LITTLE system. This is often true, but not always the case. For example, with DSU big and little cores can be placed within the same cluster. > And cache coherence betwwen clusters requires the > memory regions are marked as 'Outer Shareable' and is very expensive. This is not correct. Linux requires that all cores it uses are within the same Inner Shareable domain, regardless of whether they are in distinct clusters. Linux does not support systems where cores are in distinct Inner Shareable domains. This is the intended use of the architecture. Per ARM DDI 0487E.a page B2-144: | This architecture assumes that all PEs that use the same operating | system or hypervisor are in the same Inner Shareable shareability | shareability ... where a PE is a "Processing Element", which you can think of as a single core. > I have checked the kernel code, and seems it only requires coherence in > 'Inner Shareable' domain. So my question is how can linux guarantees > cache coherence in 'CPU migration' or 'Global Task Scheduling' models > wich both clusters are active at the same time? For example, a thread > ran in Cluster A and modified 'Inner Shareable' memory, then it migrates > to Cluster B. As above, this works because all the relevant cores are within the same Inner Shareable domain. > 2. ARM64 cache maintenance code sync_icache_aliases() for non-aliasing icache. > In linux kernel on arm64 platform, the flow function sync_icache_aliases() > is used to sync i-cache and d-cache. I understand the aliasing case. but > for non-aliasing case why it just does "dc cvau" (in __flush_icache_range()) > whithout really invalidate the icache? The __flush_icache_range/__flush_cache_user_range assembly function does both the D-cache maintenance with DC CVAU, then the I-cache maintenance with IC IVAU, so I think you have misread it. Thanks, Mark. > Will i-cache refill from L2 cache? > > void sync_icache_aliases(void *kaddr, unsigned long len) > { > unsigned long addr = (unsigned long)kaddr; > > if (icache_is_aliasing()) { > __clean_dcache_area_pou(kaddr, len); > __flush_icache_all(); > } else { > /* > * Don't issue kick_all_cpus_sync() after I-cache invalidation > * for user mappings. > */ > __flush_icache_range(addr, addr + len); > } > } > > -- > Cheers, > Changbin Du