From patchwork Wed Jul 12 16:20:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 119292 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1284708vqm; Wed, 12 Jul 2023 09:59:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlGhuz11pzRdurlYQgqLO5srWQjltmmRMz/D48PaUAVMunNsGMqV6S2ZvWtvo8MSE7V/9/jp X-Received: by 2002:a05:6a20:7f8e:b0:12f:df4:6102 with SMTP id d14-20020a056a207f8e00b0012f0df46102mr19752194pzj.27.1689181149333; Wed, 12 Jul 2023 09:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689181149; cv=none; d=google.com; s=arc-20160816; b=KOSI0CZsKlMwtyDAUuqQ4aetcOeVD1YS0XXFsFoa0Jn0qZXXpkCjxcOQSakAMweBve DDvMe7dDBoSmhsApVqzjQTsKH9l1V2OuA/JlFGD0ZHZurpP2PzQoCKIzvxUs893/dF4X PJzcFn9NZsE4MF2ibR91mGscJarWxcD9N8Xd9VFIINZj/YI0QkdOmp2LflzsRWvALB/U flOkMTnHmWQmQAnGF2x/Rd+XMzsJEB41fU29pVdOqOtV+05XtGeX4cLq4c5s6cp8+BIV i8sDuK3XiQrigz51p1aSuOr0uve4p2GhFWVDdMwMDZ3R9aDzn7y3Wv+l6Fr35LKLtJ3E l7tA== 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=l5pADeT4G6dWswC8nfrVWgC9Alv6DnXYYp25ShjDEu0=; fh=NIj/+GUN0nfTfLL1QUeUcIYuoW7bxqt4VddoB/dywiU=; b=XZBaIbpbXB+DfiZHOnZ61Qm1sDPaVFsFb2h3sQxuxen0zW/TnReZgMcJMtnJH2Z4Pm 82HC7PcmvMs0FRwvnAxLPrixnQcp+3dMJlQMIQl0vsymF7MnwphQ3GU/uNjczr08mVot gWVOjxqQpzwAU5josDNsTMPie8TA5dCsmNoxqlATQ65VWLURNHQVqoz1Aw8OhJlEyY5Y xwkd3sIFtnBgo28JDvSdBSmNDx5eTKBeHQh+mxs2zMxb+KsGzO1axXyQHARtAQ3L8nWF HE4r4n71Ogo+xgAT7oo2eJKAroifjf1w4Qn9VTnTZYzJzGkt1u/5ZCoEbesndi+mGtxV dHFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=z8EvYG8S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bw22-20020a056a00409600b0067a5e893341si3476806pfb.89.2023.07.12.09.58.57; Wed, 12 Jul 2023 09:59:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=z8EvYG8S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231689AbjGLQWF (ORCPT + 99 others); Wed, 12 Jul 2023 12:22:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231309AbjGLQVg (ORCPT ); Wed, 12 Jul 2023 12:21:36 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B18BE2D5D for ; Wed, 12 Jul 2023 09:20:35 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7835bbeb6a0so65584739f.0 for ; Wed, 12 Jul 2023 09:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20221208.gappssmtp.com; s=20221208; t=1689178833; x=1689783633; 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=l5pADeT4G6dWswC8nfrVWgC9Alv6DnXYYp25ShjDEu0=; b=z8EvYG8S5XMLJha2b8s+8bz5IUiF5XfCeUz1Lnp7n4DrQRmF83P+RZiMKgmaAu34cu wAf+IrXZud92EHRWW4zLUBHPk253rBGs5nNVbk+i1qg43rSCdGPjI/U0gW3GmYBgeOkL nvqb19xvJaLyNDVVzGsz31D+fD0LcUj5IYcklQ62cTIYH7ysoGImt4PFNIN2IMVi9gLG ltz8U1WpFlDd7BwHemLRWsuv+0h62Ry5VqxNmLKdJz6VA6A8ArKVOp/1V/DZrQZZpnhZ ywZqYnr9YW6B1HD65lN0nq9lSOdkzH3vhlXyzPppn5czxqNPgN1Q6iYKLQg3ce6yQBIb Uwkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689178833; x=1689783633; 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=l5pADeT4G6dWswC8nfrVWgC9Alv6DnXYYp25ShjDEu0=; b=Y3yrKmTxM0PzOzwQmR7FDiICrLJRDY7ME1b/4hyZBI4bw7yfZu9rq2IeEzElpIgnTR VuB1MiJacdaMlB8mgQjG6CXOb1+iPkExIpYQZ241dtwD+NxA3sZ6U1tWkj9EFDEGKNNi wdcLt79pfYUw58YiA9Uvx0hMhO+FgabGFYJ4MyRoJAI6UN2kBT7XQFxT577z3rZGXZgO fPo4lK5fSYmHQQYF/TEa/D2wBq6kMSP4nawc/XXG33rgD+rR7+rJFKjae7DdKAde2QOe ptOKWYUXfyYuGe4lJ9Or/1VBeGhpFGt0t6BllzFjDv6PxVZUMgU+MRrzclnGG9j4ptOj Qnrg== X-Gm-Message-State: ABy/qLb0rBBqCFqs7Iw2ieTaOesb69VTB5umkAUZFnKVI4DvKZeFZX5f 8TFVIvv4fkB+MkgXA7XDCs5pIg== X-Received: by 2002:a05:6602:3993:b0:780:c6bb:ad8d with SMTP id bw19-20020a056602399300b00780c6bbad8dmr20527642iob.0.1689178833263; Wed, 12 Jul 2023 09:20:33 -0700 (PDT) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id x24-20020a029718000000b0042aec33bc26sm1328775jai.18.2023.07.12.09.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 09:20:32 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, peterz@infradead.org, andres@anarazel.de, Jens Axboe Subject: [PATCH 7/8] futex: make the vectored futex operations available Date: Wed, 12 Jul 2023 10:20:16 -0600 Message-Id: <20230712162017.391843-8-axboe@kernel.dk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230712162017.391843-1-axboe@kernel.dk> References: <20230712162017.391843-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_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771234813177594463 X-GMAIL-MSGID: 1771234813177594463 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 f6598d8451fb..4d73d2978e50 100644 --- a/kernel/futex/futex.h +++ b/kernel/futex/futex.h @@ -290,6 +290,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 f8fb6550061d..0383da9f737f 100644 --- a/kernel/futex/waitwake.c +++ b/kernel/futex/waitwake.c @@ -369,7 +369,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 * @@ -379,7 +379,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; @@ -407,7 +407,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; @@ -469,7 +469,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; @@ -554,7 +554,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;