Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5083362imb; Thu, 7 Mar 2019 07:24:01 -0800 (PST) X-Google-Smtp-Source: APXvYqyclTmbmoeLjqfDiXiK7nrCcNj2TRXQ2A0Rm3XU6xcGheroYHysK5VPSzHmwXeqhyPEBqr0 X-Received: by 2002:aa7:8390:: with SMTP id u16mr13130270pfm.63.1551972241676; Thu, 07 Mar 2019 07:24:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551972241; cv=none; d=google.com; s=arc-20160816; b=ioEEXOuKvaTf4XW025aEu8EiEicW3oY0T7p3o/SBapTaq2gDe+RmA0ol+0f6uCCJqz WNs7j3ublFSjkaUmwSHKS2SBKDFb3RzE/gTj/ru5OZOoT9H7zb1E44uHFjee6sGbdsNW ZmhajZX1foGKtl4cTzzYlma6huIccgfhH/NeSg0whZxQQosCGJqzRb1MrgOz75JD/Qox UlZDEPiTHYwbDLuBzsZvyewDELmnbOiDmguv1mAqqpDa/d1cVpmxT7kvTa2D4fxbMWRN 8TacAKblg/ksri8y6+q/bbm6/amIzRi7t0yoZKISLt/AnjtBI+iCoh4OcOhi+Q+8358O HZew== 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=lriR7WASp5nsgjxCChNyT3abCozfX4OM1DoSSH4yT44=; b=F7bvNR7a56XsgO+QRkWHwc3hdvIOxuT0eenQ71plJU+ZXmN3wV3sUyMUws421Khpd7 e8j6h47CUE217aQPqPbaoQyIlNuXyoEuDtHaljlQQJx0hFDVjVdAPfrvxSxb3wxnk3WS 6chl9sWpJAWn3LTmAq3JuNtF2v0pH8+G3jMi6a3WGRWxbNuy6iZPrvj47qTb7+f8GZ94 TaG3x87vhhW1hcBF74+UNHtWiu0g5PDqUAKP19EuTYuYnBGil519GTF04Vfl1VdCxsA5 Nk/oiJLSGNYrGDIhzhKIQDRvwmT5BEEfd8PWhSt/Fkw6qnkg38T0n5wqp54BB9Xt80hE QQAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T8cROAQM; 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 9si4282210plc.121.2019.03.07.07.23.45; Thu, 07 Mar 2019 07:24:01 -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=@kernel.org header.s=default header.b=T8cROAQM; 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 S1726521AbfCGPXH (ORCPT + 99 others); Thu, 7 Mar 2019 10:23:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:33098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbfCGPXH (ORCPT ); Thu, 7 Mar 2019 10:23:07 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0BE1A20840; Thu, 7 Mar 2019 15:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551972185; bh=lCO3T/XpRXUd0bBBzJFZCQZ2nBBRK9+DkfsiRbJa12c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T8cROAQMU7pzNz0iJSmrs9g07QSB0UTZJB0ZtrY7ra7fexbvXRJbYCW8G1h/8jKjF CmX5g1gM9KLgorDDRSvvLft3pqx9ESdoMt05DBS+Vl2Vn+o9MSqOROaTTgrBCt/j5r WTHEiZQXaaOBwh/La/WHteiU06L01I8fs23noqmM= Date: Thu, 7 Mar 2019 16:23:03 +0100 From: Greg KH To: Joel Fernandes 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: <20190307152303.GA9819@kroah.com> References: <20190301160856.129678-1-joel@joelfernandes.org> <20190307150343.GB258852@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190307150343.GB258852@google.com> User-Agent: Mutt/1.11.3 (2019-02-01) 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 10:03:43AM -0500, Joel Fernandes wrote: > On Thu, Mar 07, 2019 at 09:58:24AM +0100, Geert Uytterhoeven wrote: > > Hi Joel, > > > > 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. thanks, greg k-h