Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2328882imb; Mon, 4 Mar 2019 02:12:28 -0800 (PST) X-Google-Smtp-Source: APXvYqyUiDbxv8TelIkLYJ3FcdF+BV957f+UuRFNt7pbOV19RmY17l0yKx4fi6MdvC2tJleiREdt X-Received: by 2002:a17:902:e00d:: with SMTP id ca13mr19538908plb.206.1551694347981; Mon, 04 Mar 2019 02:12:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551694347; cv=none; d=google.com; s=arc-20160816; b=wdmmZaRUBttQ3mzsxGHsBVg9DhuP1sIfvUgfb8kNEy/NQTCrdkZLcdA+L2BpHdLS8I DXNeh54760M17tM/hYAREtOjYDFp+zKiv6FlgHTT6rDxrjqaFvbHyQARlAMMTbbVXyjp mb5lBJsPwDFtNB3U8qto3tJSM+Q1FNlFUE7c9dQMtDOfZi317OR5I9pLjBnnWwz6njR6 dbgLGyFfGg+HxzSlVrZNZ9ZXUxbrgc6DQWiqycvb94dF0irS7XHimNrURzn/75f6o2cd 8xKEMsZp/gVY/w132aYCRmY2VicWwYFitYtUy7hL73JbFWX1JFxhQ3mpXqB/kIx5VV2/ tTag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GnlNTXzWNcsYGkrROUWKstGiSe8R6kfVZq8nFhziDsg=; b=R9PS1tK4Nxb8wXFhKtIL7KTIJ58YMPx+KItq1I9RM2VH0Ep+M3Cy8V8AnhodSZC3df SOEJkVtZcemBbvxE6Ud1tvQ7ENokcBz/OmfRqj/jXs6GrDyn6ymcrUp9IUV5uh0pup+P DpW6KtcFlb/C04D9cCwhEr4LawfCx+S1jf4a1JxOJmGyE2ZZLT56V0s6BDHCH0kgS9Vg RkbICzOe10BkzBd5St5PEftLAXgtJ8s7tNQw5lLZXzJmBOzamxtKA17gaX1mnHoOq2tU hUqfi8EGM3D9Bl+1jZRY8Svb6ua8LDMc5xOZByEh58/3aY0QRYkm0kkqbEUZQfYrNQaW 2MHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=AVvyYWoR; 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 k3si5169307pfb.100.2019.03.04.02.12.11; Mon, 04 Mar 2019 02:12:27 -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=@infradead.org header.s=bombadil.20170209 header.b=AVvyYWoR; 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 S1726090AbfCDKLt (ORCPT + 99 others); Mon, 4 Mar 2019 05:11:49 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:51482 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726029AbfCDKLt (ORCPT ); Mon, 4 Mar 2019 05:11:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GnlNTXzWNcsYGkrROUWKstGiSe8R6kfVZq8nFhziDsg=; b=AVvyYWoRt+SetRYPmMIJZM6Ps mlXGa8EbwMAuMG3IPoXVG+VC5zYYlIeKFR+19wIUohEZjV2Z8JfYObmoMW95CXiR/tqWpLN+mcG9T QVZe3qdkzocmZbw0SJ+H0PHPprYjaVwQMWdf8DkLTtG2vC5nLoUpDFRDXfv4pFoqvvDIDkHDmJW0t zMEvblwM3r/qmHGmxGCl8CBt2gh4dMygENUlV0b7Voahmn+anCANdQXr41hR90WLHxPOPF/nuYrfM gzBxzDnbhmNJgplVHupzMn+oxfg7jw+Wrvdv3HcFh34LQRi8kfcIknQqHzacQq6p5GO9LSSVbobzC cgn4xP7EQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0kZU-0006ft-9r; Mon, 04 Mar 2019 10:11:44 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9728920295AAE; Mon, 4 Mar 2019 11:11:41 +0100 (CET) Date: Mon, 4 Mar 2019 11:11:41 +0100 From: Peter Zijlstra To: Fenghua Yu Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Paolo Bonzini , Dave Hansen , Ashok Raj , Ravi V Shankar , Xiaoyao Li , linux-kernel , x86 , kvm@vger.kernel.org Subject: Re: [PATCH v4 03/17] wlcore: Align reg_ch_conf_pending and tmp_ch_bitmap to unsigned long for better performance Message-ID: <20190304101141.GB32477@hirez.programming.kicks-ass.net> References: <1551494711-213533-1-git-send-email-fenghua.yu@intel.com> <1551494711-213533-4-git-send-email-fenghua.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1551494711-213533-4-git-send-email-fenghua.yu@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 01, 2019 at 06:44:57PM -0800, Fenghua Yu wrote: > A bit in reg_ch_conf_pending in wl271 and tmp_ch_bitmap is set atomically > by set_bit(). set_bit() sets the bit in a single unsigned long location. If > the variables are not aligned to unsigned long, set_bit() accesses two > cache lines and thus causes slower performance. On x86, this scenario is > called split lock and can cause overall performance degradation due to > locked BTSL instruction in set_bit() locks bus. > > To avoid performance degradation, the two variables are aligned to > unsigned long. > > Signed-off-by: Fenghua Yu > --- > drivers/net/wireless/ti/wlcore/cmd.c | 3 ++- > drivers/net/wireless/ti/wlcore/wlcore.h | 6 ++++-- > 2 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/wireless/ti/wlcore/cmd.c b/drivers/net/wireless/ti/wlcore/cmd.c > index 903968735a74..8d15a6307d44 100644 > --- a/drivers/net/wireless/ti/wlcore/cmd.c > +++ b/drivers/net/wireless/ti/wlcore/cmd.c > @@ -1707,7 +1707,8 @@ int wlcore_cmd_regdomain_config_locked(struct wl1271 *wl) > { > struct wl12xx_cmd_regdomain_dfs_config *cmd = NULL; > int ret = 0, i, b, ch_bit_idx; > - u32 tmp_ch_bitmap[2]; > + /* Align to unsigned long for better performance in set_bit() */ > + u32 tmp_ch_bitmap[2] __aligned(sizeof(unsigned long)); > struct wiphy *wiphy = wl->hw->wiphy; > struct ieee80211_supported_band *band; > bool timeout = false; > diff --git a/drivers/net/wireless/ti/wlcore/wlcore.h b/drivers/net/wireless/ti/wlcore/wlcore.h > index dd14850b0603..92d878f01fa5 100644 > --- a/drivers/net/wireless/ti/wlcore/wlcore.h > +++ b/drivers/net/wireless/ti/wlcore/wlcore.h > @@ -321,8 +321,10 @@ struct wl1271 { > > /* Reg domain last configuration */ > u32 reg_ch_conf_last[2] __aligned(8); > - /* Reg domain pending configuration */ > - u32 reg_ch_conf_pending[2]; > + /* Reg domain pending configuration. Aligned to unsigned long for > + * better performane in set_bit(). > + */ > + u32 reg_ch_conf_pending[2] __aligned(sizeof(unsigned long)); > > /* Pointer that holds DMA-friendly block for the mailbox */ > void *mbox; This has nothing to do with better performance. This is generic code, not x86 arch code. Many RISC platforms will already refuse unaligned atomic ops. Also, how is this set_bit() usage endian safe? And no wireless person on Cc anywhere.