Received: by 10.223.176.46 with SMTP id f43csp1624632wra; Wed, 24 Jan 2018 20:36:09 -0800 (PST) X-Google-Smtp-Source: AH8x225o8VOOm9Xx7EguPCtKxQMLxVDvIp+zFz7XuMgkMeG62vnwi+nwVn/ltwdpO4sdECDTlAuH X-Received: by 10.99.51.133 with SMTP id z127mr12346746pgz.324.1516854969090; Wed, 24 Jan 2018 20:36:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516854969; cv=none; d=google.com; s=arc-20160816; b=l5YTx+92m/vqtD5ziW+lgU2OSKwy96lrPiniGp8NNVJ9r3aOr/vgi1TyLFGtSZKd2L //VF5NOiCZH9rS5WNwhbTeti9AoV1egNuWZ8q7yEzno3uTa5mWyYz9Sz4u+MDdMnso81 hJI7RUksHzxvmu2U1o3Whq+mqyOgNb6tBrDf6YrI8fdxOLbD5lomUr7Dtv7kitXwYg9P B1bYy9CQ0TE4LftXBzAHzndR0jpGO6j2BydpqZrB36nm9gu7Hc4G2qYiJHItzFfJ5nPn SSKjJVZOhIKA4XvYyJgOnxPrGyCkJesImaToPxO5Ik34fuaL4XLnR9RfNTd78NdNWAYE bWNg== 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=zsCpeQHVzQs5hpUHrq9NoRrmbzWdFQ0kSR22IlduQ9k=; b=NOTisZGEPCekxU1Yeg1zD+riN+msKYsGTAU1XZpD1EB5fqZoJ8PbdUHWtDTlTf1kD6 jN/GU26fPmk6I44QOybxqEL+BLNZrEemXYGLmO3g9Lu05ToSEQb8uYqu2QR9dQPbXRXJ FxE4MnEaSuIirwvsFnB/OdEjN3JIRmkrekKV2liZFgBqd9rxTC53ezxGzx5XRepj5emY 4ENxpFaQT6D96Fw3GOkCyeFB7hxVUs9Li3CXhP1B50cnlygHLSinSui+D/b/uTXC5ITF boK/jbRnWd6rreRoo1xBME5BBnjoTs4b1Mm5wSnPnk2ABug41sEIJEBMF9YdUNIo9JlT wqUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UwXetStw; 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 c9si1018960pgq.542.2018.01.24.20.35.54; Wed, 24 Jan 2018 20:36:09 -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=UwXetStw; 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 S933451AbeAYE3n (ORCPT + 99 others); Wed, 24 Jan 2018 23:29:43 -0500 Received: from mail-it0-f42.google.com ([209.85.214.42]:42192 "EHLO mail-it0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933369AbeAYE3l (ORCPT ); Wed, 24 Jan 2018 23:29:41 -0500 Received: by mail-it0-f42.google.com with SMTP id p139so7766115itb.1 for ; Wed, 24 Jan 2018 20:29:41 -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=zsCpeQHVzQs5hpUHrq9NoRrmbzWdFQ0kSR22IlduQ9k=; b=UwXetStwMjULGQPQlDHaLODt4HGdr6QEQY0nAVLp7vb3LC7yffholJpbRKX6kfFtwq bTd28v1rqyfR/nJAV3Q8/OMpi5qBbX7EmhfcPztWqQRglwiaTVZC1TEEeQrq4O+t5Hnm lo9AEFJIja1onu4TI8Lx4KLCpx/4bcIXlfpnVoBdL8Zd/EBakXXtTXK9vhSLAUrS/95n y+XuKNpmUkAdIfh/BrBkfK5ev6zNh640yVJlVXWA2xo4hrsDTTsV4V0XIReyg0nOf8Nq Mzk+jDFEqXhiTPjWnmdKLi2YWol9+cZ9j3nj7Ook2KJuln/GOs1cPpYcmHcvJ9qYQ0t6 rVeg== 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=zsCpeQHVzQs5hpUHrq9NoRrmbzWdFQ0kSR22IlduQ9k=; b=OWpSUsXeZ7kMtQERTbT4lpoF8GX8mXkFTq2x58QyrH1lpTd8fL1xgOXMPPR/GgsNuP dGoTRw7AOeJGxaFMiFMMQpYRN1qtZkD3RgLakFY4mqBIpdvfN6lH0w8FsJ6QtrqlIrGN WlTnu7eEwUVfcE01gXeyeiZef9/HTZrSi90v9rhqmXHDyaCI89Ci2doS1npxmS9nMSW0 FFXCewolZGEh661qTdVq/fdfrs9Quc8BBqSxyZAvw5oBJic6R5/jZU0MKRxhiqqA0m7k 1E5Uq+hjEQ/Xu0ZjBOnv+miAh7OHCDQQ2fXuLOHPtVVA/QW8a/NG3CUt/SIF0DjOAb6V uAiQ== X-Gm-Message-State: AKwxytdU3xLgk5q6WH09Ntlirl3Jput5ct6WVUoaCKUBdN81yuVPa8Kr ElNc081UyB6aXcwNk/C4kIm+cRpan4CF/AiAy2CfNBx0vbI= X-Received: by 10.36.218.196 with SMTP id z187mr11015701itg.122.1516854580169; Wed, 24 Jan 2018 20:29:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.172.135 with HTTP; Wed, 24 Jan 2018 20:29:39 -0800 (PST) In-Reply-To: References: From: Joel Fernandes Date: Wed, 24 Jan 2018 20:29:39 -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 , bblanco@plumgrid.com, Alison Chaiken , "Cc: Android Kernel" , Mathieu Desnoyers , Josef Bacik , Yonghong Song , Steven Rostedt 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 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.