[tip:,locking/core] locking/ww_mutex/test: Make sure we bail out instead of livelock
Message ID | 169537029684.27769.17114350620697997504.tip-bot2@tip-bot2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5661226vqi; Fri, 22 Sep 2023 08:21:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMzj/xNSkrKMDZDRCz4XZ0nw3w4nH0eDTEzTtnAymCECgbmG3cNVFhHuLUw8fYEHoBo+9z X-Received: by 2002:a05:6a00:23d3:b0:690:c1e5:937e with SMTP id g19-20020a056a0023d300b00690c1e5937emr9482494pfc.13.1695396118008; Fri, 22 Sep 2023 08:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695396117; cv=none; d=google.com; s=arc-20160816; b=Alj0w9zaAkst98zLecAnTq/ZkU9zAfxFYZ5/F8MVv7HmGfVsxE42drvv3MMuKM1oKH WylnIu513xxb+qWxV3zKkbmYdHcdimGjPjtWHHVOj/6PmPGqHERFix0bMw6fzsz5Az8u da37OoOCwjSYAP0UbvC17ZVfd3gih+YLytRfRHkF6UzLeYrHny804+KintVXpN0ELdEC IwGOh3wnBY0k4f8bYeqk5mIjha+FwhdYBaoCKBOvbI0ODgGfxtLEroa7VjdlULM/2nMt YtkKgxJM3uPNfiOVSEFTzTNsn5wYilzXdiVuScGBuBShZautU/UO5Peq78keLGjL4/VQ U3Vw== 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ei42-20020a056a0080ea00b00690c6da95c4si3769299pfb.273.2023.09.22.08.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 08:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 2603C8317E85; Fri, 22 Sep 2023 01:12:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232577AbjIVIMG (ORCPT <rfc822;chrisfriedt@gmail.com> + 30 others); Fri, 22 Sep 2023 04:12:06 -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 <rfc822;linux-kernel@vger.kernel.org>); 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" <tip-bot2@linutronix.de> 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 <zhijianx.li@intel.com>, John Stultz <jstultz@google.com>, Ingo Molnar <mingo@kernel.org>, 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: <tip-bot2@linutronix.de> Robot-Unsubscribe: Contact <mailto:tglx@linutronix.de> to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 01:12:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777751679608309843 X-GMAIL-MSGID: 1777751679608309843 |
Series |
[tip:,locking/core] locking/ww_mutex/test: Make sure we bail out instead of livelock
|
|
Commit Message
tip-bot2 for Thomas Gleixner
Sept. 22, 2023, 8:11 a.m. UTC
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 <jstultz@google.com> AuthorDate: Fri, 22 Sep 2023 04:36:01 Committer: Ingo Molnar <mingo@kernel.org> 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 <zhijianx.li@intel.com> Signed-off-by: John Stultz <jstultz@google.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> 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);