Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp970842imm; Fri, 22 Jun 2018 08:15:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIMaZ2OUA3DyIlB9JxAxD4tLnvY6TT4hzQgEMLBfNsUHklK+uiLmU4HoqIBJUdemNcwUpnR X-Received: by 2002:a63:78c6:: with SMTP id t189-v6mr1773962pgc.239.1529680524902; Fri, 22 Jun 2018 08:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529680524; cv=none; d=google.com; s=arc-20160816; b=QCzFWS9C8OIfQtBYpG7ULQddu6v/95sexmTWU7xc6yzegQaFMAx/+fnpQ1HQ6v780+ i50P2IhcLy8ZIYpJrqjeO3hHJSvc489EG25xf6E8EeUfTcByw6AyX5PlGur67HYY1W+N zLVsJdLtZMzXWGKDvGS7kUdYeEefA13W+bEbSskQ36QYyAFakln2tSJi1f70/J6AT5ZN mBOkZ1q6oZX9KlsoiASSb7KuVj3JtVNB7tffROhLp0vMsgUCbAzX/Cj5ic/EfmZDFQ4v 2/6DBBr/u4IyDoLBEHf4YEa6C3uxSI1cgOkmvKzwhI6jTHMLFmoZlpCXZfy3SLXtLSQS 0T9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=uHExfcuStvjafPYUNSkjwynDxCKc4HWrNFqIOzDSboI=; b=tH2f7brA4sDhqcLvAWDy8yEPjYXF/qKNpdBVrEMGKgJYy8qv9LPJBuwsc40YFs//qY zOrRV9x4niZiWDQB+gqYnCwGD1hKpNI5KmEWCOkpLpacgr3PObeRHoqN7nWfEvAnIqVm +rgyB4vkdIahX+ttHlzJP7zCroBIOG47neqhgJZbmA0RmVTVWupaEELbjMHhzxLcjf8G quip+NtpVWht2Lp7n0hnrLKbJyXdEF8kPGg+PKt59ITk2Ocup6tECDZLp/pLPYpFsE7t Hp7OJ1EaGu25udoOlU2KqbrFUHBVYlpB35ZfHuIJahFR+Eco2OvG9d5zZwIQ5WKSruQj xMwA== 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 63-v6si7561770pfx.61.2018.06.22.08.15.10; Fri, 22 Jun 2018 08:15:24 -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 S933691AbeFVPOP (ORCPT + 99 others); Fri, 22 Jun 2018 11:14:15 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:41972 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933354AbeFVPOO (ORCPT ); Fri, 22 Jun 2018 11:14:14 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fWNlF-0007G3-AD; Fri, 22 Jun 2018 17:14:05 +0200 Date: Fri, 22 Jun 2018 17:14:04 +0200 (CEST) From: Thomas Gleixner To: "Chang S. Bae" cc: Andy Lutomirski , "H . Peter Anvin" , Ingo Molnar , Andi Kleen , Dave Hansen , Markus T Metzger , Ravi Shankar , LKML Subject: Re: [PATCH v4 6/7] x86/vdso: Introduce CPU number helper functions In-Reply-To: <1529536506-26237-7-git-send-email-chang.seok.bae@intel.com> Message-ID: References: <1529536506-26237-1-git-send-email-chang.seok.bae@intel.com> <1529536506-26237-7-git-send-email-chang.seok.bae@intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 20 Jun 2018, Chang S. Bae wrote: > CPU number initialization in vDSO is now a bit cleaned up by > the new helper functions. The helper functions will take > care of combing CPU and node number and reading each from s/combing/combining/ please > the combined value. > > Suggested-by: Andy Lutomirski > Signed-off-by: Chang S. Bae > Cc: H. Peter Anvin > Cc: Andi Kleen > Cc: Dave Hansen > Cc: Thomas Gleixner > Cc: Ingo Molnar > Acked-by: Andy Lutomirski > --- > arch/x86/entry/vdso/vgetcpu.c | 4 ++-- > arch/x86/entry/vdso/vma.c | 16 ++++++++-------- > arch/x86/include/asm/segment.h | 28 ++++++++++++++++++++++++++++ > arch/x86/include/asm/vgtod.h | 2 -- > 4 files changed, 38 insertions(+), 12 deletions(-) > > diff --git a/arch/x86/entry/vdso/vgetcpu.c b/arch/x86/entry/vdso/vgetcpu.c > index 8ec3d1f..3284069 100644 > --- a/arch/x86/entry/vdso/vgetcpu.c > +++ b/arch/x86/entry/vdso/vgetcpu.c > @@ -18,9 +18,9 @@ __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused) > p = __getcpu(); While we are touching this, can we please as a first step change __getcpu() to something else? I've tripped over this several times in the past and confused it with a (nonexisting) variant of get_cpu(). > > if (cpu) > - *cpu = p & VGETCPU_CPU_MASK; > + *cpu = lsl_tscp_to_cpu(p); > > if (node) > - *node = p >> 12; > + *node = lsl_tscp_to_node(p); Are these new helpers going to be used at some other place than this? If not, then there is really no point at all. Then just go and make this: __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused) { vdso_read_cpu_and_node(cpu, node); return 0; } > diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c > index 833e229..1fc93da 100644 > --- a/arch/x86/entry/vdso/vma.c > +++ b/arch/x86/entry/vdso/vma.c > @@ -340,19 +340,19 @@ static void vgetcpu_cpu_init(void *arg) > int cpu = smp_processor_id(); > struct desc_struct d = { }; > unsigned long node = 0; > + unsigned long cpu_number = 0; That's hardly a CPU number. It's encoded CPU and node information. > #ifdef CONFIG_NUMA > node = cpu_to_node(cpu); > #endif While at it please get rid of the ifdeffery. If CONFIG_NUMA=n then cpu_to_node(cpu) resolves to (0). > + cpu_number = make_lsl_tscp(cpu, node); So the whole thing can be reduced to: u64 cpudata = vdso_encode_cpu_and_node(cpu, cpu_to_node(cpu)); Or some other sensible function name. Thanks, tglx