Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1612614ybt; Thu, 9 Jul 2020 11:01:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjam6Idp5oKzmn4NgOdNhr5Ng6K3DiE7xEk2stIx1OdvCmH+q69wcwNbTN23duqzYaD0Ae X-Received: by 2002:a17:906:edb3:: with SMTP id sa19mr56468195ejb.21.1594317673821; Thu, 09 Jul 2020 11:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594317673; cv=none; d=google.com; s=arc-20160816; b=UDnbucLDcP3EnP4MWuZ9xDyRKLE/mnI8N/12Wbo/SL+z9q2NE3ZaMNzcFB/CLSnLgH 4EtUfJi1EGrjAeNwQt/sEWZZ3+bzq4fyghbSemcVS3NpqFvXzJiDBxbWLnRrlSbnC7Y7 C2LzmnoHMzEp4vyw10YghgxirT0NKMxTZLVDP0W2vJawycu7tdbSJmwcxRkB9jh/nunH 04GMjiBOPhQbLNE2eSYLbguFYiHEv7i81lsdtzbxI3K7ih7nhP6gNp4D9aJuvb8ExOiq ACSOAYOrd06nQa/zC++FM8nY+smUHEmTDabPaGWWzDcX1IeffNVCYGsqsDPr1tsCj320 XWQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=jUU9tLahOnn2jlPUVirsWDsFOjCgx+5Jhyr9qe46uJg=; b=eOmdAgdKJhW1x/qS+gpKrxiiasyRElyhF1bH0S30NQRdlPd/PnJ3k8GDyp6Xdn333z Fji4boixNnE0Bk1xMOIek5Qc/WBipHu657OUbH60I9OBItVKFGCBVyS40el+BX6Mubd5 u9FAo+0gxSAFX65tqbzymxq2uvKms1z3QNvW/4HtlnIXSdLWuihZAY8WE2rhzU5Dq6Y6 Srp4bpbZ8A+hJlCt81YxlWSuLbT3GeWux/d3EoLSQUvqF5hlkRx54TfapVwBmh9xyS6p Q1r18zpkPblVRZPQvS2BBN1CQ0mxifn92Nb7NTi/tXD8lx4NjdpBYjpKZJLnDp0exOc2 rR2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm9si2635215ejc.624.2020.07.09.11.00.49; Thu, 09 Jul 2020 11:01:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728408AbgGISAl (ORCPT + 99 others); Thu, 9 Jul 2020 14:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726793AbgGISAk (ORCPT ); Thu, 9 Jul 2020 14:00:40 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8AB1C08C5CE; Thu, 9 Jul 2020 11:00:40 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id C5E122A65E7 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: linux-kernel@vger.kernel.org, tglx@linutronix.de, peterz@infradead.org Cc: krisman@collabora.com, kernel@collabora.com, andrealmeid@collabora.com, dvhart@infradead.org, mingo@redhat.com, pgriffais@valvesoftware.com, fweimer@redhat.com, libc-alpha@sourceware.org, malteskarupke@web.de, linux-api@vger.kernel.org, arnd@arndb.de Subject: [RFC v2 0/4] futex2: Add new futex interface Date: Thu, 9 Jul 2020 14:59:17 -0300 Message-Id: <20200709175921.211387-1-andrealmeid@collabora.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, This RFC is a followup to the previous discussion initiated from my last patch "futex: Implement mechanism to wait on any of several futexes"[1]. As stated in the thread, the correct approach to move forward with the wait multiple operation would be to create a new syscall that would have all new cool features. The first patch adds the new interface and just translate the call for the old interface, without implementing new features. The goal here is to establish the interface and to check if everyone is happy with this API. The rest of patches are selftests to show the interface in action. I have the following questions: - What suggestions do you have to implement this? Start from scratch or reuse the most code possible? - The interface seems correct and implements the requirements asked by you? Those are the cool new features that this syscall should address some day: - Operate with variable bit size futexes, not restricted to 32: 8, 16 and 64 - Wait on multiple futexes, using the following semantics: struct futex_wait { void *uaddr; unsigned long val; unsigned long flags; }; sys_futex_waitv(struct futex_wait *waiters, unsigned int nr_waiters, unsigned long flags, struct __kernel_timespec *timo); - Have NUMA optimizations: if FUTEX_NUMA_FLAG is set, the `void *uaddr` argument won't be a value of type u{8, 16, 32, 64} anymore, but a struct containing a NUMA node hint: struct futex32_numa { u32 value __attribute__ ((aligned (8))); u32 hint; }; struct futex64_numa { u64 value __attribute__ ((aligned (16))); u64 hint; }; Thanks, André Changes since v1: - The timeout argument now uses __kernel_timespec as type - time32 interface was removed v1: https://lore.kernel.org/patchwork/cover/1255437/ [1] https://lore.kernel.org/patchwork/patch/1194339/ André Almeida (4): futex2: Add new futex interface selftests: futex: Add futex2 wake/wait test selftests: futex: Add futex2 timeout test selftests: futex: Add futex2 wouldblock test MAINTAINERS | 2 +- arch/x86/entry/syscalls/syscall_32.tbl | 2 + arch/x86/entry/syscalls/syscall_64.tbl | 2 + include/linux/syscalls.h | 7 ++ include/uapi/asm-generic/unistd.h | 8 +- include/uapi/linux/futex.h | 10 ++ init/Kconfig | 7 ++ kernel/Makefile | 1 + kernel/futex2.c | 73 ++++++++++++ kernel/sys_ni.c | 4 + tools/include/uapi/asm-generic/unistd.h | 7 +- .../selftests/futex/functional/.gitignore | 1 + .../selftests/futex/functional/Makefile | 4 +- .../selftests/futex/functional/futex2_wait.c | 111 ++++++++++++++++++ .../futex/functional/futex_wait_timeout.c | 38 ++++-- .../futex/functional/futex_wait_wouldblock.c | 33 +++++- .../testing/selftests/futex/functional/run.sh | 3 + .../selftests/futex/include/futex2test.h | 77 ++++++++++++ 18 files changed, 373 insertions(+), 17 deletions(-) create mode 100644 kernel/futex2.c create mode 100644 tools/testing/selftests/futex/functional/futex2_wait.c create mode 100644 tools/testing/selftests/futex/include/futex2test.h -- 2.27.0