Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1136697lqt; Sat, 20 Apr 2024 02:13:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVgDMdCulngJzTy/5Fm4lURKsiuWv4wA7Au8QBJ9H8R2TT7iZMQIFoPoY8FOaC4co5GMhyAW1me/u+w4Q0GbYO0glrEesvzQ/yLZGSRww== X-Google-Smtp-Source: AGHT+IGZpMSZqUIzhgaBOtRALKZ4wrKBt6MVSLo6marAu7ukVSgyFRgnCFLVu8+5bb9FiXQhtqwv X-Received: by 2002:a05:6a21:2709:b0:1a7:a422:7394 with SMTP id rm9-20020a056a21270900b001a7a4227394mr5419815pzb.17.1713604407173; Sat, 20 Apr 2024 02:13:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713604407; cv=pass; d=google.com; s=arc-20160816; b=k+5R/BocKwUC8NmMjGu4NMku1NKfAKQv4c+B6Khk9IZDLJDmjZXI50ffCcuDNhNKgz eSyni0l8pyROF2Y6oSKb5a4umqhbiTqvMliJavZ+eI1Cv66r+4RLELwogfMOfGKYjeoI h06JYNlmu7cn5KEVTMcF9P5cQhhJFX36FnKAry1yowULKyqRezvSkbIjsaSIHzSQPOub hv9fYFJXYixRW5nADl7ODeS9yZQOFz8GlQkNv4nn0autqdKGvc9KM9HnZYZM8zUbYVLM vY76FdTeFZNwbUqZOafEpDmCoCWLYA+XDaBdarMZaoKM6FPl8rpJGIciv7tUK4PsMV7F yxuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=J+ia4LygfpdKBgxb6mfRm4OxaBCRDEXMcm+O/rxKE1Y=; fh=Cxwo/A+C89tjOzVq8R/o/DH+l+P6Lpt8VwbqwppZI0Y=; b=NwKFe/bHU920T2cIJ4DyemJTLEWQgOzDdgKFj/+stO4j9JcQHot+Z+XNbTHjti28za /VyN7+zMa6WapizQNOeIh58hcEvId73MDxM08hGupFLBM5A13bpuU13/AFMVk5s3l/dz H0GNJiWkMsRii9wCXzmyLcI0v53xgCv6uxutqebeFej7aeHcUe7E37ieRfY6rj5cDcoC q+wtqieLFGCVqhqD2fFLZ/wrCOJCeK2yPy+1cEZ2NQEGhLpaBmqaTA3bsoGkcSuIZ+w4 S+fc1/9/fevArti45/o7oC3eRnWLrGajiarDaVHGAzUqZbBWOMsFFDZZ15guhfaSL22V CKSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=taGM3GwO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-152198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152198-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c32-20020a631c20000000b005dbf4efa1f8si4435903pgc.852.2024.04.20.02.13.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 02:13:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=taGM3GwO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-152198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152198-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C67592811CC for ; Sat, 20 Apr 2024 09:13:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 320D2208A3; Sat, 20 Apr 2024 09:10:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="taGM3GwO" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51E2557302; Sat, 20 Apr 2024 09:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713604220; cv=none; b=J7CSfY7Thqxn39xYr2uogkruBzLfbuOdzK5LMqvVvXy2vcmbd3MILRJVEHXmH2EvqaOmPMp7UEwJnSfK6VRMozQbeO5hf7FVK1kQwWnP9gMUKI2Dq4YPPpLd3Vl1I/f5VLPCnEo0PpSHHDlcMwtchXY1GkTWzgNYcXKREUVyN4g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713604220; c=relaxed/simple; bh=aXjaLAo8w7f1r4ljQUU5ih9OuYPeG7aGbIwQFqg5Jvs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BA/eP8TA5myYsQxmSBcrhucRoLJFNNciJbSaID/VIvXDsz2QeXAoCu7CPkLZ+KamFVB5xAYu4Pd+krwVXke0psMj6xIc2HunwsmbWvLrQlAoekVuKN2qn8yXP26QcEvh5IKLYP8/amSolhaVTwCiV3CRvKM2Bv5LlGabDC0SS10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=taGM3GwO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBEE5C3277B; Sat, 20 Apr 2024 09:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713604220; bh=aXjaLAo8w7f1r4ljQUU5ih9OuYPeG7aGbIwQFqg5Jvs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=taGM3GwOBBh2rTeJOpFqF9XElBm2/62TsG3JORY9fiekvMBFT+OWq7mEmmR1qhqOM WUJ1iFZzJc7wBCxDy2oBmmrTeA2VgJr6FGjEGmX7uodP1nSSJqkuSfS6dnmz05HA8e Ujr2UyyFg76WqyrG+4Go9JuZiX1A49otJUPNC65Yggo25/P4c3xAeLPSiIl82Rhebp zXvvLh5wEaoIWBvGpOBMgcqfJcogqqv7s3jBYInlG8W23jK7Yeqw8vx5tl48rCqcLN +xkjEDiE/WwGgq2NC5AMH5VwQ7+tweeZxtZ9LA4bp6B9npm1zvdTxRLpDtkV2Do3EU /RbLZbjNBvpCw== From: Benjamin Tissoires Date: Sat, 20 Apr 2024 11:09:15 +0200 Subject: [PATCH bpf-next v2 15/16] bpf: add bpf_wq_start Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240420-bpf_wq-v2-15-6c986a5a741f@kernel.org> References: <20240420-bpf_wq-v2-0-6c986a5a741f@kernel.org> In-Reply-To: <20240420-bpf_wq-v2-0-6c986a5a741f@kernel.org> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Benjamin Tissoires X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1713604159; l=1465; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=aXjaLAo8w7f1r4ljQUU5ih9OuYPeG7aGbIwQFqg5Jvs=; b=ddj8HgMHu7o3alQ2ylp5x0qDkClnlNbjoHtfkfK+EU5FLA+7/FD/UfcsJfLAYvVuLQLxTy07U WE52vNksS5kD/OJf7cQtp6qjS/QJLP2Gg/W11X2O6DaEdq+EU7hJQe2 X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= again, copy/paste from bpf_timer_start(). Signed-off-by: Benjamin Tissoires --- changes in v2: - dropped spinlock and use READ_ONCE() instead --- kernel/bpf/helpers.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 85d3f483f27f..07550a657d7f 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -2711,6 +2711,23 @@ __bpf_kfunc int bpf_wq_init(struct bpf_wq *wq, void *p__map, unsigned int flags) return __bpf_async_init(async, map, flags, BPF_ASYNC_TYPE_WQ); } +__bpf_kfunc int bpf_wq_start(struct bpf_wq *wq, unsigned int flags) +{ + struct bpf_async_kern *async = (struct bpf_async_kern *)wq; + struct bpf_work *w; + + if (in_nmi()) + return -EOPNOTSUPP; + if (flags) + return -EINVAL; + w = READ_ONCE(async->work); + if (!w || !READ_ONCE(w->cb.prog)) + return -EINVAL; + + schedule_work(&w->work); + return 0; +} + __bpf_kfunc int bpf_wq_set_callback_impl(struct bpf_wq *wq, int (callback_fn)(void *map, int *key, struct bpf_wq *wq), unsigned int flags, @@ -2804,6 +2821,7 @@ BTF_ID_FLAGS(func, bpf_dynptr_clone) BTF_ID_FLAGS(func, bpf_modify_return_test_tp) BTF_ID_FLAGS(func, bpf_wq_init) BTF_ID_FLAGS(func, bpf_wq_set_callback_impl) +BTF_ID_FLAGS(func, bpf_wq_start) BTF_KFUNCS_END(common_btf_ids) static const struct btf_kfunc_id_set common_kfunc_set = { -- 2.44.0