]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
dtrace: support SDT in single-file modules
authorNick Alcock <nick.alcock@oracle.com>
Thu, 19 May 2016 20:45:56 +0000 (21:45 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 20 May 2016 10:38:29 +0000 (11:38 +0100)
A limitation of long standing in the SDT machinery is that it didn't
support modules that were implemented entirely in one file.  This is
because the SDT stubs generation machinery (which emits zero-byte
assembler stubs for all DTrace probe points) was implemented at the
point at which multi-file modules are linked into a single file prior to
modpost.  Since single-file modules *have* no such stage, they never got
their stubs, and probes never fired.  This becomes essential to fix so
that perf_events probes will work, because some of those are in
single-file modules.

We fix it by tearing out the sdtstub code from its prior home in
Makefile.build, and moving it into the late modpost stage, at the same
point at which sdtinfo files are generated.  We use the same prerequites
trick as is used for CTF files to link the sdtstub files into the
resulting modules; because this all happens at the very last possible
moment, it shares the same code path for single- and multifile modules,
and is a good bit simpler to boot (no need to manipulate the link
process or transform filenames intricately during stub generation).

There is one additional wrinkle: because the dtrace probes are now
always undefined until the last minute, we must adjust modpost to
disregard all undefined symbols that start "__dtrace_probe_".

Orabug: 23316392
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Acked-by: Kris Van Hees <kris.van.hees@oracle.com>
scripts/Makefile.build
scripts/Makefile.modpost
scripts/mod/modpost.c

index 63645acf5d7ab93e8ece77a5c54d565423f082f9..01df30af4d4a50f7ffec08993115b2e412128d1f 100644 (file)
@@ -380,38 +380,9 @@ $($(subst $(obj)/,,$(@:.o=-y)))), $^)
 quiet_cmd_link_multi-y = LD      $@
 cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
 
-ifdef CONFIG_DTRACE
-
-# We need secondary expansion for the %.sdtstub.S creation rule
-.SECONDEXPANSION:
-
-sdtgen = $(srctree)/scripts/dtrace_sdt.sh
-
-quiet_cmd_sdtstub = SDTSTB  $@
-      cmd_sdtstub = $(sdtgen) sdtstub $@ \
-                             $(filter $(addprefix $(obj)/, \
-                               $($(subst $(obj)/,,$(@:.sdtstub.S=-objs))) \
-                               $($(subst $(obj)/,,$(@:.sdtstub.S=-y)))), \
-                               $(subst |,,$(multi-objs-m)))
-
-$(multi-used-m:.o=.sdtstub.S) : %.sdtstub.S: $(multi-objs-m)
-       $(call if_changed,sdtstub)
-
-$(multi-used-m:.o=.sdtstub.o) : %.sdtstub.o: %.sdtstub.S
-       $(call if_changed,as_o_S)
-
-$(multi-used-m) : %.o: %.sdtstub.o
-
-quiet_cmd_link_multi-m = LD [M]  $@
-cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $*.sdtstub.o $(cmd_secanalysis)
-
-else
-
 quiet_cmd_link_multi-m = LD [M]  $@
 cmd_link_multi-m = $(cmd_link_multi-y)
 
-endif
-
 $(multi-used-y): FORCE
        $(call if_changed,link_multi-y)
 $(call multi_depend, $(multi-used-y), .o, -objs -y)
index 9039cd5fb4d0d3e457ca1f4f17ad4f65628edbd4..2ad9dd919661b44cce714a9239e070f580e1babb 100644 (file)
@@ -105,7 +105,8 @@ vmlinux.o: FORCE
 $(symverfile):         __modpost ;
 $(modules:.ko=.mod.c): __modpost ;
 
-# Step 5), compile all *.mod.c files (includes the generation of SDT data)
+# Step 5), compile all *.mod.c files (includes the generation of SDT data
+# and SDT stubs)
 
 # modname is set to make c_flags define KBUILD_MODNAME
 modname = $(notdir $(@:.mod.o=))
@@ -114,6 +115,9 @@ quiet_cmd_cc_o_c = CC      $@
       cmd_cc_o_c = $(CC) $(c_flags) $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE) \
                   -I$(dir $@) -c -o $@ $<
 
+quiet_cmd_as_o_S = AS      $@
+      cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
+
 ifdef CONFIG_DTRACE
 
 sdtgen = $(srctree)/scripts/dtrace_sdt.sh
@@ -121,16 +125,30 @@ sdtgen = $(srctree)/scripts/dtrace_sdt.sh
 quiet_cmd_sdtinfo = SDTINF  $@
       cmd_sdtinfo = $(sdtgen) sdtinfo $@ $< kmod
 
+quiet_cmd_sdtstub = SDTSTB  $@
+      cmd_sdtstub = $(sdtgen) sdtstub $@ $<
+
 $(modules:.ko=.sdtinfo.c): %.sdtinfo.c: %.o
        $(call cmd,sdtinfo)
 
+$(modules:.ko=.sdtstub.S) : %.sdtstub.S: %.o
+       $(call cmd,sdtstub)
+
 $(modules:.ko=.mod.o): %.mod.o: %.mod.c %.sdtinfo.c FORCE
        $(call if_changed_dep,cc_o_c)
+
+$(modules:.ko=.sdtstub.o): %.sdtstub.o: %.sdtstub.S
+       $(call if_changed,as_o_S)
+
+module-sdt-modular-prereq = %.sdtstub.o
+
 else
 
 $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
        $(call if_changed_dep,cc_o_c)
 
+module-sdt-modular-prereq =
+
 endif
 
 targets += $(modules:.ko=.mod.o)
@@ -264,7 +282,7 @@ quiet_cmd_ld_ko_o = LD [M]  $@
                             $(patsubst $(ctf-dir)/%,,$(filter-out FORCE,$^)) && \
                    $(OBJCOPY) $(module-ctf-flags) $@.tmp $@ && rm -f $@.tmp
 
-$(modules): %.ko : %.o %.mod.o $(module-ctfs-modular-prereq) FORCE
+$(modules): %.ko : %.o %.mod.o $(module-sdt-modular-prereq) $(module-ctfs-modular-prereq) FORCE
        $(call cmd_touch_ctf)
        $(call if_changed,ld_ko_o)
 
index 148af0d92eae63ac5ecfce0339b92f55b720142b..8ac053304ad3dc89971d83f956934c06cf5f707d 100644 (file)
@@ -2158,7 +2158,8 @@ static int add_versions(struct buffer *b, struct module *mod)
        for (s = mod->unres; s; s = s->next) {
                exp = find_symbol(s->name);
                if (!exp || exp->module == mod) {
-                       if (have_vmlinux && !s->weak) {
+                       if (have_vmlinux && !s->weak &&
+                           !strstarts(s->name, "__dtrace_probe_")) {
                                if (warn_unresolved) {
                                        warn("\"%s\" [%s.ko] undefined!\n",
                                             s->name, mod->name);