From patchwork Wed Feb 21 16:25:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 204315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1151596dyc; Wed, 21 Feb 2024 08:35:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV3M69vRRE7wTNGrdXpfQ/8U3r4wOsc6z3xei4OgtXkkS9XbVxdGym/VpVd6SK4nJ6mmR2MAeLmH/72b8gs040cww6VgQ== X-Google-Smtp-Source: AGHT+IFl/A5u+Nwd6UQYWKW2APRM9/XjOEyZhLjRXRggGQUrbdipMjdHDVSz+Xcpp95p9EekfKv/ X-Received: by 2002:a05:6a00:80d4:b0:6e2:de02:598e with SMTP id ei20-20020a056a0080d400b006e2de02598emr10432895pfb.33.1708533344018; Wed, 21 Feb 2024 08:35:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708533344; cv=pass; d=google.com; s=arc-20160816; b=aYh6tG/qwmd/ZUiVcTVZvFe+uwZXH4YDGpFRsiGzDiOK9jsv0qgrAH4lJxehoGFH1u 5g9An9UhJ2KVmrALdBAYFaI9akdqJsdWO33chELhlODnJ+LG2twGRZFMMDGZydSGHr+p BU7jH446hGuJOg5IF8IIxpRjL/UUI74xztMZCQFN8XgLE68C2JOmc9F8BvRpBlSpbyPh FqbJzeppHXfq4COBfdpylqA5iStO3nfRTYv064YeHzZLzyGiyUM6noHZwyDK9tCnawAj tYVVY+AMBlJOLR7qd1feF0ThhHuqofP/OLxswk5nyn7DfRM1tlsPtxqwgqNzLu2YMLbW KyDg== 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=i2ofzzXR66lmJsG2e2Gkjtpj+cQplTDfpB2Jsno6/LQ=; fh=hc4Y6F7QBSV+XcCZzl4ZOgjmnikSFu9Au/ny4/yLvAg=; b=qXD+eSelWCc88FOLSis4Q8/dJbO/N/A3dixIE7po27Xlej6/le5J+nCy0SZu4QXf++ 7pNUS9Uvc2CFgB+VvUvcW3S5zy8EUIiZmz4cHQlZ9T3s/kST05Qf6jxXHDBTrZcWpDpo J99fZCVJP1uz/GwI5fP/mbqg0wE97BPdu4b+ml68KHKIc9all92h5WWoRAL0cYZh8tXH G7Xqli2Bqd+JiKPIERni5uAb3QLn+CcSfSpBjNEi4mgl9ebVg6kvVcjgSs/jPkHjRMHf FXdYjYL+9gfoc7NcxvNMwNod98jU95uMK08mkLavkyKzznDbMunSPAaQ7qUv5oG8MSym deig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CRuFjLOz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75111-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75111-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z18-20020a056a001d9200b006e466191f79si5265024pfw.150.2024.02.21.08.35.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 08:35:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75111-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CRuFjLOz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75111-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75111-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8312AB24CFB for ; Wed, 21 Feb 2024 16:29:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A030582D75; Wed, 21 Feb 2024 16:26:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CRuFjLOz" 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 0975782D6B; Wed, 21 Feb 2024 16:26:26 +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=1708532787; cv=none; b=lp6r3Mla9YeMsxmbE3As/eSfO9S9tF25oE0ScHlBQcYqiygio/DwXMTrA0cC+VZLu/ywGRX+bHmQMhnp0Cft5n5ZiD+Wa8z7lk/d45S8NTDGTMbQN9Ee/51hutCtki/XXcVfCdRxILFgOLiwUTHgzDc0Vvyfw35S2lkRBWsufCo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532787; c=relaxed/simple; bh=aOeYWbBo6BBRgng3mWTrVA3C2orudmt4XB516sHxv3U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WtqziC5hk67sj954vTOTgIxR1U9j6g2EaN7OPhIE5pyNCK+A5IxGvp5mB+Fzfwcr9hw+rpnUQV2cS3FZsAxjjCFMBaMpqV+vGb8np5gGz/lnIJ1iWZSv3+8rt2DBWdQBj/Z0abbgEcLaccQCtK6dwJeNhG4NH4KwVB2VZqr6kFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CRuFjLOz; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78DEEC43609; Wed, 21 Feb 2024 16:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708532786; bh=aOeYWbBo6BBRgng3mWTrVA3C2orudmt4XB516sHxv3U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CRuFjLOz/oP9LGG+DScB65m5dNy1A6QCZ1/OvkXlvdRUIXEZV6/gwerU/2EOSHT4l p0q77VyVFVPTMftWeWMr/mW0huGodOw35WDnRdeLbfS69eL8ke1nfNk23OvUJmPZFz LZdECWQBTZedf8QDjGziZQz2Wnp5D6G7N7/R0Gipm7WvKYSxfnW4RmVn6QzF7FRJPm YLc/C2cR21IaHUjGiYpGVvRIOI5eYxfGu6+hl35cutkdk8E0eGhTsuhpNQ99NO9F2z vKI1odmAjBN56jZ6z+vpV2xp21JGNW2hYxltVoTWgDmH3wng3VUJO98k0sFfs86ymb A3vX4C/JmUJXw== From: Benjamin Tissoires Date: Wed, 21 Feb 2024 17:25:30 +0100 Subject: [PATCH RFC bpf-next v3 14/16] HID: bpf: allow to use bpf_timer_set_sleepable_cb() in tracing callbacks. Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240221-hid-bpf-sleepable-v3-14-1fb378ca6301@kernel.org> References: <20240221-hid-bpf-sleepable-v3-0-1fb378ca6301@kernel.org> In-Reply-To: <20240221-hid-bpf-sleepable-v3-0-1fb378ca6301@kernel.org> To: Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Jonathan Corbet , Shuah Khan Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-doc@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=1708532719; l=2207; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=aOeYWbBo6BBRgng3mWTrVA3C2orudmt4XB516sHxv3U=; b=5c6iFAL0ghfRa0CQ+I5WiS8W3VZHjDLOLVCvDikeugMAA26k2NejVsty4Ye8iMtnIQGyGpWAe kxEB5meSPzqCYxWaCyomP6nK9/TqKeiFZNYnSvFjr5lFPycq+ARmIK5 X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791527059885969302 X-GMAIL-MSGID: 1791527059885969302 Export the sleepable kfuncs we have on HID-BPF in tracing bpf programs, but with the condition of being used in a sleepable context. This allows to use the bpf_timer when used in a sleepable context through bpf_timer_set_sleepable_cb() and initiate work from a device event. Signed-off-by: Benjamin Tissoires --- no changes in v3 new in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c index e1a650f4a626..275f2057c48d 100644 --- a/drivers/hid/bpf/hid_bpf_dispatch.c +++ b/drivers/hid/bpf/hid_bpf_dispatch.c @@ -544,6 +544,11 @@ __bpf_kfunc_end_defs(); */ BTF_KFUNCS_START(hid_bpf_kfunc_ids) BTF_ID_FLAGS(func, hid_bpf_get_data, KF_RET_NULL) +BTF_ID_FLAGS(func, hid_bpf_allocate_context, KF_ACQUIRE | KF_RET_NULL | KF_SLEEPABLE) +BTF_ID_FLAGS(func, hid_bpf_release_context, KF_RELEASE | KF_SLEEPABLE) +BTF_ID_FLAGS(func, hid_bpf_hw_request, KF_SLEEPABLE) +BTF_ID_FLAGS(func, hid_bpf_hw_output_report, KF_SLEEPABLE) +BTF_ID_FLAGS(func, hid_bpf_input_report, KF_SLEEPABLE) BTF_KFUNCS_END(hid_bpf_kfunc_ids) static const struct btf_kfunc_id_set hid_bpf_kfunc_set = { @@ -566,11 +571,11 @@ static const struct btf_kfunc_id_set hid_bpf_fmodret_set = { /* for syscall HID-BPF */ BTF_KFUNCS_START(hid_bpf_syscall_kfunc_ids) BTF_ID_FLAGS(func, hid_bpf_attach_prog) -BTF_ID_FLAGS(func, hid_bpf_allocate_context, KF_ACQUIRE | KF_RET_NULL) -BTF_ID_FLAGS(func, hid_bpf_release_context, KF_RELEASE) -BTF_ID_FLAGS(func, hid_bpf_hw_request) -BTF_ID_FLAGS(func, hid_bpf_hw_output_report) -BTF_ID_FLAGS(func, hid_bpf_input_report) +BTF_ID_FLAGS(func, hid_bpf_allocate_context, KF_ACQUIRE | KF_RET_NULL | KF_SLEEPABLE) +BTF_ID_FLAGS(func, hid_bpf_release_context, KF_RELEASE | KF_SLEEPABLE) +BTF_ID_FLAGS(func, hid_bpf_hw_request, KF_SLEEPABLE) +BTF_ID_FLAGS(func, hid_bpf_hw_output_report, KF_SLEEPABLE) +BTF_ID_FLAGS(func, hid_bpf_input_report, KF_SLEEPABLE) BTF_KFUNCS_END(hid_bpf_syscall_kfunc_ids) static const struct btf_kfunc_id_set hid_bpf_syscall_kfunc_set = {