Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1041923rdb; Fri, 9 Feb 2024 08:35:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyT1hRv3eLgiP+fNnyhrk8ZTv4R7NNtuqfiXDstFE2z4HJZkkB38gyz0xMTXbUsd0lmxdk X-Received: by 2002:a05:6a20:d389:b0:19e:2d04:d783 with SMTP id iq9-20020a056a20d38900b0019e2d04d783mr2922131pzb.4.1707496520683; Fri, 09 Feb 2024 08:35:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707496520; cv=pass; d=google.com; s=arc-20160816; b=A2L22NqCTUeyo023yOZG4kaJ8fNzM1oz7/qfIVlxQAkQqrzznk8OPCCVO0q+z+m82p d+ICivsjYm3anGf9ET2A+LHpLNieabViJG0dwVpn+iPOt9ZnMIDf8VbqyF7BkxA+HTma 725lmAnaJY9XyY0roeM6ZoPeU9ggm7J+YRgJwcjLFEoFPbh9uW5HmdiqUNLtXQpg/b3s BJXSviacJqcKOULRBiRF9hWC3tfZB/oBYGeZpwm5pzi3KB4x5NarUh+rmPEaGZAjhZJ4 LrovnvExYud83nScQ4BGptwV2RWuiQYHLMroXoFjHQxXqB0r/pn1erlNxLbv865ZcKP2 k9rA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=xSVANJ9Sul+6tG8IyWGYziNKbkjPAgWV/TLqpKmQNq8=; fh=jBPuT6PadnprukOJde8qncb7QsnjZkQL00uZmIQXO+M=; b=OEU0BmyHOZ6EUqkRBmym65y1qGArWq/I3vsGc9/aujjJ1njejwvkQ5Jmu/5ExgCjhD BDGQKRvunLUMhaxughyds0Mf12bgytIBuyr+AQFyOb3xCnIbjeIxac6PqMdrhYfWB0QP RLeY+7l9DXS/yfuolRO52IuS9SLmnKMpercDO+kqaErhPVksW/P9AzMZ8TOeJMhJpaoL 4KVZJlnh8zb0hIp5lKUtKwB/cT/vujXlREsFUhJ3nyxW0tHR3Y1SaWSwOI+igcLvDMDv utk8+5+fAKfbGaw8rzPtvu8F8rUokhRxO4qjW1jtjxUvF7Fw6bEiuBa9CkOBkIncbEMt ju7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E02FXSbW; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-59602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCUOQUzlkigchnGptvc6RFPJockdp97sAwCaTMWBOW5tSjcDYR3xcZAXG1ACAWXu5+brTb9IrsxBy6WBpcwRMv5N0ER2nRDlEcX3g8RXnA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p2-20020aa79e82000000b006ddc42ea7a9si550681pfq.289.2024.02.09.08.35.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 08:35:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59602-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=@redhat.com header.s=mimecast20190719 header.b=E02FXSbW; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-59602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 A850928CE3E for ; Fri, 9 Feb 2024 16:26:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD4A67AE7E; Fri, 9 Feb 2024 16:26:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E02FXSbW" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 64D427317B for ; Fri, 9 Feb 2024 16:26:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707496007; cv=none; b=b/C7bjmuEBy6z6qOUv+D7N53iBA5VWfHJKpbJ236LFTsE+zNHI03UTBAn14PuVb7ygEauw9qRU+TP/qDiz5Pe/87nUo9rjYqnygngAvDkvs1rrekI/ZLCumCzFp7j4qgPyc+jXZyAN68l8ySr7JPk/gjrZRxaxYqUSDRUWKUOTs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707496007; c=relaxed/simple; bh=xSVANJ9Sul+6tG8IyWGYziNKbkjPAgWV/TLqpKmQNq8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=CJt536Nxf5DHjcSgzVtOIrtFQjyc2zwiCwbO/vQ2u6eZkxcTxceR5zA2QdDvpJtH4izAAsSxIM9WGqdXch4NSPCV9cxTN8MYQRTXBvocQ50yNis7c9Bge0o1eNPU+Qw8VPo5b8pWV01Ui9/c3QDgucVNuk5z8Z3Q3nF+AJ9WHgI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=E02FXSbW; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707496005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xSVANJ9Sul+6tG8IyWGYziNKbkjPAgWV/TLqpKmQNq8=; b=E02FXSbWkgj/FU+H2H20U117SYUoDWUlPwMDK9awyBr4bwiwliJZyOEH/fdxNgRho8kc04 n8N6kCl0rMk9C5mpPGEtDmW4A7BUZxvg3fVLJgVqB08PiHKqQ4+rarXg67dzUpeG3s1ash oIsCyEVZvWVnW6OFHq+qLJjXweRvdgI= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-s2_DfHDEPf-HQO1u7QexFA-1; Fri, 09 Feb 2024 11:26:41 -0500 X-MC-Unique: s2_DfHDEPf-HQO1u7QexFA-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a2c653c7b35so80373866b.0 for ; Fri, 09 Feb 2024 08:26:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707496000; x=1708100800; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xSVANJ9Sul+6tG8IyWGYziNKbkjPAgWV/TLqpKmQNq8=; b=an3S+9E5catGgFZvT7poD9sS7zYX6u9SbY9iryRqHVileTw24AMyCrugkExBeMrkk3 GAQaQ9uWs+gxs3THhSiEpKAXOqsCTNgYphFKcLNqSH0I8E5LGWZO2C1rWprtydAGP275 465HJxddx0ycsDmD3NnTawMGRV+Em9/V9DGS1A/veMBNWghGiGFBRA4PB9qvXSE9joj9 jf6pfsvYuAi6f4bOcjOpSvJXgbTtGGaLqvvsEe65ZmHJf/wnzqgADf8xR9VsZhs89PdV rGzYheH9SBKH6EAKbPzRiSBsJuXzA4ec4HELyTfuT9061uZmJKgf+/gJ3T+z5GaSxL+V WY/w== X-Gm-Message-State: AOJu0Yxb9dRYzSVXF2Ql+mB2FZyb+bOuVj+yIye8e1O8MYCgLRngRCPX rgzB5l60aO6dinGSa4nwWaTaJw0payDxMDCiNjOX42jDjmnyhzzCY7FEDp+FYEi6T2h4p4jCBt+ WuprJL9uYjg/9w6vR3meYnfHptb84jGuIqgzUnNS1Tgo9GA7VoJE4Tf7XoE3vWCpYGNouHM0QT+ IE4JLBnwSWhQyBaIrYlUap5056zZkGUBLH2IAX X-Received: by 2002:a17:906:a3d6:b0:a37:e35b:9a3e with SMTP id ca22-20020a170906a3d600b00a37e35b9a3emr1642617ejb.40.1707496000225; Fri, 09 Feb 2024 08:26:40 -0800 (PST) X-Received: by 2002:a17:906:a3d6:b0:a37:e35b:9a3e with SMTP id ca22-20020a170906a3d600b00a37e35b9a3emr1642604ejb.40.1707495999966; Fri, 09 Feb 2024 08:26:39 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240209-hid-bpf-sleepable-v1-0-4cc895b5adbd@kernel.org> <87bk8pve2z.fsf@toke.dk> In-Reply-To: <87bk8pve2z.fsf@toke.dk> From: Benjamin Tissoires Date: Fri, 9 Feb 2024 17:26:27 +0100 Message-ID: Subject: Re: [PATCH RFC bpf-next 0/9] allow HID-BPF to do device IOs To: =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= Cc: Benjamin Tissoires , 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 , Jonathan Corbet , Shuah Khan , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 9, 2024 at 4:42=E2=80=AFPM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > > Benjamin Tissoires writes: > > > [Putting this as a RFC because I'm pretty sure I'm not doing the things > > correctly at the BPF level.] > > [Also using bpf-next as the base tree as there will be conflicting > > changes otherwise] > > > > Ideally I'd like to have something similar to bpf_timers, but not > > in soft IRQ context. So I'm emulating this with a sleepable > > bpf_tail_call() (see "HID: bpf: allow to defer work in a delayed > > workqueue"). > > Why implement a new mechanism? Sounds like what you need is essentially > the bpf_timer functionality, just running in a different context, right? Heh, that's exactly why I put in a RFC :) So yes, the bpf_timer approach is cleaner, but I need it in a workqueue, as a hrtimer in a softIRQ would prevent me to kzalloc and wait for the device. > So why not just add a flag to the timer setup that controls the callback > context? I've been toying with something similar for restarting XDP TX > for my queueing patch series (though I'm not sure if this will actually > end up being needed in the end): > > https://git.kernel.org/pub/scm/linux/kernel/git/toke/linux.git/commit/?h= =3Dxdp-queueing-08&id=3D54bc201a358d1ac6ebfe900099315bbd0a76e862 > Oh, nice. Good idea. But would it be OK to have a "timer-like" where it actually defers the job in a workqueue instead of using an hrtimer? I thought I would have to rewrite the entire bpf_timer approach without the softIRQ, but if I can just add a new flag, that will make things way simpler for me. This however raises another issue if I were to use the bpf_timers: now the HID-BPF kfuncs will not be available as they are only available to tracing prog types. And when I tried to call them from a bpf_timer (in softIRQ) they were not available. Cheers, Benjamin