Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4958679rdb; Fri, 15 Sep 2023 19:14:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnXS6oFiV5nJejTWOCZRh9TPGQzRZM3S6o3QdbEGutlYiKt6p91/NmJ15UvYAYV6MfHU2x X-Received: by 2002:a17:902:ab5d:b0:1c3:62c4:7f12 with SMTP id ij29-20020a170902ab5d00b001c362c47f12mr3222714plb.5.1694830496976; Fri, 15 Sep 2023 19:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694830496; cv=none; d=google.com; s=arc-20160816; b=XQ1UpvE+zBflfsLCgnm3bkaE2dh4C3sUmmazmw/Dw5kg2IxCIOaV/ntIqHg9NORf7P hW8DdKAGqDArhq9h/2iw+8te+m5R6FmBOMJ7EjW/rvUcoG1CKExRhNy/NpbnLXWZ6cIF TNNTVOQ2/1QGI9N2P09SxnyVzAQI73Ou25TLJJ3iu1OR8njFawfd3MpFaMrkcEB/cf33 9kInL7kymP1tY7/5RW9N3TLdbMOlJ66zIRKUfUzw3emhtpCGpzuXZ6fTzdmdw3Mdly9O y44sf3PDnVDHnMd6z3E+nQt1Jy5NUzx/z3WOSvsp6sHy6GNn4s05lXtomobQXJLjjXjs obcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=EepSFHCMYZW3HHl5l7+iK7+nAfFDmswP137z9WEz90s=; fh=LlV8Ntbqwce8J/PcLj0O4FdthsjIv5+B9rByn6MR7wo=; b=hCX5sVFwcjbalL8aDUZo3oKU9kMPciF2qb8tuHhify7xtNDmzs+VJRAiB+cbg75vvd IcnBKbggOTmxtsw9Y3rNZLTGao6k9MeQLNsDwu28HFvY59kF7pDoVTRQRwq7yPi1UzN3 rw3FrQqlnt7cb2KV0BmnZucpC6K7MOukUecuApsAxl0K9FXHVxFnofbYgOzOxNvaUNFV Gy5O0Z07MwEH7ya4LQl+7lWPTI0/sAvHYU/Frs/lblEkyHctekqRkPsfRKEURQX2iZT8 hKK+ONdrmV79KGiyBcRMlMeGL7o1n+8wi5XnmjGnbKvzOXIf9ZKTYv4OaQWzNk+IiSq6 eT+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="S9/HzAQO"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l10-20020a170903120a00b001b873b80747si4510503plh.39.2023.09.15.19.14.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 19:14:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="S9/HzAQO"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1F6C480FA9C7; Fri, 15 Sep 2023 12:00:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236912AbjIOTAW (ORCPT + 99 others); Fri, 15 Sep 2023 15:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236641AbjIOS7v (ORCPT ); Fri, 15 Sep 2023 14:59:51 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D80AD98 for ; Fri, 15 Sep 2023 11:59:46 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694804385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EepSFHCMYZW3HHl5l7+iK7+nAfFDmswP137z9WEz90s=; b=S9/HzAQOidxN9pRaf1uOk5lpHKA57YPJxEk2hnHGPah/eiRocG6JLckSuzD8XliL6zEoEU MvJ0AvUe+uZfBX3LBhq7WXy+KXUTH77Bmn28AWj8cviMstEJJFIM2mRf8uy+sC9+5VJMrm fKYPNCCYfmZewuz41h6qk0H5OfrWz7zXwUocuV2hweG/TQacspWMJw6SEJs64yj52kEA+8 LJByV20lRCPgc+IY/2yugCDYS1sZOqwT0UVyFBsSlqoL4tdJgkJ2I5iSdksVkmegXjj3GT xWVifckA/oGn7mb0NnBNuDp9DEJKDGU+R2Ua+8bx8cmIhaYBRMLFLNGq7/tmvQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694804385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EepSFHCMYZW3HHl5l7+iK7+nAfFDmswP137z9WEz90s=; b=JHNRSkDmPjMUVSBdvACZnUJYDTMoCwqcNb+u6exVB1QeiNywewrKaoS0AEeNUiQMt872gI v1/NrhgIheFMGXBw== To: Peter Zijlstra Cc: Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, boqun.feng@gmail.com, bristot@redhat.com, bsegall@google.com, dietmar.eggemann@arm.com, jstultz@google.com, juri.lelli@redhat.com, longman@redhat.com, mgorman@suse.de, mingo@redhat.com, rostedt@goodmis.org, swood@redhat.com, vincent.guittot@linaro.org, vschneid@redhat.com, will@kernel.org Subject: Re: [PATCH v3 7/7] locking/rtmutex: Acquire the hb lock via trylock after wait-proxylock. In-Reply-To: <20230915151943.GD6743@noisy.programming.kicks-ass.net> References: <20230908162254.999499-1-bigeasy@linutronix.de> <20230908162254.999499-8-bigeasy@linutronix.de> <20230911141135.GB9098@noisy.programming.kicks-ass.net> <87fs3f1tl0.ffs@tglx> <20230915151943.GD6743@noisy.programming.kicks-ass.net> Date: Fri, 15 Sep 2023 20:59:44 +0200 Message-ID: <877cor1cv3.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 12:00:50 -0700 (PDT) On Fri, Sep 15 2023 at 17:19, Peter Zijlstra wrote: > On Fri, Sep 15, 2023 at 02:58:35PM +0200, Thomas Gleixner wrote: > *However* the case at hand is where a waiter is leaving, in this case the race > means a waiter that is going away is not observed -- which is harmless, > provided this race is explicitly handled. > > This is a somewhat dangerous proposition because the converse race is not > observing a new waiter, which must absolutely not happen. But since the race is > valid this cannot be asserted. Correct. But adding a new waiter requires to hold hb::lock which _IS_ held by the unlocking code when it deals with the outgoing race. So I'm not too worried about it. > Signed-off-by: Peter Zijlstra (Intel) > /* > * If we failed to acquire the lock (deadlock/signal/timeout), we must > - * first acquire the hb->lock before removing the lock from the > - * rt_mutex waitqueue, such that we can keep the hb and rt_mutex wait > - * lists consistent. > + * must unwind the above, however we canont lock hb->lock because > + * rt_mutex already has a waiter enqueued and hb->lock can itself try > + * and enqueue an rt_waiter through rtlock. > + * > + * Doing the cleanup without holding hb->lock can cause inconsistent > + * state between hb and pi_state, but only in the direction of not > + * seeing a waiter that is leaving. > + * > + * See futex_unlock_pi(), it deals with this inconsistency. > + * > + * There be dragons here, since we must deal with the inconsistency on > + * the way out (here), it is impossible to detect/warn about the race > + * the other way around (missing an incoming waiter). > * > - * In particular; it is important that futex_unlock_pi() can not > - * observe this inconsistency. > + * What could possibly go wrong... If some code in the future tries to enqueue a waiter w/o holding hb::lock then this corner case will be the least of our worries. There are tons of other things which will insta go south. Reviewed-by: Thomas Gleixner