Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E11AC61DA4 for ; Sat, 18 Feb 2023 06:14:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbjBRGOP (ORCPT ); Sat, 18 Feb 2023 01:14:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229520AbjBRGOO (ORCPT ); Sat, 18 Feb 2023 01:14:14 -0500 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99F925454E for ; Fri, 17 Feb 2023 22:14:12 -0800 (PST) Received: by mail-lj1-x236.google.com with SMTP id n4so64235ljq.3 for ; Fri, 17 Feb 2023 22:14:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=M9meo/2HsyQjWTOLBePu8gQ8aMOImbRjLtTEkBnxFWA=; b=rNW4pWyLBgZAXvqJjvCoQS8lk2lmt0bpvLoQdrZ4JtZt7F/xLQANfMR03xhYfnh+h2 rmKCOP/qyMs+J36NL88QnT7nLTcqAAMfUbpj9E0xe3jdJKKjcCQ++dD7IBc/gnmYd8Ln WROBH3wQ8mnvc2t6fvC/87NGLDoo+sxFiJiaE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=M9meo/2HsyQjWTOLBePu8gQ8aMOImbRjLtTEkBnxFWA=; b=oSbaFhT+z9md4TUOHRqMoOumdY5IXGRvQirGJVyUXIEKADgcWUEE9HwXq6x+coZ6D0 jqF38r00g13Ti71zQDGzI1lm99sEqLB+OnLUsA7c7x066MxF3tzCeOVBVuS3lmfR70FI TVfofFqnaSzIQO2fmp8OxoBKKVI7xv83/ESeDgHUNFGY/BvguvJjQIGO+IMNR61ja/3c zJHDW7QAglgcDjgDa96MlO8n/zFC2UMwivJqB+G+vdae/ugPzRd/yi2mGh6+vYuLWHO7 AHzZOIdIl4jmF94kPdDXAHCyKcpXVCezbb5hCRLts8XjEvzrUXK4eLtVvFethABnxNfC ZS6w== X-Gm-Message-State: AO0yUKU7x6osYhueyscc0aUDIiOZnzjw7uKrkR6eFFqgflXvGGQh6bpn jhoJJ7BOfuT8FjuQ1sY+NdBnrOj7tnAJardkb0eWQGS0JfA42sNb X-Google-Smtp-Source: AK7set/q4K2z6T8tTM3H+wXeDE+gFiACy9O/yEXPJeOfHZ8S48WmuHxW5F7bIDV9xIb0GRZIxHoXzwQbijx97x4nEzs= X-Received: by 2002:a05:651c:1688:b0:293:4647:364a with SMTP id bd8-20020a05651c168800b002934647364amr1066205ljb.3.1676700850733; Fri, 17 Feb 2023 22:14:10 -0800 (PST) MIME-Version: 1.0 References: <20230204004843.GA2677518@paulmck-ThinkPad-P17-Gen-1> <20230204014941.GS2948950@paulmck-ThinkPad-P17-Gen-1> <20230204222411.GC2948950@paulmck-ThinkPad-P17-Gen-1> In-Reply-To: From: Joel Fernandes Date: Sat, 18 Feb 2023 01:13:59 -0500 Message-ID: Subject: Re: Current LKMM patch disposition To: Alan Stern Cc: "Paul E. McKenney" , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-team@meta.com, mingo@kernel.org, parri.andrea@gmail.com, will@kernel.org, peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alan, On Sat, Feb 11, 2023 at 9:59 PM Alan Stern wrote: > [...] > > Would you like to post a few examples showing some of the most difficult > points you encountered? Maybe explanation.txt can be improved. One additional feedback I wanted to mention, regarding this paragraph under "WARNING": =========== The protections provided by READ_ONCE(), WRITE_ONCE(), and others are not perfect; and under some circumstances it is possible for the compiler to undermine the memory model. Here is an example. Suppose both branches of an "if" statement store the same value to the same location: r1 = READ_ONCE(x); if (r1) { WRITE_ONCE(y, 2); ... /* do something */ } else { WRITE_ONCE(y, 2); ... /* do something else */ } =========== I tried lots of different compilers with varying degrees of optimization, in all cases I find that the conditional instruction always appears in program order before the stores inside the body of the conditional. So I am not sure if this is really a valid concern on current compilers, if not - could you provide an example of a compiler and options that cause it? In any case, if it is a theoretical concern, it could be clarified that this is a theoretical possibility in the text. And if it is a real/practical concern, then it could be mentioned the specific compiler/arch this was seen in. Thanks! - Joel > > > > I'm not sure that breaking this relation up into pieces will make it any > > > easier to understand. > > > > Yes, but I tried. I will keep trying to understand your last patch > > more. Especially I am still not sure, why in the case of an SRCU > > reader on a single CPU, the following does not work: > > let srcu-rscs = ([Srcu-lock]; data; [Srcu-unlock]). > > You have to understand that herd7 does not track dependencies through > stores and subsequent loads. That is, if you have something like: > > r1 = READ_ONCE(*x); > WRITE_ONCE(*y, r1); > r2 = READ_ONCE(*y); > WRITE_ONCE(*z, r2); > > then herd7 will realize that the write to y depends on the value read > from x, and it will realize that the write to z depends on the value > read from y. But it will not realize that the write to z depends on the > value read from x; it loses track of that dependency because of the > intervening store/load from y. > > More to the point, if you have: > > r1 = srcu_read_lock(lock); > WRITE_ONCE(*y, r1); > r2 = READ_ONCE(*y); > srcu_read_unlock(lock, r2); > > then herd7 will not realize that the value of r2 depends on the value of > r1. So there will be no data dependency from the srcu_read_lock() to > the srcu_read_unlock(). > > Alan