Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3422814rwb; Mon, 3 Oct 2022 15:00:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7rrkJgHsf7uRmuaTP9qa7Jztlyo5oWCVebST/v4V3+N8qG5x/x/2WJskcPxBOsP9edfpfI X-Received: by 2002:a17:902:a5c5:b0:17f:6c95:88e8 with SMTP id t5-20020a170902a5c500b0017f6c9588e8mr2782571plq.64.1664834435364; Mon, 03 Oct 2022 15:00:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664834435; cv=none; d=google.com; s=arc-20160816; b=H8chvZFLoXxA/WK6buLBrsE2lw5lRLs5p5WXd3eShvDW+QSokTBR/YJhtlLqvTxE5y QPT0m3Sc/thBsQIlertoNoWj8QfY9OKlFaW9gtrfdkKHfK4IYYy8AAUBk3h3Ja/LO6bp tvfx0CmPSZDv4SJ/899Tg3UpmERJ+d5LoPiHOZVzxRE5zboYt/q1q03cJRDF0kXY+aLB BwhbUSSZepkq8x4hqbFrO6nVzyFy+OWuc8P5aqkBSCLE8dgmAt0FNK+aF0Hp1cO4a61C 9M48Jxc+5jSgi6FDoxOIY8JfWLZPqs+Q1N3t1V6yvJx3EqaK5qP3gQFRh0s3rBzB4Oze vAWw== 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=wyqNJEpK8hc99eBxWvCga97s0cP9TToGQQczW693ZQg=; b=YkNuGoZ8wot/ksh7C2fGfBr50dYRlOx5FPCZ0Ydt+e6p4QMpn88bl6NRWxy6CIEW2e dbL4jRWh0CYIcW567Cp4+FfmX4YQGY4gq2QdFqYBVuC1MCiL0uEWz7wAq5I4EJQAM+45 H5hD3BZwhxQlP4Ui87iu5GB6YhjRcwx/CIIYUcIQF2Rhm4C72qLhC8OPMu1EqDxBKP3a heI6sud9D872SJb/DnAeXd8FwzLOF9Rnjq+K8AGQaBzbSQ6Z9dp6Xzz0jg0jMgp6nLLM TUd8AiqiAjdKrxIBVy1GGt786H+hMyJlajoByrmXigxz9w2AjH9JouggpHAaoBEwEycK V8Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=h8czXoK2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a170902eac400b001785c39497esi11160913pld.410.2022.10.03.15.00.23; Mon, 03 Oct 2022 15:00:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=h8czXoK2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230104AbiJCVqa (ORCPT + 99 others); Mon, 3 Oct 2022 17:46:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbiJCVqC (ORCPT ); Mon, 3 Oct 2022 17:46:02 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69B0A20BF5 for ; Mon, 3 Oct 2022 14:45:24 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id y16-20020a17090aa41000b001fdf0a76a4eso5057821pjp.3 for ; Mon, 03 Oct 2022 14:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=wyqNJEpK8hc99eBxWvCga97s0cP9TToGQQczW693ZQg=; b=h8czXoK277slpGQf+bpvwfua+gFDF9NUzYgIFFOEfmpYpF8o1tAD/fMdDL7197AECO THvbVgyzmJynlB+rrpjAGhEKfhe9Bw6gD9Bks5W4EOOOf7EUMA0tzBUKiVJJcfxtM7K6 rCMsuJYVKVVK9jAheJWA6FGDLIkABfqtfuPv4ibUAjr+aSQFC/wyp99fSj+1FtrsKm5I 0FhQMMQI8gPFhzdO54qaj6Nh0pMyr58ioMFEGdDYOkDOvXqIX6zA3prnyeKAlivv9XsC iBHQ4EP3+NwiGdGBfj3mb+s4fc1mi6HjC8UTwx9MVWitByDPwAO7pyRcSDtIHDY2B3q0 c2fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=wyqNJEpK8hc99eBxWvCga97s0cP9TToGQQczW693ZQg=; b=AguMcZvXvwNTog+HQhwEZ6KyBp40cF+mQOsB6RmO677bcjQFemtxmFQgMPpUOlzjEX MKZH6d1OjDObrXTqxouIdJ7Q+dGEGFPhMHzvuxWpFJUbY/bYDgeTfqibp9L1GX8A2Pej M5uq7/20gPBLolC2uDloVlMNCSxLlIpVEaiqLZjs3twr9ZgQAjDZpWwoFshcvmsH9/+E Axz69ABW6pALaLCAuteeTRmYTgiwAb1+iP/T5FM2JhZWjEk4czQMadCM6EOEDVKVnmTE 4lbKO8sfZpBAvES0FeERZa1Giaq9yu6m2GWMdfAf+SfQEFKh4S/gAxx+aMgtn2D6fb8E GO6Q== X-Gm-Message-State: ACrzQf1OHebBDM6pXI/wYOu9aB7ckO/z4BuKlaVbtznTdeZf7Sjx6w// C6QWJ/YzDAlTp51mNSJGm6LcKRfkfaUKlLXH3LijPOTlBKKmvnxSyn4pKR3RENOZ2JiMxVjRIbc hjhTgpaj0LPlgQ57hEPNv2c7I+BclWAkfy0u1raFAMkJjfWhwQ9qClBjLy8sthq2KIe0ug48I X-Received: from connoro.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:a99]) (user=connoro job=sendgmr) by 2002:a17:90b:3ec9:b0:205:cc2d:7fb6 with SMTP id rm9-20020a17090b3ec900b00205cc2d7fb6mr13833913pjb.142.1664833523279; Mon, 03 Oct 2022 14:45:23 -0700 (PDT) Date: Mon, 3 Oct 2022 21:45:01 +0000 In-Reply-To: <20221003214501.2050087-1-connoro@google.com> Mime-Version: 1.0 References: <20221003214501.2050087-1-connoro@google.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog Message-ID: <20221003214501.2050087-12-connoro@google.com> Subject: [RFC PATCH 11/11] locktorture: support nested mutexes From: "Connor O'Brien" To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, John Stultz , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Will Deacon , Waiman Long , Boqun Feng , "Paul E . McKenney" , "Connor O'Brien" 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: X-Mailing-List: linux-kernel@vger.kernel.org Quick hack to better surface bugs in proxy execution. The single lock used by locktorture does not reliably exercise proxy exec code paths for handling chains of blocked tasks involving >1 mutex. Add 2 more mutexes and randomize whether they are taken. Signed-off-by: Connor O'Brien --- kernel/locking/locktorture.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c index 9c2fb613a55d..bc3557677eed 100644 --- a/kernel/locking/locktorture.c +++ b/kernel/locking/locktorture.c @@ -48,6 +48,8 @@ torture_param(int, stat_interval, 60, torture_param(int, stutter, 5, "Number of jiffies to run/halt test, 0=disable"); torture_param(int, verbose, 1, "Enable verbose debugging printk()s"); +torture_param(int, nlocks, 1, + "Number of locks"); static char *torture_type = "spin_lock"; module_param(torture_type, charp, 0444); @@ -327,6 +329,8 @@ static struct lock_torture_ops rw_lock_irq_ops = { }; static DEFINE_MUTEX(torture_mutex); +static DEFINE_MUTEX(torture_mutex2); +static DEFINE_MUTEX(torture_mutex3); static int torture_mutex_lock(int tid __maybe_unused) __acquires(torture_mutex) @@ -666,6 +670,7 @@ static struct lock_torture_ops percpu_rwsem_lock_ops = { */ static int lock_torture_writer(void *arg) { + bool twolocks = false, threelocks = false; struct lock_stress_stats *lwsp = arg; int tid = lwsp - cxt.lwsa; DEFINE_TORTURE_RANDOM(rand); @@ -677,6 +682,12 @@ static int lock_torture_writer(void *arg) if ((torture_random(&rand) & 0xfffff) == 0) schedule_timeout_uninterruptible(1); + twolocks = nlocks > 1 ? (torture_random(&rand) & 0x1) : 0; + if (twolocks) + mutex_lock(&torture_mutex2); + threelocks = nlocks > 2 ? (torture_random(&rand) & 0x2) : 0; + if (threelocks) + mutex_lock(&torture_mutex3); cxt.cur_ops->task_boost(&rand); cxt.cur_ops->writelock(tid); if (WARN_ON_ONCE(lock_is_write_held)) @@ -691,6 +702,11 @@ static int lock_torture_writer(void *arg) WRITE_ONCE(last_lock_release, jiffies); cxt.cur_ops->writeunlock(tid); + if (threelocks) + mutex_unlock(&torture_mutex3); + if (twolocks) + mutex_unlock(&torture_mutex2); + stutter_wait("lock_torture_writer"); } while (!torture_must_stop()); @@ -830,11 +846,11 @@ lock_torture_print_module_parms(struct lock_torture_ops *cur_ops, const char *tag) { pr_alert("%s" TORTURE_FLAG - "--- %s%s: nwriters_stress=%d nreaders_stress=%d stat_interval=%d verbose=%d shuffle_interval=%d stutter=%d shutdown_secs=%d onoff_interval=%d onoff_holdoff=%d\n", + "--- %s%s: nwriters_stress=%d nreaders_stress=%d stat_interval=%d verbose=%d shuffle_interval=%d stutter=%d shutdown_secs=%d onoff_interval=%d onoff_holdoff=%d nlocks=%d\n", torture_type, tag, cxt.debug_lock ? " [debug]": "", cxt.nrealwriters_stress, cxt.nrealreaders_stress, stat_interval, verbose, shuffle_interval, stutter, shutdown_secs, - onoff_interval, onoff_holdoff); + onoff_interval, onoff_holdoff, nlocks); } static void lock_torture_cleanup(void) -- 2.38.0.rc1.362.ged0d419d3c-goog