Received: by 10.223.176.46 with SMTP id f43csp1620801wra; Wed, 24 Jan 2018 20:32:08 -0800 (PST) X-Google-Smtp-Source: AH8x225L6kPOO6fMJGWilQZKuExUbx6ET1UuyXD9aKtep8VOfoBiHYPt33/pnxNxr2oxEOe5NN17 X-Received: by 2002:a17:902:b43:: with SMTP id 61-v6mr10253171plq.127.1516854728154; Wed, 24 Jan 2018 20:32:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516854728; cv=none; d=google.com; s=arc-20160816; b=cLtMB5O/v8pPPqFeEhW5HdGILLiUIl/oJ9Ydu/vObxF0LZxHYXkZMBwLIgfvaGfolu Z0h0CvqA37LRZrc9ZFNtWmX+Y0lzSFuWEdwGl7zjVUewyPb4wqstZx/EmG8sqeVQOyhk MyIc+04lbgT9VYgLGM04vr4Y5z5QDgp0U12ivQ/OmF7Ma8OslDW+tMWltEIKw9qbv1eA F4kjeW65eMuXWcrkD6ED7YV//5bZ87fpKCzJsCGYS92XqjW//w7sCArgMSGNYw6dk8DI vfnhFooRq7woVsfiycF2sjWJ7eCyYeVglbBqWRIjsCgFasJLyHZJq0NKg2NEmf/0Kjkl IIPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=RlNPjuuEJ2+wZfyYi39qUMnHaYLuAO3vxBb7jKZTvPI=; b=bgydri2Vmd3MJwokaoSi/MBrWRuF+SkdtBPJVOS8mn/c17sVQucg6tHjVi/CZRNDCx hJV0a2zAbaeTVjiqzr/nvCNof+jCLjTS06j9tvwasrNwk9MYlJ8wVzoYr4wDxZGUWzbd RC9Qmuc/9qPjoxc+zlfxScq5+rbXOYRuNIFivsNvOzHrYfHoqGhuhLwg7d6QMNWzwouP khk4+eWX4re/uVF/uz26p89ZjsfW8k3AA3663xsc3fB0o5Sv1NAAH6/gjpuOINAiBrSj OgOuVW/w35CS4p5cecblr9tWt0RZNWNZ1Roh5UoSNLZN+H7nUECoMu8iOoTqv92w9zBM EhBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZmhBkAAV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z22-v6si669935pll.703.2018.01.24.20.31.49; Wed, 24 Jan 2018 20:32:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZmhBkAAV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933492AbeAYEay (ORCPT + 99 others); Wed, 24 Jan 2018 23:30:54 -0500 Received: from mail-io0-f173.google.com ([209.85.223.173]:45662 "EHLO mail-io0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933369AbeAYEax (ORCPT ); Wed, 24 Jan 2018 23:30:53 -0500 Received: by mail-io0-f173.google.com with SMTP id p188so7223980ioe.12 for ; Wed, 24 Jan 2018 20:30:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=RlNPjuuEJ2+wZfyYi39qUMnHaYLuAO3vxBb7jKZTvPI=; b=ZmhBkAAVKp1cf/lptSM58xvmputeF6DM7U6/X7xPeGzgMNpsLBZXHCZNfUqG8UsnnV WLUNkhYroO0fS0c3kfkktqxdosJi1rCGPxh6cx3+/HQve2RWr4WnCfsoI6WNsl5MGbGa 0b47Gt21UDow2TA2tiRkzEvv85oIoymDLeSbcpepbDlwY5rpc0YNTc1/sV/MTiHGm1+G Zd/W7oL6nmtdltOBuYEnhwOopecDZ+pCxkwKtaeXrs+1feWdQN+m4CAgpasxYHMxdrQP uUKOfjMhwBMUwGCWATfWnXN0blow0zY5lhWsBPRb87FMngwE48mwNXmlcTQoFTdvurTA arxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=RlNPjuuEJ2+wZfyYi39qUMnHaYLuAO3vxBb7jKZTvPI=; b=Nv0RX1A/jgOratsC6OgAePrXS8U6WI1AGFrofEdBrHMwE+MoK7UrdvPdIG8ndo/7+v toa0aaRFXEH2OMyRt5bxtnP455MIq0qSmqjdce6ND5vhTh02Q1nAchFd2c0vJomsJ1Mw rBLb1zIPy++bLypQQVGKUQeto4H/+MypproCShSIQBK1VlybGaup7S/i/pdCi+56KXqg tSSrYE7vE47Y2bTaINhy0huuj9vq4arhNHI6eSobFAhE42dFt3yz0LvU7KmfWLK7BqoO AxCeRX+NCKZ5/E/KvHoqghUyFO5YwZ8PWH17Xrx/SW3Jn5hjfNRfpVXw2goP1pBbwT3N JQGg== X-Gm-Message-State: AKwxytclUcAAQT87OX9kHyoSsZaGPr+Bdc70x09lh0d1PkVLby3qG+my eC3k4D1hhylfgqPL1zJCJA3g2Hn/uhZVU4/xQXyOmylRTzA= X-Received: by 10.107.140.88 with SMTP id o85mr10812034iod.219.1516854652425; Wed, 24 Jan 2018 20:30:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.172.135 with HTTP; Wed, 24 Jan 2018 20:30:51 -0800 (PST) In-Reply-To: References: From: Joel Fernandes Date: Wed, 24 Jan 2018 20:30:51 -0800 Message-ID: Subject: Re: ANNOUNCE: bpfd - a remote proxy daemon for executing bpf code (with corres. bcc changes) To: LKML , iovisor-dev@lists.iovisor.org Cc: Alexei Starovoitov , Brendan Gregg , Alison Chaiken , "Cc: Android Kernel" , Mathieu Desnoyers , Josef Bacik , Yonghong Song , Steven Rostedt , Brenden Blanco Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sigh, Correcting Brenden's email address. Apologies. On Wed, Jan 24, 2018 at 8:29 PM, Joel Fernandes wrote: > Hi Guys, > > Just providing an update: I made lots of progress last few weeks and > all the issues mentioned below (in the last post) are resolved. > I published an LWN article explaining the design of BPFd and BCC-side > changes: https://lwn.net/SubscriberLink/744522/ba023b555957408e/ > > There are still a few things that don't work well like symbol > resolution, and I am working on it. The effect is just tools that need > it wont work, which aren't that many from what I see but the goal is > to get everything working ultimately. > > My next steps are to post the BCC side changes on github as a pull > request (once I get a chance to rebase and send along with any clean > ups). I also request you to take a look at the top 7 patches on this > branch and provide any early feedback to me: > https://github.com/joelagnel/bcc/commits/bcc-bpfd > > Based on activity on twitter and folks pinging me, it seems there is a > LOT of interest for this both within Google and outside so its quite > exciting. I strongly believe this will expand the use of BCC in the > community. I look forward to presenting some demos at SCALE showing it > in action. > > I am looking forward to your comments. Thanks. > > Regards, > > - Joel > > > On Fri, Dec 29, 2017 at 12:58 AM, Joel Fernandes wrote: >> Hi Guys, >> >> I've been working on an idea I discussed with other kernel developers >> (Alexei, Josef etc) last LPC about how to make it easier to run bcc >> tools on remote systems. >> >> Use case >> ======== >> Run bcc tools on a remotely connected system without having to load >> the entire LLVM infrastructure onto the remote target and have to sync >> the kernel sources with it. >> On architecture such as ARM64 especially, its a bit more work if you >> were to run the tools directly on the target itself (local to the >> target) because LLVM and Python have to be cross-compiled for it >> (along with syncing of kernel sources which takes up space and needs >> to be kept sync'ed for correct operation). I believe Facebook also has >> some usecases where they want to run bcc tools on remote instances. >> Lastly this is also the way arm64 development normally happens, you >> cross build for it and typically the ARM64 embedded systems may not >> have much space for kernel sources and clang so its better some times >> if the tools are remote. All our kernel development for android is >> cross developed with the cross-toolchain running remotely as well. >> I am looking forward to collaborating with interested developers on >> this idea and getting more feedback about the design etc. I am also >> planning to talk about it next year during SCALE and OSPM. >> >> Implementation >> ============== >> To facilitate this, I started working on a daemon called bpfd which is >> executed on the remote target and listening for commands: >> https://github.com/joelagnel/bpfd >> The daemon does more than proxy the bpf syscall, there's several >> things like registering a kprobe with perf, and perf callbacks that >> need to be replicated. All this infrastructure is pretty much code >> complete in bpfd. >> >> Sample commands sent to bpfd are as follows: >> https://github.com/joelagnel/bpfd/blob/master/tests/TESTS >> ------------------------ >> ; Program opensnoop >> BPF_CREATE_MAP 1 8 40 10240 0 >> BPF_CREATE_MAP 4 4 4 2 0 >> >> BPF_PROG_LOAD 2 248 GPL 264721 eRdwAAAAAAC3AQAAAAAAAHsa+P8AA[...] >> BPF_PROG_LOAD 2 664 GPL 264721 vxYAAAAAAACFAAAADgAAAHsK+P8AA[...] >> ------------------------ >> Binary streams are communicated using base64 making it possible to >> keep interaction with binary simple. >> >> Several patches is written on the bcc side to be able to send these >> commands using a "remotes infrastructure", available in the branch at: >> https://github.com/joelagnel/bcc/commits/bcc-bpfd >> My idea was to keep the remote infrastructure as generic/plug-and-play >> as possible - so in the future its easy to add other remotes like >> networking. Currently I've adb (android bridge) remote and a shell >> remote: https://github.com/joelagnel/bcc/tree/bcc-bpfd/src/python/bcc/remote >> >> The shell remote is more of a "test" remote that simply forks bpfd and >> communicates with it over stdio. This makes the development quite >> easy. >> >> Status >> ====== >> What's working: >> - executing several bcc tools across process boundary using "shell" >> remote (bcc tools and bpfd both running on local x86 machine). >> - communication with remote arm64 android target using the "adb >> remote". But there are several issues to do with arm64 and bcc tools >> that I'm ironing out. Since my arm64 bcc hackery is a bit recent, I >> created a separate WIP branch here: >> https://github.com/joelagnel/bcc/tree/bcc-bpfd-arm64. I don't suspect >> these to be a major issue since I noticed some folks have been using >> bcc tools on arm64 already. >> >> Issues: >> - Since bcc is building with clang on x86 - the eBPF backend code is >> generated for x86. Although it loads fine on arm64, there seem several >> issues such as kprobe handler doesn't see arguments or return code >> correctly in opensnoop. This is (probably)easy to fix by just user >> telling bcc we're build for a certain architecture - but that would >> mean we carry code for each arch when building the bcc libraries and >> dynamically select the code path to run - than building for the C++ >> compiler's target architecture. >> - Some operations are quite slow, such as stackcount when the number >> of stack traces are a lot. Each stack trace is a key and and every key >> iterated is at a cost, which adds up. Maybe we can batch these up so >> that they're faster instead of making each key iteration a separate >> remote command/response? >> - Some tools read the ps table on the local host. This needs to be >> remotely proxied. >> - Provide mechanism to make bcc/clang build eBPF for arm64 (using a >> command line switch) ? >> - Design a generic parser mechanism to be added to all bcc tools to be >> able to pass which remote method to use, what the remote architecture >> is and what the path to the kernel sources are (for kprobes to work) >> >> Thanks a lot to Alexei for discussing ideas in conference and for all >> the great advice and help. >> >> Regards, >> >> - Joel >> >> PS: We also have some usecases where our Android networking daemon has >> hardcoded eBPF asm and our teams want to write them C and load the >> binary stream. It seems bpfd can be a good fit here as well.