From patchwork Tue Oct 29 12:38:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 178024 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp4815380ill; Tue, 29 Oct 2019 05:38:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyogzVDbjH5iDeNz9wyXGK2IoLTELAqCdiyjDVZUCui95Z/ViZa/Ef9tgZJfqGpQjmAu7L X-Received: by 2002:a17:906:4dce:: with SMTP id f14mr3038641ejw.22.1572352729824; Tue, 29 Oct 2019 05:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572352729; cv=none; d=google.com; s=arc-20160816; b=Ckk+oCiU4K387mx4YM5dqeQwJqP57S8v6xtOHqf+YVvL5Noy7YcUOicmpQam1EErSw 2iL+x5aiIAy7eLBObVVJqiLfsPuUymW0EFwR+nCVK+Dsx1jKXAQYBMRejuE9BE2+HhcM kWiUtpjrwAgVeKdMOCl+CJiZl8FT9wxLhrLGfHG68vQmeVH6un2q4Km0l5G4jwpQ0ZHq XSbNl49p0X5Dad0YwWkzgijcMguaHmDPEIbJymiIDhd2gHCNsAbp0OMW5coA9rfNp03W SUsgCurPd9rJotLxTdqCUvmdhvZzsojdrDuCrd/IkmrCW514wo1ckSJ2xyw8RI+vpMux ZI2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=AnYr/CYeWxJigHV9r38jB5sc5adlxzzRhOfW/8/opVI=; b=FgGLTMMX5retgiQgLS0RKL5ayre5OA70ta+ZVIMFOJq2USpgbYvaITRDgFb1GEuDcu D82evpcZrwfMRjWqaJTrN/00lGRUgpsp1ZyjLOcT+g58nRqmsigbclwr01zf0YEMD6qg BQwv0fgSj0873gO4/u0wfPzb4Q8dIbEbyi1dAkJt1VQj9FmNUm2ltyu8NRxkHScrz/Px 1V6gAfGRA/j3lkVxKST6cpOJrMY5fXoDVkrE3YBDTtw9dH58/ke1GiCF+b/q7GrgHLfc 198f6jlH0eLxn/j0Uk44dsO0r5wiz7GNtsRl38FWYKVeN7lhO/XVNcEHfdH8b0ziI+qm e0+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=f4Uv4e6c; 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 c36si9730236edb.58.2019.10.29.05.38.49; Tue, 29 Oct 2019 05:38:49 -0700 (PDT) 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=@nifty.com header.s=dec2015msa header.b=f4Uv4e6c; 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 S1729002AbfJ2Mip (ORCPT + 26 others); Tue, 29 Oct 2019 08:38:45 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:33927 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726048AbfJ2Min (ORCPT ); Tue, 29 Oct 2019 08:38:43 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id x9TCcFU6026616; Tue, 29 Oct 2019 21:38:17 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x9TCcFU6026616 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1572352698; bh=AnYr/CYeWxJigHV9r38jB5sc5adlxzzRhOfW/8/opVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4Uv4e6cv3GEt9iPrdZ7pwVhwECCWFmRJ43gDsvju47hGXhtEAms9Q2BcSZRNm5G3 Ov+oQROmlpVf8kTf+s9HM1UXVOK7eiImx9LJB5AyHeDWu5fyy2ZP8Q191G2KucbLgH CUJq+SEfiPiVz9zzeWhtg4ZfCTTMnUZy2A3aeOjnfjKqWfso3R7IITaM5sHecxSGH/ u3D1fgwPpuN76vv3bG9ublD0nGvEpzbs1fGOU6lG0hldidHp0go3ohs107v93Sw46w aoPomsolZaD9G5/3t6tWWxQCCA9E+rzchF5akbOjaH/KsRtmjI/3/C4tgRKJYfmnB9 9I9NKUVxXuYCg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Jessica Yu , Matthias Kaehlcke , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 1/4] modpost: do not invoke extra modpost for nsdeps Date: Tue, 29 Oct 2019 21:38:06 +0900 Message-Id: <20191029123809.29301-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029123809.29301-1-yamada.masahiro@socionext.com> References: <20191029123809.29301-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'make nsdeps' invokes the modpost three times at most; before linking vmlinux, before building modules, and finally for generating .ns_deps files. Running the modpost again and again is annoying. The last two can be unified. When the -d option is given, the modpost still does the usual job, and in addition, generates .ns_deps files. Signed-off-by: Masahiro Yamada --- Makefile | 5 ++--- scripts/Makefile.modpost | 8 +++----- scripts/mod/modpost.c | 9 ++------- 3 files changed, 7 insertions(+), 15 deletions(-) -- 2.17.1 Tested-by: Matthias Maennich Reviewed-by: Matthias Maennich diff --git a/Makefile b/Makefile index 4f4d8979bfce..0ef897fd9cfd 100644 --- a/Makefile +++ b/Makefile @@ -1682,10 +1682,9 @@ tags TAGS cscope gtags: FORCE # --------------------------------------------------------------------------- PHONY += nsdeps - +nsdeps: export KBUILD_NSDEPS=1 nsdeps: modules - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost nsdeps - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@ + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/nsdeps # Scripts to check various things for consistency # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 01c0a992d293..c9757b20b048 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -53,8 +53,7 @@ MODPOST = scripts/mod/modpost \ $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ - $(if $(KBUILD_MODPOST_WARN),-w) \ - $(if $(filter nsdeps,$(MAKECMDGOALS)),-d) + $(if $(KBUILD_MODPOST_WARN),-w) ifdef MODPOST_VMLINUX @@ -66,7 +65,8 @@ __modpost: else -MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - +MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \ + $(if $(KBUILD_NSDEPS),-d) ifeq ($(KBUILD_EXTMOD),) MODPOST += $(wildcard vmlinux) @@ -97,8 +97,6 @@ ifneq ($(KBUILD_MODPOST_NOFINAL),1) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal endif -nsdeps: __modpost - endif .PHONY: $(PHONY) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 26ba97245576..dcd90d563ce8 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2221,8 +2221,7 @@ static int check_exports(struct module *mod) add_namespace(&mod->required_namespaces, exp->namespace); - if (!write_namespace_deps && - !module_imports_namespace(mod, exp->namespace)) { + if (!module_imports_namespace(mod, exp->namespace)) { warn("module %s uses symbol %s from namespace %s, but does not import it.\n", basename, exp->name, exp->namespace); } @@ -2641,8 +2640,6 @@ int main(int argc, char **argv) err |= check_modname_len(mod); err |= check_exports(mod); - if (write_namespace_deps) - continue; add_header(&buf, mod); add_intree_flag(&buf, !external_module); @@ -2657,10 +2654,8 @@ int main(int argc, char **argv) write_if_changed(&buf, fname); } - if (write_namespace_deps) { + if (write_namespace_deps) write_namespace_deps_files(); - return 0; - } if (dump_write) write_dump(dump_write); From patchwork Tue Oct 29 12:38:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 178026 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp4815979ill; Tue, 29 Oct 2019 05:39:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxepk2D4P5BipVg9CgqfAKjMVkpoSA72L97q7wAtzb0i+zIvJVY+fibbC3Nu+AS7sqA/uLL X-Received: by 2002:a17:906:4bd7:: with SMTP id x23mr2955587ejv.320.1572352758813; Tue, 29 Oct 2019 05:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572352758; cv=none; d=google.com; s=arc-20160816; b=ziuL4mQGZ/bt57KCZFLa+o1/U5L7YFCGaP8+fxsDB2J0bOPnZPeQMZE6Jn99RW1t1s kkr6i2m+w+U/iwVfsNiSv4xgdMJ5odnaNo/QpfB7SkdkJ0TGmKAPY4hIubHSpLK0nGKE hODE51GbkTWBU1BiwA3pZU25DdggaDL5yODmchlEfTkJNOE7JEjDpQuAvqo/ieopJ6GB oB7NzL4yL6PChKPc2VCiNhCNWQIUuRyUfzvVB5ooI1WlovxWH+qedOLN/7McMybPPIsR sXM1L7IrRxVcNIwO3i072R6iM9CKz/0E1/hruBD8yXwCPecH15ENFQlcxnXID6OSGWDC b/ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=Qjpd7CVgJvkb1ynA28241oewcnt6uy01AsBABUqZ/rA=; b=ULPFGv+Tb5aae2agT4o7bC2ZfSydxvYpMWevn0i1zNjZKjRcrgOor5VePaOh4tLOhB VTmipEkgCE1QLf+ARwlFgfy3v40Ou5G8XUiJNryrppwBwnAt6tn3w0bpj9k/BR7N2o3w FnSmbVcbw4D3W0JrT8cKic8A3UPar61z5FUXWcotb3qVW2G2gAjdWorcUjF8ID2Fl6PB ynfnBobwO320AFz5y1ACcsNOnd0MwOmiWMWVHJRokJvorYgLGrwdis9jLTNyiYS1Ws0A WwDlN4HHRvRWrycNg4GPTXzm8zPqmjdcK5YNxck6MCGewp6D9Ql1L6ExjRS+eyGf+prR WIcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=XmOR88hq; 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 j8si3093657ejm.162.2019.10.29.05.39.18; Tue, 29 Oct 2019 05:39:18 -0700 (PDT) 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=@nifty.com header.s=dec2015msa header.b=XmOR88hq; 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 S1733028AbfJ2MjJ (ORCPT + 26 others); Tue, 29 Oct 2019 08:39:09 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:34504 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727675AbfJ2MjH (ORCPT ); Tue, 29 Oct 2019 08:39:07 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id x9TCcFU7026616; Tue, 29 Oct 2019 21:38:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x9TCcFU7026616 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1572352699; bh=Qjpd7CVgJvkb1ynA28241oewcnt6uy01AsBABUqZ/rA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XmOR88hqBq0zqgiK3K0n1slosMFI5cscbY5V+ih7ZQqClXzxtTmUiYS8Xbhrz6FN/ B725tspr9hquqjD3uAisavxfUNxgMQJU5QtzIBEX4kxYC/XghntnAkPMuvX6XFWgll oGKWQkB1rItA0BtJZ3QVSfR+Xbi87Nb52LNSdpN+9xYx6ivguRRGBPZV9a5RnukoLh 6G2G/t10UDKrNBx7mCSHUZAhVBhMEsFKa2h/wY8gUV5TzSylYVEaISpVITUgP3A6Dz wn+XkdS133soLRYqJy46qhEoUes4hk7jPHZG2KK73OOs0SlNeBOshjtJ53xoin93pa j8nkHYKhmRjog== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Jessica Yu , Matthias Kaehlcke , Masahiro Yamada , Jonathan Corbet , Matthias Maennich , Michal Marek , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] modpost: dump missing namespaces into a single modules.nsdeps file Date: Tue, 29 Oct 2019 21:38:07 +0900 Message-Id: <20191029123809.29301-3-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029123809.29301-1-yamada.masahiro@socionext.com> References: <20191029123809.29301-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The modpost, with the -d option given, generates per-module .ns_deps files. Kbuild generates per-module .mod files to carry module information. This is convenient because Make handles multiple jobs when the -j option is given. On the other hand, the modpost always runs as a single thread. I do not see a strong reason to produce separate .ns_deps files. This commit changes the modpost to generate just one file, modules.nsdeps, each line of which has the following format: : Please note it contains *missing* namespaces instead of required ones. So, modules.nsdeps is empty if the namespace dependency is all good. This will work more efficiently because spatch will no longer process already imported namespaces. I removed the '(if needed)' from the nsdeps log since spatch is invoked only when needed. This also solved the stale .ns_deps files problem reported by Jessica Yu: https://lkml.org/lkml/2019/10/28/467 While I was here, I improved the modpost code a little more; I freed ns_deps_bus.p because buf_write() allocates memory. Signed-off-by: Masahiro Yamada --- .gitignore | 2 +- Documentation/dontdiff | 1 + Makefile | 4 ++-- scripts/Makefile.modpost | 2 +- scripts/mod/modpost.c | 44 +++++++++++++++++----------------------- scripts/mod/modpost.h | 4 ++-- scripts/nsdeps | 21 +++++++++---------- 7 files changed, 36 insertions(+), 42 deletions(-) -- 2.17.1 Tested-by: Jessica Yu Acked-by: Jessica Yu Reviewed-by: Matthias Maennich Tested-by: Matthias Maennich diff --git a/.gitignore b/.gitignore index 70580bdd352c..72ef86a5570d 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,6 @@ *.lzo *.mod *.mod.c -*.ns_deps *.o *.o.* *.patch @@ -61,6 +60,7 @@ modules.order /System.map /Module.markers /modules.builtin.modinfo +/modules.nsdeps # # RPM spec file (make rpm-pkg) diff --git a/Documentation/dontdiff b/Documentation/dontdiff index 9f4392876099..72fc2e9e2b63 100644 --- a/Documentation/dontdiff +++ b/Documentation/dontdiff @@ -179,6 +179,7 @@ mkutf8data modpost modules.builtin modules.builtin.modinfo +modules.nsdeps modules.order modversions.h* nconf diff --git a/Makefile b/Makefile index 0ef897fd9cfd..1e3f307bd49b 100644 --- a/Makefile +++ b/Makefile @@ -1356,7 +1356,7 @@ endif # CONFIG_MODULES # Directories & files removed with 'make clean' CLEAN_DIRS += include/ksym -CLEAN_FILES += modules.builtin.modinfo +CLEAN_FILES += modules.builtin.modinfo modules.nsdeps # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include/generated \ @@ -1660,7 +1660,7 @@ clean: $(clean-dirs) -o -name '*.ko.*' \ -o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \ -o -name '*.dwo' -o -name '*.lst' \ - -o -name '*.su' -o -name '*.mod' -o -name '*.ns_deps' \ + -o -name '*.su' -o -name '*.mod' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ -o -name '*.lex.c' -o -name '*.tab.[ch]' \ -o -name '*.asn1.[ch]' \ diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index c9757b20b048..da37128c3f9f 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -66,7 +66,7 @@ __modpost: else MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \ - $(if $(KBUILD_NSDEPS),-d) + $(if $(KBUILD_NSDEPS),-d modules.nsdeps) ifeq ($(KBUILD_EXTMOD),) MODPOST += $(wildcard vmlinux) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index dcd90d563ce8..f7425f5d4ab0 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -38,8 +38,6 @@ static int sec_mismatch_count = 0; static int sec_mismatch_fatal = 0; /* ignore missing files */ static int ignore_missing_files; -/* write namespace dependencies */ -static int write_namespace_deps; enum export { export_plain, export_unused, export_gpl, @@ -2217,14 +2215,11 @@ static int check_exports(struct module *mod) else basename = mod->name; - if (exp->namespace) { - add_namespace(&mod->required_namespaces, - exp->namespace); - - if (!module_imports_namespace(mod, exp->namespace)) { - warn("module %s uses symbol %s from namespace %s, but does not import it.\n", - basename, exp->name, exp->namespace); - } + if (exp->namespace && + !module_imports_namespace(mod, exp->namespace)) { + warn("module %s uses symbol %s from namespace %s, but does not import it.\n", + basename, exp->name, exp->namespace); + add_namespace(&mod->missing_namespaces, exp->namespace); } if (!mod->gpl_compatible) @@ -2525,29 +2520,27 @@ static void write_dump(const char *fname) free(buf.p); } -static void write_namespace_deps_files(void) +static void write_namespace_deps_files(const char *fname) { struct module *mod; struct namespace_list *ns; struct buffer ns_deps_buf = {}; for (mod = modules; mod; mod = mod->next) { - char fname[PATH_MAX]; - if (mod->skip) + if (mod->skip || !mod->missing_namespaces) continue; - ns_deps_buf.pos = 0; + buf_printf(&ns_deps_buf, "%s.ko:", mod->name); - for (ns = mod->required_namespaces; ns; ns = ns->next) - buf_printf(&ns_deps_buf, "%s\n", ns->namespace); + for (ns = mod->missing_namespaces; ns; ns = ns->next) + buf_printf(&ns_deps_buf, " %s", ns->namespace); - if (ns_deps_buf.pos == 0) - continue; - - sprintf(fname, "%s.ns_deps", mod->name); - write_if_changed(&ns_deps_buf, fname); + buf_printf(&ns_deps_buf, "\n"); } + + write_if_changed(&ns_deps_buf, fname); + free(ns_deps_buf.p); } struct ext_sym_list { @@ -2560,6 +2553,7 @@ int main(int argc, char **argv) struct module *mod; struct buffer buf = { }; char *kernel_read = NULL; + char *missing_namespace_deps = NULL; char *dump_write = NULL, *files_source = NULL; int opt; int err; @@ -2567,7 +2561,7 @@ int main(int argc, char **argv) struct ext_sym_list *extsym_iter; struct ext_sym_list *extsym_start = NULL; - while ((opt = getopt(argc, argv, "i:e:mnsT:o:awEd")) != -1) { + while ((opt = getopt(argc, argv, "i:e:mnsT:o:awEd:")) != -1) { switch (opt) { case 'i': kernel_read = optarg; @@ -2606,7 +2600,7 @@ int main(int argc, char **argv) sec_mismatch_fatal = 1; break; case 'd': - write_namespace_deps = 1; + missing_namespace_deps = optarg; break; default: exit(1); @@ -2654,8 +2648,8 @@ int main(int argc, char **argv) write_if_changed(&buf, fname); } - if (write_namespace_deps) - write_namespace_deps_files(); + if (missing_namespace_deps) + write_namespace_deps_files(missing_namespace_deps); if (dump_write) write_dump(dump_write); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index ad271bc6c313..fe6652535e4b 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -126,8 +126,8 @@ struct module { struct buffer dev_table_buf; char srcversion[25]; int is_dot_o; - // Required namespace dependencies - struct namespace_list *required_namespaces; + // Missing namespace dependencies + struct namespace_list *missing_namespaces; // Actual imported namespaces struct namespace_list *imported_namespaces; }; diff --git a/scripts/nsdeps b/scripts/nsdeps index dda6fbac016e..08db427a7fe5 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -27,15 +27,14 @@ generate_deps_for_ns() { } generate_deps() { - local mod_name=`basename $@ .ko` - local mod_file=`echo $@ | sed -e 's/\.ko/\.mod/'` - local ns_deps_file=`echo $@ | sed -e 's/\.ko/\.ns_deps/'` - if [ ! -f "$ns_deps_file" ]; then return; fi - local mod_source_files=`cat $mod_file | sed -n 1p \ + local mod=${1%.ko:} + shift + local namespaces="$*" + local mod_source_files=`cat $mod.mod | sed -n 1p \ | sed -e 's/\.o/\.c/g' \ | sed "s|[^ ]* *|${srctree}/&|g"` - for ns in `cat $ns_deps_file`; do - echo "Adding namespace $ns to module $mod_name (if needed)." + for ns in $namespaces; do + echo "Adding namespace $ns to module $mod.ko." generate_deps_for_ns $ns $mod_source_files # sort the imports for source_file in $mod_source_files; do @@ -52,7 +51,7 @@ generate_deps() { done } -for f in `cat $objtree/modules.order`; do - generate_deps $f -done - +while read line +do + generate_deps $line +done < modules.nsdeps From patchwork Tue Oct 29 12:38:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 178025 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp4815870ill; Tue, 29 Oct 2019 05:39:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJWczg9EHJ5YHOFTxgtXN9xeLtGLEpETAFbQ09rgAcpguURDnpCCswwadIkMfLo2p9J+hh X-Received: by 2002:a50:b966:: with SMTP id m93mr24979506ede.228.1572352753390; Tue, 29 Oct 2019 05:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572352753; cv=none; d=google.com; s=arc-20160816; b=LgaVzKuC6XYwsEqp8SrK4s+hH7DGLEGJRaZT1JDQl8OXr3EMWJC55u/Qm2pPJv3NBc p9K3R9xGxTzdDXPY5LOsoJjsahOh78vLqOz3Pe5GJPFZ3XCP27AqH+olB0wbu8pqAEUv MHdtEiar9g7mOUljzabgUA7vcaPUslGQp6zli/oBnYeMwTCBAcf9RoEu/Y06HzJwZH78 /PkvQSFwJ8lcTCXYrU/T6fHixG6evjNrrT9fiSdObHCvaq63Jxpj2rSvGnR1nJ2O3s4P Yn9dLAij5m9E0GhGtK35tjYa4bMN6zd4dReTdL1QVrJamhEO6YWq6W8yRMuyZrAlF/xj Mh2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=z/tV1UVFmLOh9LhEg5n7pGMfQ61W9oGUm9h6rNaYBKY=; b=mdR1ctQs8qA740qV1WQTammp2XjLUBUTAEA0Kbw9lPJDjYgFQfqDvPAj+Cx1/FoOdy upFk+gTBwh1iSjApE4escOAfTIM2JyFikHbLKILsTanVTPWtDvDIdNrIMykDDwWfpjap CDwZlaC+RewDtTT6rx6bCq/wgAydRhw0hFJFetD6tM+5MhhaFY+5aql+K4NPyb3ymeaD 316tS6TP08B+pt5VizCfKQUuwfdmOwGov4xq9dtxrPF8gnsc9+JvMecQWllD3qOX6OV0 L1DtTLrmE/d4GFUrs43XENP2IidWUr7IRRAe98RNXsuozujPYGs+SRwc21cNadCzEySJ JX6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="IF6A2H6/"; 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 f19si9957268eda.435.2019.10.29.05.39.13; Tue, 29 Oct 2019 05:39:13 -0700 (PDT) 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=@nifty.com header.s=dec2015msa header.b="IF6A2H6/"; 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 S2387527AbfJ2MjK (ORCPT + 26 others); Tue, 29 Oct 2019 08:39:10 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:34529 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731583AbfJ2MjI (ORCPT ); Tue, 29 Oct 2019 08:39:08 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id x9TCcFU8026616; Tue, 29 Oct 2019 21:38:20 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x9TCcFU8026616 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1572352701; bh=z/tV1UVFmLOh9LhEg5n7pGMfQ61W9oGUm9h6rNaYBKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IF6A2H6/659VDSshC51rM8eOxVwdf2Vq7bpkxUuGg9sky0oSfaGheBOHrJBCiZqId sQfatTY7oXNjFOfk89m6ybFLdM2RpDSMQYBTUgBGuCClMWfxPe+66QCy4KfaRDd0/C yMtdbMRElyCd8BFEh1WVLHsJQtV3xaWYeMItKGLRxIl375jvusaLN+YQsqfi7kBsvV Ppc9xa/KFVl4ygOm+N9/RiKzv+ChJR+z3g1+N5bVO4vKrOY6ws9IPRCpADS9W0jdiK al/EGogQTKc83NqQIZqarz5piWxLU87ATvRPpGYVer/EnHYncReYibZ0QLPgcl+T/I rPi+YR6Tx+IDg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Jessica Yu , Matthias Kaehlcke , Masahiro Yamada , Jonathan Corbet , Matthias Maennich , Michal Marek , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] scripts/nsdeps: support nsdeps for external module builds Date: Tue, 29 Oct 2019 21:38:08 +0900 Message-Id: <20191029123809.29301-4-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029123809.29301-1-yamada.masahiro@socionext.com> References: <20191029123809.29301-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Apparently, scripts/nsdeps is written to take care of only in-tree modules. Perhaps, this is not a bug, but just a design. At least, Documentation/core-api/symbol-namespaces.rst focuses on in-tree modules: Again, `make nsdeps` will eventually add the missing namespace imports for in-tree modules:: ^^^^^^^ Having said that, I already saw at least two people trying nsdeps for external module builds. So, it would be nice to support it. Reported-by: Steve French Reported-by: Jessica Yu Signed-off-by: Masahiro Yamada --- Documentation/core-api/symbol-namespaces.rst | 3 +++ Makefile | 1 + scripts/Makefile.modpost | 2 +- scripts/nsdeps | 10 ++++++++-- 4 files changed, 13 insertions(+), 3 deletions(-) -- 2.17.1 Tested-by: Jessica Yu Acked-by: Jessica Yu Reviewed-by: Matthias Maennich Tested-by: Matthias Maennich diff --git a/Documentation/core-api/symbol-namespaces.rst b/Documentation/core-api/symbol-namespaces.rst index 982ed7b568ac..9b76337f6756 100644 --- a/Documentation/core-api/symbol-namespaces.rst +++ b/Documentation/core-api/symbol-namespaces.rst @@ -152,3 +152,6 @@ in-tree modules:: - notice the warning of modpost telling about a missing import - run `make nsdeps` to add the import to the correct code location +You can also run nsdeps for external module builds. A typical usage is:: + + $ make -C M=$PWD nsdeps diff --git a/Makefile b/Makefile index 1e3f307bd49b..780a65493866 100644 --- a/Makefile +++ b/Makefile @@ -1007,6 +1007,7 @@ endif PHONY += prepare0 export MODORDER := $(extmod-prefix)modules.order +export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps ifeq ($(KBUILD_EXTMOD),) core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index da37128c3f9f..8359f8af5ee6 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -66,7 +66,7 @@ __modpost: else MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \ - $(if $(KBUILD_NSDEPS),-d modules.nsdeps) + $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) ifeq ($(KBUILD_EXTMOD),) MODPOST += $(wildcard vmlinux) diff --git a/scripts/nsdeps b/scripts/nsdeps index 08db427a7fe5..3b8a9e173ebf 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -21,6 +21,12 @@ if [ "$SPATCH_VERSION_NUM" -lt "$SPATCH_REQ_VERSION_NUM" ] ; then exit 1 fi +if [ "$KBUILD_EXTMOD" ]; then + src_prefix= +else + src_prefix=$srctree/ +fi + generate_deps_for_ns() { $SPATCH --very-quiet --in-place --sp-file \ $srctree/scripts/coccinelle/misc/add_namespace.cocci -D ns=$1 $2 @@ -32,7 +38,7 @@ generate_deps() { local namespaces="$*" local mod_source_files=`cat $mod.mod | sed -n 1p \ | sed -e 's/\.o/\.c/g' \ - | sed "s|[^ ]* *|${srctree}/&|g"` + | sed "s|[^ ]* *|${src_prefix}&|g"` for ns in $namespaces; do echo "Adding namespace $ns to module $mod.ko." generate_deps_for_ns $ns $mod_source_files @@ -54,4 +60,4 @@ generate_deps() { while read line do generate_deps $line -done < modules.nsdeps +done < $MODULES_NSDEPS From patchwork Tue Oct 29 12:38:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 178023 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp4815367ill; Tue, 29 Oct 2019 05:38:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsiCIYNSlrmzkg+VZZA2aVqfLEvqDXKmXVF59Z8YSUuUBUiKLXST5vTz5a6TG+Geok+jSX X-Received: by 2002:aa7:d714:: with SMTP id t20mr25952007edq.129.1572352729368; Tue, 29 Oct 2019 05:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572352729; cv=none; d=google.com; s=arc-20160816; b=Y9Vx/b5oi91YAB3XPU41uKyf+ww96S9fIDYiidKUNy2yLABZ0Em0WglWUPkbeZeKJB c7owSKHCSY+U4BpW6t9zVsqtfFgMc596l+Q9M+dhyw8o9JIeuBDT56AVyDxe37SNCqYP pNb1oczePF17VQMm+adKjpiuHIhm1WyB+nASq5WH3XdnNIhYk52lNpVwxMXcAJaLfmMX U6RQF5wPfyRTj+jl4kFBxHn4ysjdeGvcscYLJODhuN3zqq6/ehAKMEhODwEckhttsiWC AxiOf1W0ykBATGUIUY2G0N8Qa+OE6f3mFRYUFl2oipmk6ioh78ecOh2ULWwZ25p9NrlV QX7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=rRs8Ed7t4bAer/X1dc9tlKv3gE2rP5G57gkcJJvIIzs=; b=Tl/ZyjISVy7u/m2Xgyxl3Rr1IU60IyHV0WyousS1gixOL8PsZZXoDrouFvwXcfvh1H uvzow4yNwAzrldHV5Pjn2u+leMOA9Gdxmi9ySQ7oOKHex2WyHdTFdTJ3lz7prWRJ5TQJ Jhkdl3+zBjeZtMuzPjN7OMUy3W165MKPdKXfCujfzZeuW3A3yAaFRq8YJqMQAS4cZZje BTfK4UGt6tzeSBc2r3ck24v617GmybcVL4L3I/FYsbMPvhiTFRRSLFYJ+WSpczJyvawi thxjSqS4Uba9ud4Mt2DH0fAFUZw+ugI3A0EP+I7uyEJI7kczWLZ+KdfuKpE1FTNokcWz aRFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Wx5lpNCA; 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 c36si9730236edb.58.2019.10.29.05.38.49; Tue, 29 Oct 2019 05:38:49 -0700 (PDT) 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=@nifty.com header.s=dec2015msa header.b=Wx5lpNCA; 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 S1728390AbfJ2Min (ORCPT + 26 others); Tue, 29 Oct 2019 08:38:43 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:33928 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726711AbfJ2Min (ORCPT ); Tue, 29 Oct 2019 08:38:43 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id x9TCcFU9026616; Tue, 29 Oct 2019 21:38:21 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x9TCcFU9026616 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1572352702; bh=rRs8Ed7t4bAer/X1dc9tlKv3gE2rP5G57gkcJJvIIzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wx5lpNCAWh0/fyhSglgPtgut//wljqNN4vx7Lbqx1ZhuPpRivg83hoCLnyCcntuzu U9RPsoIpsytpjbkToeJY+5WYt82+HYbs0pJd3BtbJMfMcBPcgOHuPZ2a+NbVs/4KBY AKaFq3Ky3cZ2t+BemZLqYWnSPrH/mekrlSpwcMCUWODxeoUYzmpnP8MVzO2qdSAZdt s27bGUd7tePUX8QCrh9dwaykFQx/SvgZ/ao/EBBNfww0FW6fZ59oWvrTJFa6Sda5U6 aU/iw2JlhQxBCOIFNY5eUHLyP/Je4/BknAL4de9oZJP9A5eA20yaCwVQIkIN8cP014 Qgm4BCvojQSxw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Jessica Yu , Matthias Kaehlcke , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 4/4] mospost: remove unneeded local variable in contains_namespace() Date: Tue, 29 Oct 2019 21:38:09 +0900 Message-Id: <20191029123809.29301-5-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029123809.29301-1-yamada.masahiro@socionext.com> References: <20191029123809.29301-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The local variable, ns_entry, is unneeded. While I was here, I also cleaned up the comparison with NULL or 0. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.17.1 Reviewed-by: Matthias Maennich diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f7425f5d4ab0..f70b924f379f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -239,10 +239,8 @@ static struct symbol *find_symbol(const char *name) static bool contains_namespace(struct namespace_list *list, const char *namespace) { - struct namespace_list *ns_entry; - - for (ns_entry = list; ns_entry != NULL; ns_entry = ns_entry->next) - if (strcmp(ns_entry->namespace, namespace) == 0) + for (; list; list = list->next) + if (!strcmp(list->namespace, namespace)) return true; return false;