From patchwork Fri Jul 14 13:39:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 13313723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79945C04FE0 for ; Fri, 14 Jul 2023 14:16:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5EF68D0003; Fri, 14 Jul 2023 10:16:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC5B08D0007; Fri, 14 Jul 2023 10:16:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C4238D0003; Fri, 14 Jul 2023 10:16:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 720048D0001 for ; Fri, 14 Jul 2023 10:16:33 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4483514028E for ; Fri, 14 Jul 2023 14:16:33 +0000 (UTC) X-FDA: 81010417866.07.DD5AFEE Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf02.hostedemail.com (Postfix) with ESMTP id 1F97B80030 for ; Fri, 14 Jul 2023 14:16:30 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=keXvIPEO; dmarc=none; spf=none (imf02.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689344191; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:references:dkim-signature; bh=QqRA1A/aeG7Vp+frAisWOweSXHDCgPVqvl/Ov07GdYA=; b=PaMpMKtHTd8QSc5fiQb3b42w4j9GoRPv+uh8sjBVaN4ClnLC3KfCSC0V0mgZdkESCccHw1 vXv/m3SJuZcxt2cssVEUR2KF5J1RKmz9NTrxkcsVqwXH0RvbbSEhhi05+yBEAqPHssZsGj T2Zj8Jhwcg51CL7zXKI+PIOPANF8smw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=keXvIPEO; dmarc=none; spf=none (imf02.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689344191; a=rsa-sha256; cv=none; b=OuTGEjlyMRx4c++icnhwC5x5bqwevkU8RBmQyASLyGjuLUtTOJ8qdsXOTuv2bROwsWEpCX yeONIglCmsSNCZ4wsJ7Fc+fwMD2GVE4wj2WHsK2Cgwu7+AQprtGGVMpdmo6n0ik6+WTHFn +/UFuumkQuR2QE8kLzuGERb2SgzWGy4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=QqRA1A/aeG7Vp+frAisWOweSXHDCgPVqvl/Ov07GdYA=; b=keXvIPEO22MCTYT4gVabzMzK4E 7zZ4B7VY3kbDqlVMOrYGQfJiEOSPC6TYRJwwLI4z77Mas0c6YAf8GNXbwWcnhfyKRjasvonlAqnBW +mJC9B+tXoPm19KZVSUqRxMF7xg73W6zJrsVfUwVqdzrEHWjFQnujsu33OkbGmCFyJwnz5GZzDle7 H9739utpS0sI3pEmgP1kgng0pbxnX6+lYHnPrWYSOAAt7it9tZSJbJHoOuUD8hx0g3LLH0uPTvNvE LhxvjVH8fIzku5xDR10iHOMR6yvT3U+fPYGSL56BOtfdNaCpQgl9mBurFiJ50dh/4e4oPwLfZQc2k fcIiaoxw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qKJah-006Iiv-21; Fri, 14 Jul 2023 14:16:16 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A22C4300513; Fri, 14 Jul 2023 16:16:13 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 5EA7E200D83A3; Fri, 14 Jul 2023 16:16:13 +0200 (CEST) Message-ID: <20230714141218.679746713@infradead.org> User-Agent: quilt/0.66 Date: Fri, 14 Jul 2023 15:39:00 +0200 From: Peter Zijlstra To: tglx@linutronix.de, axboe@kernel.dk Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, dvhart@infradead.org, dave@stgolabs.net, andrealmeid@igalia.com, Andrew Morton , urezki@gmail.com, hch@infradead.org, lstoakes@gmail.com, Arnd Bergmann , linux-api@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, malteskarupke@web.de Subject: [RFC][PATCH 01/10] futex: Clarify FUTEX2 flags References: <20230714133859.305719029@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1F97B80030 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cjwzgwccc3phcn9so56qqpjw3o64ye45 X-HE-Tag: 1689344190-337648 X-HE-Meta: U2FsdGVkX1+62P+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xGCWfljV8eWO5JqkZUH1+mwvrTulffCWkahna18PW6QoABXZmo1aj7OFp8qNV8RhbWMsc53FDgfx6VuLxJy9sVCd/JsOODTJ1pBnI1xY/uZ7u7iTNEu1p3Ci9MfoN7dAPXoUd4K+nbLZ0p7Z8FiKX4dcqsvDr7FZMnK61BAcWGI5XtdA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: sys_futex_waitv() is part of the futex2 series (the first and only so far) of syscalls and has a flags field per futex (as opposed to flags being encoded in the futex op). This new flags field has a new namespace, which unfortunately isn't super explicit. Notably it currently takes FUTEX_32 and FUTEX_PRIVATE_FLAG. Introduce the FUTEX2 namespace to clarify this Signed-off-by: Peter Zijlstra (Intel) --- include/uapi/linux/futex.h | 16 +++++++++++++--- kernel/futex/syscalls.c | 7 +++---- 2 files changed, 16 insertions(+), 7 deletions(-) --- a/include/uapi/linux/futex.h +++ b/include/uapi/linux/futex.h @@ -44,10 +44,20 @@ FUTEX_PRIVATE_FLAG) /* - * Flags to specify the bit length of the futex word for futex2 syscalls. - * Currently, only 32 is supported. + * Flags for futex2 syscalls. */ -#define FUTEX_32 2 + /* 0x00 */ + /* 0x01 */ +#define FUTEX2_32 0x02 + /* 0x04 */ + /* 0x08 */ + /* 0x10 */ + /* 0x20 */ + /* 0x40 */ +#define FUTEX2_PRIVATE FUTEX_PRIVATE_FLAG + +/* do not use */ +#define FUTEX_32 FUTEX2_32 /* historical accident :-( */ /* * Max numbers of elements in a futex_waitv array --- a/kernel/futex/syscalls.c +++ b/kernel/futex/syscalls.c @@ -183,8 +183,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uad return do_futex(uaddr, op, val, tp, uaddr2, (unsigned long)utime, val3); } -/* Mask of available flags for each futex in futex_waitv list */ -#define FUTEXV_WAITER_MASK (FUTEX_32 | FUTEX_PRIVATE_FLAG) +#define FUTEX2_MASK (FUTEX2_32 | FUTEX2_PRIVATE) /** * futex_parse_waitv - Parse a waitv array from userspace @@ -205,10 +204,10 @@ static int futex_parse_waitv(struct fute if (copy_from_user(&aux, &uwaitv[i], sizeof(aux))) return -EFAULT; - if ((aux.flags & ~FUTEXV_WAITER_MASK) || aux.__reserved) + if ((aux.flags & ~FUTEX2_MASK) || aux.__reserved) return -EINVAL; - if (!(aux.flags & FUTEX_32)) + if (!(aux.flags & FUTEX2_32)) return -EINVAL; futexv[i].w.flags = aux.flags;