From nobody Tue Dec 2 02:58:56 2025 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F6092F9C2D for ; Tue, 18 Nov 2025 00:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763427537; cv=none; b=HtqApV1/3LGtIAG3tEdAAwtSu3O1WAe5UIjeIoWpOFHaB17R6enDa34dDJpOXTptj7JCj+4GEf3Hwh87awNW4EbBJdswqFTsfmlL1fdZNG427WCQ2REr6TFtmFQ7ISf7/COOcrU15abd10nFs1tJ3cKeVLt3duI9/NoKRB3TUDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763427537; c=relaxed/simple; bh=/hxurh43P8vC9I1/T0ywT6hUFcH+xTHlJs6hwJZYagk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=eC2npMl58RNoSHinJjBsEOLMnoL/+lvraTZSl2DZhwxUZc4WbcBMpNZS2LVOaNzJ0A4rxiWd8hLeJUZPn3uqYm0qcA1iEzVxxnZr4GFAoEpjm6anzrXCxePFYHlgkTqjryBgT+8g/CCjnZIGJrmbNZGGGnYLbjIFHGrYd2pYu0o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hWglYFwc; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hWglYFwc" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-7b9321b9312so12672997b3a.1 for ; Mon, 17 Nov 2025 16:58:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763427535; x=1764032335; 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=+DEcSd5dptwQKYQuUosq48/ZpRDI7umpzBhDTI2aNWs=; b=hWglYFwcnQQh5cLxvAMy4AzMs6uk42G23k+v+zP7eNuRR+I0L5loJHBkiUQrI0Yuzn jwpU/YmGxmN6zp606M/+vEHTs+nurgWYpivzFjIXfdLcH9oXnbxd3SRNt5dhYAGcFadR HUJNEFelD6hNExW3Vn987JIJhlR+CwIHKOlvXh7uLC3XpCLeTPQY/2Ahv/j62pmcgGSq Te7RegRZgF2HT4DW9tRss5HW74iBBE5tVqifL5FPd24yYOoV9KeVlxdYGFIgQK5fccCT tDWuS9vU7gmyi1DfCyUZlP1JG6fcmUwiHU61bVnJfcU6zkWhlytlb258gLaZSrxFSkg/ eTyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763427535; x=1764032335; 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=+DEcSd5dptwQKYQuUosq48/ZpRDI7umpzBhDTI2aNWs=; b=pOzmksrXXe+Jeem/dzKd85OTcnR4G84NX5XEwvT4TsqqRy7279LCri2uyVGYJN1t+I ryVaa2oBcbc2SRfAhoeVFhDnrWpuRboa6/I6axWY+/u8lu1rdxDkH+5y6Z1K+YXHb32+ hKIGrjex74YetueUmOE2twc+UHIa9wr2LwMUFytNtAvvk7ijIBgSI3lbReF2OaJ8pILH czLpoil0FWejTIo1xEl1D4gvPnB/LHcZCJOqUS6X9Yjy1e2896cH7rHx9TnftLzDG0nE sJtIDpQUmUbaFbFmcAReU0lFkldGUolsF4fJPJxqQIQ0rKEWFxLuvslv/qUEz5TxTmQV bBjQ== X-Gm-Message-State: AOJu0YzHuBoyLAsHpQq86ytI4mbUf4SiGiiYQRld7EPx1beE//CByGvS 0h/kt40cTsGFHeyNeFA0YQKBjzBYD/ReMjerXIH/0wpk/RkWoumZNgqdOXwK9irGnG0iGromiKj 70Usd6qs4kOT0w43oJsmzBjrSQZ9l8GPJVzteMTftVJld42G9oOr+J4LcWIo8CzPPVoxb+6yP+j UfolxMVOTAL3M8DvMeuNKw+1/Nove0sNCgzVpCXOWTZsY2AbaW X-Google-Smtp-Source: AGHT+IE9jQ0+hNyYBlYGQ307mwaNIfu2L9/QeZ7PQnmTmzXlJmyHYblp4YqDtKQ5GFys5argiW7PnC5UaJrj X-Received: from pgbfm25.prod.google.com ([2002:a05:6a02:4999:b0:bac:a20:5ee2]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:5493:b0:34e:8c68:35f with SMTP id adf61e73a8af0-35b9fa7e14cmr16963347637.12.1763427535129; Mon, 17 Nov 2025 16:58:55 -0800 (PST) Date: Tue, 18 Nov 2025 00:58:36 +0000 In-Reply-To: <20251118005843.3902476-1-jstultz@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251118005843.3902476-1-jstultz@google.com> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog Message-ID: <20251118005843.3902476-4-jstultz@google.com> Subject: [RESEND x4][PATCH 3/3] test-ww_mutex: Allow test to be run (and re-run) from userland From: John Stultz To: LKML Cc: John Stultz , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , "Paul E . McKenney" , Joel Fernandes , Dietmar Eggemann , Suleiman Souhlal , kernel-team@android.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In cases where the ww_mutex test was occasionally tripping on hard to find issues, leaving qemu in a reboot loop was my best way to reproduce problems. These reboots however wasted time when I just wanted to run the test-ww_mutex logic. So tweak the test-ww_mutex test so that it can be re-triggered via a sysfs file, so the test can be run repeatedly without doing module loads or restarting. This has been particularly valuable to stressing and finding issues with the proxy-exec series. To use, run as root: echo 1 > /sys/kernel/test_ww_mutex/run_tests Signed-off-by: John Stultz --- Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: "Paul E . McKenney" Cc: Joel Fernandes Cc: Dietmar Eggemann Cc: Suleiman Souhlal Cc: kernel-team@android.com --- kernel/locking/test-ww_mutex.c | 51 ++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c index 30512b3e95c99..79b5e45f8d4c2 100644 --- a/kernel/locking/test-ww_mutex.c +++ b/kernel/locking/test-ww_mutex.c @@ -642,7 +642,7 @@ static int stress(struct ww_class *class, int nlocks, i= nt nthreads, unsigned int return 0; } =20 -static int __init run_tests(struct ww_class *class) +static int run_tests(struct ww_class *class) { int ncpus =3D num_online_cpus(); int ret, i; @@ -684,7 +684,7 @@ static int __init run_tests(struct ww_class *class) return 0; } =20 -static int __init run_test_classes(void) +static int run_test_classes(void) { int ret; =20 @@ -703,6 +703,36 @@ static int __init run_test_classes(void) return 0; } =20 +static DEFINE_MUTEX(run_lock); + +static ssize_t run_tests_store(struct kobject *kobj, struct kobj_attribute= *attr, + const char *buf, size_t count) +{ + if (!mutex_trylock(&run_lock)) { + pr_err("Test already running\n"); + return count; + } + + run_test_classes(); + mutex_unlock(&run_lock); + + return count; +} + +static struct kobj_attribute run_tests_attribute =3D + __ATTR(run_tests, 0664, NULL, run_tests_store); + +static struct attribute *attrs[] =3D { + &run_tests_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct attribute_group attr_group =3D { + .attrs =3D attrs, +}; + +static struct kobject *test_ww_mutex_kobj; + static int __init test_ww_mutex_init(void) { int ret; @@ -713,13 +743,30 @@ static int __init test_ww_mutex_init(void) if (!wq) return -ENOMEM; =20 + test_ww_mutex_kobj =3D kobject_create_and_add("test_ww_mutex", kernel_kob= j); + if (!test_ww_mutex_kobj) { + destroy_workqueue(wq); + return -ENOMEM; + } + + /* Create the files associated with this kobject */ + ret =3D sysfs_create_group(test_ww_mutex_kobj, &attr_group); + if (ret) { + kobject_put(test_ww_mutex_kobj); + destroy_workqueue(wq); + return ret; + } + + mutex_lock(&run_lock); ret =3D run_test_classes(); + mutex_unlock(&run_lock); =20 return ret; } =20 static void __exit test_ww_mutex_exit(void) { + kobject_put(test_ww_mutex_kobj); destroy_workqueue(wq); } =20 --=20 2.52.0.rc1.455.g30608eb744-goog