Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp537657imn; Thu, 28 Jul 2022 08:14:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vg42N20X6I2Wq75Jut0qYi36w/UhK2tDCsnHWkyc6Gc6UNYp1MCCuwtjBlGXBhhrziWFIQ X-Received: by 2002:a17:902:7046:b0:16d:9102:c79b with SMTP id h6-20020a170902704600b0016d9102c79bmr15332968plt.120.1659021274012; Thu, 28 Jul 2022 08:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659021274; cv=none; d=google.com; s=arc-20160816; b=ECOnZ9w1Zjh7cLXqkMrMHFDYcb87zyaxNUeZGicQEYwd5SVkXruggdcuUVjgXhBhk/ junWD4o9IwWTBx0rExmX6+0mzk5cmaVZCEP9v25nnpgp/bY1g6h6c80ROMqxVyIwlKlk oncTJMPacR93DDUYnoC6wQlFyHn8q/39IXE1IyE8/B2i5K/wnJxFkwjPUqVLa8PdDlTR JjV9zkPOOR120BlhEbOhp7vECeBCOjm8KFHkHL6m8/XgITueUzSLT7EzOHsSGEN9jbQA JcBKplfisX8EAcvlchc1YoKlwcQ1IL5EGaUCDkJBriDWCwTj9PWt4B4azVW/iAuT9RWB 8OgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kyc8YUVuh3Rv3zzhIIR94XDcLjQS32+t2XnArHkuZKU=; b=Cc6XMyP5tkpHSyH4KJrSr8IGcZstu7mu8hpj60bAjPHqhpG7rIc6cdL9d2uVHuMrWG V+OnjAazml7Gdqgi7kru1v+VcmUUbUtE3G+7n1VXUvKmEDudhrMH28Fp1E/aRjHlm7jH SM1+gQJDOXYeppY0Y0ne3EYmmAjkRrSh3WpSGkc1Qi4AFNINrjYwgqggAGfwuQMkTSTy 7fEKF2BcSBDRu3HudYc1yD8Q44X0HQCbI7ynznZvjqBys9UY6T+1gqpLhlXm3QM3QQ5s kKk4nTQ284awL5OlboqMhnOqLrwmGQ50GEAU+Vowmz12K89wA12gjbO8QZY8HoDJloGF KVXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Chunc4kY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z123-20020a633381000000b004199528d361si1318485pgz.121.2022.07.28.08.13.58; Thu, 28 Jul 2022 08:14:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Chunc4kY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbiG1PMw (ORCPT + 99 others); Thu, 28 Jul 2022 11:12:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbiG1PMp (ORCPT ); Thu, 28 Jul 2022 11:12:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5E6754AE6; Thu, 28 Jul 2022 08:12:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E4796B82495; Thu, 28 Jul 2022 15:12:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A287C433D6; Thu, 28 Jul 2022 15:12:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1659021160; bh=WhA/ckzTBm+8Dp8WwZDawmWD2DX62ACRlGO+kSspKMs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Chunc4kYxYsCQE/dMUfZERtZnUkAqWJs2po2zdkmjG5RIc6hf1Mb1KDgL344asVLM e3fYA7RCfuGfeb+bCqPlS9Vx64f7TKUIi1dpHbBTya1qec8J8rM3qJYK8oZbqb5y6L aV98A5qJV55XrTx2kLyvecyLmk6ObCBTnw9WQIS0= Date: Thu, 28 Jul 2022 17:12:38 +0200 From: Greg KH To: Benjamin Tissoires Cc: Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , Kumar Kartikeya Dwivedi , John Fastabend , KP Singh , Shuah Khan , Dave Marchevsky , Joe Stringer , Jonathan Corbet , Tero Kristo , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH bpf-next v7 23/24] HID: bpf: add Surface Dial example Message-ID: References: <20220721153625.1282007-1-benjamin.tissoires@redhat.com> <20220721153625.1282007-24-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220721153625.1282007-24-benjamin.tissoires@redhat.com> X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 21, 2022 at 05:36:24PM +0200, Benjamin Tissoires wrote: > Add a more complete HID-BPF example. > > Signed-off-by: Benjamin Tissoires > > --- > > changes in v7: > - remove unnecessary __must_check definition > > new in v6 > > fix surface dial > --- > samples/bpf/.gitignore | 1 + > samples/bpf/Makefile | 6 +- > samples/bpf/hid_surface_dial.bpf.c | 161 ++++++++++++++++++++++ > samples/bpf/hid_surface_dial.c | 212 +++++++++++++++++++++++++++++ > 4 files changed, 379 insertions(+), 1 deletion(-) > create mode 100644 samples/bpf/hid_surface_dial.bpf.c > create mode 100644 samples/bpf/hid_surface_dial.c > > diff --git a/samples/bpf/.gitignore b/samples/bpf/.gitignore > index 65440bd618b2..6a1079d3d064 100644 > --- a/samples/bpf/.gitignore > +++ b/samples/bpf/.gitignore > @@ -3,6 +3,7 @@ cpustat > fds_example > hbm > hid_mouse > +hid_surface_dial > ibumad > lathist > lwt_len_hist > diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile > index a965bbfaca47..5f5aa7b32565 100644 > --- a/samples/bpf/Makefile > +++ b/samples/bpf/Makefile > @@ -58,6 +58,7 @@ tprogs-y += xdp_redirect > tprogs-y += xdp_monitor > > tprogs-y += hid_mouse > +tprogs-y += hid_surface_dial > > # Libbpf dependencies > LIBBPF_SRC = $(TOOLS_PATH)/lib/bpf > @@ -122,6 +123,7 @@ xdp_monitor-objs := xdp_monitor_user.o $(XDP_SAMPLE) > xdp_router_ipv4-objs := xdp_router_ipv4_user.o $(XDP_SAMPLE) > > hid_mouse-objs := hid_mouse.o > +hid_surface_dial-objs := hid_surface_dial.o > > # Tell kbuild to always build the programs > always-y := $(tprogs-y) > @@ -343,6 +345,7 @@ $(obj)/hbm.o: $(src)/hbm.h > $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h > > $(obj)/hid_mouse.o: $(obj)/hid_mouse.skel.h > +$(obj)/hid_surface_dial.o: $(obj)/hid_surface_dial.skel.h > > # Override includes for xdp_sample_user.o because $(srctree)/usr/include in > # TPROGS_CFLAGS causes conflicts > @@ -429,9 +432,10 @@ $(BPF_SKELS_LINKED): $(BPF_OBJS_LINKED) $(BPFTOOL) > $(Q)$(BPFTOOL) gen skeleton $(@:.skel.h=.lbpf.o) name $(notdir $(@:.skel.h=)) > $@ > > # Generate BPF skeletons for non XDP progs > -OTHER_BPF_SKELS := hid_mouse.skel.h > +OTHER_BPF_SKELS := hid_mouse.skel.h hid_surface_dial.skel.h > > hid_mouse.skel.h-deps := hid_mouse.bpf.o > +hid_surface_dial.skel.h-deps := hid_surface_dial.bpf.o > > OTHER_BPF_SRCS_LINKED := $(patsubst %.skel.h,%.bpf.c, $(OTHER_BPF_SKELS)) > OTHER_BPF_OBJS_LINKED := $(patsubst %.bpf.c,$(obj)/%.bpf.o, $(OTHER_BPF_SRCS_LINKED)) > diff --git a/samples/bpf/hid_surface_dial.bpf.c b/samples/bpf/hid_surface_dial.bpf.c > new file mode 100644 > index 000000000000..16c821d3decf > --- /dev/null > +++ b/samples/bpf/hid_surface_dial.bpf.c > @@ -0,0 +1,161 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* Copyright (c) 2022 Benjamin Tissoires > + */ No hints as to what this, and the other program are doing here in a comment? > + > + while (running) > + ; That's burning up a CPU, why not sleep/yield/something to allow the cpu to not just pound on this variable and allow other things to happen? thanks, greg k-h