From patchwork Fri Jul 14 13:39:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 13313717 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 C68B1EB64DC for ; Fri, 14 Jul 2023 14:16:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E3516B0072; Fri, 14 Jul 2023 10:16:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3776C6B0075; Fri, 14 Jul 2023 10:16:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 233AC6B0074; Fri, 14 Jul 2023 10:16:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 157206B0071 for ; Fri, 14 Jul 2023 10:16:28 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DDC62A02B6 for ; Fri, 14 Jul 2023 14:16:27 +0000 (UTC) X-FDA: 81010417614.01.59F0597 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id 68F2C1C0034 for ; Fri, 14 Jul 2023 14:16:24 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=vBKCfPzs; spf=none (imf20.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689344185; a=rsa-sha256; cv=none; b=n29io5+KDEsRvmLS0F/Wbo8kPZo8+Qq4prXKpHhfIL1Jrf/HP7teSq+IkGyhNbJjYqIzdB 9uyz83o7Es+r9MLUSRq0WpOpJbU9vA1ZJr9tYRrPWzBFDgarmjEUDF5dmOi+8uh+giFezE KjgYerAx6w86fy4MJNtwCVqlMKFQ7mE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=vBKCfPzs; spf=none (imf20.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689344185; 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=GuDJ92pMIScKKU1gBauDG1HK4VUsLXyIVGMSjzGcY4Y=; b=raqW/0TDHEj4R0dK3GP1Zu71oncIEh76SPokk1nkrNuUKvy/5dL7LNSpByge8S/r66p2AS zSgDyPkiLtAiOktZbhiutOILwlYmhlyLuTuCtYzxnV+PW2DF8hPS0UVU2Lto0XWNIENDYZ Rs02XP6juvukqRWAN51C05NGhaXe/y8= 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=GuDJ92pMIScKKU1gBauDG1HK4VUsLXyIVGMSjzGcY4Y=; b=vBKCfPzsXlmZQm0fbY9sm4XN73 kHbqhYPRg24KF+nwElURpqsTJDlryKmDUOG3hRkpWvd0PhoT+M+UUAAfZagygwwYN+EQF96rxRzwh y6Ksh55FaQO2qES2eZnYAQMF0W7I/N7hS39vamjL/ghCgcLWgEwlM2yccrC8KGWmH4aRt4oV3JFNS hotzaBdyxJlbgmQPxYdyPurXiCwYhcjscrxIqsdlOamEmJ65hOEFV33r2X0xNYQURheEouIYUgXH7 LZl2gTROHDF1JASKWhc+5uERTwqfjo5eGhlgZOjCV9CM0JpWWZtTMWyghP3XtRYjLU3AJZkGy2PqC A1aFb12A==; 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 1qKJah-0016z8-NN; Fri, 14 Jul 2023 14:16:15 +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 B952E301A2F; Fri, 14 Jul 2023 16:16:14 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 8BA61245EFFAB; Fri, 14 Jul 2023 16:16:13 +0200 (CEST) Message-ID: <20230714141219.282650897@infradead.org> User-Agent: quilt/0.66 Date: Fri, 14 Jul 2023 15:39:09 +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: [HACK][PATCH 10/10] futex: Munge size and numa into the legacy interface References: <20230714133859.305719029@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 68F2C1C0034 X-Stat-Signature: p85bbjtrhdrrsz8dyshn4y8a64ie7j3w X-Rspam-User: X-HE-Tag: 1689344184-467759 X-HE-Meta: U2FsdGVkX18vkIy/VfKZm0GCKCT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plhcrB8h6iZ9KiK7UPBdCEJ2xkprAUMZoDsNswV+fpV6Zw3p2vWUyYDdiTwsEqEM3ZQpzqXd2qCzczApBnVnKFdhUJkKDl2u98QzQrBjFKB0nkenLQcOKFQP5qCIG0o8TxbR1yngD8yy/heNuRvZXvpycpnSD6g== 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: Avert your eyes... Arguably just the NUMA thing wouldn't be too bad. Signed-off-by: Peter Zijlstra (Intel) --- include/uapi/linux/futex.h | 15 ++++++++++++--- kernel/futex/futex.h | 9 ++++++++- kernel/futex/syscalls.c | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) --- a/include/uapi/linux/futex.h +++ b/include/uapi/linux/futex.h @@ -23,9 +23,18 @@ #define FUTEX_CMP_REQUEUE_PI 12 #define FUTEX_LOCK_PI2 13 -#define FUTEX_PRIVATE_FLAG 128 -#define FUTEX_CLOCK_REALTIME 256 -#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME) +#define FUTEX_PRIVATE_FLAG (1 << 7) +#define FUTEX_CLOCK_REALTIME (1 << 8) +#define FUTEX_NUMA (1 << 9) +#define FUTEX_SIZE_32 (0 << 10) /* backwards compat */ +#define FUTEX_SIZE_64 (1 << 10) +#define FUTEX_SIZE_8 (2 << 10) +#define FUTEX_SIZE_16 (3 << 10) + +#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | \ + FUTEX_CLOCK_REALTIME | \ + FUTEX_NUMA | \ + FUTEX_SIZE_16) #define FUTEX_WAIT_PRIVATE (FUTEX_WAIT | FUTEX_PRIVATE_FLAG) #define FUTEX_WAKE_PRIVATE (FUTEX_WAKE | FUTEX_PRIVATE_FLAG) --- a/kernel/futex/futex.h +++ b/kernel/futex/futex.h @@ -39,7 +39,7 @@ /* FUTEX_ to FLAGS_ */ static inline unsigned int futex_to_flags(unsigned int op) { - unsigned int flags = FLAGS_SIZE_32; + unsigned int sz, flags = 0; if (!(op & FUTEX_PRIVATE_FLAG)) flags |= FLAGS_SHARED; @@ -47,6 +47,13 @@ static inline unsigned int futex_to_flag if (op & FUTEX_CLOCK_REALTIME) flags |= FLAGS_CLOCKRT; + if (op & FUTEX_NUMA) + flags |= FLAGS_NUMA; + + /* { 2,3,0,1 } -> { 0,1,2,3 } */ + sz = ((op + FUTEX_SIZE_8) & FUTEX_SIZE_16) >> 10; + flags |= sz; + return flags; } --- a/kernel/futex/syscalls.c +++ b/kernel/futex/syscalls.c @@ -95,6 +95,24 @@ long do_futex(u32 __user *uaddr, int op, return -ENOSYS; } + /* can't support u64 with a u32 based interface */ + if ((flags & FLAGS_SIZE_MASK) == FLAGS_SIZE_64) + return -ENOSYS; + + switch (cmd) { + case FUTEX_WAIT: + case FUTEX_WAIT_BITSET: + case FUTEX_WAKE: + case FUTEX_WAKE_BITSET: + /* u8, u16, u32 */ + break; + + default: + /* only u32 for now */ + if ((flags & FLAGS_SIZE_MASK) != FLAGS_SIZE_32) + return -ENOSYS; + } + switch (cmd) { case FUTEX_WAIT: val3 = FUTEX_BITSET_MATCH_ANY;