Received: by 2002:a05:7412:85a1:b0:e2:908c:2ebd with SMTP id n33csp42907rdh; Mon, 30 Oct 2023 13:12:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2WR0qE/9GV99Lz1N0lKwRULHjseoekZufz2iMwt6dTBf+hOxWsLFzYCCzcgnPiG9N8LMu X-Received: by 2002:a17:90a:678f:b0:280:414d:7a64 with SMTP id o15-20020a17090a678f00b00280414d7a64mr3366582pjj.11.1698696720723; Mon, 30 Oct 2023 13:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698696720; cv=none; d=google.com; s=arc-20160816; b=T+KZ6LG6u4m4qIGcnsMZRRSst51y+yEx3YlcY5aZEp++RhZWmw8qf9s7zjwIT52z44 fGemAOoU7xu1qZjxII0OpvlUU8+yRPNRI9R7A+fEj9/X94dAiSqbvNahtj3PW+LJOUeO Vbia0/VDmbMsTM6ng/vysH2WCG259giYoRO+WdNF3HRT4xv/GtD7uA+mtEVmZWD6OyFH 822cJNc7QqJ/2Rum7jUwqwkTSgqky/YBwJUZ0wFtYLfCYQIxRH0ikY3UZE06SOhFtKOx 53z5rC6h8zFDcyDn4DqQ9ocDwDThgorjQ4xFg+jZTDA5DVGwO/9BVQmO1h6zmyOQe1Lj 2xpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Ph/OcsghE6eIdH9Kx7XtoJPjsPZiMbGgNe+IqQSRGTg=; fh=otInkNaWWxGa9jTskILH8UfKagcq7+MvPSlbUHMhSNU=; b=WpifMlD4Wx8nQFqFgsBj/4iltpToVVJhm3s+PKt4h3ifVmGQBAw28GfDBRcveNzJuo dXRrdHqbu+TJxdSCX4aT/wCyZ2JigRX84LGasY1HZJ2gLXKB9QSesM63kiY1GLKuLiYG iXvq2Mbw9GDuBvB7fPn1FNehDfHXbiWWNhJ1ogSSwSrwr158wu+p/CPyXWUCGizktbhN ATB9aggyDbCA5FqG3ipmTDKdRFZXCGPeYX40fXfWUz/LiBbZWZeVp4hGt54lynxIVC5X auk3gMGTUFkmXiQUp1UIpB0GZeGprUG2CkwNCAeogvTmx7r8csdpX/GxbMYj/Dabx0+s 1itw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J2J8gyme; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ct14-20020a17090af58e00b00263f3c1bb86si5331771pjb.158.2023.10.30.13.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 13:12:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J2J8gyme; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 66D93809FED4; Mon, 30 Oct 2023 13:11:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbjJ3ULq (ORCPT + 99 others); Mon, 30 Oct 2023 16:11:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229616AbjJ3ULo (ORCPT ); Mon, 30 Oct 2023 16:11:44 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AAF2D3; Mon, 30 Oct 2023 13:11:42 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0739DC433C8; Mon, 30 Oct 2023 20:11:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698696702; bh=MKXkpWtKRAzxJ/2VbWDO/dJ5fbKLGEFRwo46utBR/yA=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=J2J8gymeVNMF+hW4edUc+9QdN2jIzBlmdKS80aqogRD7JYId+2ICMFcVbPNe+iT0x HMG+Eh6lyd86pqjgRkc5d0s8OIYlYOoy9C/8RuqcLvZcH7/3pACRjPJ9SEBOqPUvk0 CiqzQkX1wyzmqNF/IVkUHcpM4S4oS0JW83gKYJKAAjzvtvS603hKhbqLq9Yd0Q9qqo XxhQl11w/v/9Ks8hEQbjn0/b7FrVJtxq3Xi1PIt2i8KChBXaGZyZygOCyTKfxwj8OS MFWunIjEdO/q4avNNowgWPLb0eggLQpfLE3Upc/B0r02N+TeVgANpPISFXU32vb0D8 RKVtfMp/mKreQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 9D844CE0BDD; Mon, 30 Oct 2023 13:11:41 -0700 (PDT) Date: Mon, 30 Oct 2023 13:11:41 -0700 From: "Paul E. McKenney" To: Peter Zijlstra Cc: Frederic Weisbecker , LKML , Boqun Feng , Joel Fernandes , Josh Triplett , Mathieu Desnoyers , Neeraj Upadhyay , Steven Rostedt , Uladzislau Rezki , rcu , Zqiang , "Liam R . Howlett" Subject: Re: [PATCH 2/4] rcu/tasks: Handle new PF_IDLE semantics Message-ID: <622438a5-4d20-4bc9-86b9-f3de55ca6cda@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20231027144050.110601-1-frederic@kernel.org> <20231027144050.110601-3-frederic@kernel.org> <20231027192026.GG26550@noisy.programming.kicks-ass.net> <2a0d52a5-5c28-498a-8df7-789f020e36ed@paulmck-laptop> <20231027224628.GI26550@noisy.programming.kicks-ass.net> <200c57ce-90a7-418b-9527-602dbf64231f@paulmck-laptop> <20231030082138.GJ26550@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231030082138.GJ26550@noisy.programming.kicks-ass.net> X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 30 Oct 2023 13:11:58 -0700 (PDT) On Mon, Oct 30, 2023 at 09:21:38AM +0100, Peter Zijlstra wrote: > On Fri, Oct 27, 2023 at 04:41:30PM -0700, Paul E. McKenney wrote: > > On Sat, Oct 28, 2023 at 12:46:28AM +0200, Peter Zijlstra wrote: > > > > Nah, this is more or less what I feared. I just worry people will come > > > around and put WRITE_ONCE() on the other end. I don't think that'll buy > > > us much. Nor do I think the current READ_ONCE()s actually matter. > > > > My friend, you trust compilers more than I ever will. ;-) > > Well, we only use the values {0,1,2}, that's contained in the first > byte. Are we saying compiler will not only byte-split but also > bit-split the loads? > > But again, lacking the WRITE_ONCE() counterpart, this READ_ONCE() isn't > getting you anything, and if you really worried about it, shouldn't you > have proposed a patch making it all WRITE_ONCE() back when you did this > tasks-rcu stuff? There are not all that many of them. If such a WRITE_ONCE() patch would be welcome, I would be happy to put it together. > > > But perhaps put a comment there, that we don't care for the races and > > > only need to observe a 0 once or something. > > > > There are these two passagers in the big lock comment preceding the > > RCU Tasks code: > > > // rcu_tasks_pregp_step(): > > // Invokes synchronize_rcu() in order to wait for all in-flight > > // t->on_rq and t->nvcsw transitions to complete. This works because > > // all such transitions are carried out with interrupts disabled. > > > Does that suffice, or should we add more? > > Probably sufficient. If one were to have used the search option :-) > > Anyway, this brings me to nvcsw, exact same problem there, except > possibly worse, because now we actually do care about the full word. > > No WRITE_ONCE() write side, so the READ_ONCE() don't help against > store-tearing (however unlikely that actually is in this case). Again, if such a WRITE_ONCE() patch would be welcome, I would be happy to put it together. > Also, I'm not entirely sure I see why you need on_rq and nvcsw. Would > not nvcsw increasing be enough to know it passed through a quiescent > state? Are you trying to say that if nvcsw hasn't advanced but on_rq is > still 0, nothing has changed and you can proceed? > > Or rather, looking at the code it seems use the inverse, if on_rq, nvcsw > must change. > > Makes sense I suppose, no point waiting for nvcsw to change if the task > never did anything. Exactly, the on_rq check is needed to avoid excessively long grace periods for tasks that are blocked for long periods of time. Thanx, Paul