From patchwork Mon Aug 7 12:18:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 13344116 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 69F2BC04A94 for ; Mon, 7 Aug 2023 12:37:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 490FF8E0002; Mon, 7 Aug 2023 08:37:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 15E1B6B0078; Mon, 7 Aug 2023 08:37:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBA6B900002; Mon, 7 Aug 2023 08:37:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3C8F0900002 for ; Mon, 7 Aug 2023 08:37:10 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 11ACF160A2F for ; Mon, 7 Aug 2023 12:37:10 +0000 (UTC) X-FDA: 81097258620.12.65E18AF Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id D77F940003 for ; Mon, 7 Aug 2023 12:37:07 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eqmLvazG; dmarc=none; spf=none (imf17.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691411828; 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=53jHvCThY56ekVsZwPC+RAqN66FMg8fPTI36UoUqaKU=; b=ZaSbHjk0NJbTMO1nSFAZJrf6jtgnkdGMmgFw7m+3M9UGWQ9pNZ4iZK94EJvlgqkH7cIJ0J nyAlH0Fgcjkp2sZCfYetAm5132agtmT+pfN8TOUMnI5cokuVKuAXRMwbLN3W4b5hCh8yA+ X+1qhOltQcj/5vO763dMyvr8+HsrhrI= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eqmLvazG; dmarc=none; spf=none (imf17.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691411828; a=rsa-sha256; cv=none; b=ZlBrDnhbEb0upyJaIw6Yk+JlpKFjREouSwz/4C1l5PjbKFn5wWztDjgJamXeh5lcW7RieV rHziHlcUskZO6bzh/t5Dmj4VMEZOBtlJCHUvlkRbH3Qkm2s4B7zAHu9Fl565LbjtHTeC9X qwtA5dx+tat9NgbjlDwe8Nsue8rUA6w= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=53jHvCThY56ekVsZwPC+RAqN66FMg8fPTI36UoUqaKU=; b=eqmLvazGl7vBH7qJgPl+mV8Rn1 Db9gNWnIQZ6A9f+8x4iCTa3tOp45OF1tMlCfJCzFVwpufed2L7Syzuc7UOY9iih9D4mimwCVtlcDQ 5FAN+SfFoNcoZgnC0ba/iDFxh6N7opePHRF2GS1XFSgF6jwb1TdsPczXS237JH48Uo2hQM6B4//4N 5GuRLi7XiTPgNCyPEcQw5aln/fT+PUo0QdWUVkjjAyoUG6MzYF3TqTPqdrdvCZsTN9LYGFKD0FGFf TQK0/YtXVD4x9hkj8ivhhhRiVCQ2Rx4zxOsKNOlw0CNxd3aDi11330mX1Q9ng36kvGJP2ha83Y9ht EjcAsWdA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qSzTk-00AxFz-Rv; Mon, 07 Aug 2023 12:36:57 +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)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D39913005A2; Mon, 7 Aug 2023 14:36:54 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 8A81C2021C3D4; Mon, 7 Aug 2023 14:36:54 +0200 (CEST) Message-ID: <20230807123322.814039156@infradead.org> User-Agent: quilt/0.66 Date: Mon, 07 Aug 2023 14:18:44 +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: [PATCH v2 01/14] futex: Clarify FUTEX2 flags References: <20230807121843.710612856@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D77F940003 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 16quya88i9mpdp6s9r76ecc7cj9fusor X-HE-Tag: 1691411827-505605 X-HE-Meta: U2FsdGVkX18eA9Ol54IlV2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EzhMtPM9TW7VWyIc3CITlBtetEcxN4eJYC080XtQaVDaFQhEOr65CZsSSFqGmNeccCWeeMnRepSsPEvH23PyJBdXqotIIDhnFitrbkHXnAZFV8H94VZl8BgN58712zAelz2o6QBVDS2vFKbLAq1aGt0XoyFWZ4TtTrQ== 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) Reviewed-by: Thomas Gleixner Reviewed-by: André Almeida --- 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_SIZE_U32 0x02 + /* 0x04 */ + /* 0x08 */ + /* 0x10 */ + /* 0x20 */ + /* 0x40 */ +#define FUTEX2_PRIVATE FUTEX_PRIVATE_FLAG + +/* do not use */ +#define FUTEX_32 FUTEX2_SIZE_U32 /* 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_VALID_MASK (FUTEX2_SIZE_U32 | 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_VALID_MASK) || aux.__reserved) return -EINVAL; - if (!(aux.flags & FUTEX_32)) + if (!(aux.flags & FUTEX2_SIZE_U32)) return -EINVAL; futexv[i].w.flags = aux.flags;