Received: by 2002:a05:7208:3228:b0:82:47:81bb with SMTP id cb40csp2630619rbb; Tue, 16 Apr 2024 07:16:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdMZfAR6kG1m5vd7TASayrgTCOzaht+YMe6rIl4RyHtZXaX87dWqy2Uq4zwyMASg+SM6gGyAM1yE67RusQCUGFPFIznGMaVkY9KMf09w== X-Google-Smtp-Source: AGHT+IEj+48B/WOHn7yWn90mrbv7noo8qX+GZd+3DGxInsbBo/QH+ZGI2wSL/FPzjLugHaUndedo X-Received: by 2002:a17:906:b191:b0:a46:df55:e238 with SMTP id w17-20020a170906b19100b00a46df55e238mr7400976ejy.44.1713277017285; Tue, 16 Apr 2024 07:16:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713277017; cv=pass; d=google.com; s=arc-20160816; b=bR5OHLvyuR9WWzG03MF0YTmA4yyuWdF8xrWH8bSOMKrtwPlsHVB3eHHLXaMqnOrOk7 i2FGujexIGjmrkHVhY16MO1rPK808tEGi4KWjY3WrfdGoq+3CD1F+ezYt6yVeJDrWa2f WISrXTD0QvssFaz1D48tuBx0sm/r7RmOCuKfp78SksvD0Q7TCOI1mpkzf6dX20XhLyww b6aAzlX7yrB3znkHDdPWAXXBvkhCi7QD2t+ys5HKAqyqKeLciRfNDpZqzhZQf9kLP92C ghz7t7xGM2wWBj6j3NPkn99wZ8Gu+XUa1aKPFUzmIOg4JkhpRsORC4+Mx8XPWrwS3/gp UpSg== 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=I0irUrnS4lBGkcEYW8Kiv6mftK8sW9m5SIZzPH/1UVU=; fh=Cxwo/A+C89tjOzVq8R/o/DH+l+P6Lpt8VwbqwppZI0Y=; b=CaNm8ymzNuCzU1+qbuclnzXIFnIxsYKe95yRh7oSCnVCCnYBsZQCyVjr7JXkO3oeWz Q812/Zu78xLf9Q4wjivCFObcdTt+0siaCOXUE4nSgBG5kH6q9OZWDz5jTd23/KkWJQ5N QS7S6e0Kn40WFrGC6ygAGYT5o5xnddBh4qL3Ior5BkGN/MJipwE9cYMXEAvceMmowmiw avvdViHnWIivUj3xJQgNJNW6owzDYnPX2zuf5wUElravoRDES/8/kYYaCe148SSy67CX KBbyUBE1yVvi69zqeAvoVU42egl6FnZc6o6SdqI/v8+q95A0ShFewU7RQtSmhnCbRxfu Oq2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ouzk7Scm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-146972-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146972-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id nb36-20020a1709071ca400b00a51affc3396si6129684ejc.349.2024.04.16.07.16.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:16:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146972-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ouzk7Scm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-146972-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146972-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E6E191F22667 for ; Tue, 16 Apr 2024 14:16:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 57C2413664B; Tue, 16 Apr 2024 14:11:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ouzk7Scm" 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 7BA161369BB; Tue, 16 Apr 2024 14:11:03 +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=1713276663; cv=none; b=NmwDtYN4e3ZeiiP3p2DnM7jxJIB7lGxl2fuicrzbkBBEAGviIYkXwjQ6V6YmlWFMsDMrdvWhLARGkx+D20/hdbND0VmbN9/5GsIrlJvAfpfRJqkXBU/epNEWCsObNE5Im/E1PY0M+MqgWhYx7d/eLXwdtWnoYb6npIAGfIL4xvg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713276663; c=relaxed/simple; bh=b3PkzLOIXQdFGv5PNduwNWgXmPt5byfF8ywwFY3Z51s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VM3Zy8YuHAo53wJf+mvIG/W6VjxZ7JQuBnyXeFJhVPBh/ojbgORcPE9zq84TfZrJebMlD7sO7YIgSOTn6OjDuemRHc5g2yRriw4aRYikbcHVd0uKctVIog0Jyd7NNUeV9HsNYD10kRmfBpUkGsjlNA93T3CNV11OqFxLwcXMT9A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ouzk7Scm; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC20DC4AF52; Tue, 16 Apr 2024 14:10:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713276663; bh=b3PkzLOIXQdFGv5PNduwNWgXmPt5byfF8ywwFY3Z51s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ouzk7ScmTGcsbcCyy5C6A0mRikAlG1gXv/S+Xsq0mHh0MtYKHOu4ZemxpiLiFCvIy kI4xi1nHY6wZoG0AHLT0vbgc1VGrmIRxu1powyaANcHKxaCKCXB5HONvS6P9rth+y9 4sz27fKJwtWe1x/fVHCU8W3lshmntQJVV65kRLoP1aMpYBpgAibjZJD+L+lcXagHUY vKn+WRpssdQR8FGecUZd/UkhkTKEz3Pn2KzPZs4gLf0xPtpHWIsBRJc0fX0QKx12U6 Hh2r/S91jSy1RDh8Z4Q8VRwYQqRqlC4gdjKzTXGSCXAN0H6yRy9Dom4ZFYSJT7J/ug ecaKwVoERRjmA== From: Benjamin Tissoires Date: Tue, 16 Apr 2024 16:08:30 +0200 Subject: [PATCH bpf-next 17/18] 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: <20240416-bpf_wq-v1-17-c9e66092f842@kernel.org> References: <20240416-bpf_wq-v1-0-c9e66092f842@kernel.org> In-Reply-To: <20240416-bpf_wq-v1-0-c9e66092f842@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=1713276593; l=1510; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=b3PkzLOIXQdFGv5PNduwNWgXmPt5byfF8ywwFY3Z51s=; b=qGHq6hqI33hY8ac+spbS1hKIZ4U4mwd4LG/eiNsLMlW8qLnD9HGxeaAp/QtVSNb7XJzNNUNyU X7tyfmJ0yrVCsk/g8vMgw6V2UgC8BHDlm3XwQ/ZG/GszfLKv17fsMl5 X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= again, copy/paste from bpf_timer_start(). Signed-off-by: Benjamin Tissoires --- kernel/bpf/helpers.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index e5c8adc44619..ed5309a37eda 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -2728,6 +2728,29 @@ __bpf_kfunc int bpf_wq_init(struct bpf_wq *wq, void *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; + int ret = 0; + + if (in_nmi()) + return -EOPNOTSUPP; + if (flags) + return -EINVAL; + __bpf_spin_lock_irqsave(&async->lock); + w = async->work; + if (!w || !w->cb.prog) { + ret = -EINVAL; + goto out; + } + + schedule_work(&w->work); +out: + __bpf_spin_unlock_irqrestore(&async->lock); + return ret; +} + __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__k, @@ -2821,6 +2844,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