Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp238226ybm; Thu, 28 May 2020 01:16:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbNNKLIfFe1A77C5s2ij74O3l+Hx/9pabOlP/XYoXlwCSsm02EgxMay01G+laNqMaXmQo8 X-Received: by 2002:a17:906:580e:: with SMTP id m14mr1821305ejq.447.1590653816179; Thu, 28 May 2020 01:16:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590653816; cv=none; d=google.com; s=arc-20160816; b=M2XCEk99YIQjpj1D+/seKW4EWBq41jB18/03aCBx1O4HQUst7xyV/TWGVbhQd9AW4+ wzZqxkovHu5X6JvR7tNmTgadnGxKbbp/GjMbvT4ubM10K7SRWyrlMzDLSXC2f3g0uRH4 eRvPXp0xpIYD/98E56UZgDHtOG100SLyehQxkDKW0rJNuUhpsvpW8CWd+GNvbT89MYxg uQzs92vbrlrUTJ1KnRXAgm+ehEQ5Mgu7KHMIiVjCNbtCVn4jwFcXuui5Xs/EoCdkldDz W2YrL4vFAqHY2+q2kLuOs8Z74Sl75uCserDx6PZcb/TdQbpg4tSVoB4tqJ2JoZPhmJb9 zNyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=iXwUBPLmegErFpSVRceUMEf0MhzTeP021XTltpVwAO4=; b=HdiTUn9pXRp/vf+MoDSkyRbIiHRzlEVuG25okRvDY40aYwg85Dyk8/c8MLw/9M2Dg3 KKP/BepyYi40wpGLdwZhgEXed22gWgiaqd84OSg+Bd5SsjZbn3o/XSzcawkzKvBnQFMJ euOy6u29ay2z160/2i1c5O7pD5fRaQ2GCaL+Jue88JRw0R3EQhsrFrw6Y9uf0ecndMRw aWN23mtutx/dQvHTYPCbXFF2EuVisUdsa82fFsl0xqO++gQStlgAh9KIMa/p05HUMQg1 6ZTQM7g700yX4YjoA0YbyENFAMbUj71loYTVdlwvcB6ri+NIwfTWAjQwBJGBu6Mir7JH Vusg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si449856ejz.132.2020.05.28.01.16.32; Thu, 28 May 2020 01:16:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726612AbgE1IOs (ORCPT + 99 others); Thu, 28 May 2020 04:14:48 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:49828 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbgE1IOs (ORCPT ); Thu, 28 May 2020 04:14:48 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=yun.wang@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0TzscnAD_1590653683; Received: from testdeMacBook-Pro.local(mailfrom:yun.wang@linux.alibaba.com fp:SMTPD_---0TzscnAD_1590653683) by smtp.aliyun-inc.com(127.0.0.1); Thu, 28 May 2020 16:14:44 +0800 Subject: Re: [RFC PATCH] samples:bpf: introduce task detector To: Andrii Nakryiko Cc: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , open list , "open list:BPF (Safe dynamic programs and tools)" , "open list:BPF (Safe dynamic programs and tools)" References: <6561a67d-6dac-0302-8590-5f46bb0205c2@linux.alibaba.com> From: =?UTF-8?B?546L6LSH?= Message-ID: <9a78329c-8bfe-2b83-b418-3de88e972c5a@linux.alibaba.com> Date: Thu, 28 May 2020 16:14:43 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Andrii Thanks for your comments :-) On 2020/5/28 下午2:36, Andrii Nakryiko wrote: [snip] >> --- > > I haven't looked through implementation thoroughly yet. But I have few > general remarks. > > This looks like a useful and generic tool. I think it will get most > attention and be most useful if it will be part of BCC tools. There is > already a set of generic tools that use libbpf and CO-RE, see [0]. It > feels like this belongs there. > > Some of the annoying parts (e.g., syscall name translation) is already > generalized as part of syscount tool PR (to be hopefully merged soon), > so you'll be able to save quite a lot of code with this. There is also > a common build infra that takes care of things like vmlinux.h, which > would provide definitions for all those xxx_args structs that you had > to manually define. > > With CO-RE, it also will allow to compile this tool once and run it on > many different kernels without recompilation. Please do take a look > and submit a PR there, it will be a good addition to the toolkit (and > will force you write a bit of README explaining use of this tool as > well ;). Aha, I used to think bcc only support python and cpp :-P I'll try to rework it and submit PR, I'm glad to know that you think this tool as a helpful one, we do solved some tough issue with it already. > > As for the code itself, I haven't gone through it much, but please > convert map definition syntax to BTF-defined one. The one you are > using is a legacy one. Thanks! > > [0] https://github.com/iovisor/bcc/tree/master/libbpf-tools Will check the example there :-) Regards, Michael Wang > >> samples/bpf/Makefile | 3 + >> samples/bpf/task_detector.h | 382 +++++++++++++++++++++++++++++++++++++++ >> samples/bpf/task_detector_kern.c | 329 +++++++++++++++++++++++++++++++++ >> samples/bpf/task_detector_user.c | 314 ++++++++++++++++++++++++++++++++ >> 4 files changed, 1028 insertions(+) >> create mode 100644 samples/bpf/task_detector.h >> create mode 100644 samples/bpf/task_detector_kern.c >> create mode 100644 samples/bpf/task_detector_user.c >> > > [...] >