Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1288843ybt; Thu, 9 Jul 2020 03:27:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6iTjhdgNO9GuTeGf4GEMrENyyH/QnP30HrEUI11l6WG9fDg4AayDxuOiWlbmjgy4lxHH4 X-Received: by 2002:a50:ee8a:: with SMTP id f10mr51381612edr.383.1594290467068; Thu, 09 Jul 2020 03:27:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594290467; cv=none; d=google.com; s=arc-20160816; b=Wh1EPCsEWliS5kFxqDgMooAkgE1DCXUbQ10ICyVmQhRlKM45mo/Y3hJMGU0jQ/Pb9D f3oEmGFzUvllpD6pX4AoKo8d5bXVtp9skBdIwvdqc0vnMMZwvUX0WRzNO6CG46SaSJ1c G5Ni2voJY0O3dFrM1cctNHkqeg9jsnmPeDf5V1AEiWJNTEiobPGNegCDj3y2tFA3XB+C wKUKXYdNuIoDp6CL8/roKTd9MHPLKsFTHw8GGwHYzK8q2EHtPC3q92W7tieMaJ/EK95s GLxKu02VU6Df2LFVFYv74MnM7WpNKAo5l9YTCWaeb+Gi7ct/KMDxmaLv36SwwPdmdCrW X2PA== 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 :dkim-signature; bh=NpSN3ki+N4zt0HUfgIrsSnvQ6T16fz2RkuPCF/KHwA4=; b=pSlTxM87DlKNqDQm8ou9ic25DMpsFdUjfEaC6R0GCaDqOTK0fl1DMugEItBWcjVZNv eQljdgHTaaWO7X/v8ltciJzQ3LiDLSPxsriDweMSQML9TxqINYTL90mr640TIWFqwsgC wi2QeN/B55N6RWBAYPu2oC/8EdwWsLCEWRmBPqcN7EqvVFpxAL1g6d+l3Qe4rUM6HmXN GlNqazFisjWjqGFYqDB5ZwMpN1XdDPo0pQk3b7U7edyKDzyFtYOPN0X6oYVDZw8x+q8F RgbYUmrtjfRhZ19372yveQ61rNvyyNYjHK5qO1lkMSJfE/FVDxYR8lHz8QyDtXkuN6E2 8/6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=lcNOL49+; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rn15si1648216ejb.513.2020.07.09.03.27.23; Thu, 09 Jul 2020 03:27:47 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=lcNOL49+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbgGIK0B (ORCPT + 99 others); Thu, 9 Jul 2020 06:26:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbgGIK0B (ORCPT ); Thu, 9 Jul 2020 06:26:01 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4146C061A0B for ; Thu, 9 Jul 2020 03:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NpSN3ki+N4zt0HUfgIrsSnvQ6T16fz2RkuPCF/KHwA4=; b=lcNOL49+Mdl2jAvl5oF+UTjLxQ vrGb+GpK2zM5KjxfZnfYS9juP3DkDE/vVX9zDbTGjSHx/lNkzWkb6Aqj31d52bVWq2tYkjA8pHH1j X4oYBbugE1sQP0vzJ3VDwzuouBX6kFx5FxmQKvuZ3ewovX1rtAQkJ8HvNak/lTTGcdZWfUvrHNUls kvZY933UCc5YIZWLb87GFAe0oLb+sriTw6gaWlXXRdOhxSXqaDw5fHIVsW5q6vSwmDuSaaricufw2 em88KHjCd6LiqQ/lkCrC+5igMpo53RyFqnh+x6QExX6ZHo4DSxAflVSVRjIj/J+SCG1BBR3cnA/mq Yxzsl22A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtTkZ-0006hx-5n; Thu, 09 Jul 2020 10:25:55 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E405930047A; Thu, 9 Jul 2020 12:25:50 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D0866285718DB; Thu, 9 Jul 2020 12:25:50 +0200 (CEST) Date: Thu, 9 Jul 2020 12:25:50 +0200 From: Peter Zijlstra To: Brian Gerst Cc: Nick Desaulniers , LKML , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Andy Lutomirski Subject: Re: [PATCH v2 09/10] x86/percpu: Clean up percpu_stable_op() Message-ID: <20200709102550.GN597537@hirez.programming.kicks-ass.net> References: <20200530221127.459704-1-brgerst@gmail.com> <20200530221127.459704-10-brgerst@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 02, 2020 at 10:19:51AM -0400, Brian Gerst wrote: > On Mon, Jun 1, 2020 at 4:43 PM Nick Desaulniers wrote: > > > > On Sat, May 30, 2020 at 3:11 PM Brian Gerst wrote: > > > > > > Use __pcpu_size_call_return() to simplify this_cpu_read_stable(). > > > > Clever! As in this_cpu_read() in include/linux/percpu-defs.h. Could > > be its own patch before this, but it's fine. > > Reviewed-by: Nick Desaulniers > > > > > Also remove __bad_percpu_size() which is now unused. > > > > > > Signed-off-by: Brian Gerst > > > --- > > > arch/x86/include/asm/percpu.h | 41 ++++++++++------------------------- > > > 1 file changed, 12 insertions(+), 29 deletions(-) > > > > > > diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h > > > index 7efc0b5c4ff0..cf2b9c2a241e 100644 > > > --- a/arch/x86/include/asm/percpu.h > > > +++ b/arch/x86/include/asm/percpu.h > > > @@ -85,7 +85,6 @@ > > > > > > /* For arch-specific code, we can use direct single-insn ops (they > > > * don't give an lvalue though). */ > > > -extern void __bad_percpu_size(void); > > > > > > #define __pcpu_type_1 u8 > > > #define __pcpu_type_2 u16 > > > @@ -167,33 +166,13 @@ do { \ > > > (typeof(_var))(unsigned long) pfo_val__; \ > > > }) > > > > > > -#define percpu_stable_op(op, var) \ > > > -({ \ > > > - typeof(var) pfo_ret__; \ > > > - switch (sizeof(var)) { \ > > > - case 1: \ > > > - asm(op "b "__percpu_arg(P1)",%0" \ > > > > What does the `P` do here? > > https://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html#Simple-Constraints > > says can be machine dependent integral literal in a certain range. > > https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints > > doesn't document `P` for x86 though... > > https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Extended-Asm.html#x86-Operand-Modifiers > > Removing the 'P' modifier results in this: > movq %gs:$current_task, %rdx #, pfo_val__ > > This is because the 'p' constraint treats a memory address as a > constant. I tried replacing it with __this_cpu_read(), which since > commit 0b9ccc0a should have similar non-volatile semantics. But the > compiler still reloaded it on every use, so I left the asm template > as-is for now until that can be resolved. Right, I can into that same issue a while back and gave up staring at compiler innards. __this_cpu_read() *should* allow re-loads, and it does in places (we've had bugs because of it), but this_cpu_read_stable() is somehow far more 'effective'. It would be good if someone can update the comment with that thing, to explain matters better.