Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4125657ybv; Tue, 25 Feb 2020 13:43:35 -0800 (PST) X-Google-Smtp-Source: APXvYqx73cju77Zi9B3lqFRWKogRSKluklyIBkpeIrPPG4IcWPIyRMsuSep/EcchMC6IB5a71n5I X-Received: by 2002:a9d:6c9a:: with SMTP id c26mr465638otr.279.1582667014872; Tue, 25 Feb 2020 13:43:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582667014; cv=none; d=google.com; s=arc-20160816; b=mvCAEx3Leadr5GLtLYYq3xjUnDVBZyBlzeSKqGM4+tN/vmr6SUpnrEfLf8Amz49wQe QAkUQqgUz0y91onlHKpymMADb9K6zAmgBSaqGd9dscjLMNe1Y6mSvsiRIqgdWwG+yPok KQksvOuqHF9Pwdy2oDUhlDODtIxJXzdnOJz3CLHhdigCbyk2HMwbvKyvt0H9VM3A91sG kNRScFtAP48Hn+6yAr/Rfj62v+TXJ6awZUvkGN4a+RyXNzFVMdjbUe/cL9byvqcYhY2+ nbNRx1j4EhR5Aml8QhIqxNjt8GEMkCQC7MYqbPqN+fvGAYQYP4Wu2+MD7r1EOQMOs2OG YOGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=vXsk0xInkttyO1qJ3ZyvnQ0tVifCaVx5kh+Le+O0d3g=; b=Gwn/3YKH5O8k7sGXPiqkFHSdtyfIrqVgRApNJAri3MvVg8q2zdbrWWP5n9eewoxL/x oJ63emKLdhEAJkiBiGNUcpYAsVd0juQeu5RoaXWtehEYY+rBjFKb9TzPvlH+7C6ii2Ho 7gDfY6t6QMxxfKOoS+cNE1n/Xk1CPJsnfe7SapvETYYeWyRH3ET3pJfuI6scu0XkFYIF 45k5qJQ2cYAQ3rg89wF0l4PvX9Pz7hEY3+4LL1kTVPAXYp9ncvJFu1yYbRpB+HfVRfCA dUNKG6CBLIHMmGX+ncEEpKHAOe+KSn3foFvj/v5d7elLLJ8vz1TrNJDGJVcBrLVRPZws kCqw== 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 25si218765oiz.230.2020.02.25.13.43.22; Tue, 25 Feb 2020 13:43:34 -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; 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 S1727494AbgBYVmE (ORCPT + 99 others); Tue, 25 Feb 2020 16:42:04 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:39684 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726421AbgBYVmE (ORCPT ); Tue, 25 Feb 2020 16:42:04 -0500 Received: (qmail 6807 invoked by uid 2102); 25 Feb 2020 16:42:03 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 25 Feb 2020 16:42:03 -0500 Date: Tue, 25 Feb 2020 16:42:03 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Luc Maranget cc: Boqun Feng , Andrea Parri , Jade Alglave , "Paul E. McKenney" , Kernel development list Subject: More on reader-writer locks In-Reply-To: <20200225130102.wsz3bpyhjmcru7os@yquem.inria.fr> Message-ID: 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 Tue, 25 Feb 2020, Luc Maranget wrote: > Hi, > > As far as I can remember I have implemented atomic_add_unless in herd7. Luc, have you considered whether we can use atomic_add_unless and cmpxchg to implement reader-writer locks in the LKMM? I don't think we can handle them the same way we handle ordinary locks now. Let's say that a lock variable holds 0 if it is unlocked, -1 if it is write-locked, and a positive value if it is read-locked (the value is the number of read locks currently in effect). Then operations like write_lock, write_trylock, and so on could all be modeled using variants of atomic_add_unless, atomic_dec, and cmpxchg. But will that work if the reads-from relation is computed by the cat code in lock.cat? I suspect it won't. How would you approach this problem? Alan