From patchwork Thu Sep 21 18:29:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 143129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5288424vqi; Thu, 21 Sep 2023 20:07:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjnsV5Fb3NgMjix9L4ABZvFHUiCsNA+EnywIs4KEcXrEZJubWLScVnvqpk/RozDPckgiZC X-Received: by 2002:a05:6870:c088:b0:1be:dfdf:cb1 with SMTP id c8-20020a056870c08800b001bedfdf0cb1mr8397064oad.46.1695352032398; Thu, 21 Sep 2023 20:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695352032; cv=none; d=google.com; s=arc-20160816; b=ukyeBGocCwaqbVBfjSExAqhX0pV3z4BYc3lZQYP0LT5IjaofomKqArGUHh1Rm5W9AA qtP/Yws+lTWddqXfSTtfXdnLkzQZ9Ekt62skDgpqgmir/nA0ye7ZO3nIVwnvU9n6qNcd h9DWYVOBrF13auKLsK0BtMAwHyadWRSOymwjxYajs05/28dYw4b/xVd96otc53OPO6IC ZznTjAFqW121Ftkzwz3APbqu4EBFYdR5/+ShbTeBQg9b6QwX8PlN2K6Nfshn2ARaE1is RtNDc+RWhAyEoPV5lRZXS5OZqtexJXZD6+01scHUJVoAGBGaJNgyydcjTGtWmEUr7YEs 8Phw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dMx5R6E0R0h9+pd+QZi7bIoYwQS8EWnvSyRr5gNA3m0=; fh=McWMhBXbZKPJudkA+aRuAP3u2dQeraI6k1jPJeJNhbk=; b=lozmJeN18IcOibLyIyzUN3zO/mEZzRuAUWgMUXOpJ+Ryw52QEEuhEaxUdqtRnYV4nH 7z5YGB9PXEwZhBj+Fonw5RXMjdst5YNea9W+/evAzc5eV56Qlnnv23SZVHXNzIdxUMn+ xFBmUhUiOYKYGU082po5/eDneBo2swOwqGXzrSkO3DiY5+41vm/GuH31BEyHXYvY5gp5 texgpoBYHuuCWtTOKoyWOTNGyP2WV7R3gWd0ZSic5QeDErQ1/0oocDP1QpJTNRANPp6q S9eUl/nml/V8AqLOecUeFZwgkWC9vZXMlY9PvjZn0JIC8JtzCNYME6hPI3gEIXu6YTm7 w4wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=h5zvPxbW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id m127-20020a632685000000b00577461296a9si2988993pgm.338.2023.09.21.20.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 20:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=h5zvPxbW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2F2D08275E7E; Thu, 21 Sep 2023 11:37:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230227AbjIUSh6 (ORCPT + 29 others); Thu, 21 Sep 2023 14:37:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbjIUSh0 (ORCPT ); Thu, 21 Sep 2023 14:37:26 -0400 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7C0DD8687 for ; Thu, 21 Sep 2023 11:29:23 -0700 (PDT) Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-79f96830e4dso3976939f.1 for ; Thu, 21 Sep 2023 11:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1695320963; x=1695925763; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dMx5R6E0R0h9+pd+QZi7bIoYwQS8EWnvSyRr5gNA3m0=; b=h5zvPxbWi+KBRxy2l33P4Ql1YrEkI5Vx8JkaX3wnEgJgrTip2d0QcU61NZKFXB/ZT4 +bilLkvNep0yTxPjbCHKLlY5A6YkiwfKVWsjTCN7ksJCuRSiqvnfLqwvppLCoYEGJumu vuCHLIx2ifF+PsvY37r0fd4azPnN+TqB0WDk7j8Ihho6HeE5uWIJWsTkjqFQWxL2gWij 7Uts5c0xhdZOb0cKv63m1Xo+Sbkz1cEZaftBB+TDUcnxnj9XXp/JM4wEU87WAGG1HeNv MU/aMdT3NIEBJh+ofW+2cCCCpQUh/fgqQoD0xZQdHisLwUt1HeO9K4ncQph9yhGJNFP7 6ZYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695320963; x=1695925763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dMx5R6E0R0h9+pd+QZi7bIoYwQS8EWnvSyRr5gNA3m0=; b=whuWQJxnJHIYDaUx0aZxNZyXZRLxE4WPqXR7tzgpd2o1bKmzRSMIf+zYVRfES78C6a F5AfE4jaaokBZFQREBofEzClZ9Td/0yUvKVCX8hTZ5frULb+uiwqisxd3nOMxxAgpEpf NaZbHpfUKJQe3xchWu3FDekGYDiI8Jxyj0PrpgkUskXUF8xLiifofb2DwQtTUJAX13L+ zgV7R3fowwkuMQcbclfAs2g+3h63YJaC8BegtRAxMGfh1p8Vd/VIVJdxrRbsIGOBzAS6 gM3P1BUrhLMw3xRGFLWYkjXpt66lWDiBxEVbPQNQLtZsXz93Qv6zypzdglMkBg8ZkNBv IByw== X-Gm-Message-State: AOJu0YzKEuD1FsHcjv9gtIxuvAHnfwr3kUjo7ViChV/q/aGRVDmZDm4U jqvSkBOcys+07PHw+1fIhW7Lyg== X-Received: by 2002:a05:6602:3788:b0:792:7c78:55be with SMTP id be8-20020a056602378800b007927c7855bemr6834507iob.0.1695320963064; Thu, 21 Sep 2023 11:29:23 -0700 (PDT) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id o25-20020a02c6b9000000b0042b227eb1ddsm500441jan.55.2023.09.21.11.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 11:29:22 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Cc: peterz@infradead.org, andres@anarazel.de, tglx@linutronix.de, Jens Axboe Subject: [PATCH 7/8] futex: make the vectored futex operations available Date: Thu, 21 Sep 2023 12:29:07 -0600 Message-Id: <20230921182908.160080-8-axboe@kernel.dk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230921182908.160080-1-axboe@kernel.dk> References: <20230921182908.160080-1-axboe@kernel.dk> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 21 Sep 2023 11:37:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777705452877063137 X-GMAIL-MSGID: 1777705452877063137 Rename unqueue_multiple() as futex_unqueue_multiple(), and make both that and futex_wait_multiple_setup() available for external users. This is in preparation for wiring up vectored waits in io_uring. Signed-off-by: Jens Axboe --- kernel/futex/futex.h | 5 +++++ kernel/futex/waitwake.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h index 6b6a6b3da103..8b195d06f4e8 100644 --- a/kernel/futex/futex.h +++ b/kernel/futex/futex.h @@ -366,6 +366,11 @@ extern int futex_parse_waitv(struct futex_vector *futexv, unsigned int nr_futexes, futex_wake_fn *wake, void *wake_data); +extern int futex_wait_multiple_setup(struct futex_vector *vs, int count, + int *woken); + +extern int futex_unqueue_multiple(struct futex_vector *v, int count); + extern int futex_wait_multiple(struct futex_vector *vs, unsigned int count, struct hrtimer_sleeper *to); diff --git a/kernel/futex/waitwake.c b/kernel/futex/waitwake.c index 6fcf5f723719..61b112897a84 100644 --- a/kernel/futex/waitwake.c +++ b/kernel/futex/waitwake.c @@ -372,7 +372,7 @@ void futex_wait_queue(struct futex_hash_bucket *hb, struct futex_q *q, } /** - * unqueue_multiple - Remove various futexes from their hash bucket + * futex_unqueue_multiple - Remove various futexes from their hash bucket * @v: The list of futexes to unqueue * @count: Number of futexes in the list * @@ -382,7 +382,7 @@ void futex_wait_queue(struct futex_hash_bucket *hb, struct futex_q *q, * - >=0 - Index of the last futex that was awoken; * - -1 - No futex was awoken */ -static int unqueue_multiple(struct futex_vector *v, int count) +int futex_unqueue_multiple(struct futex_vector *v, int count) { int ret = -1, i; @@ -410,7 +410,7 @@ static int unqueue_multiple(struct futex_vector *v, int count) * - 0 - Success * - <0 - -EFAULT, -EWOULDBLOCK or -EINVAL */ -static int futex_wait_multiple_setup(struct futex_vector *vs, int count, int *woken) +int futex_wait_multiple_setup(struct futex_vector *vs, int count, int *woken) { struct futex_hash_bucket *hb; bool retry = false; @@ -472,7 +472,7 @@ static int futex_wait_multiple_setup(struct futex_vector *vs, int count, int *wo * was woken, we don't return error and return this index to * userspace */ - *woken = unqueue_multiple(vs, i); + *woken = futex_unqueue_multiple(vs, i); if (*woken >= 0) return 1; @@ -557,7 +557,7 @@ int futex_wait_multiple(struct futex_vector *vs, unsigned int count, __set_current_state(TASK_RUNNING); - ret = unqueue_multiple(vs, count); + ret = futex_unqueue_multiple(vs, count); if (ret >= 0) return ret;