Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp105351yba; Fri, 12 Apr 2019 18:34:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqygNFN6XkuWwHnbb5wWK3MYAF7Q3OMSRkdIs5/rE+luY5dB5KZ5oF7RSab92t4OA6FGvE2i X-Received: by 2002:a65:4341:: with SMTP id k1mr57458464pgq.88.1555119249418; Fri, 12 Apr 2019 18:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555119249; cv=none; d=google.com; s=arc-20160816; b=XCjS82eoqqBEwNrmt2hDrvgaUUrap351XulVkzHcJwfWq5IQZ3x4rSLoNybj3PFEG8 6wNw2u5Ba6A6GXcO6BDOVKloIukJuM8MLUpRDev5jwaGRsCRkhY1JFr3T0+7VF+cwb9e k4UbF5tQeajhJp62IK10rOnmVBdaKgClR+9EmzfICL1Lb/CZjdp3NXbSDbKBTRqodjxq dF1Rs7f7F3ZSwyQv6QmGGbCqMapZ/KJTWW+YnSdvjpL4Pt6tmQ4mH3PsBeJlCjtpmmGN ZjcRTzzvHInwpCn+cByQHXhKdg3d3V3LmdMb1Aa51iiZRkMHabGwaGz3E9liZkp89/v3 hE8Q== 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 :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=AbRj27RMd8pEgTSOE0frMyOiJbfpx0njCrPKGZLSK6c=; b=tXK8pFN3hD6EbgBALqEjJQ/quoO2dvSuSguqF9P9xHJK/BbumpwEfNuYyUagwOt6T/ aCmAbdyCgNzYAbJPBTYfCs0xg/VoseFuVzYKJx1ZdUmeWv1W7yiq4JEFWCIeAAV9tRm6 kGx1jo4t8najs7eCIY7TElQpeOFGZMjpmBtzo0RS9hPHGQSZ68p9YpW7VLu/qmExBPRo MbRm1ai6A/3/6LCjcdu6f2vh51Km5S1/wn1GQnRg8r+7nhoqzFYN9067BQeMCWKu8Q4L ZR3WVB+2QgPuVQbnTAapQP7TDAuvxqGVOJBxLm5NC1PVBdrFdQo/MisAcqeB9vx3V+OX darA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=pbRnKRv+; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b18si38675940pgj.500.2019.04.12.18.33.53; Fri, 12 Apr 2019 18:34:09 -0700 (PDT) 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=@nifty.com header.s=dec2015msa header.b=pbRnKRv+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728670AbfDMBbL (ORCPT + 99 others); Fri, 12 Apr 2019 21:31:11 -0400 Received: from conssluserg-06.nifty.com ([210.131.2.91]:56540 "EHLO conssluserg-06.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727206AbfDMBbI (ORCPT ); Fri, 12 Apr 2019 21:31:08 -0400 Received: from mail-vs1-f52.google.com (mail-vs1-f52.google.com [209.85.217.52]) (authenticated) by conssluserg-06.nifty.com with ESMTP id x3D1Ukt9002455; Sat, 13 Apr 2019 10:30:47 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com x3D1Ukt9002455 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1555119047; bh=AbRj27RMd8pEgTSOE0frMyOiJbfpx0njCrPKGZLSK6c=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=pbRnKRv+xLHb3eeq1jDA5cNVauhVhHtlXp5JMAtsmkHYaUEhRIgpaSs+qKll4O1Mt x28LodrRZ+6Bzes9iA/OeoXwU6X+0OtENup7F5mm6kqh05Uj6pOIptngd7/hYz/yQv 9dEF/ALswv3hey+DAFA4HnYmDsdbmyxqVCG8YSDSotkFZ+jyaWXOzgtvERHLSjdmES wVHu+D+XqQI3zymI9oljqmCFVe84B9m1xU0mM7U68TTFbG1YQrkxvLFXYC8HzWHAbZ 5U4atY51JvgvTBuqE2SCpVcmQI+1HDfVd6tGaZ8KAlOObyXeNCFtAG0V1rx6IxModu kZUR1qKlEgBTA== X-Nifty-SrcIP: [209.85.217.52] Received: by mail-vs1-f52.google.com with SMTP id f22so6578644vso.7; Fri, 12 Apr 2019 18:30:47 -0700 (PDT) X-Gm-Message-State: APjAAAXXFHYe0csJOWHxRZKk/AJYs1ihBNbU0PcYthe89ldUkkB20lU6 PaORMCH+cnf5GAW2rKb4lsJeSgoZOyzzMgJxclM= X-Received: by 2002:a67:f714:: with SMTP id m20mr34654180vso.211.1555119045997; Fri, 12 Apr 2019 18:30:45 -0700 (PDT) MIME-Version: 1.0 References: <20190412195125.3891-1-joel@joelfernandes.org> In-Reply-To: <20190412195125.3891-1-joel@joelfernandes.org> From: Masahiro Yamada Date: Sat, 13 Apr 2019 10:30:10 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 1/2] Provide in-kernel headers to make extending kernel easier To: "Joel Fernandes (Google)" Cc: Linux Kernel Mailing List , Andrew Morton , Alexei Starovoitov , atish patra , Daniel Colascione , Dan Williams , Dietmar Eggemann , Greg Kroah-Hartman , Guenter Roeck , Jonathan Corbet , Karim Yaghmour , Kees Cook , "Cc: Android Kernel" , "open list:DOCUMENTATION" , "open list:KERNEL SELFTEST FRAMEWORK" , linux-trace-devel@vger.kernel.org, Manoj Rao , Masami Hiramatsu , Qais Yousef , Randy Dunlap , Steven Rostedt , Shuah Khan , Yonghong Song 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 On Sat, Apr 13, 2019 at 4:54 AM Joel Fernandes (Google) wrote: > > Introduce in-kernel headers which are made available as an archive > through proc (/proc/kheaders.tar.xz file). This archive makes it > possible to run eBPF and other tracing programs that need to extend the > kernel for tracing purposes without any dependency on the file system > having headers. > > A github PR is sent for the corresponding BCC patch at: > https://github.com/iovisor/bcc/pull/2312 > > On Android and embedded systems, it is common to switch kernels but not > have kernel headers available on the file system. Further once a > different kernel is booted, any headers stored on the file system will > no longer be useful. This is an issue even well known to distros. > By storing the headers as a compressed archive within the kernel, we can > avoid these issues that have been a hindrance for a long time. > > The best way to use this feature is by building it in. Several users > have a need for this, when they switch debug kernels, they do not want to > update the filesystem or worry about it where to store the headers on > it. However, the feature is also buildable as a module in case the user > desires it not being part of the kernel image. This makes it possible to > load and unload the headers from memory on demand. A tracing program can > load the module, do its operations, and then unload the module to save > kernel memory. The total memory needed is 3.3MB. > > By having the archive available at a fixed location independent of > filesystem dependencies and conventions, all debugging tools can > directly refer to the fixed location for the archive, without concerning > with where the headers on a typical filesystem which significantly > simplifies tooling that needs kernel headers. > > The code to read the headers is based on /proc/config.gz code and uses > the same technique to embed the headers. > > Other approaches were discussed such as having an in-memory mountable > filesystem, but that has drawbacks such as requiring an in-kernel xz > decompressor which we don't have today, and requiring usage of 42 MB of > kernel memory to host the decompressed headers at anytime. Also this > approach is simpler than such approaches. > > Signed-off-by: Joel Fernandes (Google) > --- I just noticed minor typos in comment lines (see below). Anyway, I have no more comment from the build system of view. So, Reviewed-by: Masahiro Yamada > diff --git a/kernel/kheaders.c b/kernel/kheaders.c > new file mode 100644 > index 000000000000..19526294a4e8 > --- /dev/null > +++ b/kernel/kheaders.c > @@ -0,0 +1,74 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Provide kernel headers useful to build tracing programs > + * such as for running eBPF tracing tools. > + * > + * (Borrowed code from kernel/configs.c) > + */ > + > +#include > +#include > +#include > +#include > +#include > + > +/* > + * Define kernel_headers_data and kernel_headers_data_end, within which the the > + * compressed kernel headers are stpred. The file is first compressed with xz. > + */ "the the" -> "the" ? "stpred" -> "stored" ? It is up to you if you want to send v8. -- Best Regards Masahiro Yamada