Message ID | 20230922043616.19282-4-jstultz@google.com |
---|---|
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 h50csp5362741vqi; Thu, 21 Sep 2023 23:37:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfOcMJWpVQvQQgja5E7m/86ogN1KWCZwajJad6oTLcYj5FbuWOjeDQuj3hGAVrHcAnVjLr X-Received: by 2002:a05:6a20:1002:b0:141:d640:794a with SMTP id gs2-20020a056a20100200b00141d640794amr6336562pzc.39.1695364647557; Thu, 21 Sep 2023 23:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695364647; cv=none; d=google.com; s=arc-20160816; b=GdYIT8B59gXgn4aJq+x8FCx8fmEbdJz294heWpQjEErat/R5s2iiVgqgAfedvfEZmX lGqBWRS84Um6usS3/jiWCxByJErRuRHwpnsVdmx1Vdfl4usibMF5Ec/KvytFYJGFPm+F BLL5SUdcJsA5oIrlXPQ3eHb/PXBIfKLh6NYO7rs1n3oF4ws0+o8tE2+cNvdn/BDmwBHz ZMNYKq+Zn0e5vJSwsL0kmnP31frni27YJQMPAPAw4bJcFRWFJr+1FIuMFWy4hV2W8mXH 4gbqHOugQTEvD6gYShf3UwasZ9O1RNcw8u62PiosrahjJBx/CW95FVF5a1uY2+cCSYtb Kiyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=r/KUuuQt1wtLnvbtfLVYFf0YPn4pz5Wk+u9cse4uVUE=; fh=h0I7AnstzSufvu/Uf0OGAflSwr+eqswdQy7WNzoBG3k=; b=AYQ5LjvMXcGwX246nMs0BaO5fQHgJGlynQDNA7IWBqXy3gFhNHQorI6Ug6bAaxYaj9 Xnu1K9NBHjNlYkr3TchT2pTsOn9v+yNruxyY9SldnMXvuy8e6rVMRcrDk2IUDdm+vl3O tK8n6hx3mhj9/dmb5GiAvUPMCtCSQx7LcZO62VoWXELDGl5zwhjEP+CZ+56zFAu8OcJG sDTeOuI4d5YuNdhCU4yIuXN349Ta/br34/Cy4U3wxnHFKxcTmLI6tWn2gyyPhS19KWHX jfmajXChprKWDyrAkt6kfnywn/54PJTCr5pm+HBreuNxQ7nwiIOFMwrDVB5E0o3g+UCC 7KZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=g0DrD1J3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id d7-20020a17090ad98700b002680abd9398si3239765pjv.88.2023.09.21.23.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 23:37:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=g0DrD1J3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5FBEF853919A; Thu, 21 Sep 2023 21:36:52 -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 S230431AbjIVEgr (ORCPT <rfc822;chrisfriedt@gmail.com> + 30 others); Fri, 22 Sep 2023 00:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230248AbjIVEgg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 22 Sep 2023 00:36:36 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6770F192 for <linux-kernel@vger.kernel.org>; Thu, 21 Sep 2023 21:36:30 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id d2e1a72fcca58-690c2fec489so1666309b3a.2 for <linux-kernel@vger.kernel.org>; Thu, 21 Sep 2023 21:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695357390; x=1695962190; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=r/KUuuQt1wtLnvbtfLVYFf0YPn4pz5Wk+u9cse4uVUE=; b=g0DrD1J3I/aBzq1Qo1EPcvjmJzgMiJ7/EkxODsE9SfoSVZYfby0JdYQaQgapzAquBI MqQpezaUPoCRhxSkDEv0cqDG/zZSAENwct5dQ3kcOv51udpojGyZuvSQcePfPMk0st5S /DMEuRM2wVCZgTyRHn7cwbO8gFnjbhuOAuFmwO3P7kGPocjCnXApXX1kqykNoDW5km+o 7bvZxD2gsr1WhwFOo26L/mn3j3pzB4820BZIj8SpvU+C/Sb3l5x7UaL/It0yisa1QRsj JXk5GDF8iC7AXwu+tL4G3g/Ob77HOLlTD1skRkhz/JmilgpA7vKwH28A8bRLY4lQSvl8 tLIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695357390; x=1695962190; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=r/KUuuQt1wtLnvbtfLVYFf0YPn4pz5Wk+u9cse4uVUE=; b=Zk5TwSpS8IkexpdbsRmYHMald7app7AWG9tWIS/XrGySl2pzzsUBwtRnrMlPVz+Buw BnDkHGu8HWUD5XixNJDNOHGuPFRMj+DDqM8e9bfRWKg5m51aW4R7dBRy35u1T3u9xHz6 TKrbjCNI+D4FAKK/vR3Q4lS9jAOPlWsW10iFahnALpu8kplVsgaB7OaULPzqEGLcKMIi UWe2SF9e4noxv1jVMfQIgfIBiG3yFhtMMbSVGbIV+4Fa0jHy1dVRSWzzo0EoLwE98yTg bvFyR1d/SbzEs4hnq+aHacXD5qX2gQ1qO1Ojtiv0XncrC2guMORdfSb79KtUTZ4EIO2i D80w== X-Gm-Message-State: AOJu0YwB+bbnZzcTMfucM3RR/XeAmr7BN1BM7jWGakfDkbLVNe2KSoB5 hC0A5mAap6O9uhULn4xJTK2+kI2Gb04q030IvBelysmh0ln/8UzOCUZd1Zjux3D9u66Nu9e5wvX SIosWncvCF0AOrw5QAen7J7UKebg17JQL49E5qj+oCtWmdV9kR4SNFAY8T649yOH0Ip79bFg= X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a05:6a00:c91:b0:690:3793:17f9 with SMTP id a17-20020a056a000c9100b00690379317f9mr127074pfv.6.1695357389355; Thu, 21 Sep 2023 21:36:29 -0700 (PDT) Date: Fri, 22 Sep 2023 04:36:01 +0000 In-Reply-To: <20230922043616.19282-1-jstultz@google.com> Mime-Version: 1.0 References: <20230922043616.19282-1-jstultz@google.com> X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog Message-ID: <20230922043616.19282-4-jstultz@google.com> Subject: [PATCH 3/3] test-ww_mutex: Make sure we bail out instead of livelock From: John Stultz <jstultz@google.com> To: LKML <linux-kernel@vger.kernel.org> Cc: John Stultz <jstultz@google.com>, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>, Waiman Long <longman@redhat.com>, Boqun Feng <boqun.feng@gmail.com>, "Paul E . McKenney" <paulmck@kernel.org>, Joel Fernandes <joelaf@google.com>, Dietmar Eggemann <dietmar.eggemann@arm.com>, kernel-team@android.com, Li Zhijian <zhijianx.li@intel.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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]); Thu, 21 Sep 2023 21:36:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777718680675573543 X-GMAIL-MSGID: 1777718680675573543 |
Series |
Fixes for test-ww_mutex stress test
|
|
Commit Message
John Stultz
Sept. 22, 2023, 4:36 a.m. UTC
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/
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Will Deacon <will@kernel.org>
Cc: Waiman Long <longman@redhat.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: "Paul E . McKenney" <paulmck@kernel.org>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: kernel-team@android.com
Reported-by: Li Zhijian <zhijianx.li@intel.com>
Link: https://lore.kernel.org/lkml/895ef450-4fb3-5d29-a6ad-790657106a5a@intel.com/
Signed-off-by: John Stultz <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 358d66150426..78719e1ef1b1 100644 --- a/kernel/locking/test-ww_mutex.c +++ b/kernel/locking/test-ww_mutex.c @@ -465,17 +465,18 @@ static void stress_inorder_work(struct work_struct *work) 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);