Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp866428pxj; Wed, 16 Jun 2021 15:47:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7ohZGQgB4Gsbev5+avMyAav/inuow6xxDlLv4wAY7d9byo9pwjq6LANhk/Hs0hP7dQVki X-Received: by 2002:a05:6638:b86:: with SMTP id b6mr1504779jad.36.1623883625394; Wed, 16 Jun 2021 15:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623883625; cv=none; d=google.com; s=arc-20160816; b=vcdX7uxHrOcm3a62ZcINc42r4KRiG0qhCVpCZSM42Eig9X96uSSoA8ecrtPCA33aDu t1ICAXg18+oDdu5LDPJAioibqsIkkS+wij7dDNdwnxfIGElNKvxnlUpALMfo/6Gky0KB Dxk/cNgHsWDjnSL3LZjw/re3QIxAU28gzHlWne4ouW68tFwMbXuppD8umDDBQRddAY8j qLqd0eWT9V2lx1af0ehUGBeip9VZ7sWe6j014Rkfg1jjuzvU/FYG+MM0AmXSZWu6VoUW XN/meVhklmr5SrdksD8VjhsrSCrDRHaTxFCK0qNfRY0diDzL0sdMiLNNPjKBFOvVDlOO UoRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=8/ypPtneFb644T/1APQoRilHyLXkxcSMhpU9RIBSKTU=; b=NaHNS3hy6IZUp44VTzpuNXyFrxFNYmyy/ddaglrRaPWd/3qAliXxarjlNfDfGzf5o3 jZN2MuKXX5TFAM11qMORU/ULSKDpeKmubB4PHiEumFS4FAtSYLuXZckUSXUu7RckntXy XAP9+h79AyyKLxwSaBSO4UrC57609xWjbnTqfTqGHBkDimnMFKYZR94EcpNrOHrEzLVg W7tY4JG/u6hq2nhTOTTZUv+bphgmd9He7bEnnmWmtTIYsfVJs2pofrxKfYW/5le8tZlB z07kOvWMXQLPrCBOerp+EfswUWZUSyg6rIrKOyuurKmTGwBctpKaz8jRXdj/VQurd3cu gn0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p1si4063558iod.55.2021.06.16.15.46.51; Wed, 16 Jun 2021 15:47:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234893AbhFPPsJ (ORCPT + 99 others); Wed, 16 Jun 2021 11:48:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:58652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235591AbhFPPrk (ORCPT ); Wed, 16 Jun 2021 11:47:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F41A460FE3; Wed, 16 Jun 2021 15:45:31 +0000 (UTC) Date: Wed, 16 Jun 2021 16:45:29 +0100 From: Catalin Marinas To: "Russell King (Oracle)" Cc: Peter Zijlstra , Andy Lutomirski , x86@kernel.org, Dave Hansen , LKML , linux-mm@kvack.org, Andrew Morton , Mathieu Desnoyers , Nicholas Piggin , linux-arm-kernel@lists.infradead.org, Will Deacon Subject: Re: [PATCH 7/8] membarrier: Remove arm (32) support for SYNC_CORE Message-ID: <20210616154529.GD22433@arm.com> References: <2142129092ff9aa00e600c42a26c4015b7f5ceec.1623813516.git.luto@kernel.org> <20210616103446.GC22278@shell.armlinux.org.uk> <20210616132226.GD22278@shell.armlinux.org.uk> <20210616150456.GC22433@arm.com> <20210616152326.GG22278@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210616152326.GG22278@shell.armlinux.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 16, 2021 at 04:23:26PM +0100, Russell King wrote: > On Wed, Jun 16, 2021 at 04:04:56PM +0100, Catalin Marinas wrote: > > On Wed, Jun 16, 2021 at 02:22:27PM +0100, Russell King wrote: > > > If it's a problem, then it needs fixing. sys_cacheflush() is used to > > > implement GCC's __builtin___clear_cache(). I'm not sure who added this > > > to gcc. > > > > I'm surprised that it works. I guess it's just luck that the thread > > doing the code writing doesn't migrate before the sys_cacheflush() call. > > Maybe the platforms that use ARM MPCore avoid the issue somehow (maybe > by not using self-modifying code?) Not sure how widely it is/was used with JITs. In general, I think the systems at the time were quite tolerant to missing I-cache maintenance (maybe small caches?). We ran Linux for a while without 826cbdaff297 ("[ARM] 5092/1: Fix the I-cache invalidation on ARMv6 and later CPUs"). > > > Likely only in places where we care about I/D coherency - as the data > > > cache is required to be PIPT on these SMP platforms. > > > > We had similar issue with the cache maintenance for DMA. The hack we > > employed (in cache.S) is relying on the MESI protocol internals and > > forcing a read/write for ownership before the D-cache maintenance. > > Luckily ARM11MPCore doesn't do speculative data loads to trigger some > > migration back. > > That's very similar to the hack that was originally implemented for > MPCore DMA - see the DMA_CACHE_RWFO configuration option. Well, yes, that's what I wrote above ;) (I added the hack and config option IIRC). > An interesting point here is that cache_ops_need_broadcast() reads > MMFR3 bits 12..15, which in the MPCore TRM has nothing to with cache > operation broadcasting - but luckily is documented as containing zero. > So, cache_ops_need_broadcast() returns correctly (true) here. That's typical with any new feature. The 12..15 field was added in ARMv7 stating that cache maintenance is broadcast in hardware. Prior to this, the field was read-as-zero. So it's not luck but we could have avoided negating the meaning here, i.e. call it cache_ops_are_broadcast(). > > The simpler fix for flush_icache_range() is to disable preemption, read > > a word in a cacheline to force any dirty lines on another CPU to be > > evicted and then issue the D-cache maintenance (for those cache lines > > which are still dirty on the current CPU). > > Is just reading sufficient? If so, why do we do a read-then-write in > the MPCore DMA cache ops? Don't we need the write to force exclusive > ownership? If we don't have exclusive ownership of the dirty line, > how can we be sure to write it out of the caches? For cleaning (which is the case for I/D coherency), we only need reading since we are fine with clean lines being left in the D-cache on other CPUs. For invalidation, we indeed need to force the exclusive ownership, hence the write. -- Catalin