Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp737572img; Thu, 28 Feb 2019 07:07:36 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib+mI9BStRHTUTtZ1699BQCus0txJUqlg2+S5q/iBDo0KPZBycZ8Mq8mBvmj0JuUa6CfBd4 X-Received: by 2002:a63:8048:: with SMTP id j69mr8862127pgd.432.1551366456000; Thu, 28 Feb 2019 07:07:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551366455; cv=none; d=google.com; s=arc-20160816; b=Fl0KvYGsvQlaaAQihBtebDDXHgBpaKT59vhs4YGvGD9tQnMmxctQWouPnswRpyEEgP Q6siFYp+a/3dqBdpg6t0IMLrh/ygPwuuCcKeNsXDzfISFtgatkgYqw1qC6Kaz6XbEwVJ b+EfGrlc9fAZGUV+dPEnMEA+w61mJbVp6T4LyLIIlks37uhFsIG/+/mw+PCSCN9orjr/ iJDwuWsosXb8WFRYS33S1xJQkqgcpJl1Y8VnXkzPj3rPBBVP9jOpoQYFA6tIQjrJjnnu yj277csrfxOZzq/aF8Fkyh9PLlL15ZyoqJ9MicZtKy8iAgIPKoxSl+v5i16guV5MoI8y KZbQ== 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=URNHzscQ4qPaUJmS41Sp3RUkVJopCE5QU3VQWfAy40E=; b=G4j9bkPhosYUnrjOtirixP00r5+3TAVScAFsKQAOsz+5YW24V3YMIqE6p4LkAbCCQr pqx55ZGChvDpdfy86O/QXwPdz+38TEmdwHHWTDKTMOsn3QlATMmKkbW8vCxTqpm6g4Ws /W0JOTmZkCkq3MzaOeA8KDkYMhFxaxDnF6pP/Cgwjy3x8PYzClIJmNQNJl0nuJ/Q+CDO xfI30/R9syKPkCJOPAXmCpNADJvlpOr6pd6OybqqYyDtQIMrLfcjXuKB0O/t/zIw7CL8 CVWeawwS3sIoc7JCBab/X7oZZ/6ZJu4MXrivbMuMUHlPOLKksXwh4TrTI5qcdgVQxbuN BnVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=fcfxUFrx; 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 j132si18483428pfc.84.2019.02.28.07.07.20; Thu, 28 Feb 2019 07:07:35 -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=fcfxUFrx; 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 S1732754AbfB1PA6 (ORCPT + 99 others); Thu, 28 Feb 2019 10:00:58 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:41134 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730851AbfB1PA5 (ORCPT ); Thu, 28 Feb 2019 10:00:57 -0500 Received: by mail-qt1-f195.google.com with SMTP id v10so23787332qtp.8 for ; Thu, 28 Feb 2019 07:00:56 -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=URNHzscQ4qPaUJmS41Sp3RUkVJopCE5QU3VQWfAy40E=; b=fcfxUFrx/N1MBaUtE/U8RR6YEfsLOEuRvK0zDOUeqgKoBrzdNIbhG3iljCtSo5q0H4 wtSf8W1cB213EF+MPYb4NjJNFK54xv3wB/SUj/5zMKCrB/qT/SZOZlVkq9vUie6/s170 /v+3IvK5wB4f59ckQzb7Qk3SZuyczvveHohZk= 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=URNHzscQ4qPaUJmS41Sp3RUkVJopCE5QU3VQWfAy40E=; b=Ep/MqAFeqDw/qfaMNDEuvC5A5wFeKd4BkhqKhGuC6j3mTeQm5x8iNf9NUCO7FW/VR7 r3HwhKPXZM3xv1uPNBwEl9Kodsw7As0Q9m6WkE3RC0hlCCQX9vN8507dfA3beMgFCMX2 WMRCPr3xjYKZpRKUhQPfIBsUhmnPjykS2874HKaaEqIA3hOqyzvGA/3vREJOcjfxXKuY QXge2GULN/qN2KFzKtYMstALAI8abpp6h97as/A2xizAvZ0EqXNIKKIlPH6orD4rU6qs 2N+Rp9p6S/snsWUiuBmPMZLZVdGiwYCgYEt4TKDxFwCz6DXnWQzdnATcBfBRTJzA8HCX 3yyg== X-Gm-Message-State: APjAAAVYTs6qmoucSJNYdKPVU1ZYnYy+LIy3rjDvB7edzFxh5LeuJQuI PuJIkB/C31YOD7EnM6OXFSfnTw== X-Received: by 2002:a0c:9acb:: with SMTP id k11mr6562969qvf.197.1551366056148; Thu, 28 Feb 2019 07:00:56 -0800 (PST) Received: from localhost ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id s76sm6597265qki.42.2019.02.28.07.00.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 07:00:55 -0800 (PST) Date: Thu, 28 Feb 2019 10:00:54 -0500 From: Joel Fernandes To: Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, Andrew Morton , ast@kernel.org, atishp04@gmail.com, dancol@google.com, Dan Williams , gregkh@linuxfoundation.org, Guenter Roeck , Jonathan Corbet , karim.yaghmour@opersys.com, Kees Cook , kernel-team@android.com, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-devel@vger.kernel.org, Manoj Rao , Masahiro Yamada , paulmck@linux.vnet.ibm.com, "Peter Zijlstra (Intel)" , qais.yousef@arm.com, rdunlap@infradead.org, rostedt@goodmis.org, Shuah Khan , Thomas Gleixner , yhs@fb.com Subject: Re: [PATCH v3 1/2] Provide in-kernel headers for making it easy to extend the kernel Message-ID: <20190228150054.GB156098@google.com> References: <20190227193748.132301-1-joel@joelfernandes.org> <20190228173444.54403795211d80ba540b61cb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190228173444.54403795211d80ba540b61cb@kernel.org> 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, Feb 28, 2019 at 05:34:44PM +0900, Masami Hiramatsu wrote: > Hi Joel, > > On Wed, 27 Feb 2019 14:37:47 -0500 > "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. > > Hmm, isn't it easier to add kernel-headers package on Android? I have already been down that road. In the Android ecosystem, the Android teams only provide a "userspace system image" which goes on the system partition of the flash (and a couple other images are also provided but system is the main one). The system image cannot contain GPL source code. It is also not possible to put kernel headers for every kernel version on the system images that ship and is not practical. Android boots on 1000s of forked kernels. It does not make sense to provide headers on the system image for every kernel version and I already had many discussions on the subject with the teams, it is something that is just not done. Now for kernel modules, there's another image called the "vendor image" which is flashed onto the vendor parition, this is where kernel modules go. This vendor image is not provided by Google for non-Pixel devices. So we have no control over what goes there BUT we do know that kernel modules that are enabled will go there, and we do have control over enforcing that certain kernel modules should be built and available as they are mandatory for Android to function properly. We would also possibly make it a built-in option as well. Anyway my point is keeping it in the kernel is really the easiest and the smartest choice IMO. > > 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. > > But it also requires to install build environment (tools etc.) > on the target system... Yes, that's true. Check the other thread with Masahiro that we are discussing this point on and let us continue discussing there: https://lore.kernel.org/patchwork/patch/1046307/#1238223 https://lore.kernel.org/patchwork/patch/1046307/#1238491 > > 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 > > It seems a bit complex, but no difference from compared with carrying > kheaders.tar.gz. I think we would better have a psudo filesystem > which can mount this compressed header file directly :) Then it becomes > simpler, like > > modprobe headerfs > mkdir $HOME/headers > mount -t headerfs $HOME/headers > > And this doesn't consume any disk-space. I felt using a compressed tar is really the easiest way because of all the tools are already available. There isn't a compressed in-ram filesystem right now that I'm aware off that can achieve the kind of high compression ratio this patchset does. thanks, - Joel