From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EEBEC43603 for ; Wed, 11 Dec 2019 18:44:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4649820836 for ; Wed, 11 Dec 2019 18:44:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729742AbfLKSoS (ORCPT ); Wed, 11 Dec 2019 13:44:18 -0500 Received: from mga03.intel.com ([134.134.136.65]:54605 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726411AbfLKSoR (ORCPT ); Wed, 11 Dec 2019 13:44:17 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Dec 2019 10:44:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,302,1571727600"; d="scan'208";a="210817858" Received: from agluck-desk2.sc.intel.com (HELO agluck-desk2.amr.corp.intel.com) ([10.3.52.68]) by fmsmga007.fm.intel.com with ESMTP; 11 Dec 2019 10:44:16 -0800 Date: Wed, 11 Dec 2019 10:44:16 -0800 From: "Luck, Tony" To: Peter Zijlstra Cc: Andy Lutomirski , "Yu, Fenghua" , David Laight , Ingo Molnar , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , "Raj, Ashok" , "Shankar, Ravi V" , linux-kernel , x86 , Will Deacon Subject: Re: [PATCH v10 6/6] x86/split_lock: Enable split lock detection by kernel parameter Message-ID: <20191211184416.GA6344@agluck-desk2.amr.corp.intel.com> References: <3481175cbe14457a947f934343946d52@AcuMS.aculab.com> <20191121185303.GB199273@romley-ivt3.sc.intel.com> <20191121202508.GZ4097@hirez.programming.kicks-ass.net> <20191122092555.GA4097@hirez.programming.kicks-ass.net> <3908561D78D1C84285E8C5FCA982C28F7F4DD19F@ORSMSX115.amr.corp.intel.com> <20191122203105.GE2844@hirez.programming.kicks-ass.net> <20191211175202.GQ2827@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191211175202.GQ2827@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 11, 2019 at 06:52:02PM +0100, Peter Zijlstra wrote: > Sure, but we're talking two cpus here. > > u32 var = 0; > u8 *ptr = &var; > > CPU0 CPU1 > > xchg(ptr, 1) > > xchg((ptr+1, 1); > r = READ_ONCE(var); It looks like our current implementation of set_bit() would already run into this if some call sites for a particular bitmap `pass in constant bit positions (which get optimized to byte wide "orb") while others pass in a variable bit (which execute as 64-bit "bts"). I'm not a h/w architect ... but I've assumed that a LOCK operation on something contained entirely within a cache line gets its atomicity by keeping exclusive ownership of the cache line. Split lock happens because you can't keep ownership for two cache lines, so it gets escalated to a bus lock. -Tony