From patchwork Fri Jul 21 10:22:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 13321855 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 04201C001DC for ; Fri, 21 Jul 2023 10:58:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDB3B2801B5; Fri, 21 Jul 2023 06:58:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B8BCB2801A0; Fri, 21 Jul 2023 06:58:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CA7E2801B5; Fri, 21 Jul 2023 06:58:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6D87A2801B6 for ; Fri, 21 Jul 2023 06:58:52 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3B6BA12011F for ; Fri, 21 Jul 2023 10:58:52 +0000 (UTC) X-FDA: 81035321304.02.2BB6AD8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id 561591C000D for ; Fri, 21 Jul 2023 10:58:49 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lFE5dOaG; dmarc=none; spf=none (imf18.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=1689937130; 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=XSqABfDSg7CpbZUYjtE0SoRmY/PgIzg7fdq61l7mHfEplqwnC1wuvIDHSTsR6GHYe+e47T AX6JrDf6mLjXP2vRYH3G9SHa1JuhISgql0B6l+FoXllDh+NodhUDszZWiUKZAjKMzA4okU +35UfgTvKJ4lO7vnAWReVC64ZB2sRDM= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lFE5dOaG; dmarc=none; spf=none (imf18.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=1689937130; a=rsa-sha256; cv=none; b=oqUop+7x5Wc92Te25BC4youhPa2HtfVrjsKM3r0Kg4sgmIsCGJ2Cm3NQglJc1VAKCV5S0c mf2P/DeIWqr0MgbdfDjkKoPexVeayUDTDv2JlGP310X9CyxFSka2CPLudbNQ6m5e8RgwPy 1BPZ/ghu1MstspkaBDH0v+7hGkCAkog= 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=QqRA1A/aeG7Vp+frAisWOweSXHDCgPVqvl/Ov07GdYA=; b=lFE5dOaGAlq2HalXhGp6uGQIwK esgYEROcz1Z6gk7Ytrd5tH8FRsG5OraXU5DaAG3mohup4EZtz2C7uGTEdDJgwGcFd5YlPZVSDnapP 8QsC1JaNsIo2SS6rv3zyjqt5LbwmVZrhtzE5D+QvYdUoWmP9/8NZ+Twmb4Wx6kxVG2goXOQC3OmiQ idJezFWYDjADNhx1Iz2iXmcLZu6awhOdlZQYjsThacLzjLe9IZTXsqtzsnBnp5cN2I2ueP48gmbk/ a5aYgcIuyM6UEqCwnWWBb4kn6f8E7y1Cuu6lR4NT7wYYwfmpd1zQPV6iWAagupMEQsDaARZ48MD5H bIcqw28A==; 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 1qMnqJ-0012OV-Jo; Fri, 21 Jul 2023 10:58:40 +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 2E5DF300513; Fri, 21 Jul 2023 12:58:38 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id E9077314E02E1; Fri, 21 Jul 2023 12:58:37 +0200 (CEST) Message-ID: <20230721105743.751364377@infradead.org> User-Agent: quilt/0.66 Date: Fri, 21 Jul 2023 12:22:38 +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 v1 01/14] futex: Clarify FUTEX2 flags References: <20230721102237.268073801@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: rdgyuh7aheozi8mmtrhd9yywphohaac3 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 561591C000D X-HE-Tag: 1689937129-108297 X-HE-Meta: U2FsdGVkX19T1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fdxYViUxek7YjdG8BNxA6jIaNxMo8VOVvOVmBBuEGcB7oU3byfPZCgWUu2UHEBQJheGbuRoLg1npKoRSCX2R8G2rtAXojCtFllUtEmD4MMIE7hq1OziKxacoVGNpvy+e699mL/ibWETKa4HOs+XTw94CkPVlsNSx+jQJifz0Vzjhlr2T1yQ== 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 --- 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;