Received: by 10.223.185.116 with SMTP id b49csp3971172wrg; Mon, 26 Feb 2018 09:02:39 -0800 (PST) X-Google-Smtp-Source: AH8x225QRXqOjWSviNOUAgUkRmVplTZ1vGoJQm5o9zjuaLg5Ib6xdSyZcCk3XLCTKIZJ9G9+h1ls X-Received: by 10.99.63.9 with SMTP id m9mr9245926pga.247.1519664559657; Mon, 26 Feb 2018 09:02:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519664559; cv=none; d=google.com; s=arc-20160816; b=ofrwMi3c53yWBB9DoblVw2Z4QU2tR1zhBpCWS95PkACuMLxSIgnSVy6P/VEW5s+S/C EEKjvFdkzrGlQRhs1adcUjqnOXHcgZ+qksrwSRXtAWDfWCy2Xbe5YlA2WJ1Ho6cN4gFi 2aXe+X7+D7rRKOhgKyTh9beU9+rZ1mtUfNo2ZhkdwYAQ2BA2psIaCdVsi2Wh/Uhq1TQg tJJvC2HdNA6tfPzDEQrtKpb7FTSyTsTAVb5Nmr6aYy0q59jsYGOFXy8Gd4BTWUFN+7tf HbtMXUiOUmu0juYzpzn9r+Koz81pOYqdMZw9Weg4S+jJzEl7U9Ug+9YblXXKm6dp5odS 3qig== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=2XR3ejJfPZ4N6OCi4jDOxNGbUuy+hv4vJemcIj4+O/8=; b=qT5pUy3asF/Cj11kCsoyY+YH/a/+cGTvYvkIFxlLuhTKiLO7KhILYX6d4311ZMWIv6 fxrvtptTZaTDP1TzZId67/a72eZEG3ZtxnpDaw5CHnTsiE0vz6AtS3uxWe46LCBQgZyU BlYX6vGH4lX6Xb9WhqMr2ma1m9FBiBZIYL3V4cek9Gtw6oopRj+0Krp/XHWxkndFYyca p2f9TLtUD90KQNCzLy4PDfBP63h/5qLN5DKutGh2RBhL10rux031mPIpJnKkKyhmOIN/ XbsNlPnwvfuKHv+8NTUl7NrB3WSb8AnTIzGtHpbXCiNJ3Z9rPeo1eq2iGc9xeilJ+AuF ReIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ckXtrDkX; 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 c129si7000831pfa.362.2018.02.26.09.02.04; Mon, 26 Feb 2018 09:02:39 -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=ckXtrDkX; 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 S1751463AbeBZRAq (ORCPT + 99 others); Mon, 26 Feb 2018 12:00:46 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:40747 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750767AbeBZRAp (ORCPT ); Mon, 26 Feb 2018 12:00:45 -0500 Received: by mail-io0-f193.google.com with SMTP id v6so16832968iog.7 for ; Mon, 26 Feb 2018 09:00:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=2XR3ejJfPZ4N6OCi4jDOxNGbUuy+hv4vJemcIj4+O/8=; b=ckXtrDkX7N5RPEa3ARrMHVZ4twX3QJQ/5OU0mroqYZC1SRwSdliMqx0sJS4qOIE+Bw dgm6dt3rDcxkUExaZ0Rhi7Xe4D/mU13gmCQkn2a3e6Ow66xlxwgAZ2QBR/AoC2K+JVOy Np1wmDgLlM2G14eQcq+wK+QWOiOGZqPKXqcS1vtjOjIs+s4bUedSnoKsxn+OirDvZK07 vHdd2YnMysO16ZaiuTVpILjKHt2M331JsOiY2lT10gc9huNzfIwE6+r+l/hxXx+iz7K7 aHBVFOIFW/4wnrM7ERVrapVWviXOrz098vTigjVe34lYrTTIGYNe1qDF2Tjt2TqIn408 RmMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=2XR3ejJfPZ4N6OCi4jDOxNGbUuy+hv4vJemcIj4+O/8=; b=uDcMZIBF0caDqQK7h5dwdCWdokJYL/eL4evkGH4nZksVUFRGH84bcIlxY8v7NeMO5r HXBMb7FO3ANdUsEwF8cvyb+BZDzYuGvlYX/0oTGNw6/tMorkm+TDY123Eb6CcsTa5zCa hJGAH/Eiku/N56pT1gO94lNcbepS/TXh1mtD8FIBXVkkqcqtRCJm1n/RrTQfCV/WySoZ 4EbntcFHV3nCBCFi+v3X6B8wUbA5VsapG2hJg4y1P5zg7qDpzR2IXVzw3TdC6JY9Wi43 QLo5Y4DbCeaMKg82bjtPDwRwq8kX/ofoMdo83K2bbSKZ2FOiw5zdhgPiePgvw2Z1BTdM x6Kg== X-Gm-Message-State: APf1xPBtNDlkC0lEwLKpyizhwDn0fxzyE8ejf+RV2QblGbqcikn7KvhA kx8X1Yib+9Vk1/Rz54t2yrb5u0mPiZat4zu6vnA= X-Received: by 10.107.12.213 with SMTP id 82mr12414114iom.48.1519664444234; Mon, 26 Feb 2018 09:00:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.135.221 with HTTP; Mon, 26 Feb 2018 09:00:43 -0800 (PST) In-Reply-To: <20180226162426.GB17158@arm.com> References: <1519301990-11766-1-git-send-email-parri.andrea@gmail.com> <20180222134004.GN25181@hirez.programming.kicks-ass.net> <20180222141249.GA14033@andrea> <82beae6a-2589-6136-b563-3946d7c4fc60@nvidia.com> <20180222181317.GI2855@linux.vnet.ibm.com> <20180222182717.GS25181@hirez.programming.kicks-ass.net> <563431d0-4fb5-9efd-c393-83cc5197e934@nvidia.com> <20180226142107.uid5vtv5r7zbso33@yquem.inria.fr> <20180226162426.GB17158@arm.com> From: Linus Torvalds Date: Mon, 26 Feb 2018 09:00:43 -0800 X-Google-Sender-Auth: 7iIGf982YrN04alRJSl1OUEuFWQ Message-ID: Subject: Re: [RFC PATCH] riscv/locking: Strengthen spin_lock() and spin_unlock() To: Will Deacon Cc: Luc Maranget , Daniel Lustig , Peter Zijlstra , "Paul E. McKenney" , Andrea Parri , Linux Kernel Mailing List , Palmer Dabbelt , Albert Ou , Alan Stern , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Akira Yokosawa , Ingo Molnar , linux-riscv@lists.infradead.org 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, Feb 26, 2018 at 8:24 AM, Will Deacon wrote: > > Strictly speaking, that's not what we've got implemented on arm64: only > the read part of the RmW has Acquire semantics, but there is a total > order on the lock/unlock operations for the lock. Hmm. I thought we had exactly that bug on some architecture with the queued spinlocks, and people decided it was wrong. But it's possible that I mis-remember, and that we decided it was ok after all. > spin_lock(&lock); > WRITE_ONCE(foo, 42); > > then another CPU could do: > > if (smp_load_acquire(&foo) == 42) > BUG_ON(!spin_is_locked(&lock)); > > and that could fire. Is that relied on somewhere? I have a distinct memory that we said the spinlock write is seen in order, wrt the writes inside the spinlock, and the reason was something very similar to the above, except that "spin_is_locked()" was about our spin_unlock_wait(). Because we had something very much like the above in the exit path, where we would look at some state and do "spin_unlock_wait()" and expect to be guaranteed to be the last user after that. But a few months ago we obviously got rid of spin_unlock_wait exactly because people were worried about the semantics. So maybe I just remember an older issue that simply became a non-issue with that. Linus