From nobody Fri Dec 19 17:50:26 2025 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 F0F421E3DE8 for ; Fri, 5 Dec 2025 01:35:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764898526; cv=none; b=tll23x9btCVscmiq806hvCdf1uNlNHKW1Gx8C7lSuFStH1B9wGZZpvxFWUifBSIlYzyo82g85gL92Dvity2kBV3zGedPtMQoytbghEqYjV8HgQdbK5g9iDFH3rBzPpOvkkh3wdfZ+ypS8b50Zgx8nYc+tPOwk7WTill6PiJILGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764898526; c=relaxed/simple; bh=fceokh9ZDj3iTBx5iWtCTbWWN8dcyN/kyS4Uh7Ge2SM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cOwZX0hZ+LPAvqr2HUh9m+S+jSDxNWDvNJNClWxtdIjV2zMI2P/tltBREeolP/SZyGiE2wJ3DLwibsmJipxkAvMc0Phg+4W2x51Q5DbMAXrrRJAk/5Bzobk5VPxllC77+pxwbWEiXIeCLsUHsa/JhaIopJ4JBS6mPaPT/cQzNIo= 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=2M5smhb0; arc=none smtp.client-ip=209.85.216.73 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="2M5smhb0" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-340bc4ef67fso1733738a91.3 for ; Thu, 04 Dec 2025 17:35:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764898524; x=1765503324; 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=rm/x06f7hG+OOm8I2O8TRX4qj73dKa/XNTRoxwtX7cY=; b=2M5smhb0tUir4gUy+na0GdCB2V52M/OZT9VxI96gLfhO4aZ4O6IFnQF5F1YC7A/Z6g INTc7Q5TjNL/x8IW5gnxWikDznygxATmGh2O/ALTuKmULjK20vkDZ4NlBtepQuUxR8pp rT6hS/9ka9qjrXaoRxUTKodHVe5i3clfNUVHRCkK98Tepkc0zGaulGaVWb7rij66llHi oBSfkFSv67ohhcim9agHPs/4/BV7/UXeNjzsDumdTyuWPQdApk6S22H/e0H+9QjiPMzW +IAIf/GaHUv+UP8PijE9sP40WKO1wvI5e1zFBjrtq638roOUAhUfNnvxUYGg7I9haLO0 12gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764898524; x=1765503324; 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=rm/x06f7hG+OOm8I2O8TRX4qj73dKa/XNTRoxwtX7cY=; b=Wf8jDeaxCuHImoJvj7H5MDUemHTl6GruxwMG3OjGGG4cLhKZJSVX2NFn2eA9xUawin zUPSOpZzTOvqxtIQrLmxLnVLaMxN7uVM0LgfQXGv1/dCoVQalM0PAWhte9TAH6MTOURC jma07OHM6fSdFgIIYc0/WEwfPIAMFEbdbus6vL/R7Fs/Wr6tLzwnMP1mV0n+TphbVXcZ 7nodA5qYLd92q8FK0dKdw5zzTQ0nDPFPDd9FcDQn3nYK+n+0uA2RQ5mJ+A2Urq4MNLiA x+jAGp3vI1q1lRFiovOHEykfYDDLF/iuDQoWicIHhGsKDmnP2WYECgxglYcH48Ty6gwV xj4g== X-Gm-Message-State: AOJu0Yx4s+Kpo080Iu7ZjKNnicSsUTGHEDx5vAdq5o+/XVrcZ27bTLu9 V3DgdCkT0Y9L8x2Me/Wo+1ViW9VGGtXHiuut4ETFWVmWgApkNVYRnd5ny0hxSI6seZoXh15aAr3 Ivk/54NlHbyxEXFQGYTHfpiseYgMf80c0ZFCGljh8D10w7WnkvJMByuXZWrfUpYNZhI0YBhGPWM VJuO/pw103WPkrNOB7X5k9023jsNaYH/ikbE2JYN5zs6VOvyco X-Google-Smtp-Source: AGHT+IEYUhdXd+yr0MRwOv7fosCzQ5DqubqfzfP5XgbfTyrzJ19jumGbMrQ3La0zM1isi3xSF2CcqlJFdwTs X-Received: from pjq8.prod.google.com ([2002:a17:90b:5608:b0:340:9a17:4b10]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:17c5:b0:340:f7d6:dc70 with SMTP id 98e67ed59e1d1-34947da717emr3949914a91.13.1764898523929; Thu, 04 Dec 2025 17:35:23 -0800 (PST) Date: Fri, 5 Dec 2025 01:35:11 +0000 In-Reply-To: <20251205013515.759030-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: <20251205013515.759030-1-jstultz@google.com> X-Mailer: git-send-email 2.52.0.223.gf5cc29aaa4-goog Message-ID: <20251205013515.759030-4-jstultz@google.com> Subject: [RESEND x5][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.223.gf5cc29aaa4-goog