Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp648807ybm; Thu, 28 May 2020 11:36:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp3RMIvJ8rGZ9oSd5wl68THsICFn974KUFCmpxzZsNze6wjEiK5gZ9ge2MBiRdswSsOhIv X-Received: by 2002:a17:906:90d8:: with SMTP id v24mr2421122ejw.245.1590691017047; Thu, 28 May 2020 11:36:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590691017; cv=none; d=google.com; s=arc-20160816; b=FTkL1yDaoVDDH6TsU1FSUI3JxfBkYccppW4fwnsl33kpv/jU2/H+jTPdbpcND54A2+ 8WLc7ngNhosbTenR9rrHhSX1D5huc22JsCF1P/jTJ5GQho2yNpLGZNrWfd/mpcP6hxht 2vK2U5bsmc6cczM5/jQpp2h7caFyxt+P0AhT2mM0k4PpAjK+6idt8/qgt0gyqNw/DZvb h5bOMkJhwLmLpq14mxg36epAT5iyMdV+7CbkxHjSjHdYQ3TE1HyH0k1LhWEbu/1t0b99 usbfjVIXmS8Hn6c4/2S7qpqq0FfjSBeZoF/WE9NzV2SRhI6y4ILa6nuiGpssfY2BrUa5 Hu/A== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=DrK+nlSE8fWyydBa/BxyXKvC67NSQZxVCHU0aPhkfzA=; b=vZqVi9JDbx1XEYI06pnrYi8EPsJG1WK6BiTavUkW4lrwWfOfe1ikenoIxYwiZf4pmo fzX+m+NuF7abMNlH1ooxCyQDjjw+F6k8z44L13/jwroeUqR8AVhU+EpMHsChOoKwwltQ q6e0s/jOaOdWokOi7wAJP8hnyoPgm9OEgneeOQPm77Jtr7HzZlc4oUFPAEKdVZrDSJuK G9wTgYyh5e7zNn0e7C8YRsGbfYtIo9YjNbEXhzHeGYxPo3YqLqLSi8CwOQ12MyfyoCca WQNqH62zNJGJB2onSloaOtiSDoFRUyy/N+vpppKiAy5PpNg5bNIWCmk2V8z07PhE+pdq 4TGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i+qwcWWG; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si3998751ejx.451.2020.05.28.11.36.32; Thu, 28 May 2020 11:36:57 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i+qwcWWG; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405856AbgE1Sen (ORCPT + 99 others); Thu, 28 May 2020 14:34:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405831AbgE1Sej (ORCPT ); Thu, 28 May 2020 14:34:39 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10E52C08C5C6; Thu, 28 May 2020 11:34:39 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id s1so4068077qkf.9; Thu, 28 May 2020 11:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=DrK+nlSE8fWyydBa/BxyXKvC67NSQZxVCHU0aPhkfzA=; b=i+qwcWWGjVfNAnpXXgA+vCCmiuQTw7bThfut4HpZ/2X6FtCMgCtQiesLYJLyhf3YyJ G5oQH4x+DWlsFuCRN8Qt3Zc2ReMAB3x0suEWPZzsbDxaRthTSWlolP6vMSRHW/A8wWTf xjghj71+g2h0p5l06ou0mb4bYMMkL4TMpp+ZVvS1F8qAY7qUx5T4hu8js19FJi3+aKhL /l2lbRuEmoSF7N5zwCWfsfInjo2G1pV2NH7PGEOOxAJ97KzzcCnN1VU6uQgYLBAjYtYM PuqLAdFW1RrDAW47Vg/ErZ8NdsJtyuxv9NjhXJ5ll33Uk//PqfiGth5SZUgpglh0J+J1 denw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=DrK+nlSE8fWyydBa/BxyXKvC67NSQZxVCHU0aPhkfzA=; b=gvwTEuENkgsI3PhxxndJJUhWdjEI0ixkjVDYbzu/nYTTPqaO/OWHwqBnNCqsZ4cymo yx5oznflfk7cU7T6aXcAXMRHyAGxHKvyRlPxPmNWkW5wHwS6QCkFsi1a2EphQTCKkpIS obYjhiWj69ODarIX+qyoYiniJ8PvKEsul+3bRPc/zKXizMzSAisIp/1IewcdDhA88TCN /gwqNfL0qR4Yszd8WHIT8jr0IInASGkjGuJLktDZjGvdVrIBr0Jt8dd0l3IUbldGtE2M oHasrC36izXJDSrOblY6jaHg7JccgbSpulh5WtKRgP/EiBMA8zdDK7gnGfQt1WuxqvY/ Yj9Q== X-Gm-Message-State: AOAM5315qGSKES76EW56gA3u8MJKQPuNRAZXm+bnS2bjNdpxkHeLDCc6 hU+qOkWf+8q/OuD3n5HLdzrVjwH5WGhmPNAYRLE= X-Received: by 2002:a37:4595:: with SMTP id s143mr4546043qka.449.1590690878252; Thu, 28 May 2020 11:34:38 -0700 (PDT) MIME-Version: 1.0 References: <6561a67d-6dac-0302-8590-5f46bb0205c2@linux.alibaba.com> <9a78329c-8bfe-2b83-b418-3de88e972c5a@linux.alibaba.com> In-Reply-To: <9a78329c-8bfe-2b83-b418-3de88e972c5a@linux.alibaba.com> From: Andrii Nakryiko Date: Thu, 28 May 2020 11:34:25 -0700 Message-ID: Subject: Re: [RFC PATCH] samples:bpf: introduce task detector To: =?UTF-8?B?546L6LSH?= 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)" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 1:14 AM =E7=8E=8B=E8=B4=87 wrote: > > Hi, Andrii > > Thanks for your comments :-) > > On 2020/5/28 =E4=B8=8B=E5=8D=882: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 > libbpf-tools don't use BCC at all, they are just co-located with BCC and BCC tools in the same repository and are lightweight alternatives to BCC-based tools. But it needs kernel with BTF built-in, which is the only (temporary) downside. > 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 > >> > > > > [...] > >