Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2281822imb; Mon, 4 Mar 2019 00:41:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IaMco5AUznumOO06Wovo9Gd1MkKLAYept9Cav1WeUIFuYtzjQLaz6LbN5U9saKQKUtXmjDB X-Received: by 2002:aa7:9102:: with SMTP id 2mr18697436pfh.179.1551688886855; Mon, 04 Mar 2019 00:41:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551688886; cv=none; d=google.com; s=arc-20160816; b=c6lIkAsywh6WWvSEpfyI8kneSk0yfRO3PrxqEFtpKWmqnccpJ7Pq9/3nzctOCzJL1x J0UNRLCxjTgDlPWVyjQVMTDC0ae6An5g0JLccrvkgD5jBRVWJRlqhosBuR8TI1ZjQ33O GWT8re/TRJKAO/4A6CuLy09iOBduXwN6AGm0ccrp9l6/sN3GF9AwVrwPg6CRKBss6hDv nIWhtN2o3PJnM4tMpajloDihWJ0tO0bT+pn9tBKESqs0v0xG34INxp/4C793cRBRYiJg uqx2BbcP4WE+59yU67vVEVCMhEqQHDDJexi63nJXFFHoIfM9Bd6fg6meZR6ekV9pjN+b 3gFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=aZk/j0+GQYkbIPBGm26QhzjK7GmLVO7MEyFy7JizhuI=; b=TQZ4d5cucij1SeYZ3oX7hkQpld0dlLbwlk+OeBzLZphO7hfhSqrRlEMmNQRAJr3wkd LRbEpl3dm7lQyl1wNOGTXjBGYK7b3rqFDvRDjNaIRZgBDxt0n+DqV40OY2XVzF1ibmNO s/fh35npH2VVx7UiBSc/IES86OtIqNsYGtm2TaLApw1JwZmMUK4VB/fcrfH6ycWdmJCp k1zmSkM+g4irKYZhN2+fqDwYEF4HvtBcTffu6gyQtPctyqKIHjKqBl7sKtT++aH5DKS6 EUV9DkiWfZge1fNiLaCvy1qHK1uYCJlUOh78RKoQdQ4+6/Nop6IHxxnXaLlFVkVA9N16 cfrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZTC4JrPD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q20si4745075pls.263.2019.03.04.00.41.05; Mon, 04 Mar 2019 00:41:26 -0800 (PST) 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=fail header.i=@gmail.com header.s=20161025 header.b=ZTC4JrPD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbfCDIj6 (ORCPT + 99 others); Mon, 4 Mar 2019 03:39:58 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55393 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727172AbfCDIdU (ORCPT ); Mon, 4 Mar 2019 03:33:20 -0500 Received: by mail-wm1-f65.google.com with SMTP id q187so3694824wme.5; Mon, 04 Mar 2019 00:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:openpgp:autocrypt:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=aZk/j0+GQYkbIPBGm26QhzjK7GmLVO7MEyFy7JizhuI=; b=ZTC4JrPDq9pfKNtyqg0/RLX6rOgbBaiAEeQL714mu1tx3ly6lsqhXIfNJcknqESRro bBYwpoe4U/IEqKva1ieodhIJr/eINcyGacMS/HugZv0qS1/e28W1Kj/KhwfrAfN+hms9 jNOTWCW7PzsWNhayKsOiNdumnzk7rHeu5ZbmNBcf4LgPm9v/G934NS8P50N8SytGhKE9 QxgWHr84UsoQswOTkMLkcQiuXwxWe3OBbsQA0nWsjCfNHj5lMx1ukM/kSfImDGOnHQR8 oh04Snddzx5u3ZAHLDfAmjrYrRP9fGgTfZJXmx7tp6CeaUrSfLrv7BclBP1mf1TNNVrg E4Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:openpgp :autocrypt:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=aZk/j0+GQYkbIPBGm26QhzjK7GmLVO7MEyFy7JizhuI=; b=j3j0/Bsdb05Pwziw0xaN2ureQOGT/Jos4o0SEVWYlZTqeRmADG0jB0ACp8uFZbJPBS xj+fhejc3tk3XRuEil+HFPHLmlC07dOUfNjKQ4jYfN17ePnSg4hmniALsZ55gDRzVmw1 9q8Tko6jyUjreH1HTYIfdiay9tTA1+YTAq1fGaEwN1H7u4MHVBIngqe2zvGpFojuJGZZ NRuwo8qhBi3kqzbXdaUoQ9AmhnYiQQedBtB/lDZmfyYE8H7aQGriWFmrijS4JSLUqqNW sr0mpyDjR6kQtN4/Vy5nuQyiDPkQ3978r3LtugjikPAKpDZj7DIC44WWfpD0HBt6YpGG /9bA== X-Gm-Message-State: APjAAAUPv9jJascxfai6Ptk8dIU4buGz0YA20TUS818vHS8N76P42krF 56VHASYbi8FNW3UfvDUg2lYi+Gt3 X-Received: by 2002:a1c:9957:: with SMTP id b84mr9557526wme.95.1551688397810; Mon, 04 Mar 2019 00:33:17 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:102e:b101:9b89:f7ef? ([2001:b07:6468:f312:102e:b101:9b89:f7ef]) by smtp.googlemail.com with ESMTPSA id w4sm7420779wrk.85.2019.03.04.00.33.16 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 00:33:17 -0800 (PST) Subject: Re: [PATCH v4 01/17] x86/common: Align cpu_caps_cleared and cpu_caps_set to unsigned long To: Fenghua Yu , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Dave Hansen , Ashok Raj , Peter Zijlstra , Ravi V Shankar , Xiaoyao Li Cc: linux-kernel , x86 , kvm@vger.kernel.org References: <1551494711-213533-1-git-send-email-fenghua.yu@intel.com> <1551494711-213533-2-git-send-email-fenghua.yu@intel.com> From: Paolo Bonzini Openpgp: preference=signencrypt Autocrypt: addr=pbonzini@redhat.com; keydata= mQHhBFRCcBIBDqDGsz4K0zZun3jh+U6Z9wNGLKQ0kSFyjN38gMqU1SfP+TUNQepFHb/Gc0E2 CxXPkIBTvYY+ZPkoTh5xF9oS1jqI8iRLzouzF8yXs3QjQIZ2SfuCxSVwlV65jotcjD2FTN04 hVopm9llFijNZpVIOGUTqzM4U55sdsCcZUluWM6x4HSOdw5F5Utxfp1wOjD/v92Lrax0hjiX DResHSt48q+8FrZzY+AUbkUS+Jm34qjswdrgsC5uxeVcLkBgWLmov2kMaMROT0YmFY6A3m1S P/kXmHDXxhe23gKb3dgwxUTpENDBGcfEzrzilWueOeUWiOcWuFOed/C3SyijBx3Av/lbCsHU Vx6pMycNTdzU1BuAroB+Y3mNEuW56Yd44jlInzG2UOwt9XjjdKkJZ1g0P9dwptwLEgTEd3Fo UdhAQyRXGYO8oROiuh+RZ1lXp6AQ4ZjoyH8WLfTLf5g1EKCTc4C1sy1vQSdzIRu3rBIjAvnC tGZADei1IExLqB3uzXKzZ1BZ+Z8hnt2og9hb7H0y8diYfEk2w3R7wEr+Ehk5NQsT2MPI2QBd wEv1/Aj1DgUH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ToO53DliFMkVTecLptsXaes uUHgL9dKIfvpm+rNXRn9wAwGjk0X/A== Message-ID: <461f162c-694f-2bb7-f9cb-55fa915434bc@redhat.com> Date: Mon, 4 Mar 2019 09:33:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <1551494711-213533-2-git-send-email-fenghua.yu@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/03/19 03:44, Fenghua Yu wrote: > cpu_caps_cleared and cpu_caps_set may not be aligned to unsigned long. > Atomic operations (i.e. set_bit and clear_bit) on the bitmaps may access > two cache lines (a.k.a. split lock) and lock bus to block all memory > accesses from other processors to ensure atomicity. > > To avoid the overall performance degradation from the bus locking, align > the two variables to unsigned long. > > Defining the variables as unsigned long may also fix the issue because > they are naturally aligned to unsigned long. But that needs additional > code changes. Adding __aligned(unsigned long) are simpler fixes. > > Signed-off-by: Fenghua Yu > --- > arch/x86/kernel/cpu/common.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c > index cb28e98a0659..51ab37ba5f64 100644 > --- a/arch/x86/kernel/cpu/common.c > +++ b/arch/x86/kernel/cpu/common.c > @@ -488,8 +488,9 @@ static const char *table_lookup_model(struct cpuinfo_x86 *c) > return NULL; /* Not found */ > } > > -__u32 cpu_caps_cleared[NCAPINTS + NBUGINTS]; > -__u32 cpu_caps_set[NCAPINTS + NBUGINTS]; > +/* Unsigned long alignment to avoid split lock in atomic bitmap ops */ > +__u32 cpu_caps_cleared[NCAPINTS + NBUGINTS] __aligned(sizeof(unsigned long)); > +__u32 cpu_caps_set[NCAPINTS + NBUGINTS] __aligned(sizeof(unsigned long)); > > void load_percpu_segment(int cpu) > { > (resending including the list) Why not instead change set_bit/clear_bit to use btsl/btrl instead of btsq/btrq? Thanks, Paolo