From nobody Mon Jun 8 23:55:57 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 388CB3DFC73 for ; Mon, 25 May 2026 09:20:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779700808; cv=none; b=E6NXMpQ5jCyKmdb/vinjyDng021xpCGjVc81VSiF2W7dNY8HYBHNFkqnXR4U1184OA2wVxZRuEzNiQZyn4QjBdpK+Nr18S0/aBIWjWBy3LcJekPl3DZ9H6O2TfUV915VZTC29wr+mn+yD1R3YL2u3SHKXaZoqZRhfpz+7t0M9C8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779700808; c=relaxed/simple; bh=rvEK/iPW4RtRD8O8VyOSwmZPo8hSedYLVeoRRc6cBQQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=F1nH6lwLquJyIkG4iHxAn+W97UnetfaIVXcSisn5RyzYO2f0rUhODI3P22b11/7i4PU6rRrexl/zVZ60hKFcZ7pYVqZMzBxP5Tylm3ByvDRXSY4s4msdiOK7gujWYrpDeohMbju/o4iItvUD5bxsB65uDyYIXziu9VC43FigEfw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--wakel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qPB5KBwF; arc=none smtp.client-ip=209.85.216.74 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--wakel.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qPB5KBwF" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-36641fe4aedso18061855a91.1 for ; Mon, 25 May 2026 02:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779700806; x=1780305606; 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=izyWWdSFXUefAHwONWZHlFgfT9Xkrh+4p3hJFMuUItU=; b=qPB5KBwFexrDhQFepWFgrpI82tDS6/iYGTYwLgvmPM0Dl6va8AtSEZeWclyuB8jpg9 3rebJ6lMMygT0FqtcvrxWo1N9wAIplFguvcVg5CCcBrYYHg/p9umRL4bRIzVyXnBUxH8 SULATFc58/lWeLUZN7zwkyD4PapsgHgiXG9rZUjH1Jdt9vJvqRNnMXNQ0Q18hTgsr5ln JAR8zki+Y3HYcs5fbP0vsaJ3GxSnkfUn9XziIVx/gXTAaJjD3XscbZAyiDK2Pgd3pbWT lRsRKnHpyJPSHyoWuKTgn5+gYB4JiYDpW4vk/qXqOhHBmIn+KDPh0797wqbx1gZJOveW ThJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779700806; x=1780305606; 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=izyWWdSFXUefAHwONWZHlFgfT9Xkrh+4p3hJFMuUItU=; b=cZWc/WXGt7C7G+AOwMvm32zA5uT4tTgkJ85ei25M+q4V/GjDtq6CclqizSikIO8+Wr YuVR5KfNGEPuuJYFtkh7vz/ZFyK+MkstXjIjgg9+UUeQwy74hbS3AxNT1fKohaDI1J/n 2G8CC6FGRuDRRd1PDBQLDmjNbNEnBvUEfRqG2kmRfw33FkYipn5J+fM+0nEJJw0lZujZ UNroUro5e8IcwLahyojah6b0yUMtgp/r726o5cYfkiFoSZ1Oj2/JdurbO3x7dI2sf6Lt fUWuE2c3xXYbHyjv6I1wQfEXe97qiVUUn9n+8siSGrqTAd0BDlJyGlPHlu6xFPIJrg40 Gzmg== X-Forwarded-Encrypted: i=1; AFNElJ+gez52XbQkC0xXNn/Nx6EdwZnjJ+tj1bJs3XvX01dWXRSNmciWe7bBbwgZex7ch/20c3sQ9SSZ2KRvT9Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzVUDUjCFbAwF9JVluHopEa8taiis0Yy+H0EuLN1pbceKKzDl89 EgP37WI+64DSSK1kqQHwL+PEqf2TECfXRao9Ce6qjuub4cgti0+iXYiwpshTSCZSPd0RghZHhgI NTA== X-Received: from pjsk5.prod.google.com ([2002:a17:90a:62c5:b0:369:6a36:2fe2]) (user=wakel job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2d50:b0:364:e97f:64e7 with SMTP id 98e67ed59e1d1-36a676372f2mr13955686a91.27.1779700806272; Mon, 25 May 2026 02:20:06 -0700 (PDT) Date: Mon, 25 May 2026 09:20:00 +0000 In-Reply-To: <20260525092002.3762888-1-wakel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260525092002.3762888-1-wakel@google.com> X-Mailer: git-send-email 2.54.0.746.g67dd491aae-goog Message-ID: <20260525092002.3762888-2-wakel@google.com> Subject: [PATCH 1/3] selftests/futex: Migrate futex_wait to harness From: Wake Liu To: Thomas Gleixner , Ingo Molnar , Shuah Khan , linux-kselftest@vger.kernel.org Cc: Peter Zijlstra , Darren Hart , Davidlohr Bueso , "=?UTF-8?q?Andr=C3=A9=20Almeida?=" , Carlos Llamas , linux-kernel@vger.kernel.org, wakel@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Migrate futex_wait test to the kselftest harness framework, removing mixed legacy ksft_* API usages and ensuring proper thread joining. Signed-off-by: Wake Liu --- .../selftests/futex/functional/futex_wait.c | 125 +++++++++++------- 1 file changed, 77 insertions(+), 48 deletions(-) diff --git a/tools/testing/selftests/futex/functional/futex_wait.c b/tools/= testing/selftests/futex/functional/futex_wait.c index 7b8879409007..ed4b040600b8 100644 --- a/tools/testing/selftests/futex/functional/futex_wait.c +++ b/tools/testing/selftests/futex/functional/futex_wait.c @@ -9,6 +9,7 @@ #include #include #include +#include =20 #include "futextest.h" #include "kselftest_harness.h" @@ -19,125 +20,153 @@ =20 void *futex; =20 +struct waiter_args { + struct __test_metadata *_metadata; + unsigned int flags; +}; + static void *waiterfn(void *arg) { + struct waiter_args *args =3D (struct waiter_args *)arg; + struct __test_metadata *_metadata =3D args->_metadata; struct timespec to; - unsigned int flags =3D 0; - - if (arg) - flags =3D *((unsigned int *) arg); + int res; =20 to.tv_sec =3D 0; to.tv_nsec =3D timeout_ns; =20 - if (futex_wait(futex, 0, &to, flags)) - printf("waiter failed errno %d\n", errno); + res =3D futex_wait(futex, 0, &to, args->flags); + if (res) { + EXPECT_EQ(res, 0) + TH_LOG("waiter failed errno %d: %s", errno, strerror(errno)); + } =20 + free(args); return NULL; } =20 TEST(private_futex) { - unsigned int flags =3D FUTEX_PRIVATE_FLAG; + struct waiter_args *args =3D malloc(sizeof(*args)); u_int32_t f_private =3D 0; pthread_t waiter; int res; =20 + args->_metadata =3D _metadata; + args->flags =3D FUTEX_PRIVATE_FLAG; futex =3D &f_private; =20 /* Testing a private futex */ - ksft_print_dbg_msg("Calling private futex_wait on futex: %p\n", futex); - if (pthread_create(&waiter, NULL, waiterfn, (void *) &flags)) - ksft_exit_fail_msg("pthread_create failed\n"); + TH_LOG("Calling private futex_wait on futex: %p", futex); + ASSERT_EQ(pthread_create(&waiter, NULL, waiterfn, args), 0) + TH_LOG("pthread_create failed"); =20 usleep(WAKE_WAIT_US); =20 - ksft_print_dbg_msg("Calling private futex_wake on futex: %p\n", futex); + TH_LOG("Calling private futex_wake on futex: %p", futex); res =3D futex_wake(futex, 1, FUTEX_PRIVATE_FLAG); - if (res !=3D 1) { - ksft_test_result_fail("futex_wake private returned: %d %s\n", - errno, strerror(errno)); - } else { - ksft_test_result_pass("futex_wake private succeeds\n"); - } + EXPECT_EQ(res, 1) + TH_LOG("futex_wake private returned: %d %s", res, res < 0 ? strerror(err= no) : ""); + + pthread_join(waiter, NULL); } =20 TEST(anon_page) { + struct waiter_args *args =3D malloc(sizeof(*args)); u_int32_t *shared_data; pthread_t waiter; int res, shm_id; =20 + args->_metadata =3D _metadata; + args->flags =3D 0; + /* Testing an anon page shared memory */ shm_id =3D shmget(IPC_PRIVATE, 4096, IPC_CREAT | 0666); if (shm_id < 0) { - if (errno =3D=3D ENOSYS) - ksft_exit_skip("shmget syscall not supported\n"); - perror("shmget"); - exit(1); + if (errno =3D=3D ENOSYS) { + free(args); + SKIP(return, "shmget syscall not supported"); + } + ASSERT_GE(shm_id, 0) + TH_LOG("shmget failed: %s", strerror(errno)); } =20 shared_data =3D shmat(shm_id, NULL, 0); + if (shared_data =3D=3D (void *)-1) { + free(args); + ASSERT_NE(shared_data, (void *)-1) + TH_LOG("shmat failed: %s", strerror(errno)); + } =20 *shared_data =3D 0; futex =3D shared_data; =20 - ksft_print_dbg_msg("Calling shared (page anon) futex_wait on futex: %p\n"= , futex); - if (pthread_create(&waiter, NULL, waiterfn, NULL)) - ksft_exit_fail_msg("pthread_create failed\n"); + TH_LOG("Calling shared (page anon) futex_wait on futex: %p", futex); + ASSERT_EQ(pthread_create(&waiter, NULL, waiterfn, args), 0) + TH_LOG("pthread_create failed"); =20 usleep(WAKE_WAIT_US); =20 - ksft_print_dbg_msg("Calling shared (page anon) futex_wake on futex: %p\n"= , futex); + TH_LOG("Calling shared (page anon) futex_wake on futex: %p", futex); res =3D futex_wake(futex, 1, 0); - if (res !=3D 1) { - ksft_test_result_fail("futex_wake shared (page anon) returned: %d %s\n", - errno, strerror(errno)); - } else { - ksft_test_result_pass("futex_wake shared (page anon) succeeds\n"); - } + EXPECT_EQ(res, 1) + TH_LOG("futex_wake shared (page anon) returned: %d %s", res, res < 0 ? s= trerror(errno) : ""); =20 + pthread_join(waiter, NULL); shmdt(shared_data); } =20 TEST(file_backed) { + struct waiter_args *args =3D malloc(sizeof(*args)); u_int32_t f_private =3D 0; pthread_t waiter; int res, fd; void *shm; =20 + args->_metadata =3D _metadata; + args->flags =3D 0; + /* Testing a file backed shared memory */ - fd =3D open(SHM_PATH, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); - if (fd < 0) - ksft_exit_fail_msg("open\n"); + fd =3D open(SHM_PATH, O_RDWR | O_CREAT, 0600); + if (fd < 0) { + free(args); + ASSERT_GE(fd, 0) + TH_LOG("open failed: %s", strerror(errno)); + } =20 - if (ftruncate(fd, sizeof(f_private))) - ksft_exit_fail_msg("ftruncate\n"); + if (ftruncate(fd, sizeof(f_private))) { + free(args); + close(fd); + ASSERT_TRUE(0) + TH_LOG("ftruncate failed: %s", strerror(errno)); + } =20 shm =3D mmap(NULL, sizeof(f_private), PROT_READ | PROT_WRITE, MAP_SHARED,= fd, 0); - if (shm =3D=3D MAP_FAILED) - ksft_exit_fail_msg("mmap\n"); + if (shm =3D=3D MAP_FAILED) { + free(args); + close(fd); + ASSERT_NE(shm, MAP_FAILED) + TH_LOG("mmap failed: %s", strerror(errno)); + } =20 memcpy(shm, &f_private, sizeof(f_private)); =20 futex =3D shm; =20 - ksft_print_dbg_msg("Calling shared (file backed) futex_wait on futex: %p\= n", futex); - if (pthread_create(&waiter, NULL, waiterfn, NULL)) - ksft_exit_fail_msg("pthread_create failed\n"); + TH_LOG("Calling shared (file backed) futex_wait on futex: %p", futex); + ASSERT_EQ(pthread_create(&waiter, NULL, waiterfn, args), 0) + TH_LOG("pthread_create failed"); =20 usleep(WAKE_WAIT_US); =20 - ksft_print_dbg_msg("Calling shared (file backed) futex_wake on futex: %p\= n", futex); + TH_LOG("Calling shared (file backed) futex_wake on futex: %p", futex); res =3D futex_wake(shm, 1, 0); - if (res !=3D 1) { - ksft_test_result_fail("futex_wake shared (file backed) returned: %d %s\n= ", - errno, strerror(errno)); - } else { - ksft_test_result_pass("futex_wake shared (file backed) succeeds\n"); - } + EXPECT_EQ(res, 1) + TH_LOG("futex_wake shared (file backed) returned: %d %s", res, res < 0 ?= strerror(errno) : ""); =20 + pthread_join(waiter, NULL); munmap(shm, sizeof(f_private)); remove(SHM_PATH); close(fd); --=20 2.54.0.746.g67dd491aae-goog From nobody Mon Jun 8 23:55:57 2026 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 9C543334688 for ; Mon, 25 May 2026 09:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779700810; cv=none; b=m+GmY4j9nNTAzw4soN4nfnDBzikVhphzo9OzOGlcCHZOx1HsCgsVpUu1kW7O+ttfxDKZ5VXWQTTbIu4YkhjHq77bg5LFAcFNTWR3kTrNDOmxykPsVJ3fBurRMgnEWI7VST5csdVyWNDe7PAp1JDBZYIntL6ga7e75Ox8liSZaN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779700810; c=relaxed/simple; bh=kWqFkiHe76KEg8h6wRQq06fEaCSgYX8ATRUxr7MIA0s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=r1ZgJIYskbPB36PzMBnuDNIwKNdpXxiXbAAhcT/NQua+UQHueiSGbc0gU4pK7J42xZFu5VqcFID/7sj7J9RZG1nsDNXzmF6KXFcjuvUpIQnt2bfmDbUB/6KT3EiyGL/qo6PpdZeST64R1kmAo3WV1OPNUxCNxnmsuwWPDUsJBM4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--wakel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=IC7n2kXl; arc=none smtp.client-ip=209.85.215.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--wakel.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IC7n2kXl" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c828f0f5c23so4465938a12.1 for ; Mon, 25 May 2026 02:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779700809; x=1780305609; 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=vHJboG/TgtXeVPCljhjnqt/N6w+2uxNP4jcRivG2kgc=; b=IC7n2kXllhp+oVIhKoF+VezO2kAKrhM0iJ79MORnv+0s70DxNGZcgnqRDMl5ZLPwnt L5PpvAaAflEgzUokd5DPAKRzm8MQQ13M5ypT6q/RhpzpQodp4C9UmomVMke//eVOSh3U LQwZjBRcmmF4VPN6q+Fb+N0E9zN8UvndeZhsY6I9TZa0rOpHaDQ91NNoSeb2mief54yR ZYvk/4nrLfhnk+14maq4UF/cqt2XKPD6FReIkZa367zIIWE5lU104/vPV3G3ybNfQ/NW Sd4g7WqMqkjJglhmF+825Tmu8xta/BnaSvQTyapu2DZLCLXjMiZEPcVKpISwzS1/Wgkt Lhmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779700809; x=1780305609; 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=vHJboG/TgtXeVPCljhjnqt/N6w+2uxNP4jcRivG2kgc=; b=IzYAnO3WKycNkGbiN9Ypo9SG/kYwJxoyISuHRycsOTnXIf6A1FMmy0QFQ1WoPUlc2i +VFEklp1MQr9L4KyAINQFcitD6oofuTBKLuGwD9/b17EBzMnXFXZGnYpkLwxV3WBQqyR 6N6IZOL8gVdwbEivFlv7YsEEK6iKLMly0Qo1xx2lj/+oAApsZLBqbewTwt+A8JfBvnhi KfaIbjGd/AFSSW2BUjJUKOeeo8QaHmJcrjZBtKrL6Ayjz9Xnal0w2bdmzWIvYwKbucQp 1JzaHVUF3dxfIaRLbtc2YdqOgXQqertFnV8bBgu9sL4GMIwBTgKAJPp6cKu3DEh+MWF+ nypw== X-Forwarded-Encrypted: i=1; AFNElJ+56k/7tEzoQxuKNUF0NFxivaosGL9w1OzhAfbzyaVbpYLRQPPTGqq5WOWpxaPpFEZFMO1ixBpunHa334Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzX1jIGDuSNhHuKDpmz8+bOYT9uZySLg0mTDzmgyctcq0hyJOuM /U/uKlew2j7CGtXqQumgd4aGebWMsHD90hyxwyLCF7+46UtwsX00uVfY5NRcGLax+UeCRduy61B XSw== X-Received: from pfbfp6.prod.google.com ([2002:a05:6a00:6086:b0:841:9a22:890c]) (user=wakel job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:430d:b0:829:8a84:b9fc with SMTP id d2e1a72fcca58-8415f0ebe54mr12973292b3a.8.1779700808265; Mon, 25 May 2026 02:20:08 -0700 (PDT) Date: Mon, 25 May 2026 09:20:01 +0000 In-Reply-To: <20260525092002.3762888-1-wakel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260525092002.3762888-1-wakel@google.com> X-Mailer: git-send-email 2.54.0.746.g67dd491aae-goog Message-ID: <20260525092002.3762888-3-wakel@google.com> Subject: [PATCH 2/3] selftests/futex: Migrate futex_wait_private_mapped_file to harness From: Wake Liu To: Thomas Gleixner , Ingo Molnar , Shuah Khan , linux-kselftest@vger.kernel.org Cc: Peter Zijlstra , Darren Hart , Davidlohr Bueso , "=?UTF-8?q?Andr=C3=A9=20Almeida?=" , Carlos Llamas , linux-kernel@vger.kernel.org, wakel@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Migrate futex_wait_private_mapped_file test to the kselftest harness framew= ork, removing mixed legacy ksft_* API usages and passing test metadata to helper= thread. Signed-off-by: Wake Liu --- .../futex_wait_private_mapped_file.c | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/futex/functional/futex_wait_private_ma= pped_file.c b/tools/testing/selftests/futex/functional/futex_wait_private_m= apped_file.c index 2a749f9b14eb..b4d0502a6611 100644 --- a/tools/testing/selftests/futex/functional/futex_wait_private_mapped_fi= le.c +++ b/tools/testing/selftests/futex/functional/futex_wait_private_mapped_fi= le.c @@ -26,6 +26,7 @@ #include #include #include +#include =20 #include "futextest.h" #include "kselftest_harness.h" @@ -41,17 +42,18 @@ struct timespec wait_timeout =3D { .tv_sec =3D 5, .tv_n= sec =3D 0}; =20 void *thr_futex_wait(void *arg) { + struct __test_metadata *_metadata =3D (struct __test_metadata *)arg; int ret; =20 - ksft_print_dbg_msg("futex wait\n"); + TH_LOG("futex wait"); ret =3D futex_wait(&val, 1, &wait_timeout, 0); if (ret && errno !=3D EWOULDBLOCK && errno !=3D ETIMEDOUT) - ksft_exit_fail_msg("futex error.\n"); + ASSERT_TRUE(0) TH_LOG("futex error: %s", strerror(errno)); =20 if (ret && errno =3D=3D ETIMEDOUT) - ksft_exit_fail_msg("waiter timedout\n"); + ASSERT_TRUE(0) TH_LOG("waiter timedout"); =20 - ksft_print_dbg_msg("futex_wait: ret =3D %d, errno =3D %d\n", ret, errno); + TH_LOG("futex_wait: ret =3D %d, errno =3D %d", ret, errno); =20 return NULL; } @@ -61,22 +63,18 @@ TEST(wait_private_mapped_file) pthread_t thr; int res; =20 - res =3D pthread_create(&thr, NULL, thr_futex_wait, NULL); - if (res < 0) - ksft_exit_fail_msg("pthread_create error\n"); + res =3D pthread_create(&thr, NULL, thr_futex_wait, _metadata); + ASSERT_EQ(res, 0) TH_LOG("pthread_create error"); =20 - ksft_print_dbg_msg("wait a while\n"); + TH_LOG("wait a while"); usleep(WAKE_WAIT_US); val =3D 2; res =3D futex_wake(&val, 1, 0); - ksft_print_dbg_msg("futex_wake %d\n", res); - if (res !=3D 1) - ksft_exit_fail_msg("FUTEX_WAKE didn't find the waiting thread.\n"); + TH_LOG("futex_wake %d", res); + EXPECT_EQ(res, 1) TH_LOG("FUTEX_WAKE didn't find the waiting thread"); =20 - ksft_print_dbg_msg("join\n"); + TH_LOG("join"); pthread_join(thr, NULL); - - ksft_test_result_pass("wait_private_mapped_file"); } =20 TEST_HARNESS_MAIN --=20 2.54.0.746.g67dd491aae-goog From nobody Mon Jun 8 23:55:57 2026 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 891263E170E for ; Mon, 25 May 2026 09:20:11 +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=1779700812; cv=none; b=QR6z31GXex0OJup9FNobMZrTwr/nd2wXjLdO0I5A/4BD69DTBwEwYofJhksfdwNYtv7ZINQqeAyIh4y8+BvvW1bIuskr3ZQmh4+imA9C3e0j3i4wnMnQ8lgnDrAX4tqB/EGdEO8expjO37ClFGiKmqkS3+ZI5hlmny6xJrhoZ9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779700812; c=relaxed/simple; bh=UjNgp/l8IfR0ufhjmYSDKZagxt6lpAcyv8eIgEIuRv0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gJDv+HdPaT09jOwJX7DsO1Z/co0YasA87E+DvLyLYi806ibRs9YEXGUJZSZ9dsyzef7GtIMqZMQSMJYntKI+hFfUyLqkC1FjY9tTjHa4VuQa6Y+vQgwu9ywp6r2tOjt57GXrZFeTxBLhxm4Q0loTn0Q7Wizq4Q5NQv4otWNKOAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--wakel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=L55d9ODM; 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--wakel.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L55d9ODM" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-365faf6006dso9288259a91.1 for ; Mon, 25 May 2026 02:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779700811; x=1780305611; 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=YxamJpJTdi3VHVTfOnkpOEJCHh7lF42Wf7zmG8DNdAg=; b=L55d9ODMw4kDCS3v6p6/qy8EngsVr+wPMMAjJQhzu6Ku49zoTEliA012PtB81fe9Ew zIeBVbW9p5TYGCfUuExsiDkzhFpcq0E/hJwkVOvA0O1yj7yTC6Sm/ps5A/H4gkXFbfU7 1hSXbFX6KxO9KdbOU6ebj4avn004DrV7mOU25Jfrw7tNZZ4B1hCbXDcS8edv2m0/MXmE 9DD9Q8dXX8Zugw4gSVUY7npPE/yRliifzjqseFgLRObKSYFfDDVWCRsadYFTZCEewIc4 3ODx9Z/PzY8fB7g8FbkJ0C+gL6cDIE1eliQ0vpbgDAzcoK55hDQA1afX2yYJb/AA2FQk GtdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779700811; x=1780305611; 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=YxamJpJTdi3VHVTfOnkpOEJCHh7lF42Wf7zmG8DNdAg=; b=slJOrU3/rpQLkMB2Fi0nKQdCc1nH9fDnfJLMCAHBfsfJ1wUszb+ZBjBh2b6ySuPUF/ MsNhioI1HCsoEtSLVjAAWiZM4yrYckcoefPlmen50Bsp3XnjxROVl06Qy0NZyN+O2R2s iRn3vYdBhEXhHUvnUTGkBfUZJogJtUNcigZJ2Pyr/yYAeYfAmzwZm1hd02WkdR5HMnHV Pksz623dhrJOECyqk4OftoEhfUY4HWHQRReOkvKYTK5p9XCTkLgIqP/QumB/pQlLiZfJ O4325uksSYq9emxINLyD8oQoDiXjL8SfCdhJX8Gofk99//eHTHK1epemW82N1be8R1uo f94Q== X-Forwarded-Encrypted: i=1; AFNElJ/PwDsei8AaBOT3a0Pe0NANQRdcFMD8c1ZB7p0TP6O+nnKzQ9nFVoPycC177bsfl+opcONLjfH11Xgybbs=@vger.kernel.org X-Gm-Message-State: AOJu0YzXkNSSBCObEp9hJQ5YYVugb1KIpyNIz+CJic78ABy0zWGPkTRc VLQWfutm+Y2GkE2ElPOaQHgdf0OvXanuX5uji0evNlhi9d36nv73u7C9Q6OMfkVxzTR3t2o8Bdd Kmw== X-Received: from pjbdt2.prod.google.com ([2002:a17:90a:fa42:b0:369:be75:6dd]) (user=wakel job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:380b:b0:35d:a3b4:2f0d with SMTP id 98e67ed59e1d1-36a6773cb46mr11796036a91.6.1779700810665; Mon, 25 May 2026 02:20:10 -0700 (PDT) Date: Mon, 25 May 2026 09:20:02 +0000 In-Reply-To: <20260525092002.3762888-1-wakel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260525092002.3762888-1-wakel@google.com> X-Mailer: git-send-email 2.54.0.746.g67dd491aae-goog Message-ID: <20260525092002.3762888-4-wakel@google.com> Subject: [PATCH 3/3] selftests/futex: Migrate futex_wait_uninitialized_heap to harness From: Wake Liu To: Thomas Gleixner , Ingo Molnar , Shuah Khan , linux-kselftest@vger.kernel.org Cc: Peter Zijlstra , Darren Hart , Davidlohr Bueso , "=?UTF-8?q?Andr=C3=A9=20Almeida?=" , Carlos Llamas , linux-kernel@vger.kernel.org, wakel@google.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Migrate futex_wait_uninitialized_heap test to the kselftest harness framewo= rk, removing mixed legacy ksft_* API usages and ensuring proper thread joining. Signed-off-by: Wake Liu --- .../futex_wait_uninitialized_heap.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/futex/functional/futex_wait_uninitiali= zed_heap.c b/tools/testing/selftests/futex/functional/futex_wait_uninitiali= zed_heap.c index b07d68a67f31..ae1da2c6c8ad 100644 --- a/tools/testing/selftests/futex/functional/futex_wait_uninitialized_hea= p.c +++ b/tools/testing/selftests/futex/functional/futex_wait_uninitialized_hea= p.c @@ -28,6 +28,7 @@ #include #include #include +#include =20 #include "futextest.h" #include "kselftest_harness.h" @@ -40,6 +41,7 @@ void *buf; =20 void *wait_thread(void *arg) { + struct __test_metadata *_metadata =3D (struct __test_metadata *)arg; int res; =20 child_ret =3D true; @@ -47,7 +49,7 @@ void *wait_thread(void *arg) child_blocked =3D 0; =20 if (res !=3D 0 && errno !=3D EWOULDBLOCK) { - ksft_exit_fail_msg("futex failure\n"); + EXPECT_EQ(res, 0) TH_LOG("futex failure: %s", strerror(errno)); child_ret =3D false; } pthread_exit(NULL); @@ -63,21 +65,19 @@ TEST(futex_wait_uninitialized_heap) =20 buf =3D mmap(NULL, page_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); - if (buf =3D=3D (void *)-1) - ksft_exit_fail_msg("mmap\n"); + ASSERT_NE(buf, MAP_FAILED) TH_LOG("mmap failed: %s", strerror(errno)); =20 - ret =3D pthread_create(&thr, NULL, wait_thread, NULL); - if (ret) - ksft_exit_fail_msg("pthread_create\n"); + ret =3D pthread_create(&thr, NULL, wait_thread, _metadata); + ASSERT_EQ(ret, 0) TH_LOG("pthread_create failed"); =20 - ksft_print_dbg_msg("waiting %dus for child to return\n", WAIT_US); + TH_LOG("waiting %dus for child to return", WAIT_US); usleep(WAIT_US); =20 - if (child_blocked) - ksft_test_result_fail("child blocked in kernel\n"); + EXPECT_EQ(child_blocked, 0) TH_LOG("child blocked in kernel"); + EXPECT_TRUE(child_ret) TH_LOG("child error"); =20 - if (!child_ret) - ksft_test_result_fail("child error\n"); + pthread_join(thr, NULL); + munmap(buf, page_size); } =20 TEST_HARNESS_MAIN --=20 2.54.0.746.g67dd491aae-goog