Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1335454ybg; Tue, 2 Jun 2020 07:22:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrFUWO65Co9InC+epCRT0JnGJSa4KaQjxKlHMPIgFTOqziCyNIHnCAjf8seJRi3BgA7UE5 X-Received: by 2002:a17:906:f185:: with SMTP id gs5mr10727235ejb.223.1591107774809; Tue, 02 Jun 2020 07:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591107774; cv=none; d=google.com; s=arc-20160816; b=bSxoiLZw5aWzgjqb911usIfQT5J7ynwqRhaDPTNr4EizadTmE+nL1Cq8Tswymv2c4W Vkuql8PLwo0WrjgzQdJH3T/UczlQu1R0xKxNGhQcEf4os6X01JIyS9VMPL81EUOzXB1/ rx7FIixxF6ZAgIbDB+WfBTCMK73nRkiYf7LJsN1f3xPJXqbA4VCjOpd1qVyBrfhm9SJ9 XZffnuxUDZEwa4+ann8BS4xcqdiUnfW9YcBeqqHLDwX7h2aYYAyH8f8A05s/33goaHw5 cpb6qfZQHBnSxBao/XuHuxd1/HMd7mXl/2s5MbX6U6jw39r3NbMwi8exnepUmeQcJS4t DTkQ== 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=gTKrdi+FmTwitSR67MLzUCwXXUWMx4K0w1icK0dDzI4=; b=vaEdK5gxdKU/JeN3j76dxvzYRfZrshbwGHyRFkTe4Q0oNSVoJQC6BSS7aUU7NtQuHT iQ4DsDosKpX3wI6lXYmFIOLBK+b6SAeRRHQroTknBGdyuBnJp3JIJREjQwbmC43LKtXw TeGwoYRK2uPnLu24STf1QGHWbpUXMvjSBN6KagBSdkB3ds6FspThFu6/+Yw+0PhkDnQS /ejoW3TZ2l1TCUCxCbEI6SB5dc4Uuk34xP2y0RyxCnTO/0BIsvndNKrKJ0dlLsDF4mRH tUI6zFPf+ED0KrSsMPBiufkrYzs02rbRDR22h0lIYjQwPsrue7l78zbiJv/kluDMEHZQ sN2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WDh9T0Mz; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c7si1554915edv.93.2020.06.02.07.22.31; Tue, 02 Jun 2020 07:22:54 -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=pass header.i=@gmail.com header.s=20161025 header.b=WDh9T0Mz; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728364AbgFBOUD (ORCPT + 99 others); Tue, 2 Jun 2020 10:20:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728080AbgFBOUD (ORCPT ); Tue, 2 Jun 2020 10:20:03 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AB4EC08C5C0 for ; Tue, 2 Jun 2020 07:20:03 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id j8so10953038iog.13 for ; Tue, 02 Jun 2020 07:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gTKrdi+FmTwitSR67MLzUCwXXUWMx4K0w1icK0dDzI4=; b=WDh9T0MzEQbVqOcDSnRU44nLaP+mu+XQvI2hYAlCUAyxVtbNZo/5OQhNcvN65+QOWS bSnMHUUgyLDptNAOss4k4qbRaA3E/XZqKJbcp+AEE8wJCd9TWWA9g+mn3TLBsNIuEYqr Lbzm19NRKORu88a0s7luHo9mCqEsbvBmwwc61no8zWSSjwWhNvxc7GChzWjQdTVGcJ+B xNqbbwHCTEPKDMSb927p2Ap/dfgiIxu07a84tvtf4B1HAazOI9BEq+OtmYpgOr8hC1J5 IEy54LIdDbaY5V4XLiMDNfZ9uz8uYutCm3NKRETQQ1jsUroe+xKD2uQSwgGHNxSlwE7G hNIg== 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=gTKrdi+FmTwitSR67MLzUCwXXUWMx4K0w1icK0dDzI4=; b=rqhMDVW4Lg8rsFXTVvA3qRw+m1JV/AeisKXA/WfH24cCK/OEdMhDSZhNasM6+TJOrR tY+sfHsQnUkleXyM2WWjdB04RjsTyaMGknD/cYMlycxCcVnWB5Hq3bAwwo50gBIoZp6A mXAcp8unBZMiFV2kJc8GqwUPJFRy4QNiL+OUfA616hp8fXypZfDlurE947z8Dfk1D8od FgNjL3X0GV4uDasteGr81oFyYKsmSI1a8YuZnGf9R4TdrBLlS+gJQ7dcM9z6vN+ppvzk BJzCUikSLN/1F4v21vw2P1uHuZo64MytWSOsMJp0JKyDRbfHL88m2tbLgh9oSLMD/6RK eMWw== X-Gm-Message-State: AOAM530O0Xrv45AYiQuEXrTruICEf2px1OtAAntCZjRN7nd97V1/CqHI gvfwWMpjiZHm5DOJkAA3SbSMUFN7wires43OjkzdD14+Vg== X-Received: by 2002:a02:958e:: with SMTP id b14mr26155030jai.126.1591107602546; Tue, 02 Jun 2020 07:20:02 -0700 (PDT) MIME-Version: 1.0 References: <20200530221127.459704-1-brgerst@gmail.com> <20200530221127.459704-10-brgerst@gmail.com> In-Reply-To: From: Brian Gerst Date: Tue, 2 Jun 2020 10:19:51 -0400 Message-ID: Subject: Re: [PATCH v2 09/10] x86/percpu: Clean up percpu_stable_op() To: Nick Desaulniers Cc: LKML , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Andy Lutomirski , Peter Zijlstra 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, 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. -- Brian Gerst