From patchwork Wed Feb 14 17:18:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 201060 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1372660dyb; Wed, 14 Feb 2024 09:24:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVEbL7pnoei2fMEAfM0u0WGmdxIs0ZpsyAPwYZCpT9R5ydpQDHtT7lJMFvofQ2gSs6VflkEkSAk6MnGoIdhAPD0DKxHgQ== X-Google-Smtp-Source: AGHT+IGImXVfLRBiHTiDrtgn6ym5WiYYUfwY+er88Dhc295i6bjJuk2bWyNj4KPd8Y62BM4SvMxd X-Received: by 2002:a17:906:ae09:b0:a3b:7216:3091 with SMTP id le9-20020a170906ae0900b00a3b72163091mr2120622ejb.20.1707931461978; Wed, 14 Feb 2024 09:24:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707931461; cv=pass; d=google.com; s=arc-20160816; b=WvAHJ4i6acbKjIYA7dK7XBL2gBBYhfB4KhyFUzpNXux2EirsJzyQqCFb5yeMzAn+Oy vHHB98l+Y1XhkO9iXdrkw+GQKyKU2MWGae3lugNHyOzbLo+bH2KQopYDHLeMzauKGqwz +72/D1IJ13JgNc8+I/4sGoMvfIKgLetT72viqCrSPoLzs2j9GC/ocIJt/VNW09dZ9Say DDygAq39k71USkPW87tDXWtt1MMLu1gYyDIMdvqKs1hKbISragkq+QIUyBjXoxEkE1+j k4ylS2hoO3ZcwMT+SqtzIhtLSQpWdbSxW+yI6TLflBRSdEXeoO05Pm9N8Z737CmyTpsQ fYzw== 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=j9lW6cJnrEuwV7ywyQ506azVQ1uipiaLSKr4dPqAxlM=; b=A+eekFUbBti411KlX2dhqqcQ1N1HaKK0Nnhw1UJh7siBWaih+QDDAw6Kyt8sofxqnk ol9JzLJEIa4eNFlfBQhDdmVSI3zKilSZhbPTeEL4s1zNBXJc7ExKLUeceDdPHZ5SkxFE mTo/NI7RyOn+/yMB7XFSitD+Nk7hEkkQavKLCct5GdWl9EYyPJdxV1FTSTUnrXv8aNsY GBSvWBHOcaGXF7WbT4dsCl5+XRIXl9kMs+UUj44jbwIQX1GzZjNjLxke5/59nmmNr3+w Ho4lDcMdgbo1VnldV0zLTAtprBX6xp6cNXcDDVEk2pAEAPL8LptdGG61cvfW6UtGyKbF apZA==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65648-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUzpIQdH/o4ZItRuA0ksLIzZvTvsLSNvA7M1tHh4Jqhcrc7ACyhCDv3z+XKNkxhB/ZAsM6XgqC9U50eJdlJ8DJwLC6o3A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x19-20020a170906299300b00a3d7651b979si73497eje.155.2024.02.14.09.24.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 09:24:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65648-ouuuleilei=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=WwuavARF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65648-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65648-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 622AF1F2B884 for ; Wed, 14 Feb 2024 17:22:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97C59127B43; Wed, 14 Feb 2024 17:19:42 +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 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= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790895940354693470 X-GMAIL-MSGID: 1790895940354693470 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 = {