Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1787286lqp; Mon, 15 Apr 2024 18:37:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX3m0dJqpaxfvwFtlJBo5aFK0qEJ15cb93fISjGcquzR0tS+0otmB2mp/8g20cokhOfoUELrlaz9Nf4waHS0yxapkucT+GKy3g2daLNag== X-Google-Smtp-Source: AGHT+IHmD/NyqL8bTdVPiGmeBuh4oThke3d6OgTav5yEtXMpqHTfepIk9AMpto4ymleY3GVWFb+F X-Received: by 2002:a17:90b:1205:b0:2a9:f3d1:c0db with SMTP id gl5-20020a17090b120500b002a9f3d1c0dbmr3666467pjb.24.1713231439951; Mon, 15 Apr 2024 18:37:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713231439; cv=pass; d=google.com; s=arc-20160816; b=oTyzRi3kCtUCK6fAOTkXrb5r5dGr8g1Wn1LDCxicB87e3KdjllyqWEn9uYOMZS+0xA xDhnzU27hLbyngOT+ousIbFrobO9ejePlm7hovwBCTZbG0DXwCJCR0EtddcfNWHEF13Z vtHz6ALXUETXtA5Qv2DQePIWYy1EApnCpULyLbg6eHGCG/N4I/81jfiblAP6s9fXjOVH eoqL4Vk2gJkUU8jm/qsnhv2Y/SekbNRbhvP3DcPzM0EJKW/ZKJAV+smBiaveed+uBUGY IvI+49OFJPI0jIUgRUjU93CZtmkr0wVqaoHE8YUQdu2lwdrteQIuGqaxlvpyTDiwg07B Qj+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mD7kGOKMw9/SgIhNijECJqDpS2n0gwPnb6QPtQ/fOO8=; fh=eVY06L/C5FDTmF2RNqfudsnjwkB3tbhT/y33cGhZc0I=; b=sj+dK0zrx4FgJAUOORYWSfmZD4qS/mgoAkqaBwRsHZ8n/asegkR/T0IcJJ3BP/P+xo YXkndDsP9AGaCf2mMhcSHa2xGxlpdTYOUdGkMaDPo/dvrL9Hc9f/meSMZoZedkUoAUTE KopG/HiBymfpWO5VAUuqKzkM0rqHG2geOS1VrDZl/4klR2kwwT71ubiFGxjmadr1lC9S Gpx8F6uM51l5A+hh9AQxThJdkpgwJm4R5onbZzaVDPEKyTcR4ZEeL3L7D4ji6nnLjMVL gsTyaNN9uAHKllt+U5PF00HqrsxZWGtgtdQBZaRr+w3AHEakaNWbs8EunYC3xLSHgAQp hDCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=KxXzA6Os; arc=pass (i=1 spf=pass spfdomain=codeweavers.com dkim=pass dkdomain=codeweavers.com dmarc=pass fromdomain=codeweavers.com); spf=pass (google.com: domain of linux-kernel+bounces-146076-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i9-20020a17090ad34900b002a53775b99fsi8667069pjx.22.2024.04.15.18.37.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 18:37:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146076-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=KxXzA6Os; arc=pass (i=1 spf=pass spfdomain=codeweavers.com dkim=pass dkdomain=codeweavers.com dmarc=pass fromdomain=codeweavers.com); spf=pass (google.com: domain of linux-kernel+bounces-146076-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 68113287E67 for ; Tue, 16 Apr 2024 01:15:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DF8D15B0F4; Tue, 16 Apr 2024 01:10:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="KxXzA6Os" Received: from mail.codeweavers.com (mail.codeweavers.com [4.36.192.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0DBA11CA1; Tue, 16 Apr 2024 01:10:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=4.36.192.163 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713229833; cv=none; b=T/A/5ehTWvTxavsUSWcTYWKVFXtS0Uq3sW99JiF6QCYObGLXDXyFSCv6j47Tg8rq9T5irtcszJs3JsZYyHXjq8No6zk2euMv/Nb2PSt88KR2sXqZrW4RLCQJVytd0b5rYZ6yaTM3Fab35BZqKM3Uq3sOvRdNDzRT2G4FGabcWJA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713229833; c=relaxed/simple; bh=FzJOOSC9UUHrWRcI7UAQtasAek/KIUNP0SrrKFAkeFc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kT8/Z2m/Enjij1gaYq+yDdzwyyUw4nXP6zDhEOOzznbZC64wCOvI3f43t8SFucq94GV4DetZEvPF7OhmV11512WLUwLBHzYhKpV6gNzbw8YTmPn8uqoyWWzHsiQt4PJNh7euyfYY1IcukIpG/hySA0u1i4OwQOyloZOiedImVJA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeweavers.com; spf=pass smtp.mailfrom=codeweavers.com; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b=KxXzA6Os; arc=none smtp.client-ip=4.36.192.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeweavers.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codeweavers.com; s=s1; h=Message-ID:Date:Subject:Cc:To:From:Sender; bh=mD7kGOKMw9/SgIhNijECJqDpS2n0gwPnb6QPtQ/fOO8=; b=KxXzA6OsUiL33imG0X4U+6ZmUQ VSM3937+x8uTNcCpgLyu3NmIOwhNvVhDFAmfAx6v6NxD0GUECf9jq5VQa2cq2Mmkj84EVtRytwU1b hvnKmBUnoeRv1qBDpLMtKaCpVwtT+0Qg6yQOKK4fZssHU7RFaICHCWmb0mEkqm+TkqHVeYSJT6E/O oYpNJpEtb8YrGy4yRfeza899q4EkmIYqZhy3ucMSDfnRJ2rgeVc+P7gX4j8tLDpUtbb/DojF43r3M VuCHxA7wtCQjLm/pXdyb4CsX+gvt3OjUJVclQN4gWJnbw/WbhmzAQAjKq6fgPVe+hvYnM4UVSqLhw esw63d3A==; Received: from cw137ip160.mn.codeweavers.com ([10.69.137.160] helo=camazotz.mn.codeweavers.com) by mail.codeweavers.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rwXL5-00FbQv-1v; Mon, 15 Apr 2024 20:10:23 -0500 From: Elizabeth Figura To: Arnd Bergmann , Greg Kroah-Hartman , Jonathan Corbet , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, wine-devel@winehq.org, =?UTF-8?q?Andr=C3=A9=20Almeida?= , Wolfram Sang , Arkadiusz Hiler , Peter Zijlstra , Andy Lutomirski , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Randy Dunlap , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , Elizabeth Figura Subject: [PATCH v4 24/27] selftests: ntsync: Add some tests for wakeup signaling via alerts. Date: Mon, 15 Apr 2024 20:08:34 -0500 Message-ID: <20240416010837.333694-25-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416010837.333694-1-zfigura@codeweavers.com> References: <20240416010837.333694-1-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Expand the alert tests to cover alerting a thread mid-wait, to test that the relevant scheduling logic works correctly. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c index 5465a16d38b3..968874d7e325 100644 --- a/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c @@ -1113,9 +1113,12 @@ TEST(wake_all) TEST(alert_any) { struct ntsync_event_args event_args = {0}; + struct ntsync_wait_args wait_args = {0}; struct ntsync_sem_args sem_args = {0}; __u32 index, count, signaled; + struct wait_args thread_args; int objs[2], fd, ret; + pthread_t thread; fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); ASSERT_LE(0, fd); @@ -1163,6 +1166,34 @@ TEST(alert_any) EXPECT_EQ(0, ret); EXPECT_EQ(2, index); + /* test wakeup via alert */ + + ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_RESET, &signaled); + EXPECT_EQ(0, ret); + + wait_args.timeout = get_abs_timeout(1000); + wait_args.objs = (uintptr_t)objs; + wait_args.count = 2; + wait_args.owner = 123; + wait_args.index = 0xdeadbeef; + wait_args.alert = event_args.event; + thread_args.fd = fd; + thread_args.args = &wait_args; + thread_args.request = NTSYNC_IOC_WAIT_ANY; + ret = pthread_create(&thread, NULL, wait_thread, &thread_args); + EXPECT_EQ(0, ret); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(ETIMEDOUT, ret); + + ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, thread_args.ret); + EXPECT_EQ(2, wait_args.index); + close(event_args.event); /* test with an auto-reset event */ @@ -1199,9 +1230,12 @@ TEST(alert_any) TEST(alert_all) { struct ntsync_event_args event_args = {0}; + struct ntsync_wait_args wait_args = {0}; struct ntsync_sem_args sem_args = {0}; + struct wait_args thread_args; __u32 index, count, signaled; int objs[2], fd, ret; + pthread_t thread; fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); ASSERT_LE(0, fd); @@ -1235,6 +1269,34 @@ TEST(alert_all) EXPECT_EQ(0, ret); EXPECT_EQ(2, index); + /* test wakeup via alert */ + + ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_RESET, &signaled); + EXPECT_EQ(0, ret); + + wait_args.timeout = get_abs_timeout(1000); + wait_args.objs = (uintptr_t)objs; + wait_args.count = 2; + wait_args.owner = 123; + wait_args.index = 0xdeadbeef; + wait_args.alert = event_args.event; + thread_args.fd = fd; + thread_args.args = &wait_args; + thread_args.request = NTSYNC_IOC_WAIT_ALL; + ret = pthread_create(&thread, NULL, wait_thread, &thread_args); + EXPECT_EQ(0, ret); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(ETIMEDOUT, ret); + + ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, thread_args.ret); + EXPECT_EQ(2, wait_args.index); + close(event_args.event); /* test with an auto-reset event */ -- 2.43.0