Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp841483yba; Fri, 3 May 2019 11:19:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNcmLjjs0IuyuQx5M9AD190fxkaaEvPEXQlDdfSxYY40k7rU+8hRxhfVbK5TjIbNnfQuBj X-Received: by 2002:a17:902:4681:: with SMTP id p1mr12391905pld.139.1556907580232; Fri, 03 May 2019 11:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556907580; cv=none; d=google.com; s=arc-20160816; b=oLzxddK4cFFCTaXrBXst+tGqf4qYqrZcVZKWilXKHRe0gR/TjDMJJj5AD6xqyFys0a zrKj4q9Ce9Z73EWf6W5A6kxcUE5rrhF5NoZQ+Z9PmxY1w5sMS0uSFIu9NA/dcJNXOcnF 2jLusYMJW/iGvnIJM8XTTJE1bycDph1bUNVBKFkoQwCMRFvY00n8oSfn9Bjn0Ifu3Lkp qTjZpJquzzgQIDclIYXhWnF2BXyHPOOfpzN8vAHuPCxOcE72/zb/xhPitTAC0LiX8FJM dlbcxZ8mnZqnwQKdZy5mYFH3u0AAr+7coMYzj1gyLQQeFLp91j8feO9uE21wQFgU5x2V Ag2Q== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=A16I8FiHguPYBIEmMDQwU131e81YyolMq9ThyDFhyk0=; b=GzOBi/j4aJ2dO0FB6kvCDED65uVJABDuROQtVgjKsGlD19p2BFwlaOa02LTN1WyylP 1eI4u4Pm4Famp7SvjX85Ls8q6pr3coZHK/4u2oOB0Xt1a6mSnLzoa3z2uOzE64Vq6lDB iGT48u6INcOoZZwAKSHxH4zwzD5HDoP101DTRyKQEcoNQ8jvBYrVF0qk49rPhLkmdR9n PgkYWc+N1k/UtqB6iquOVA+kh1I0mf9LmmWnvOWaI+koKPqTEWHqx/3mSbvVklJh9cJu 5IIH6mt1MbDJnhH07bWqkNjJeuheExF3TheX8d9bCU7h/HDU34yB2xLkUxDT1aibobcA euBw== 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 c25si3310678pfr.94.2019.05.03.11.19.24; Fri, 03 May 2019 11:19:40 -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 S1728561AbfECSPg (ORCPT + 99 others); Fri, 3 May 2019 14:15:36 -0400 Received: from gate.crashing.org ([63.228.1.57]:44738 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726480AbfECSPg (ORCPT ); Fri, 3 May 2019 14:15:36 -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 x43IF9Dv008894; Fri, 3 May 2019 13:15:09 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x43IF8rU008889; Fri, 3 May 2019 13:15:08 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Fri, 3 May 2019 13:15:08 -0500 From: Segher Boessenkool To: Christophe Leroy Cc: linux-kernel@vger.kernel.org, Scott Wood , Paul Mackerras , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH] powerpc/32: Remove memory clobber asm constraint on dcbX() functions Message-ID: <20190503181508.GQ8599@gate.crashing.org> References: <20180109065759.4E54B6C73D@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 Hi Christophe, On Fri, May 03, 2019 at 04:14:13PM +0200, Christophe Leroy wrote: > A while ago I proposed the following patch, and didn't get any comment > back on it. I didn't see it. Maybe because of holiday :-) > Do you have any opinion on it ? Is it good and worth it ? > Le 09/01/2018 ? 07:57, Christophe Leroy a ?crit?: > >Instead of just telling GCC that dcbz(), dcbi(), dcbf() and dcbst() > >clobber memory, tell it what it clobbers: > >* dcbz(), dcbi() and dcbf() clobbers one cacheline as output > >* dcbf() and dcbst() clobbers one cacheline as input You cannot "clobber input". Seen another way, only dcbi clobbers anything; dcbz zeroes it instead, and dcbf and dcbst only change in what caches the data hangs out. > >--- a/arch/powerpc/include/asm/cache.h > >+++ b/arch/powerpc/include/asm/cache.h > >@@ -82,22 +82,31 @@ extern void _set_L3CR(unsigned long); > > > > static inline void dcbz(void *addr) > > { > >- __asm__ __volatile__ ("dcbz 0, %0" : : "r"(addr) : "memory"); > >+ __asm__ __volatile__ ("dcbz 0, %1" : > >+ "=m"(*(char (*)[L1_CACHE_BYTES])addr) : > >+ "r"(addr) :); > > } The instruction does *not* work on the memory pointed to by addr. It works on the cache line containing the address addr. If you want to have addr always aligned, you need to document this, and check all callers, etc. > > static inline void dcbf(void *addr) > > { > >- __asm__ __volatile__ ("dcbf 0, %0" : : "r"(addr) : "memory"); > >+ __asm__ __volatile__ ("dcbf 0, %1" : > >+ "=m"(*(char (*)[L1_CACHE_BYTES])addr) : > >+ "r"(addr), "m"(*(char > >(*)[L1_CACHE_BYTES])addr) : > >+ ); > > } Newline damage... Was that your mailer? Also, you may want a "memory" clobber anyway, to get ordering correct for the synchronisation instructions. I think your changes make things less robust than they were before. [ Btw. Instead of __asm__ __volatile__ ("dcbf 0, %0" : : "r"(addr) : "memory"); you can do __asm__ __volatile__ ("dcbf %0" : : "Z"(addr) : "memory"); to save some insns here and there. ] Segher