Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2104627lqo; Sun, 19 May 2024 13:47:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUpkmKcLdFO2XufcSlwY4QiptTDt0ZeQthHbuyKp/wCwsJ/JLGMVw1DxdVtIwhIr62Oo2jz+vwOqVdsDvUGpmvfID3cTbJ/3gaF+iwuHg== X-Google-Smtp-Source: AGHT+IGNLeA02NZ75jyXLEJBvjzkCpqKOe81dChOY4I4qZZuji2Tl84tnH7jUlpFe/7gRZNyY1Lf X-Received: by 2002:a50:d518:0:b0:575:2ccc:13c1 with SMTP id 4fb4d7f45d1cf-5752ccc14damr3503800a12.9.1716151668088; Sun, 19 May 2024 13:47:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716151668; cv=pass; d=google.com; s=arc-20160816; b=grvuP5Tj7FrTHXpyDiSr6Vzjn/EttNPKj9SCAyWkqnMhoiglkwQvWcOyamqksnuRe+ oe83SRZVeOKTT6iAnNqf6Z9oeathXYQuZ4wJDzn+wcR8T4gOrmRiwzDozwAY40xq5eWk Q8ZuIyvAhs6mMiw8M5KikT18cb78Cw/9OrPMm8/jkCvA7Duooo7eps9v9/O2nK/TQsmU tEHxxU4T82pW8vjf0ps3oJdjTjZuoYdXl56edpjyxZ5vh3KFKD1corJ90gK4p9zh2jyX BECve8l6lJLLEUnt2uSG54XK293t660hpqURUsf19skFNKCnaF2gG5F9zGbY2A8i/JaN MT7A== 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=tlwkhyW3khwADOinzeaPSPdfRlUQzQSrVhmO5ypWb6X4QIafuzEZeIfQqHByejGGMn 5rRGkIBqlKB/FHqgBup4HWErMAul+0foslpsNxeps2GYWhrg3qhVWWHxRG6kL52UfhOR hT7AWGC620LA/PWN5D0UpqeVqGZc6Xc3VL0y5lLJ6tN9dtTLkEbFpbu+cBtBlAhS8cVN tIwoyyugBDKtlUUovM5fI7xXhmAUVe9DqUqhFuhbXNefhOMerDaOLkNeXy8PbhXICHhb s8NmtAuIi7D2wi2iI3q0ldOIdKHXX2uYtTpNO0+D6+RDJ5o/WYcB4aX/p2lGYU06cn7f xRGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=QCbrF+CJ; 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-183252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-574ec926a32si6533833a12.590.2024.05.19.13.47.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 13:47:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=QCbrF+CJ; 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-183252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183252-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 98B231F22C98 for ; Sun, 19 May 2024 20:30:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D2BB80C04; Sun, 19 May 2024 20:25:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="QCbrF+CJ" 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 82A2171B52; Sun, 19 May 2024 20:25:17 +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=1716150319; cv=none; b=Ihz8YHw5c0JS3S0XZBMU+BdnuUz8tKXQ3um8KXX1ef9jz6Li1TqZzSbduD0I3ok+yfshg+4ASDPWBLSUnynGwyaz9OR9uIN8If1Kx8cKKbZKGCvND81Xt4j2zvp0ibnRQ5h4W9oEcLOkB/quH2kgDCJflJa9356044bGodks3lo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716150319; c=relaxed/simple; bh=FzJOOSC9UUHrWRcI7UAQtasAek/KIUNP0SrrKFAkeFc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pebZen4N4PpTKBFg+uV+bHsFmSOw3fpSc9mQIjlkuaRmoLP6KGtI2cAOssOqGTUf6A8v2zl0coW4/+KXpC/rWp5S0WXhnbQyt6VlocehL312pUSXG7xZ/lsm5LXfzUjoKi6UrFGzX5YBJVJTWSEe5+TH9hZcYoiF9GOdOLMaoS4= 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=QCbrF+CJ; 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=QCbrF+CJT8vL3VIl0W0pStHPvH mLaVYIbWbk7zFe3FuiEMvC3CzWpx6hu/UvNdVAFfV68nGuPT+Yqu68YBDtHk5mEkh+t0F6RJfYLDg 9WjfHLVnhVyFh4vWKxkUs64mIE+FJ9qMvjGPoLvEKkz8bEIi0n0NFGpmLqC0AdB5tRoT4hAjFCSDs ou15sT9aG5nS1uos6ZnISFEc04h0u6XdzbjrM4Bvbjm9Qvgpg11UQnfktykvjsZfKV4qoGncpG78/ VLWEX+ZDYgGST6CUDtJx6/uG1k+7Ke6ZMb76aXtnK7O2VrDwEmk0Mt702nHQDNpR4ZjnrHuPblFN1 tZueIiLw==; 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 1s8n5h-008wIn-1U; Sun, 19 May 2024 15:25:09 -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 v5 24/28] selftests: ntsync: Add some tests for wakeup signaling via alerts. Date: Sun, 19 May 2024 15:24:50 -0500 Message-ID: <20240519202454.1192826-25-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240519202454.1192826-1-zfigura@codeweavers.com> References: <20240519202454.1192826-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