Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp724007rdh; Wed, 14 Feb 2024 09:24:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWfB7KQ2oiCeLPwhREWnL2GeWiv1APlc5OJnMBux3vYFvgE288s8dG8Ozn69s1tiGAFqGP7gj7ogHddB5rlVWMo38rjHf8v5vo7Z7oSrA== X-Google-Smtp-Source: AGHT+IEKl74iceIUZKPKvnxwNxWJYggq6AyUOEWYoomI7ZlFXGHdoGu71rFZ+hUX2ovJaVgwVMWC X-Received: by 2002:a05:6359:4113:b0:178:be64:c3bb with SMTP id kh19-20020a056359411300b00178be64c3bbmr3566737rwc.14.1707931486618; Wed, 14 Feb 2024 09:24:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707931486; cv=pass; d=google.com; s=arc-20160816; b=iiqz+eF6WJZ5cm0PaxoXgMnbLloDwTvhpmcgIIGoJyM3PibwjGFvSO53RaYrm14rld k+Szm50c8X7K0YBTWZmkry5H4HU9BCxxWRjNke+l1bJORc941z2B79kcigrfrNAcPo6a 9Vvi/otxdoY5F4NCMKMKIPoecu9dZ9iarHmVXHz4K/ibObTIiFySwonNiHfDEPeiEM7j etIYZASSVICKCLZTMy0M1ySsZUva/c3OQ+LW7BVVP3yjyinyLu0An616dDPHkn0BMncQ EqIcsz1Dh060BJ65xFCTwc5ruZGurSmDpYnmSAaYQ96/x3hx0luVKsiHMG0F/BUOvZVg Y35g== 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=gjGY5geS4OiEaSZiUGSjAM0fkHIbgTUcyt/EXdNKreE=; fh=bpyexzPA98njr1V8BztPOU18dBfKKJq6VRSRLjzFAaM=; b=I2/C6msU6w4ZvxsS8Xrd3cEf+m4IiyddYpvI0SBjkSHlUdw997ru0RLP6eAjiThU+C jHGMbzhGMNFk2IKkcDIPL8gN8OEbQzOAqBSEkJodPUhaUw6Mj0KdRdcAOODj6WIqpoGT +vjlo6ZVKxQm8DB+cBjyNTWGD9SVUJ2BAB1i0gSElOLZQubvuuW9/I/UbaDkpu3rgPM3 b240IzBx8xV3xZ/YGwg5JmrZbk1Oqs6KZfY6yMKqdmdIjfSseU2BAYEM3DUMeSwvHbDo YI53jdjRdFjPtJVAozPtjyYKmZUZWYDppnxN4hSaoxVgIm/rcY7VtMJZ+o6oio3XlCta npGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WwuavARF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65648-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65648-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCV8wDX/LK1wsuLJpK3/HPT5Dg7D7LiRXuv90rzSYrcUHowIcwdjkyncmfBT1Q6bbG6kVoghugjVjAnv/whpZAgCVbnLKwXKL5dZQtXv4Q== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y63-20020a638a42000000b005dc8368c570si3237603pgd.684.2024.02.14.09.24.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 09:24:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65648-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=WwuavARF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65648-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65648-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 2422528BD12 for ; Wed, 14 Feb 2024 17:22:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF03C1272AE; Wed, 14 Feb 2024 17:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WwuavARF" 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 035271272BC; Wed, 14 Feb 2024 17:19:39 +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=1707931180; cv=none; b=qbsjaG8HbPpqGEqQpyPOg0f1/f0iF0FG5dou+g4mxPO4OovAl37Xl4zrfQKJ2M6WELZexCEYpOBV+qfmiHSFolJLkNx/MYBhGHaq+cPMoKnlzQlNaY4Djc2Op1zZ3upj1vnHrRAkiqrwPMTTOAXY+5ti/vUBvPxoU53jZU23i0A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707931180; c=relaxed/simple; bh=DWfwQbRXjVrD14SVINGcgMqWHxYUtxveD0dIZGefNe4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LQ/J66KsTazjDVy37hiloOGdOcW5hM2f2Iz1UYwQlqc685YSDsQ7HFVazlRC0tsq4I4QSsH1WJrFMtB+iz4QGsaIfTNXiOKZpfh8ID45gFdS29ts5ANazUzbyogBKbhdotdDpQHzBF1vC0fl7ZsSXm5BNFROfmGRoioTzq0cfw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WwuavARF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85F5EC433C7; Wed, 14 Feb 2024 17:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707931179; bh=DWfwQbRXjVrD14SVINGcgMqWHxYUtxveD0dIZGefNe4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WwuavARF9I4Kdb+4gH2EMa1VpbiqZ7jEt5VqMfxhR415jxzUl69jx8RzI7Zj/sJpv iVtRtXzlQjrLr8w4Cjp5DAdY+RrgW5xtBg4JfWrrkkddtTLvdQXm1uMeGHhNhxW6KR FgN+LrCZjHJcm4P9CNrW2jnKK7b4yM8ijgGc+YM9OHhXPkqS54W/bL5gZ9G7g36dlS P2rDXwWaNxF2pJ8TfaZ9Y+kQMJqm2WG0+fWzK9q5ZC9InbIZzTSYQI+hwIVo/0gOZd qYRPDQwjyImkvN0l/dAvDa9EvIOi2VDYLHMabLLzLceoi/48pQIRnkb+SOdAPYUFBa OrhogM1VX11CQ== From: Benjamin Tissoires Date: Wed, 14 Feb 2024 18:18:38 +0100 Subject: [PATCH RFC bpf-next v2 09/10] 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240214-hid-bpf-sleepable-v2-9-5756b054724d@kernel.org> References: <20240214-hid-bpf-sleepable-v2-0-5756b054724d@kernel.org> In-Reply-To: <20240214-hid-bpf-sleepable-v2-0-5756b054724d@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=1707931135; l=2187; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=DWfwQbRXjVrD14SVINGcgMqWHxYUtxveD0dIZGefNe4=; b=SWDa0TnPBLVOiw7xrbgzrI8gf6Q6gEt3YUt/IUl1nisfdqR0LGrlAAsx9WOkI9wfLB5WdB3Ei sUQwYt8/cYdC/He9YxXi7bmTJb/e+Yrfb3r3OEFYB1DjGlTehEb7Wk0 X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= 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 --- 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 = { -- 2.43.0