From patchwork Fri Mar 12 09:55:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1451810 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=mdVrloUh; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dxh5s46BSz9sVw for ; Fri, 12 Mar 2021 20:56:01 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=O9fzOiIEjAct0UkCHTcofhVaLsYsvX4qJQzajCEOXc8=; b=mdVrloUhV/hdIgZCAFWJmNElz 8RJpoKOLvwJDpd5AqWDoOMWrpDXKW20Sep+9ia1GAi0Vtk/p4XPOpE0G6JDnRPSwDnReiE0rspZMs dRSSWApWuxxj9TRFOwt9Axt9UWVAPAjjZfFKFD104qyTFjGeBEQUq2LZh7pOHAI47yA8iGvIYZVL4 bvxavbWA+xRnGwq6Mct8kWHORmDvR/4LtGScLiJVFYpvpG+nOGDJeQHQWHuMs2MT+xWGCNzsL2dGn zJkrEppueuEftUKjnT2rP432Tj6udWU2M2o1odgm+sc5cAr/uTdlXzNfPEIzEjqS8Zk+b4oetOjMW 5XTWHAHkg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKeWM-00B5Zm-Jz; Fri, 12 Mar 2021 09:55:50 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2] helo=sipsolutions.net) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKeW5-00B5Tj-Lv for linux-um@lists.infradead.org; Fri, 12 Mar 2021 09:55:43 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1lKeW0-00F7m8-Ro; Fri, 12 Mar 2021 10:55:29 +0100 From: Johannes Berg To: linux-kernel@vger.kernel.org, linux-um@lists.infradead.org Cc: Jessica Yu , Alexander Viro , linux-fsdevel@vger.kernel.org, Johannes Berg Subject: [PATCH 1/6] seq_file: rename mangle_path to seq_mangle_path Date: Fri, 12 Mar 2021 10:55:21 +0100 Message-Id: <20210312104627.3ac77adf84c4.I2f2e5cec5cc82a51652dafbeb0d1b88708b3c565@changeid> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210312095526.197739-1-johannes@sipsolutions.net> References: <20210312095526.197739-1-johannes@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_095534_690530_AB017362 X-CRM114-Status: GOOD ( 12.25 ) X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Johannes Berg The symbol mangle_path conflicts with a gcov symbol which can break the build of ARCH=um with gcov, and it's also not very specific and descriptive. Rename mangle_path() to seq_mangle_path(), and also remove the export since it's not needed or used by any modules. Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg The symbol mangle_path conflicts with a gcov symbol which can break the build of ARCH=um with gcov, and it's also not very specific and descriptive. Rename mangle_path() to seq_mangle_path(), and also remove the export since it's not needed or used by any modules. Signed-off-by: Johannes Berg --- fs/seq_file.c | 11 +++++------ include/linux/seq_file.h | 2 +- lib/seq_buf.c | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/fs/seq_file.c b/fs/seq_file.c index cb11a34fb871..dfa1982a87ca 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -413,7 +413,7 @@ void seq_printf(struct seq_file *m, const char *f, ...) EXPORT_SYMBOL(seq_printf); /** - * mangle_path - mangle and copy path to buffer beginning + * seq_mangle_path - mangle and copy path to buffer beginning * @s: buffer start * @p: beginning of path in above buffer * @esc: set of characters that need escaping @@ -423,7 +423,7 @@ EXPORT_SYMBOL(seq_printf); * Returns pointer past last written character in @s, or NULL in case of * failure. */ -char *mangle_path(char *s, const char *p, const char *esc) +char *seq_mangle_path(char *s, const char *p, const char *esc) { while (s <= p) { char c = *p++; @@ -442,7 +442,6 @@ char *mangle_path(char *s, const char *p, const char *esc) } return NULL; } -EXPORT_SYMBOL(mangle_path); /** * seq_path - seq_file interface to print a pathname @@ -462,7 +461,7 @@ int seq_path(struct seq_file *m, const struct path *path, const char *esc) if (size) { char *p = d_path(path, buf, size); if (!IS_ERR(p)) { - char *end = mangle_path(buf, p, esc); + char *end = seq_mangle_path(buf, p, esc); if (end) res = end - buf; } @@ -505,7 +504,7 @@ int seq_path_root(struct seq_file *m, const struct path *path, return SEQ_SKIP; res = PTR_ERR(p); if (!IS_ERR(p)) { - char *end = mangle_path(buf, p, esc); + char *end = seq_mangle_path(buf, p, esc); if (end) res = end - buf; else @@ -529,7 +528,7 @@ int seq_dentry(struct seq_file *m, struct dentry *dentry, const char *esc) if (size) { char *p = dentry_path(dentry, buf, size); if (!IS_ERR(p)) { - char *end = mangle_path(buf, p, esc); + char *end = seq_mangle_path(buf, p, esc); if (end) res = end - buf; } diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index b83b3ae3c877..0a7dda239e56 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h @@ -104,7 +104,7 @@ static inline void seq_setwidth(struct seq_file *m, size_t size) } void seq_pad(struct seq_file *m, char c); -char *mangle_path(char *s, const char *p, const char *esc); +char *seq_mangle_path(char *s, const char *p, const char *esc); int seq_open(struct file *, const struct seq_operations *); ssize_t seq_read(struct file *, char __user *, size_t, loff_t *); ssize_t seq_read_iter(struct kiocb *iocb, struct iov_iter *iter); diff --git a/lib/seq_buf.c b/lib/seq_buf.c index 707453f5d58e..90b50a514edb 100644 --- a/lib/seq_buf.c +++ b/lib/seq_buf.c @@ -274,7 +274,7 @@ int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc) if (size) { char *p = d_path(path, buf, size); if (!IS_ERR(p)) { - char *end = mangle_path(buf, p, esc); + char *end = seq_mangle_path(buf, p, esc); if (end) res = end - buf; } From patchwork Fri Mar 12 09:55:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1451814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=QUydDQ58; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dxh68311nz9sRR for ; Fri, 12 Mar 2021 20:56:16 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Ypvj5oK+bpwO74XRXUcYo18cLFFGdeWEp1ZwzljrPUg=; b=QUydDQ58IBtZhLTKsvdw0U9K3 CBPqkgm74yaehSBw6VIktiHDKG2NHhZczNYbJEnivQ0bzVsVJd9qzpicZwmGAN/iq+d6NhNvYejir sNYCduztICQzAvdeIxLstlv/OYfhy4qlb/zlXA1l36911f+6aXKIYvyZ/LxJl6oB401Cq7+5OZ0Z+ XoQoLEU3ulk+g9kmst8BeP4ianGrHVVcC947GnQmAFFxqwZsGpu0Irj99HO+sRscCQJF2RhXgxOkc aIEdQo00D9EPqJH3uEFw2/nQ/nM4Er/cqzK4AEwIa2kD8BNxsc0CrM/4z5QsEydT/EaMgUs4rKNLn /pxjmHPGw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKeWZ-00B5e3-IM; Fri, 12 Mar 2021 09:56:04 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2] helo=sipsolutions.net) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKeW5-00B5Tm-Ra for linux-um@lists.infradead.org; Fri, 12 Mar 2021 09:55:49 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1lKeW1-00F7m8-KI; Fri, 12 Mar 2021 10:55:29 +0100 From: Johannes Berg To: linux-kernel@vger.kernel.org, linux-um@lists.infradead.org Cc: Jessica Yu , Alexander Viro , linux-fsdevel@vger.kernel.org, Johannes Berg Subject: [PATCH 2/6] module: add support for CONFIG_MODULE_DESTRUCTORS Date: Fri, 12 Mar 2021 10:55:22 +0100 Message-Id: <20210312104627.8b2523b0593c.Ib0fb7906e3d7bd69ebe5eb877e2e9f33ef915d4b@changeid> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210312095526.197739-1-johannes@sipsolutions.net> References: <20210312095526.197739-1-johannes@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_095534_855185_CFE6C0D8 X-CRM114-Status: GOOD ( 19.92 ) X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Johannes Berg At least in ARCH=um with CONFIG_GCOV (which writes all the coverage data directly out from the userspace binary rather than presenting it in debugfs) it's necessary to run all the atexit handlers (dto [...] Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg At least in ARCH=um with CONFIG_GCOV (which writes all the coverage data directly out from the userspace binary rather than presenting it in debugfs) it's necessary to run all the atexit handlers (dtors/fini_array) so that gcov actually does write out the data. Add a new config option CONFIG_MODULE_DESTRUCTORS that can be selected via CONFIG_WANT_MODULE_DESTRUCTORS that the arch selects (this indirection exists so the architecture doesn't have to worry about whether or not CONFIG_MODULES is on). Additionally, the architecture must then (when it exits and no more module code can run) call run_all_module_destructors to run the code for all modules that are still loaded. When modules are unloaded, the handlers are called as well. Signed-off-by: Johannes Berg --- include/linux/module.h | 14 ++++++++++++++ init/Kconfig | 17 +++++++++++++++++ kernel/module.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/include/linux/module.h b/include/linux/module.h index 59f094fa6f74..8574d76a884d 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -517,6 +517,12 @@ struct module { unsigned int num_ctors; #endif +#ifdef CONFIG_MODULE_DESTRUCTORS + /* Destructor functions. */ + ctor_fn_t *dtors; + unsigned int num_dtors; +#endif + #ifdef CONFIG_FUNCTION_ERROR_INJECTION struct error_injection_entry *ei_funcs; unsigned int num_ei_funcs; @@ -853,4 +859,12 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, unsigned long), void *data); +#ifdef CONFIG_MODULE_DESTRUCTORS +void run_all_module_destructors(void); +#else +static inline void run_all_module_destructors(void) +{ +} +#endif + #endif /* _LINUX_MODULE_H */ diff --git a/init/Kconfig b/init/Kconfig index 22946fe5ded9..b0f0f51f9d2c 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -2295,6 +2295,23 @@ config UNUSED_KSYMS_WHITELIST endif # MODULES +config WANT_MODULE_DESTRUCTORS + bool + help + Architectures may select this if they need atexit functions (such as + generated by the compiler for -ftest-coverage/gcov) to run in modules. + They're then responsible for calling run_all_module_destructors() at + shutdown so that module destructors are called for all still loaded + modules as well. + + Note that CONFIG_GCOV_KERNEL does *not* require this since it keeps + all the coverage data in the kernel, notably CONFIG_GCOV in ARCH=um + requires this. + +config MODULE_DESTRUCTORS + def_bool y + depends on WANT_MODULE_DESTRUCTORS && MODULES + config MODULES_TREE_LOOKUP def_bool y depends on PERF_EVENTS || TRACING diff --git a/kernel/module.c b/kernel/module.c index 30479355ab85..3023b5f054d4 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -904,6 +904,27 @@ EXPORT_SYMBOL(module_refcount); /* This exists whether we can unload or not */ static void free_module(struct module *mod); +#ifdef CONFIG_MODULE_DESTRUCTORS +static void do_mod_dtors(struct module *mod) +{ + unsigned long i; + + for (i = 0; i < mod->num_dtors; i++) + mod->dtors[i](); +} + +void run_all_module_destructors(void) +{ + struct module *mod; + + /* we no longer need to care about locking at this point */ + list_for_each_entry(mod, &modules, list) + do_mod_dtors(mod); +} +#else +static inline void do_mod_dtors(struct module *mod) {} +#endif + SYSCALL_DEFINE2(delete_module, const char __user *, name_user, unsigned int, flags) { @@ -966,6 +987,7 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user, MODULE_STATE_GOING, mod); klp_module_going(mod); ftrace_release_mod(mod); + do_mod_dtors(mod); async_synchronize_full(); @@ -3263,6 +3285,23 @@ static int find_module_sections(struct module *mod, struct load_info *info) } #endif +#ifdef CONFIG_MODULE_DESTRUCTORS + mod->dtors = section_objs(info, ".dtors", + sizeof(*mod->dtors), &mod->num_dtors); + if (!mod->dtors) + mod->dtors = section_objs(info, ".fini_array", + sizeof(*mod->dtors), &mod->num_dtors); + else if (find_sec(info, ".fini_array")) { + /* + * This shouldn't happen with same compiler and binutils + * building all parts of the module. + */ + pr_warn("%s: has both .dtors and .fini_array.\n", + mod->name); + return -EINVAL; + } +#endif + mod->noinstr_text_start = section_objs(info, ".noinstr.text", 1, &mod->noinstr_text_size); From patchwork Fri Mar 12 09:55:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1451813 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=kEktuU/o; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dxh660w1kz9sRR for ; Fri, 12 Mar 2021 20:56:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FUk5TLhVlLbQgDTG5brbVEtqUEWE4C/TV2CcX2uzrzU=; b=kEktuU/oCMS07DRnej6CORaC2 ofluQsNx10rXYt+d1EmIsVXwPTZLyaGy1REirTrjyJmP4zeGBqLe+k6UAOyWbidiDJzxeTRr3CStH 5zGk2c51g/jx7VR2BiSFLlP3ih31M/G+jsOVWyS3pEktmom5e7etDifEOjMyq/tbqLkiWk/U08kjP heDYC/hrCdo1BdqBeUjghQcI0/6DkPMV1meXU+69KjMV+VghOlCmJGkpHR7ShdbO2gRosPjzAyAYr V086B5U8mDQJYvXB5jJ2n1IeeiACMkHFpqDxxQCwkSUZAw+1MxP32xn4aWnS6byuq9oSzX+xdJgr+ 4i/fasWng==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKeWW-00B5cr-40; Fri, 12 Mar 2021 09:56:00 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2] helo=sipsolutions.net) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKeW5-00B5Tn-RN for linux-um@lists.infradead.org; Fri, 12 Mar 2021 09:55:44 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1lKeW1-00F7m8-Ug; Fri, 12 Mar 2021 10:55:30 +0100 From: Johannes Berg To: linux-kernel@vger.kernel.org, linux-um@lists.infradead.org Cc: Jessica Yu , Alexander Viro , linux-fsdevel@vger.kernel.org, Johannes Berg Subject: [PATCH 3/6] .gitignore: also ignore gcda files Date: Fri, 12 Mar 2021 10:55:23 +0100 Message-Id: <20210312104627.77a4bc149381.I4f7b3002fa9ef4a168fca1f7952a277b52cae695@changeid> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210312095526.197739-1-johannes@sipsolutions.net> References: <20210312095526.197739-1-johannes@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_095534_826999_50D73C71 X-CRM114-Status: UNSURE ( 8.17 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Johannes Berg We already ignore gcno files that are created by the compiler at build time for -ftest-coverage. However, with ARCH=um it's possible to select CONFIG_GCOV which actually has the kernel binary write ou [...] Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg We already ignore gcno files that are created by the compiler at build time for -ftest-coverage. However, with ARCH=um it's possible to select CONFIG_GCOV which actually has the kernel binary write out gcda files (rather than have them in debugfs like CONFIG_GCOV_KERNEL does), so an in-tree build can create them. Ignore them so the tree doesn't look dirty for that. Signed-off-by: Johannes Berg --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3af66272d6f1..91e46190d418 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ *.dwo *.elf *.gcno +*.gcda *.gz *.i *.ko From patchwork Fri Mar 12 09:55:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1451812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=efvpbX9R; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dxh5z27vGz9sRR for ; Fri, 12 Mar 2021 20:56:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pzC7UP3aTjZAp5A/mbs2M5YZxnFZoTYrCL3NFdLxy5Y=; b=efvpbX9Rf52O8pmZpUlv+vpEP HmGqnS9uldsSkg5sYt3Yy5ISNNy7OY37AiuqL8cYiNnC13oRz3KiICMmFeDNmbtptifEaKPKIm/bb 4BHi3F81b9TEyPKVo4SfAgBPcX+ZQQv6eS4Bn7uJVD9UsvMtB8aJQ1IGUSkR+Xp6FtRQCu3kqtsNf Z4vmpznULy22CYiv68HzlXCRdhob+A6RbDnU/h9rJxHWGkY3PrZ96AVW66bVVhtqHJQtDwBx/uxjp zHOdgX22koFoYe5HENgx8yHipVTHE2KgyQM+RPkrhkb8Bepbx6b8OzMZwUPK78lrLB5gCuD/avb+h BKz/9mPdQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKeWR-00B5bf-T1; Fri, 12 Mar 2021 09:55:55 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2] helo=sipsolutions.net) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKeW5-00B5To-Rl for linux-um@lists.infradead.org; Fri, 12 Mar 2021 09:55:44 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1lKeW2-00F7m8-93; Fri, 12 Mar 2021 10:55:30 +0100 From: Johannes Berg To: linux-kernel@vger.kernel.org, linux-um@lists.infradead.org Cc: Jessica Yu , Alexander Viro , linux-fsdevel@vger.kernel.org, Johannes Berg Subject: [PATCH 4/6] um: split up CONFIG_GCOV Date: Fri, 12 Mar 2021 10:55:24 +0100 Message-Id: <20210312104627.927fb4c7d36f.Idb980393c41c2129ee592de4ed71e7a5518212f9@changeid> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210312095526.197739-1-johannes@sipsolutions.net> References: <20210312095526.197739-1-johannes@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_095534_946423_79DD93DC X-CRM114-Status: GOOD ( 17.31 ) X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Johannes Berg It's not always desirable to collect coverage data for the entire kernel, so split off CONFIG_GCOV_BASE. This option only enables linking with coverage options, and compiles a single file (reboot.c) w [...] Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg It's not always desirable to collect coverage data for the entire kernel, so split off CONFIG_GCOV_BASE. This option only enables linking with coverage options, and compiles a single file (reboot.c) with them as well to force gcov to be linked into the kernel binary. That way, modules also work. To use this new option properly, one needs to manually add '-fprofile-arcs -ftest-coverage' to the compiler options of some object(s) or subdir(s) to collect coverage data at the desired places. Signed-off-by: Johannes Berg --- arch/um/Kconfig.debug | 38 ++++++++++++++++++++++++++++++-------- arch/um/Makefile-skas | 2 +- arch/um/kernel/Makefile | 11 ++++++++++- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/arch/um/Kconfig.debug b/arch/um/Kconfig.debug index 315d368e63ad..ca040b4e86e5 100644 --- a/arch/um/Kconfig.debug +++ b/arch/um/Kconfig.debug @@ -13,19 +13,41 @@ config GPROF If you're involved in UML kernel development and want to use gprof, say Y. If you're unsure, say N. -config GCOV - bool "Enable gcov support" +config GCOV_BASE + bool "Enable gcov support (selectively)" depends on DEBUG_INFO - depends on !KCOV + depends on !KCOV && !GCOV_KERNEL help This option allows developers to retrieve coverage data from a UML - session. + session, stored to disk just like with a regular userspace binary, + use the same tools (gcov, lcov, ...) to collect and process the + data. - See for more - details. + See also KCOV and GCOV_KERNEL as alternatives. - If you're involved in UML kernel development and want to use gcov, - say Y. If you're unsure, say N. + This option (almost) only links with the needed support code, but + doesn't enable coverage data collection for any code (other than a + dummy file to get everything linked properly). See also the GCOV + option which enables coverage collection for the entire kernel and + all modules. + + If you're using UML to test something and want to manually instruct + the compiler to instrument only parts of the code by adding the + relevant options for the objects you care about, say Y and do that + to get coverage collection only for the parts you need. + + If you're unsure, say N. + +config GCOV + bool "Enable gcov support (whole kernel)" + depends on DEBUG_INFO + depends on !KCOV && !GCOV_KERNEL + select GCOV_BASE + help + This enables coverage data collection for the entire kernel and + all modules, see the GCOV_BASE option for more information. + + If you're unsure, say N. config EARLY_PRINTK bool "Early printk" diff --git a/arch/um/Makefile-skas b/arch/um/Makefile-skas index ac35de5316a6..b5be5f55ac11 100644 --- a/arch/um/Makefile-skas +++ b/arch/um/Makefile-skas @@ -8,5 +8,5 @@ GCOV_OPT += -fprofile-arcs -ftest-coverage CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT) CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT) -LINK-$(CONFIG_GCOV) += $(GCOV_OPT) +LINK-$(CONFIG_GCOV_BASE) += $(GCOV_OPT) LINK-$(CONFIG_GPROF) += $(GPROF_OPT) diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index c1205f9ec17e..0403e329f931 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile @@ -21,7 +21,7 @@ obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \ obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o obj-$(CONFIG_GPROF) += gprof_syms.o -obj-$(CONFIG_GCOV) += gmon_syms.o +obj-$(CONFIG_GCOV_BASE) += gmon_syms.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-$(CONFIG_GENERIC_PCI_IOMAP) += ioport.o @@ -32,6 +32,15 @@ include arch/um/scripts/Makefile.rules targets := config.c config.tmp +# This just causes _something_ to be compiled with coverage +# collection so that gcov is linked into the binary, in case +# the only thing that has it enabled is a module, when only +# CONFIG_GCOV_BASE is selected. Yes, we thus always get some +# coverage data for this file, but it's not hit often ... +ifeq ($(CONFIG_GCOV_BASE),y) +CFLAGS_reboot.o += -fprofile-arcs -ftest-coverage +endif + # Be careful with the below Sed code - sed is pitfall-rich! # We use sed to lower build requirements, for "embedded" builders for instance. From patchwork Fri Mar 12 09:55:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1451808 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=epOzQVTW; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dxh5q6KpRz9sRR for ; Fri, 12 Mar 2021 20:55:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JiKaHg5Z7iWxmmJBrPd9TxUyIgi2R5Pys/6J7xer2cI=; b=epOzQVTWkcCsN8nW36TcGyDhh 6F5YU2MPV6fLWE3jDDHuQAUFgVeg5E55whgCJBaNW0oIOcU1qjjcJU496Atinmiiw64g+aRHVMdO2 Cph0hFOYHBjHIzGg5JmsZ2alMuRjCBT7so3HgEJ9Tbs8PPD3oNCrqdzksp5XIMM/Z8tkksvUzCbsc 8S8r93LTvQEyXGIqK5xeZh8uiMNK0483vwk5df0IbNtlLxzNl+BB6y8Li/Ge4ahQEy1Mib4iASfwp ia7pAy1zuNPG5RRD7/9SH4iF8D8C/554CEqZjMd1I4bHZU1MRi7luVbUu8OiMZCMuTCfKLSVK0iq6 zqwhM1p0w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKeWF-00B5XI-HI; Fri, 12 Mar 2021 09:55:43 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2] helo=sipsolutions.net) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKeW5-00B5Tl-Lv for linux-um@lists.infradead.org; Fri, 12 Mar 2021 09:55:38 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1lKeW2-00F7m8-Jg; Fri, 12 Mar 2021 10:55:30 +0100 From: Johannes Berg To: linux-kernel@vger.kernel.org, linux-um@lists.infradead.org Cc: Jessica Yu , Alexander Viro , linux-fsdevel@vger.kernel.org, Johannes Berg Subject: [PATCH 5/6] um: fix CONFIG_GCOV for built-in code Date: Fri, 12 Mar 2021 10:55:25 +0100 Message-Id: <20210312104627.9355049045fe.Ie4896d26d2a4e1116c760cdb91087a1817807ca6@changeid> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210312095526.197739-1-johannes@sipsolutions.net> References: <20210312095526.197739-1-johannes@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_095534_352373_B010FF5C X-CRM114-Status: UNSURE ( 9.12 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Johannes Berg With contemporary toolchains, CONFIG_GCOV doesn't work because gcov now relies on both init and exit handlers, but those are discarded from the binary. Fix the linker scripts to keep them instead, so [...] Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg With contemporary toolchains, CONFIG_GCOV doesn't work because gcov now relies on both init and exit handlers, but those are discarded from the binary. Fix the linker scripts to keep them instead, so that CONFIG_GCOV can work again. Note that this does not make it work in modules yet, since we don't call their exit handlers. Signed-off-by: Johannes Berg --- arch/um/include/asm/common.lds.S | 2 ++ arch/um/kernel/vmlinux.lds.S | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/common.lds.S index eca6c452a41b..1223dcaaf7e3 100644 --- a/arch/um/include/asm/common.lds.S +++ b/arch/um/include/asm/common.lds.S @@ -84,11 +84,13 @@ .init_array : { __init_array_start = .; *(.init_array) + *(.init_array.*) __init_array_end = .; } .fini_array : { __fini_array_start = .; *(.fini_array) + *(.fini_array.*) __fini_array_end = .; } diff --git a/arch/um/kernel/vmlinux.lds.S b/arch/um/kernel/vmlinux.lds.S index 16e49bfa2b42..2245ae4907d2 100644 --- a/arch/um/kernel/vmlinux.lds.S +++ b/arch/um/kernel/vmlinux.lds.S @@ -1,6 +1,8 @@ KERNEL_STACK_SIZE = 4096 * (1 << CONFIG_KERNEL_STACK_ORDER); +#define RUNTIME_DISCARD_EXIT + #ifdef CONFIG_LD_SCRIPT_STATIC #include "uml.lds.S" #else From patchwork Fri Mar 12 09:55:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1451811 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=jjGwGt2G; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dxh5y0WBdz9sRR for ; Fri, 12 Mar 2021 20:56:06 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6BZdMZQYt9mNQJswSvonrBPyF3OfKKjVN6sX+5viLjs=; b=jjGwGt2GEpHaonSKDF6Ukc68m oggyPrvbjKCBhnV3+1dONozC+ei00W5w2JUkxZlw8pO/+N0pHQGGUjdLdM2vXoKvefVrRj5n2me6V 2EwWIIuRXZaxcUvP0pGTJgaZMfEoCLE0ClmJAR20d13BnImML3cZc+VI6FHETedq5fmlciTHEjw4R A4mS1XYhK6IwIO8DEq7njowgCNPq0dfxI5oh4n8+9VI2dNlxhNbpeC8W5V/olIaZtSDcLO7JVYYwQ vzMNr5ilNQr3CikhYEx+mkt270oqbHbW4ccaGB6I2QbkhQJh/RIsVyRIYq7q8VzpbBQ0L50whsmIO 94dpIt93Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKeWO-00B5au-VY; Fri, 12 Mar 2021 09:55:53 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2] helo=sipsolutions.net) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKeW5-00B5Tk-RK for linux-um@lists.infradead.org; Fri, 12 Mar 2021 09:55:45 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1lKeW2-00F7m8-UP; Fri, 12 Mar 2021 10:55:31 +0100 From: Johannes Berg To: linux-kernel@vger.kernel.org, linux-um@lists.infradead.org Cc: Jessica Yu , Alexander Viro , linux-fsdevel@vger.kernel.org, Johannes Berg Subject: [PATCH 6/6] um: fix CONFIG_GCOV for modules Date: Fri, 12 Mar 2021 10:55:26 +0100 Message-Id: <20210312104627.54210a33e4c0.I9807ad0ea6ee21a81f86d367f3b61e5f24f8b30b@changeid> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210312095526.197739-1-johannes@sipsolutions.net> References: <20210312095526.197739-1-johannes@sipsolutions.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_095534_912467_4CEE85AD X-CRM114-Status: UNSURE ( 8.79 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Johannes Berg At least with current toolchain versions, gcov (as enabled by CONFIG_GCOV) requires init and exit handlers to run. For modules, this wasn't done properly, so use the new support for CONFIG_MODULE_DEST [...] Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg At least with current toolchain versions, gcov (as enabled by CONFIG_GCOV) requires init and exit handlers to run. For modules, this wasn't done properly, so use the new support for CONFIG_MODULE_DESTRUCTORS as well as CONFIG_CONSTRUCTORS to have gcov init and exit called appropriately. Signed-off-by: Johannes Berg --- arch/um/Kconfig.debug | 2 ++ arch/um/kernel/process.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/um/Kconfig.debug b/arch/um/Kconfig.debug index ca040b4e86e5..74b27b11cb44 100644 --- a/arch/um/Kconfig.debug +++ b/arch/um/Kconfig.debug @@ -17,6 +17,8 @@ config GCOV_BASE bool "Enable gcov support (selectively)" depends on DEBUG_INFO depends on !KCOV && !GCOV_KERNEL + select CONSTRUCTORS + select WANT_MODULE_DESTRUCTORS help This option allows developers to retrieve coverage data from a UML session, stored to disk just like with a regular userspace binary, diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index c5011064b5dd..33f895a95ff8 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -240,6 +240,8 @@ void do_uml_exitcalls(void) call = &__uml_exitcall_end; while (--call >= &__uml_exitcall_begin) (*call)(); + + run_all_module_destructors(); } char *uml_strdup(const char *string)