From nobody Sat Jul 25 02:10:51 2026 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 2AF954779A9 for ; Mon, 20 Jul 2026 17:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784570067; cv=none; b=L8x+JGrqQGjSxg7v8P99VSJmmdkFChCQbsgqmannJAKSCi/BKhfCNFlFJFju0kLQMxuK8U3Oz1rOhUce1dHjsLg+qfywm9vPeTLI2V79alfoNM3LZDRiGqZi/p7ijZbuC+yoXRBU0wVRg5nyzee5QY0Bbfr12d5fEivtn7FZOwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784570067; c=relaxed/simple; bh=8PnWAwaPwirmO4GgL7LEGlIqHi6SyKLQQ7uw3JXA7yQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CJZyjNkHmFhzSDD3EXhD43ft8NCRdfPUbZFLOOW8wozCm9evJir60V6C7nnYSQVlaleDqc/XzYyFvU/7zlZTWBinzRDeQpg+5+5/wFUZprU6hST8Agm0Dhd90bZFHKAVHQnitq8YS79VSqyUf0THZauZ/6FfTdyXPVqYZAk8ZPw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HyIqqgSr; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HyIqqgSr" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-38e08baf860so8007626a91.2 for ; Mon, 20 Jul 2026 10:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784570059; x=1785174859; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=NzAJq7vlEZOu57+6zY6rNgf3B6FzEOANzSndOpxDhqo=; b=HyIqqgSrmaPkAM/HeyiCHpeJsgqnMgCvDzj/c26lbx8Bf4EF2ADU1pa7Brv2lHItTN TvOjdPH/UMtVIv2J5N+WpUztdToTAxAtb0amKdMbL4mP4rnWYBLbhSFxlyNMC1eOmYnU RwUqYRWg1x3/yDdX+mLGdpAqag+ZIOwwBXiP/YBaJyordQfUaKXgwGn5+RIacZVT1t9k u1gIG6NP0dz597//asX4gYY6kyYp672ifYPasSL5Tq/r0jiOKH4fjStVM31atIcHGPKN Ug40fU4GzuZ73s8S2fwOjThelElhstrfb8T9611EO2yP12rxUP3QUbge5l7c9rBNNaAy Fo/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784570059; x=1785174859; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=NzAJq7vlEZOu57+6zY6rNgf3B6FzEOANzSndOpxDhqo=; b=n9wQUwECmgLbobPYWH208ukOjafLwubzEATuLr9g0e7FMjUCTftTBOdvuw3ZChJhCF kDJJp3bHUY4BGXGC5PA1OkrG5Q2H5CKzAEYZtsmE4Vq09fu/d4YxCSc+JIdvM2yi/34I SbWHr8mRIXWR3t4kNheJ9At5Scoqv9nqA5s+4kWkcPetGOmsS0MIIujNUC9UHTYpt3hD PxaQXLVXFvFX0blY541j+lyC53vjhSLjQSTMVvMd5RrSqK77etBbI/hoI1KMY+KYWEdU MfKxacx1QVE0QCuhn/Zan9hKRUJTSy+2CWffYMqVnfVZ4nsZkmJ2Z/k4DLiHVBw6XsaM n3Tg== X-Forwarded-Encrypted: i=1; AHgh+RrbuORq/trvH6UhcQZFQUs4D0XKdvcC2B+G3tSn6/bEW5jSAVZtdOdQO4ggW5RQjvz1+nvvOeGvxER8/Sk=@vger.kernel.org X-Gm-Message-State: AOJu0Ywt7tT4okVHswEi125qDYSumFbC4bwWQSia9w6V8+cLGzxB0BEO SleOhvvdII9pbFPnRjnSlvdR6okR2py/AZplwTa32NMLzKCfn+R5NmgK X-Gm-Gg: AR+sD11g4dNPHXcAfGhtIItetrGmRL6ij8lmDgwckxY6aKGFNHMYT3N0vARuMv+LRXK CLjbsBQgEuame4ESZdr1QTWDQpHdbq/5ftG0bTrfGc+yNERqSf+gp5Q672eE/6/fa9SCQsdowZy igzTk4l3WMrmuK9DbyV8uRS1Mx1KD/WVtjBcI06eJTsfkkrlpe2rUTlDeUW8scWcWzRxce7ABsQ A++ylDXfKwx45Ok7SW6bozBy1fAF4C/8WnHJ8lAQv93KxAW+eK1dSQi1VkRun0yYzDxlLHqSH8m bgkB7KGYd0Wccxf9q2+j69HA25qAngh7zZpOlIDs8XDivk+WPmaqMhzNGtZ5iiKGiaaRUs2B7Ys EWGco/PCUHRUoKcSGIZXVOK0PvsmxKmiOha/vtRkpr+310AK6yU/5QAebT0vVE2C0xJwus3PV X-Received: by 2002:a17:90b:5588:b0:38d:a150:ee04 with SMTP id 98e67ed59e1d1-38e4b55aabfmr15311812a91.30.1784570058844; Mon, 20 Jul 2026 10:54:18 -0700 (PDT) Received: from unix.. ([181.229.23.179]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13ce2de31a7sm33370583c88.15.2026.07.20.10.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 10:54:18 -0700 (PDT) From: =?UTF-8?q?Iv=C3=A1n=20Ezequiel=20Rodriguez?= To: Elizabeth Figura Cc: Jonathan Corbet , linux-doc@vger.kernel.org, Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Iv=C3=A1n=20Ezequiel=20Rodriguez?= Subject: [PATCH 1/2] docs: ntsync: align ioctl names and struct layouts with uapi Date: Mon, 20 Jul 2026 14:54:01 -0300 Message-ID: <20260720175402.44338-2-ivanrwcm25@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720175402.44338-1-ivanrwcm25@gmail.com> References: <20260720175402.44338-1-ivanrwcm25@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The uAPI documentation used outdated or conceptual ioctl macro names and listed ntsync_event_args / ntsync_wait_args fields in the wrong order. Match include/uapi/linux/ntsync.h and note that absolute MONOTONIC timeouts are interpreted in the caller's time namespace. Signed-off-by: Iv=C3=A1n Ezequiel Rodriguez --- Documentation/userspace-api/ntsync.rst | 33 +++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Documentation/userspace-api/ntsync.rst b/Documentation/userspa= ce-api/ntsync.rst index 25e7c4aef968..a778016feb87 100644 --- a/Documentation/userspace-api/ntsync.rst +++ b/Documentation/userspace-api/ntsync.rst @@ -83,18 +83,18 @@ structures used in ioctl calls:: }; =20 struct ntsync_event_args { - __u32 signaled; __u32 manual; + __u32 signaled; }; =20 struct ntsync_wait_args { __u64 timeout; __u64 objs; __u32 count; - __u32 owner; __u32 index; - __u32 alert; __u32 flags; + __u32 owner; + __u32 alert; __u32 pad; }; =20 @@ -152,7 +152,7 @@ The ioctls on the device file are as follows: =20 The ioctls on the individual objects are as follows: =20 -.. c:macro:: NTSYNC_IOC_SEM_POST +.. c:macro:: NTSYNC_IOC_SEM_RELEASE =20 Post to a semaphore object. Takes a pointer to a 32-bit integer, which on input holds the count to be added to the semaphore, and on @@ -186,7 +186,7 @@ The ioctls on the individual objects are as follows: unowned and signaled, and eligible threads waiting on it will be woken as appropriate. =20 -.. c:macro:: NTSYNC_IOC_SET_EVENT +.. c:macro:: NTSYNC_IOC_EVENT_SET =20 Signal an event object. Takes a pointer to a 32-bit integer, which on output contains the previous state of the event. @@ -194,12 +194,12 @@ The ioctls on the individual objects are as follows: Eligible threads will be woken, and auto-reset events will be designaled appropriately. =20 -.. c:macro:: NTSYNC_IOC_RESET_EVENT +.. c:macro:: NTSYNC_IOC_EVENT_RESET =20 Designal an event object. Takes a pointer to a 32-bit integer, which on output contains the previous state of the event. =20 -.. c:macro:: NTSYNC_IOC_PULSE_EVENT +.. c:macro:: NTSYNC_IOC_EVENT_PULSE =20 Wake threads waiting on an event object while leaving it in an unsignaled state. Takes a pointer to a 32-bit integer, which on @@ -213,7 +213,7 @@ The ioctls on the individual objects are as follows: afterwards, and a simultaneous read operation will always report the event as unsignaled. =20 -.. c:macro:: NTSYNC_IOC_READ_SEM +.. c:macro:: NTSYNC_IOC_SEM_READ =20 Read the current state of a semaphore object. Takes a pointer to struct :c:type:`ntsync_sem_args`, which is used as follows: @@ -225,7 +225,7 @@ The ioctls on the individual objects are as follows: * - ``max`` - On output, contains the maximum count of the semaphore. =20 -.. c:macro:: NTSYNC_IOC_READ_MUTEX +.. c:macro:: NTSYNC_IOC_MUTEX_READ =20 Read the current state of a mutex object. Takes a pointer to struct :c:type:`ntsync_mutex_args`, which is used as follows: @@ -242,7 +242,7 @@ The ioctls on the individual objects are as follows: ``EOWNERDEAD``. In this case, ``count`` and ``owner`` are set to zero. =20 -.. c:macro:: NTSYNC_IOC_READ_EVENT +.. c:macro:: NTSYNC_IOC_EVENT_READ =20 Read the current state of an event object. Takes a pointer to struct :c:type:`ntsync_event_args`, which is used as follows: @@ -255,7 +255,7 @@ The ioctls on the individual objects are as follows: - On output, contains 1 if the event is a manual-reset event, and 0 otherwise. =20 -.. c:macro:: NTSYNC_IOC_KILL_OWNER +.. c:macro:: NTSYNC_IOC_MUTEX_KILL =20 Mark a mutex as unowned and abandoned if it is owned by the given owner. Takes an input-only pointer to a 32-bit integer denoting the @@ -276,11 +276,12 @@ The ioctls on the individual objects are as follows: * - ``timeout`` - Absolute timeout in nanoseconds. If ``NTSYNC_WAIT_REALTIME`` is set, the timeout is measured against the REALTIME clock; - otherwise it is measured against the MONOTONIC clock. If the - timeout is equal to or earlier than the current time, the - function returns immediately without sleeping. If ``timeout`` - is U64_MAX, the function will sleep until an object is - signaled, and will not fail with ``ETIMEDOUT``. + otherwise it is measured against the MONOTONIC clock in the + caller's time namespace. If the timeout is equal to or earlier + than the current time, the function returns immediately + without sleeping. If ``timeout`` is U64_MAX, the function will + sleep until an object is signaled, and will not fail with + ``ETIMEDOUT``. * - ``objs`` - Pointer to an array of ``count`` file descriptors (specified as an integer so that the structure has the same --=20 2.43.0 From nobody Sat Jul 25 02:10:51 2026 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 00071478874 for ; Mon, 20 Jul 2026 17:54:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784570071; cv=none; b=ABagDwKV/fOo0fr+pSVIrLRJVOwBD8PCVyosKyAETTUJ9wetkWuYUv/NZ7bK9qivwvk1Igw3tE8DE1+mvPyMFW27lixKf850GYczVUt4CJ1lqUCNuzVyIhx6oBXDtlw+toEvGTq15McJq/0fj1Q2qGKiTrMByIqvRIcPSrbbzWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784570071; c=relaxed/simple; bh=YPrW1TXrbX+u0gKgK8sf9Rj21grSgx0mklEsAxueIjU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ORy2RpzarbuNSbU395JpFerCYN2ILbYgVBUzF3wgQyNwouX/Ko4p3isTIh/QO2Z+8pfUsSnMTXzEdOyfgv5vP3YseIuvk9FmwIC7xPo9iqNkiIdAl6nM241z6wsfhhppILTGZTR5Nls9SCa96K9p9wYSG1xXXJoPVbxmd1xUHYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ksr75Z6L; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ksr75Z6L" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-382ef647e20so9888761a91.1 for ; Mon, 20 Jul 2026 10:54:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784570062; x=1785174862; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=iyEs7k1vrNWNt95uYWZYqppv3Skiym40EV0k7tALo6w=; b=ksr75Z6L6BMa/cCk38UpzCJ2R1JQx+pg5cP3BRL2GjDk+pcginU3hwhuIznpTKpp7u Tf7jA0PHkaUy9J6kg9uD9/KMOybSJBUsnSZC9+w9XH77azve59Zdo0pVALDdfWP0rQzO IX9U6KMuogQYJ2r07VUdDE0KEq+fn5Ag1jlBYIJHij0jH8hLoxEpvKX3vxMHG3zg+THq 15CNRHVF6A9hMUQXeOz0N1cyyI7tFm7CYKBxcsxnAUh6+VC02GabY+6kFmEU7VrMS7wM 6kaQMpPWYOwSyoLqH6QSQHlWlVrHe7epcWPk+iA7qpuwS1LBrJdBn0KlcLskc2PKs1hm zUDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784570062; x=1785174862; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=iyEs7k1vrNWNt95uYWZYqppv3Skiym40EV0k7tALo6w=; b=Nzb6ho0UdR3ZUU+U5Dff2PyOye/kP3Y2cElUyRygO7LT894yNL/gq+YcJ6UY1t0sJ0 fHftFcf7soJzlmJMtR4OeEhN/LQ88KgTudQkWPNzTP3Cq2CmcfSFtamQ0FBfBjNdV7mh fOphege2F9CJg7rN3QJ+Ek5/dlkQ8jaTBVg01f3RwGdHNfbttfc5YRgi53TBy72N4Gc4 HTGHBpfxDiElPsHn+z5pye5hdroR/upvDgl2p10Bn76w3qzRgamG7FVX/JODN7xE3zw2 FztTNT6pMN+0nMU2bE8TNgQekQ2LRMemoCJA0DCTY4zb6kkHu1bekrtxsojCM7Qko/Ui eg8A== X-Forwarded-Encrypted: i=1; AHgh+RoRRKmJciWmjCfrjQjvWIL6X7YFyKRgev5OHHYSaLHOVPb+swQ1ynuo8ioDEZ1CF7naWRKk1GgpkU66m7w=@vger.kernel.org X-Gm-Message-State: AOJu0Ywvm1DJ1Hoz6ACrM1JiH0FO189ox4vH4TUW63z5KncOcsT1HWkZ f4ScSmW881Och/iq9n09/1bau+O5YgucQg0AcDx0r5Cd15lfnyucj70G X-Gm-Gg: AR+sD12pMJ2JnWzGCyJZoym8dGhxi0nmNPEsG1tR7NfCYKm9yBIxZhGYqMztqJNAWkK 6w3gUY9lIcyPIwCcYW6kTR6PiigwcixQy1q5Apl8MlzP6xE4esNGngDFrgxxTi6bY9dXdHqLprz kfV0JJtE5Am8TCIFWDqjZxD9HLcvGWAK5kH7xBWQsm9TXtkniVGvU4IituLgym3CQ1CFQrCM8GQ 4d8oya8i4WpmzUI+FSn7pDVNuKzTSnuBVUhT3eWbbFFbZK9eeirmFnobgguUHitdYRZ+QoFRa2t NthRPvjUxE0e4JfoW8iFH6wbeGaDpz0hLibRQkxp/sJFO2PqNZIcQGGaY5+vv1WZdbrK8qQdwCo +lEb8yjBPadyU59pyYuQ+TA+4fshhllxO5tkrwvG1KPv0P9sMl6f/R9ihFyWf/UY2v/zCdThq X-Received: by 2002:a17:90b:1b43:b0:38d:eb10:6f01 with SMTP id 98e67ed59e1d1-38e4b422875mr15703816a91.4.1784570061412; Mon, 20 Jul 2026 10:54:21 -0700 (PDT) Received: from unix.. ([181.229.23.179]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13ce2de31a7sm33370583c88.15.2026.07.20.10.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 10:54:20 -0700 (PDT) From: =?UTF-8?q?Iv=C3=A1n=20Ezequiel=20Rodriguez?= To: Elizabeth Figura Cc: Jonathan Corbet , linux-doc@vger.kernel.org, Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Iv=C3=A1n=20Ezequiel=20Rodriguez?= , Maoyi Xie Subject: [PATCH 2/2] selftests: ntsync: test absolute MONOTONIC waits under time namespaces Date: Mon, 20 Jul 2026 14:54:02 -0300 Message-ID: <20260720175402.44338-3-ivanrwcm25@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720175402.44338-1-ivanrwcm25@gmail.com> References: <20260720175402.44338-1-ivanrwcm25@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Cover the timens conversion in ntsync_schedule(): with a negative CLOCK_MONOTONIC offset, a 100 ms absolute wait must not return immediately against the host clock. Suggested-by: Maoyi Xie Signed-off-by: Iv=C3=A1n Ezequiel Rodriguez --- .../testing/selftests/drivers/ntsync/ntsync.c | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testin= g/selftests/drivers/ntsync/ntsync.c index e6a37214aa46..ce000ff41535 100644 --- a/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c @@ -8,12 +8,18 @@ #define _GNU_SOURCE #include #include +#include #include +#include #include #include #include #include "kselftest_harness.h" =20 +#ifndef CLONE_NEWTIME +#define CLONE_NEWTIME 0x00000080 +#endif + static int read_sem_state(int sem, __u32 *count, __u32 *max) { struct ntsync_sem_args args; @@ -1340,4 +1346,85 @@ TEST(stress_wait) close(stress_device); } =20 +/* + * Absolute MONOTONIC timeouts must honour the caller's time namespace. + * With a negative monotonic offset, a 100 ms wait must still take ~100 ms + * of namespace time (not return immediately against the host clock). + */ +TEST(wait_any_monotonic_timens) +{ + struct ntsync_sem_args sem_args =3D {0}; + struct ntsync_wait_args wait_args =3D {0}; + struct timespec start, end; + char buf[64]; + __u64 elapsed_ns; + int fd, offset_fd, sem, ret, status, len; + pid_t pid; + + if (access("/proc/self/ns/time", F_OK)) + SKIP(return, "Time namespaces are not supported"); + + fd =3D open("/dev/ntsync", O_CLOEXEC | O_RDONLY); + if (fd < 0) + SKIP(return, "/dev/ntsync is not available"); + + ret =3D unshare(CLONE_NEWTIME); + if (ret) { + close(fd); + if (errno =3D=3D EPERM) + SKIP(return, "need CAP_SYS_ADMIN for CLONE_NEWTIME"); + ASSERT_EQ(0, ret); + } + + len =3D snprintf(buf, sizeof(buf), "%d %d 0", CLOCK_MONOTONIC, -10); + offset_fd =3D open("/proc/self/timens_offsets", O_WRONLY); + ASSERT_LE(0, offset_fd); + ASSERT_EQ(len, write(offset_fd, buf, len)); + close(offset_fd); + + pid =3D fork(); + ASSERT_LE(0, pid); + if (!pid) { + int obj; + + sem_args.count =3D 0; + sem_args.max =3D 1; + sem =3D ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); + if (sem < 0) + _exit(1); + + obj =3D sem; + wait_args.timeout =3D get_abs_timeout(100); + wait_args.objs =3D (uintptr_t)&obj; + wait_args.count =3D 1; + wait_args.owner =3D 123; + wait_args.index =3D 0xdeadbeef; + + if (clock_gettime(CLOCK_MONOTONIC, &start)) + _exit(2); + ret =3D ioctl(fd, NTSYNC_IOC_WAIT_ANY, &wait_args); + if (clock_gettime(CLOCK_MONOTONIC, &end)) + _exit(2); + + if (ret !=3D -1 || errno !=3D ETIMEDOUT) + _exit(3); + + elapsed_ns =3D (end.tv_sec - start.tv_sec) * 1000000000ULL + + (end.tv_nsec - start.tv_nsec); + /* Without timens conversion this returns in ~0 ms. */ + if (elapsed_ns < 50 * 1000000ULL) + _exit(4); + if (elapsed_ns > 1000 * 1000000ULL) + _exit(5); + + _exit(0); + } + + ASSERT_EQ(pid, waitpid(pid, &status, 0)); + EXPECT_TRUE(WIFEXITED(status)); + EXPECT_EQ(0, WEXITSTATUS(status)); + + close(fd); +} + TEST_HARNESS_MAIN --=20 2.43.0