Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp79021rdg; Tue, 10 Oct 2023 05:01:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzNkp6MVA3GTzgAzTFrHyPpHNb/+nz8FwWJXxytB4zDwfwH1w5X7Ze0mAylBBKKlF0GysQ X-Received: by 2002:a17:902:f682:b0:1c9:b785:bc50 with SMTP id l2-20020a170902f68200b001c9b785bc50mr1141912plg.47.1696939304070; Tue, 10 Oct 2023 05:01:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696939304; cv=none; d=google.com; s=arc-20160816; b=xfRfobPaEN82goqdSjzRxfb0NC4quYl4DyyR8GPMQgDEa0DDP/0z9D2/D7LUlk1nTs BR5M49tlpBeR5AOKn0EWoH/H+9JT5LwI62IyI1LyNxYPwg59CBrKXLsTmcBN0ASb4apu q21sBJDLKEgvrQEor96HzSZwdxCDvEt5n2meUhzdRqyXiFScZhtd3p3oBvQIu3D16hz+ E7UtY4PYrMxoFdBl7n5LEa6YTyZmLL/sXyBiFJQHztKBd91gGK508NmU/vZwcAPT3D2y yKvictnKdWUm6knsrUgjj/7mJtb1/oHGO7/mv7TnksOBhnlIoZ8lCv719r6YiCyVzVOp +/Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=L2iE0z8BbbmMkvAGCfakyBsmuTg01ifyb76TqSb3Vjk=; fh=9o1vzmbQvXEiiOZAoGEKGHmVR4Ieb6r+octdNZgYFWA=; b=eo9me3wunNAq485/93OIxlU+/rn42eE6zGb7xbK1hAdxsjbeqWKEU31ztF4xbtqbWY jWObcighHyEq71T6s4sgK9j4edYtWC7HBUPytPa55XaXL1BYDWVksE8MidHMU3J3dSUP OazZzBJgX/v8HNQnDbdDyUCz3Bx8oYj0goILi2+PpS272xaWLcytQcWvfyC+E6OAts4r eGxryk6Xn+q+rXZ1ICGfacWTScaA1lHiwRwAxRXFgF+aabFheceNsF1tHqsVHue55ktK 2hbF52K41Tdyeg9buyfW10HC1Q0zsUUEU2OWs3n2Y2vCfixARbjIxR4g+Xps3avO/rcz Oh9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F3s41Ps2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d8-20020a170902cec800b001c35864fdbbsi12598878plg.406.2023.10.10.05.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 05:01:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F3s41Ps2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 95199801E74D; Tue, 10 Oct 2023 05:01:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231654AbjJJMAn (ORCPT + 99 others); Tue, 10 Oct 2023 08:00:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231793AbjJJMA0 (ORCPT ); Tue, 10 Oct 2023 08:00:26 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09B99DA; Tue, 10 Oct 2023 05:00:05 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0773C433C7; Tue, 10 Oct 2023 12:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696939205; bh=z/6W7Sq91lXYiT+T8Ou3AD0oMBmwnQ8VicZ7CbcAyQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F3s41Ps24rSzylBKXRoRs6u5kl4sd3f8NZJIl5j5mVH5Gmqz50IGYmpv12lWlAIan fjA2A+cQQ6APRxtB6LiEJW6a7oOw5epFCfXB8lLYSSzp2JYhhQZt2QroGVjXkcMbQm febf1QkZU8CY1lwxKMIvLx3KlaifAIadxhaxlYF455QGYHHJ0j8YwFkpphSz6skX+B ffCQxP2N8CVjqzEPKd7wFcb2nKudj5JoE2gI4dw6ZbXarzLNYcUHwaLX/pDAadc9yC akasjg8jn+AAfK3oV/9fomzq+4OJmVdJ9fLtSLJXQbKULPVUg3q1fZTt4v/zh71uto rr2vO3+TPBcTg== From: Frederic Weisbecker To: LKML Cc: "Paul E. McKenney" , Boqun Feng , Joel Fernandes , Josh Triplett , Mathieu Desnoyers , Neeraj Upadhyay , Steven Rostedt , Uladzislau Rezki , rcu , Frederic Weisbecker Subject: [PATCH 11/23] locktorture: Add acq_writer_lim to complain about long acquistion times Date: Tue, 10 Oct 2023 13:59:09 +0200 Message-Id: <20231010115921.988766-12-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010115921.988766-1-frederic@kernel.org> References: <20231010115921.988766-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 10 Oct 2023 05:01:11 -0700 (PDT) X-Spam-Level: ** From: "Paul E. McKenney" This commit adds a locktorture.acq_writer_lim module parameter that specifies the maximum number of jiffies that is expected to be consumed by write-side lock acquisition. If this limit is exceeded, a WARN_ONCE() causes a splat. Note that this limit applies to the main lock acquisition only, not to any nested acquisitions. Signed-off-by: Paul E. McKenney Signed-off-by: Frederic Weisbecker --- kernel/locking/locktorture.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c index c8c322e69a90..296815ef67ae 100644 --- a/kernel/locking/locktorture.c +++ b/kernel/locking/locktorture.c @@ -33,6 +33,7 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Paul E. McKenney "); +torture_param(int, acq_writer_lim, 0, "Write_acquisition time limit (jiffies)."); torture_param(int, long_hold, 100, "Do occasional long hold of lock (ms), 0=disable"); torture_param(int, nested_locks, 0, "Number of nested locks (max = 8)"); torture_param(int, nreaders_stress, -1, "Number of read-locking stress-test threads"); @@ -852,11 +853,13 @@ static struct lock_torture_ops percpu_rwsem_lock_ops = { */ static int lock_torture_writer(void *arg) { - struct lock_stress_stats *lwsp = arg; - int tid = lwsp - cxt.lwsa; - DEFINE_TORTURE_RANDOM(rand); + unsigned long j; + unsigned long j1; u32 lockset_mask; + struct lock_stress_stats *lwsp = arg; + DEFINE_TORTURE_RANDOM(rand); bool skip_main_lock; + int tid = lwsp - cxt.lwsa; VERBOSE_TOROUT_STRING("lock_torture_writer task started"); if (!rt_task(current)) @@ -883,12 +886,20 @@ static int lock_torture_writer(void *arg) cxt.cur_ops->nested_lock(tid, lockset_mask); if (!skip_main_lock) { + if (acq_writer_lim > 0) + j = jiffies; cxt.cur_ops->writelock(tid); if (WARN_ON_ONCE(lock_is_write_held)) lwsp->n_lock_fail++; lock_is_write_held = true; if (WARN_ON_ONCE(atomic_read(&lock_is_read_held))) lwsp->n_lock_fail++; /* rare, but... */ + if (acq_writer_lim > 0) { + j1 = jiffies; + WARN_ONCE(time_after(j1, j + acq_writer_lim), + "%s: Lock acquisition took %lu jiffies.\n", + __func__, j1 - j); + } lwsp->n_lock_acquired++; cxt.cur_ops->write_delay(&rand); -- 2.34.1