Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5155060imb; Thu, 7 Mar 2019 08:56:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwJkpZWJUYD/rCND0kz1FWxSNdjrL8wJyoT4z948t496YKokka4lij3FAoYoyVA6TJxrufO X-Received: by 2002:a62:489d:: with SMTP id q29mr13597182pfi.119.1551977803122; Thu, 07 Mar 2019 08:56:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551977803; cv=none; d=google.com; s=arc-20160816; b=UAqbLHURmu205J6IZ0FxTlA0ExlqN6hiNkSYWgplVwNWAxVPr/B2TOBD/Jl3dvihJY J9PASEPmk8R5Llq5oUvd64svGr3WTiBscPYZ6iRuUUoijHPYEthdGZxMRnfxWfZa2e2v iUHE7o/g7Ial8I9sHSEaE4Jl8MbOxUnweJtXJdLMMB09c8W+fGMS+SYCj0E1a1qcB3wM Kn+Z8QXm4zNqbbBkEeVaxs3drRYvARS14rkpSQZmpgOXgy2r4wb/4FKakRyOyEeKFX/f 9ylrm7mjgEw3NBBfF/VIsmq8bKWT7qkPKJ4odhU8+ZE4QJKqvzL6AXedpLlwN3VNj19P l4ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=AXHynj04NMZ0CS1NnWbfes4n6qunWNiY93VEbJEipOQ=; b=TS2fWtNa0DsR8rgqemk6oteMTZm3VY0P9u1czAECmKhWIC09/uxuClWpZ7cxq774Si FVKuPVKGOS6FvKpR/UiO/kUeKwiOF6J8MipCv0VF3df3OR75BNCpmIFuuDyJZOhMpQyH a4s2w7HPs4o264EGhuTVe88QSlWc7AqNOt3PrYNCkGC5ZrfLwfmYCrsTa8vpZIQw4gPJ hsT5XqQvxDpdCCnE65QsUHiMuAFqiNgQ8oJbKtXz1kg8hi61oJsZSG8n7q4H+tu6BN+P UtUp7VPFNCBC784R7DN0wBMI0L6fyPiDMNO4IE9HhCVXGEO9R70CLJ/G9BitgURFJJBG t8uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=VzAx11ix; 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 s19si4502258plq.148.2019.03.07.08.56.27; Thu, 07 Mar 2019 08:56:43 -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=@joelfernandes.org header.s=google header.b=VzAx11ix; 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 S1726431AbfCGQyh (ORCPT + 99 others); Thu, 7 Mar 2019 11:54:37 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:38572 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726286AbfCGQyh (ORCPT ); Thu, 7 Mar 2019 11:54:37 -0500 Received: by mail-qt1-f195.google.com with SMTP id s1so17866082qte.5 for ; Thu, 07 Mar 2019 08:54:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=AXHynj04NMZ0CS1NnWbfes4n6qunWNiY93VEbJEipOQ=; b=VzAx11ixOrKiy7adFBoN7ejFE8lbSz504yc3bt7PTgL1AQ7iGkqvPLM4JSAWH1k68a xTF7lVX8FjOa9kgqFtdvTb89sxk/WHkOHdxrdSlX+nWLLjkZb2MrTeKWS/sHzUq2XOrR 9u87K/SBUPFgfPeUboPRvJ87GW7TvwunI/hSk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=AXHynj04NMZ0CS1NnWbfes4n6qunWNiY93VEbJEipOQ=; b=fElkbNrczDe4M3zp8tAZaEIEhhtkH5V6mNcWjsbYrlEChZJzRZw7T4JvUZcN4Yy5nf Mk13A+m1KrF3N9cKw1DkV+Yfu7NcCdANh/sNWskmVCGfyGQIjuFQuuOrdFQofgPUZCwO K4adRQ3OhQE3i7c7tVhRfTJttKzSOTD0Aivwa7R5E2VuW7XLE2fpEBM0hiTTtiZI6ABK 5YFNn4xBa86lv5I6GgdsfHxfHtzYH/jP7uy59HYCb+VXn+T3X1oc87CcJ5iL9Pd+BxTX 02oHIOFcEv0R3gjnj7VYVqULQoq6OoZo0stR2r1csYm2fh5daReLTdiGkq7uGKrsENZR NSig== X-Gm-Message-State: APjAAAV6b+uqykbq6ss0s2TCTwk45NKCRx9h+CotX7Xpjvf7WjZKhvpm 5n13ozFd1Yqh1EQxTgWdp+Blrw== X-Received: by 2002:a0c:b758:: with SMTP id q24mr11372279qve.149.1551977675747; Thu, 07 Mar 2019 08:54:35 -0800 (PST) Received: from localhost ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id g20sm279630qtg.4.2019.03.07.08.54.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 08:54:34 -0800 (PST) Date: Thu, 7 Mar 2019 11:54:33 -0500 From: Joel Fernandes To: Greg KH Cc: Geert Uytterhoeven , Linux Kernel Mailing List , Andrew Morton , Alexei Starovoitov , atishp04@gmail.com, dancol@google.com, Dan Williams , Dietmar Eggemann , Guenter Roeck , Jonathan Corbet , karim.yaghmour@opersys.com, Kees Cook , Android Kernel Team , "open list:DOCUMENTATION" , "open list:KERNEL SELFTEST FRAMEWORK" , linux-trace-devel@vger.kernel.org, Manoj Rao , Masahiro Yamada , Masami Hiramatsu , qais.yousef@arm.com, Randy Dunlap , Steven Rostedt , Shuah Khan , yhs@fb.com Subject: Re: [PATCH v4 1/2] Provide in-kernel headers for making it easy to extend the kernel Message-ID: <20190307165433.GA90983@google.com> References: <20190301160856.129678-1-joel@joelfernandes.org> <20190307150343.GB258852@google.com> <20190307152303.GA9819@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190307152303.GA9819@kroah.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 07, 2019 at 04:23:03PM +0100, Greg KH wrote: > > > On Fri, Mar 1, 2019 at 5:10 PM Joel Fernandes (Google) > > > wrote: > > > > Introduce in-kernel headers and other artifacts which are made available > > > > as an archive through proc (/proc/kheaders.tar.xz file). This archive makes > > > > it possible to build kernel modules, run eBPF programs, and other > > > > tracing programs that need to extend the kernel for tracing purposes > > > > without any dependency on the file system having headers and build > > > > artifacts. > > > > > > > > On Android and embedded systems, it is common to switch kernels but not > > > > have kernel headers available on the file system. Raw kernel headers > > > > also cannot be copied into the filesystem like they can be on other > > > > distros, due to licensing and other issues. There's no linux-headers > > > > package on Android. Further once a different kernel is booted, any > > > > headers stored on the file system will no longer be useful. 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 feature is also buildable as a module just in case the user desires > > > > it not being part of the kernel image. This makes it possible to load > > > > and unload the headers on demand. A tracing program, or a kernel module > > > > builder can load the module, do its operations, and then unload the > > > > module to save kernel memory. The total memory needed is 3.8MB. > > > > > > > > The code to read the headers is based on /proc/config.gz code and uses > > > > the same technique to embed the headers. > > > > > > > > To build a module, the below steps have been tested on an x86 machine: > > > > modprobe kheaders > > > > rm -rf $HOME/headers > > > > mkdir -p $HOME/headers > > > > tar -xvf /proc/kheaders.tar.xz -C $HOME/headers >/dev/null > > > > cd my-kernel-module > > > > make -C $HOME/headers M=$(pwd) modules > > > > rmmod kheaders > > > > > > As the usage pattern will be accessing the individual files, what about > > > implementing a file system that provides read-only access to the internal > > > kheaders archive? > > > > > > mount kheaders $HOME/headers -t kheaders > > > > I thought about it already. This is easier said than done though. The archive > > is compressed from 40MB to 3.6MB. If we leave it uncompressed in RAM, then it > > will take up the entire 40MB of RAM and in Android we don't even use > > disk-based swap. > > > > So we will need some kind of intra file compressed memory representation that > > a filesystem can use for the backing store. I thought of RAM-backed squashfs > > but it requires squashfs-tools to be installed at build time (which my host > > distro itself didn't have). > > > > It is just so much easier to use tar + xz at build time, and leave the > > decompression task to the user. After decompression, the files will live on > > the disk and the page-cache mechanism will free memory when/if the files fall > > off the LRUs. > > > > WDYT? > > I think the compressed tarball is much simpler/easier overall. If > someone really wants the filesystem, they just uncompress it into a > tmpfs mount. It's much less moving kernel code to worry about. Agreed, I also feel the same. thanks, - Joel