Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1025023img; Thu, 28 Feb 2019 11:42:57 -0800 (PST) X-Google-Smtp-Source: APXvYqxr8KRdKB4tT0E6g2dnPC7kWxFaC8gGtz0AxObeP0EACXZnHwda9HpF202WURn9ZE42b0WX X-Received: by 2002:a17:902:5992:: with SMTP id p18mr1066256pli.231.1551382977402; Thu, 28 Feb 2019 11:42:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551382977; cv=none; d=google.com; s=arc-20160816; b=UnZswxSiopHp/d/pxziYgAAZJah2FtzLfRMiH1NekQwjY6mComfOKY9nlBWXBnjFUQ zxhrcKSEJZUQiJdoKpqP2fKiO5hGj5qopk/nRIch7c5jwbyreAVNSaW6hRVHUQOQnjLq EDqLZmjH6Ah7v79DNIgPyPAtu+rau4lZgkAPRRnLjtYNdQRIo5gOGanUuVPJ5Tcb530l tct02eWO0QheEod07AsHqH0da1rwdfDUJrKi0HvHg3Gx4/xRBRAjarw+q4tZIdB+qKQm ppHwajLfgxZzazP0ynSjMsR+wCyImTqoEvn94E5FiAoNRBc5v7nR/H6GEXdcjcBP9AtS QXlg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=9NWe223iTLkglgyQK1/Y5el3/aTz6u9+2DjGI/UA+wA=; b=L/Idk9wAoeLDDSYZ6djoO3WyzdrOY55skQNcnq67zBOrmXy9+si4ENyQ3O3ryjGgxJ w1jqXTRykaJgTh7GahhjpYNATHxxSv7T1AQVpaYlexYed3hsgTMGaYP3gtQLyY2Xw0Si 0ID+tK8f7ykVWfHJgDhMCnX7633lZC3UXVTiFSKoL/I/FJUVigUHwpKndWTW/olsLT/S exrmjnJ//j8487ye3/hEPbwtJ5RlGomxvsi9q8d8QtpHIOR9Clnc8vSbpBA/LXJbwtd+ JfKOh38JlOsIrjQEGLGgaNBuy+3HuYtSdEioS3DFqwaO/WrZSwLX+mDjsXGQQ9BgXZSq beVA== ARC-Authentication-Results: i=1; mx.google.com; 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 y32si18432983pga.518.2019.02.28.11.42.42; Thu, 28 Feb 2019 11:42:57 -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; 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 S1732941AbfB1QsJ (ORCPT + 99 others); Thu, 28 Feb 2019 11:48:09 -0500 Received: from foss.arm.com ([217.140.101.70]:51462 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726717AbfB1QsJ (ORCPT ); Thu, 28 Feb 2019 11:48:09 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3BC6EEBD; Thu, 28 Feb 2019 08:48:08 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.17]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EF7463F720; Thu, 28 Feb 2019 08:48:03 -0800 (PST) Date: Thu, 28 Feb 2019 16:48:01 +0000 From: Qais Yousef To: Dietmar Eggemann Cc: Joel Fernandes , 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 , mhiramat@kernel.org, paulmck@linux.vnet.ibm.com, "Peter Zijlstra (Intel)" , 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: <20190228164801.iahwphx5o2zeks4n@e107158-lin.cambridge.arm.com> References: <20190227193748.132301-1-joel@joelfernandes.org> <20190228135343.23kzkilig3bsioov@e107158-lin.cambridge.arm.com> <20190228144759.GA156098@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/28/19 17:04, Dietmar Eggemann wrote: > Hi Joel, > > On 2/28/19 3:47 PM, Joel Fernandes wrote: > > On Thu, Feb 28, 2019 at 01:53:43PM +0000, Qais Yousef wrote: > > > Hi Joel > > > > > > On 02/27/19 14:37, Joel Fernandes (Google) wrote: > > [...] > > > Ah good catch, I made this change for "file_list=${@:2}" in my tree but > > forgot to push it. Below is the updated patch. Sorry and I'll refresh the > > series with the change after we finish the discussion in the other thread. > > Meanwhile the updated patch is as follows... > > > > ---8<----------------------- > > > > From: "Joel Fernandes (Google)" > > Subject: [PATCH v3.1] Provide in-kernel headers for making it easy to extend the kernel > > > > 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. > > This version gives me the header files on a v5.0-rc8 kernel on my arm64 box > but does not compile anymore on v4.20: > > kernel/kheaders.c:25:22: error: expected identifier or ‘(’ before string > constant > #define KH_MAGIC_END "IKHD_ED" > ^ > kernel/kheaders_data.h:1:1: note: in expansion of macro ‘KH_MAGIC_END’ > KH_MAGIC_END; > ^~~~~~~~~~~~ > kernel/kheaders.c: In function ‘ikheaders_read_current’: > kernel/kheaders.c:38:12: error: ‘kernel_headers_data’ undeclared (first use > in this function); did you mean ‘kernel_headers_data_size’? > kernel_headers_data + KH_MAGIC_SIZE, > ^~~~~~~~~~~~~~~~~~~ > kernel_headers_data_size > kernel/kheaders.c:38:12: note: each undeclared identifier is reported only > once for each function it appears in > kernel/kheaders.c: In function ‘ikheaders_init’: > kernel/kheaders.c:31:10: error: ‘kernel_headers_data’ undeclared (first use > in this function); did you mean ‘kernel_headers_data_size’? > (sizeof(kernel_headers_data) - 1 - KH_MAGIC_SIZE * 2) > ^ > kernel/kheaders.c:57:23: note: in expansion of macro > ‘kernel_headers_data_size’ > proc_set_size(entry, kernel_headers_data_size); > ^~~~~~~~~~~~~~~~~~~~~~~~ > kernel/kheaders.c: In function ‘ikheaders_read_current’: > kernel/kheaders.c:40:1: warning: control reaches end of non-void function > [-Wreturn-type] > } > > > The reason for me to stay on v4.20 is that with v5.0-rc8 I don't have ebpf > 'raw tracepoint' support any more on my arm64 board. But this issue is not > related to your patch though. And this is caused by a38d1107f937 (bpf: support raw tracepoints in modules) which renamed bpf_find_raw_tracepoint() which bcc-tools relies on to detect if raw tracepoints are supported.. https://github.com/iovisor/bcc/blob/master/src/python/bcc/__init__.py#L860 Speaking of fragile depedencies :-) I guess the check can be extended to check for both symbols - but it'll stay fragile. Not sure if they can do better. I filed a bug https://github.com/iovisor/bcc/issues/2240 -- Qais Yousef > > Another point which supports the functionality your patch provides is the > fact that maintainers don't want to see new TRACE_EVENTs in their code. So > here your patch comes handy when using ebpf for tracing in embedded > environments.