Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11339171ybi; Thu, 25 Jul 2019 14:32:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBK3LcLYSO2oIAj3eR8w7+jnPHPFIrMU1Q2iTHWcZhKJsyup97P4PX02PSlI8BrJYx8YF5 X-Received: by 2002:a17:90a:b908:: with SMTP id p8mr7096562pjr.94.1564090362712; Thu, 25 Jul 2019 14:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564090362; cv=none; d=google.com; s=arc-20160816; b=e6fEG6POkKJruI4NC2WiUij3Q6teqduweL2DNhGAM+OpoLPW9cLBtYc1afp7968dSH 1JE/8bgjNvNnWa1IfHLgzJylTdAwcP7ZNkp/FpYrR/g42UFf5H7zTmv4yd5rY8chz15q OikLF8kIZsE7MkFuOw9Cc87g0jsheRq2zrsW2S0N3Je+UFwFM37/3iaqmSk3bRpDbzXR 4nUUdFl22XlBTWhbCJi2X5M9DiRBaGdvtfvkXkP31FaznNtc9C524F5KfuL4fcciHkk/ 4xTQDscxfhU9UT8whPxz7UPwKMRGOxHmeejrNJIY9ad1Jeto0XP0o+qoLVBmyLBiKWCs dJqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mfaBZ71hrJPdlZeMC578OQz4LN6coQODfHCSFL4DY30=; b=Hrk2Xn0eGAFQWVrqmZredoDPnWsyeVrvLE8BW2dMJxObmOc4j19Z10Qslt1d6GxnOs 86+tc3mwMJmKUVumgTiNL7GitBagZEkSewR64cLnCNg4JT6ue+kXT1jgja83Egf1h/2H X3I1GL1T32OpKgApwm+DgegKGyqbGrecLXnMIWNGdlmLxfuV+DjIcoXCfd/Of8whfM7W DY4RykOpmFX4FPShEvAWJkhiNmH7nCbe0u5AS7NlDy6wtykjdtxO/AQIY36856Y/SzTL CEaFAKVFemBOspE1kvUYWGXVKa6tgXg1Jqy7J1A+vC4VuJcpttCNZdsd8a93dZPHKLp9 7Gsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=L1PQzO25; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e66si16451599plb.254.2019.07.25.14.32.27; Thu, 25 Jul 2019 14:32:42 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=L1PQzO25; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726739AbfGYVbE (ORCPT + 99 others); Thu, 25 Jul 2019 17:31:04 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:34877 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726447AbfGYVbE (ORCPT ); Thu, 25 Jul 2019 17:31:04 -0400 Received: by mail-pl1-f193.google.com with SMTP id w24so23890210plp.2 for ; Thu, 25 Jul 2019 14:31:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mfaBZ71hrJPdlZeMC578OQz4LN6coQODfHCSFL4DY30=; b=L1PQzO25HSmegQlGogBRTDRVTJihGQ8nW9Pn1vU/pcEljVrJpCDHdb5G5+wUOZRaji zXIIf53eCREsVmf57JKSXVPPLdRqtrwWoKl74voeX8/y2vPEEjikuw990cW8pTWz42n3 ABhie+Ty3rfGMfWkgYDzV8jMxGv16NOkmEN3RYHdennsIIwff6Z3ZxELWILi6yjguG51 EDfK+J1awSDH2gdNIicNi7/QO22SW1WjMemBbfQb+Qy6tBUGqaqNEO5LyOMHRj8dwaxK OgaNX6VSDa5tUrSrABbZy9yBQmccK4Hs8OK2TQ3ZC78A1yP4XhW9aJYEbXDQnsQXinQb Etyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mfaBZ71hrJPdlZeMC578OQz4LN6coQODfHCSFL4DY30=; b=d8TjaAGTBthAF3HwmHpkML6Dfrh/a2qeQ7zSsgYP51mkjKZ4EGLZi8cn7jb07MD3QT 8aQfha57RL/oJKjMODaAKVXZhBTEjvIdtcMbUIqkOBMzlc0/t5A/20+GyOc3StZ+LKg2 nVUcjFqiO1vcwUXSfI3em9A9QavtKWtpGgyTSMTEA+pzRVV3pNFBECCqzxENPKsDkyQj ppCYJhgV7PK/IE86VPIlYpk97Wj18doYsEwanVBkpto90Sr1iDWJLR+QAJ13CRMAPHJu p6TiqKeqXUGvvTj/MjXGMZWrFk6Wp/qok9cQK9Pxf3nYZOyrIxM67N7SBeiIKRU9pEfL CnMQ== X-Gm-Message-State: APjAAAXjdwLICrXDSjFpksnkIKQKqLLBT38BhejuTSDGLzkSvl6296a2 N941CvDI2q3bY+SBQizrFnUKJe4Qx86rnEF1DLzsEg== X-Received: by 2002:a17:902:b944:: with SMTP id h4mr16697787pls.179.1564090262638; Thu, 25 Jul 2019 14:31:02 -0700 (PDT) MIME-Version: 1.0 References: <20190709064952.GA40851@archlinux-threadripper> <20190719032456.GA14108@archlinux-threadripper> <20190719152303.GA20882@gate.crashing.org> <20190719160455.GA12420@archlinux-threadripper> <20190721075846.GA97701@archlinux-threadripper> <20190721180150.GN20882@gate.crashing.org> <20190722024140.GA55142@archlinux-threadripper> <20190722061940.GZ20882@gate.crashing.org> <20190722175817.GE20882@gate.crashing.org> In-Reply-To: <20190722175817.GE20882@gate.crashing.org> From: Nick Desaulniers Date: Thu, 25 Jul 2019 14:30:51 -0700 Message-ID: Subject: Re: [PATCH v2] powerpc: slightly improve cache helpers To: Segher Boessenkool Cc: Nathan Chancellor , Christophe Leroy , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, LKML , clang-built-linux , James Y Knight , Joel Stanley , dja@axtens.net Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 22, 2019 at 10:58 AM Segher Boessenkool wrote: > > On Mon, Jul 22, 2019 at 10:21:07AM -0700, Nick Desaulniers wrote: > > On Sun, Jul 21, 2019 at 11:19 PM Segher Boessenkool > > wrote: > > > On Sun, Jul 21, 2019 at 07:41:40PM -0700, Nathan Chancellor wrote: > > > > On Sun, Jul 21, 2019 at 01:01:50PM -0500, Segher Boessenkool wrote: > > > > > On Sun, Jul 21, 2019 at 12:58:46AM -0700, Nathan Chancellor wrote: > > > > > > 0000017c clear_user_page: > > > > > > 17c: 94 21 ff f0 stwu 1, -16(1) > > > > > > 180: 38 80 00 80 li 4, 128 > > > > > > 184: 38 63 ff e0 addi 3, 3, -32 > > > > > > 188: 7c 89 03 a6 mtctr 4 > > > > > > 18c: 38 81 00 0f addi 4, 1, 15 > > > > > > 190: 8c c3 00 20 lbzu 6, 32(3) > > > > > > 194: 98 c1 00 0f stb 6, 15(1) > > > > > > 198: 7c 00 27 ec dcbz 0, 4 > > > > > > 19c: 42 00 ff f4 bdnz .+65524 > > > > > > > > > > Uh, yeah, well, I have no idea what clang tried here, but that won't > > > > > work. It's copying a byte from each target cache line to the stack, > > > > > and then does clears the cache line containing that byte on the stack. > > > > > > > > > > I *guess* this is about "Z" and not about "%y", but you'll have to ask > > > > > the clang people. > > > > > > > > > > Or it may be that they do not treat inline asm operands as lvalues > > > > > properly? That rings some bells. Yeah that looks like it. > > > > > > The code is > > > __asm__ __volatile__ ("dcbz %y0" : : "Z"(*(u8 *)addr) : "memory"); > > > > > > so yeah it looks like clang took that *(u8 *)addr as rvalue, and > > > stored that in stack, and then used *that* as memory. > > > > What's the %y modifier supposed to mean here? > > It prints a memory address for an indexed operand. > > If you write just "%0" it prints addresses that are a single register > as "0(r3)" instead of "0,r3". Some instructions do not allow offset > form. > > > addr is in the list of > > inputs, so what's wrong with using it as an rvalue? > > It seems to use *(u8 *)addr as rvalue. Asm operands are lvalues. It > matters a lot for memory operands. Hmm...not sure that's specified behavior. Anyways, I've filed: https://bugs.llvm.org/show_bug.cgi?id=42762 to see if folks more familiar with LLVM's ppc backend have some more thoughts. I recommend considering reverting commit 6c5875843b87 ("powerpc: slightly improve cache helpers") until the issue is resolved in clang, otherwise I'll probably just turn off our CI builds of PPC32 for the time being. -- Thanks, ~Nick Desaulniers