Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2724954rdb; Fri, 22 Sep 2023 06:56:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFlvX+XwafOOefLgktgefyIE7LHoYHoO12DxraExhHRt6TEISeU+LV3xfcp7VAqfz5WcwBU X-Received: by 2002:a05:6808:1527:b0:3a3:9df9:1928 with SMTP id u39-20020a056808152700b003a39df91928mr10204591oiw.17.1695391006379; Fri, 22 Sep 2023 06:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695391006; cv=none; d=google.com; s=arc-20160816; b=zF1VEBPko4kbMk6FRszm/jfQdQMXKjGzlUsr/2URl4VJx3LKQSCYdsdvJFHvy6VycD S+0+IqTBo45bmNdjoG8oOpmVRAy0OZGIFcJM7wmBzlX/u7Rd2eM42sb6QFkitIED5tr7 ql/9xBKXDB1zRD5/8tAHfabliTvKz37OG4a62SusAcTDR4Ei5GIWX/OGVsnFFoA3hXh2 cqVi/6iQ4gzRd19/zQfK7oPGw64tnI9IevHP+auE8zjya0ebHY1N5xTLZlcH6T/2B7i7 YUFDyUpBXQ+oKQtp6hk5FGVB2VgZu6g41ctSKEeoiqj2WRti2HEAAPUOHob/XL+IC03h cfKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=geNEPFvjv2X0tF060Xkd/gkYK1ZYVMX72QmM0tmt0Sg=; fh=RQUj1JUmwqsjfBhDyPQn+Ce/NWuV3XoUDdza5wVOCdQ=; b=JeM0uj/FRS/o7ICeCeAXHm+v176JBcZeI3fo+zK8GzcdwCXdU76dktuqc2pf037N8j mAF041ToSko0aybkT1A2WzTP0MJXeeMT/8PqmlpX5aaqKAEzOgaCjuMIqZ9BStSf3Run v9hPEx016LrPdzkjvFk/12E2SVxNGO1R++7D9WQiit2szLxNI/rnSsnLW0+QjCGHhHp+ fPvCPC0KMM5vlFFbXMBdNEj0SLPRsht9nQkbz1MP4xEM/Ra9aL4JMaZ/hchv05bttzes lOJs+hnkTt761FjdaefMRUzJmMu2s7zD4HkoimSFFJqwJHnbKj6UOBPOyKNpndKQKHU7 qDPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4t2Ml+6m; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=tYkk6tq4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id g20-20020a056a001a1400b00690208f6d56si4025773pfv.340.2023.09.22.06.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 06:56:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4t2Ml+6m; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=tYkk6tq4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 8B5FC835A3B4; Fri, 22 Sep 2023 01:12:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232572AbjIVIMF (ORCPT + 99 others); Fri, 22 Sep 2023 04:12:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232489AbjIVILq (ORCPT ); Fri, 22 Sep 2023 04:11:46 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03E57E61; Fri, 22 Sep 2023 01:11:39 -0700 (PDT) Date: Fri, 22 Sep 2023 08:11:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695370297; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=geNEPFvjv2X0tF060Xkd/gkYK1ZYVMX72QmM0tmt0Sg=; b=4t2Ml+6ms+YGiUdMNzCyd1HU3b5svpkAez+g7/WPUDmvni39qBn1siGeS/Nim+C4crgOoe NUSPim8FcBUwhQvA4DqZEWA4K7Ren3uD/SgfyoDt4n3FspcIJ7lthp3ALw7Hn4m4DSx2/J m2YiNjJGURK09bXUEVmHGLFBTyYDIfPS6psJJZYSLVQxjHzRkEwFOWQa/fu1fA2lv5Z+38 yYlFfsYzkEDui6SlGKIqW1TwpIMfByj6G20v1ZVRw5SyLsQ/SJyuv8u4ax+JblfjTdohIT qvMC4Q2DdI5WpMfIhkZF4dJMfge+AKyaQf3z420GJI/Eqhk9AO6IDC6UabESAQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695370297; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=geNEPFvjv2X0tF060Xkd/gkYK1ZYVMX72QmM0tmt0Sg=; b=tYkk6tq4bBwOXxiWGlFsM6p7E46uo1bNvu6Aw+IwIc9s6KcYwjGbO+B30kOiEUPunG9VwP IvMMBL0hIr4emvDQ== From: "tip-bot2 for John Stultz" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] locking/ww_mutex/test: Make sure we bail out instead of livelock Cc: Li Zhijian , John Stultz , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230922043616.19282-4-jstultz@google.com> References: <20230922043616.19282-4-jstultz@google.com> MIME-Version: 1.0 Message-ID: <169537029684.27769.17114350620697997504.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Fri, 22 Sep 2023 01:12:11 -0700 (PDT) The following commit has been merged into the locking/core branch of tip: Commit-ID: cfa92b6d52071aaa8f27d21affdcb14e7448fbc1 Gitweb: https://git.kernel.org/tip/cfa92b6d52071aaa8f27d21affdcb14e7448fbc1 Author: John Stultz AuthorDate: Fri, 22 Sep 2023 04:36:01 Committer: Ingo Molnar CommitterDate: Fri, 22 Sep 2023 09:43:41 +02:00 locking/ww_mutex/test: Make sure we bail out instead of livelock I've seen what appears to be livelocks in the stress_inorder_work() function, and looking at the code it is clear we can have a case where we continually retry acquiring the locks and never check to see if we have passed the specified timeout. This patch reworks that function so we always check the timeout before iterating through the loop again. I believe others may have hit this previously here: https://lore.kernel.org/lkml/895ef450-4fb3-5d29-a6ad-790657106a5a@intel.com/ Reported-by: Li Zhijian Signed-off-by: John Stultz Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20230922043616.19282-4-jstultz@google.com --- kernel/locking/test-ww_mutex.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c index 358d661..78719e1 100644 --- a/kernel/locking/test-ww_mutex.c +++ b/kernel/locking/test-ww_mutex.c @@ -465,17 +465,18 @@ retry: ww_mutex_unlock(&locks[order[n]]); if (err == -EDEADLK) { - ww_mutex_lock_slow(&locks[order[contended]], &ctx); - goto retry; + if (!time_after(jiffies, stress->timeout)) { + ww_mutex_lock_slow(&locks[order[contended]], &ctx); + goto retry; + } } + ww_acquire_fini(&ctx); if (err) { pr_err_once("stress (%s) failed with %d\n", __func__, err); break; } - - ww_acquire_fini(&ctx); } while (!time_after(jiffies, stress->timeout)); kfree(order);