From patchwork Wed Jan 31 02:13:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 194458 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1629615dyb; Tue, 30 Jan 2024 18:31:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGj0CbE5JjyKWptxaxADqc+pcNMjv2gpu0Ic3aZ81hKtUBaAV+8obmpwS86eImJ4qTqcGXv X-Received: by 2002:a05:6214:29cb:b0:68c:5e07:63e9 with SMTP id gh11-20020a05621429cb00b0068c5e0763e9mr372519qvb.24.1706668262900; Tue, 30 Jan 2024 18:31:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706668262; cv=pass; d=google.com; s=arc-20160816; b=EZu9S0G3/WbIzl6ERwtOcQz87UY5AyT2+EQLphhB5oTa1W5l12TBScvRJaXa/C+X+E AdAxirsScOPF5B9HWsOuPLvs7v8y6Denfr6kx3BznEFFt11L4S9iLcBaym/F51UnUKcu Zg4q0Wku5J+hviA5JZ8Nfo0mG77ZvIs2RWLexUOAzr+lcwxMTF61QJ6t8jNubIj8iyaL eegDG++qhowOcVqFNPDb2ExAWYtqQJu8qdFlf62MBnzMkP0SkBzAm9MgrVEkzctBrxxn HMPQb0GUR5nXS+YITSqTZReTZRuTV/k6339HaDU0mHI+VLfmmqHDyQO0l+cydd4TBScD DXSw== 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=In2g/SxOslWdr0ggX/uaBmW3P5Of+22LEm91YJWAe0A=; fh=8eXT+0/cH4c0iDmgMKQmo0uo/p2j09jBBwhOJLOe0CM=; b=UF/F+o+m/8IWbPUQhrsYbCjaXHf+hsDR67QUwD/tOfZxrqQvyZ4qQEB/bh7WfF9+i+ JapDyhsYzPj0zToVjBo8uVnOyZE+2oXgR65mn+VQTHMLWVMoJN2jZYh48lOukrOtsc1y Xi07Sd7qjnWKHmkf9rvvFGxHv/MBGjjkrF50d0qxOY/gXBXb1dqeSVBC7QUewG4kqwgO 1SvKgk+MYl8qJnvogQeC2rm4h+1fFpNYv1VHvCuzUgENotshdOU61AE4IDpsFcGa1cQr fSS3KPD2WzNHOkSvrl6xlz+fX2LhKLKtT2KuvbQqvbl3VJss9cBzMnkLXKqkS1DC1xR+ 4row==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=O6rqaQpH; 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-45650-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45650-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com X-Forwarded-Encrypted: i=1; AJvYcCVVdMDlGR6iQyuV+cc6kNa5dV0CVfCAeYpcHkwqFBiKi16fMnyCQU4t97M6ZsMmF3tb+uR6LA6+DwDgLTGkQP1tQphEdw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id kc7-20020a056214410700b0068c5deda105si3038914qvb.211.2024.01.30.18.31.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 18:31:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45650-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=O6rqaQpH; 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-45650-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45650-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D55B41C27756 for ; Wed, 31 Jan 2024 02:23:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 313223D576; Wed, 31 Jan 2024 02:16:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="O6rqaQpH" 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 947E7746E; Wed, 31 Jan 2024 02:16:06 +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=1706667368; cv=none; b=Pa1mYoBVKQv1xasu4BMIfbxpiGzXHy/6E2W3BnQofubMWojDwbNVSzwbkNyJcqslBvIni7xaK0ZULWowJJUiPxsNRfWar8rWHThl4xKwt1/3WnucRZGG05NpjhupryWFQRrTR+s2xmt7m/YnaINlR2eFgwjwAr1cuLhzPkK77UI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706667368; c=relaxed/simple; bh=0/+/hcgGDqBe60bUVEVmocVH9t5svTQdQZc0NkVSSpc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pT3Cao5OFiX1Jer00CwIDCtQCMmDnzuNaReg7khAI9bf8nLQlzUMMAELY+K2Y8AFNJ0DAS7jeWaEnE2YTJeLuuwFSHsVz7ZkRD1POseVKNKz1LZ2r/5vbtQzgSR3Oa8KnKlinZd4wwquvdDO23uN4iFR2FpcWS2gp99EPI+dGS4= 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=O6rqaQpH; 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=In2g/SxOslWdr0ggX/uaBmW3P5Of+22LEm91YJWAe0A=; b=O6rqaQpHDK+OJLCivF6+Qd0XyV wJQMzjsrn5//04CHK55yjO4hL0I64rS7vXKWVcZ+OErnP0JU8IIXsBCT5mt0T8eBEOOjbcP0KkJmG GDhx2EY9uzYeKaxqiwtKkcDbcb+TsIZFHn4vi5VFmgVpSczH3Y2gDgXbpO9ZivyOBwT2iCJHWG0CX UPKaa3a9dfFyY/SOif9ji24x4+aMRpH1niNLV7rYPLfxjsRLeoJzuuwOokNftlDNEiqLP10aODZBP sxZInVET5kfrRxgrMRQJaAFhS98kKLljV0SENNvAucxDDFA8/jaWeFO1aixdmHa8fxwG+cefI04+7 Qu0IqO/w==; 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 1rV08s-0038Kv-0d; Tue, 30 Jan 2024 20:15:58 -0600 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_Almeida?= , Wolfram Sang , Arkadiusz Hiler , Peter Zijlstra , Andy Lutomirski , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Elizabeth Figura Subject: [RFC PATCH v2 27/29] selftests: ntsync: Add some tests for wakeup signaling via alerts. Date: Tue, 30 Jan 2024 20:13:54 -0600 Message-ID: <20240131021356.10322-28-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131021356.10322-1-zfigura@codeweavers.com> References: <20240131021356.10322-1-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789571380113973875 X-GMAIL-MSGID: 1789571380113973875 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 6c00a55909aa..09153d0686ac 100644 --- a/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c @@ -1080,9 +1080,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); @@ -1130,6 +1133,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 */ @@ -1166,9 +1197,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); @@ -1202,6 +1236,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 */