Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8153419ybi; Tue, 9 Jul 2019 10:07:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiVZOKjH+SkWBnQvvrfjKSBE5JaIZRk5HYkTJDSS356hsMWW2gCwFN4VXZm3Rgy1bqwIUk X-Received: by 2002:a63:a41:: with SMTP id z1mr31591922pgk.290.1562692024943; Tue, 09 Jul 2019 10:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562692024; cv=none; d=google.com; s=arc-20160816; b=ZqnjzLdS9EyXtHyWGzVqYSm2H2SloOMmXo+O1p4RVBdrQjkSSOE03Pj7yQ/2GzBWp/ byhoKP/EgFrSrjiZzHu8SCESDQfGh+y9D929yTq59Dpqsmj/X3mgpAaHNr/TayKseabn nWGCdc5OMpDJBVstVB8NI3svxeK5cmAuXESYZXRrHhmPQDhafGSSnR27yE5zUA/xFmMt omn1vkO0nx6tJeB4dWfYLqd9spSR/yFPmjN7+LZWYlPKpNiIPxmeQuQChfoDld5ZBh3m OYa0xqwnSXktktDqsZ6pltSbS0aqQfD/6X7Nc9+E9vQj6xIMST7uH+h8nWjj1s4kKOQZ jk4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=pgRBi5Gwk70hRYKWAu7pWGdZGDoHHQL6b9mLDNzhxLk=; b=zRNbTORgkPmacU7UHIX6v7XJdC7HwSxiiEEuCxIzEFVDBMhwmg8HQgHjzGkfbw8YX+ 7LqmzP3Gk7QYOGQoiJt9HqCMDGXwioyavgrnD1bwdgU2ffOOA7U4QiByYDvK29qAa1/I 3w66WpMmYbwvuc8OJxyU72PUAF2EeqLWoAoq21fribNhEbbJTbfVLZcUYo5CbH0YLREX A/soA0qG3O62vA4a2FM4/6WeZdVv3TMqUPuhjE3w/Mp+FZaIU6e38yqqRMh3GopJhe4N kubG5E86jPNK5nlzvXm5HbjNyl5AQdZ4oYyLVC0uiLnfoP0Rmii2MyJjx9YWuel+nSRk VRoA== 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 c1si1928535plr.405.2019.07.09.10.06.49; Tue, 09 Jul 2019 10:07:04 -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 S1726569AbfGIREx (ORCPT + 99 others); Tue, 9 Jul 2019 13:04:53 -0400 Received: from gate.crashing.org ([63.228.1.57]:39653 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725816AbfGIREx (ORCPT ); Tue, 9 Jul 2019 13:04:53 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x69H4Oop012194; Tue, 9 Jul 2019 12:04:24 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x69H4Mr9012191; Tue, 9 Jul 2019 12:04:22 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 9 Jul 2019 12:04:22 -0500 From: Segher Boessenkool To: "Aneesh Kumar K.V" Cc: "Oliver O'Halloran" , Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev , Linux Kernel Mailing List Subject: Re: [PATCH 4/4] powerpc/64: reuse PPC32 static inline flush_dcache_range() Message-ID: <20190709170422.GM30355@gate.crashing.org> References: <239d1c8f15b8bedc161a234f9f1a22a07160dbdf.1557824379.git.christophe.leroy@c-s.fr> <87y318d2th.fsf@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 09, 2019 at 08:21:54AM +0530, Aneesh Kumar K.V wrote: > On 7/9/19 7:50 AM, Oliver O'Halloran wrote: > >I don't think it's that, there's some magic in flush_icache_range() to > >handle dropping prefetched instructions on 970. > > > >>So overall wondering why we need that extra barriers there. > > > >I think the isync is needed there because the architecture only > >requires sync to provide ordering. A sync alone doesn't guarantee the > >dcbfs have actually completed so the isync is necessary to ensure the > >flushed cache lines are back in memory. That said, as far as I know > >all the IBM book3s chips from power4 onwards will wait for pending > >dcbfs when they hit a sync, but that might change in the future. > > > > ISA doesn't list that as the sequence. Only place where isync was > mentioned was w.r.t icbi where want to discards the prefetch. You need an isync to guarantee all icbi insns before the isync have been performed before any code after the isync is fetched. Killing the prefetch is just part of it. > >If it's a problem we could add a cpu-feature section around the isync > >to no-op it in the common case. However, when I had a look with perf > >it always showed that the sync was the hotspot so I don't think it'll > >help much. > > What about the preceding barriers (sync; isync;) before dcbf? Why are > they needed? This isn't very generic code. The code seems to be trying to do coherency in software. Like you needed to do for DART on U3/U4, or for some of the PMU/SMU communication -- both are through main memory, but both are not cache coherent. Which means all rules go out of the window. To do this properly you need some platform-specific code, for example to kill hardware and software prefetch streams. Or hope^Wguarantee those never touch your communication buffers. I recommend you keep the original function, maybe with a more specific name, for the DART etc. code; and have all normal(*) dcbf users use a new more normal function, with just a single sync instruction. Segher (*) As far as anything using dcbf can be called "normal"!