Skip to contentSkip to conversation

oom-killer problem

DISCUSSION Daniel Ritz 6 participants 9 messages Jun 26, 2006 – Jul 5, 2006 Kbuild

lore
Share & tools
lore
#0 lore raw

hi

i got the same here. reason is a recent change that made modules always shows as module.mod. it breaks modprobe and probably many scripts..besides lsmod looking horrible.
stuff like this in modprobe.conf:

	install pcmcia_core /sbin/modprobe --ignore-install pcmcia_core; /sbin/modprobe pcmcia

makes modprobe fork/exec endlessly calling itself...until oom interrupts it... reverting the attached patch fixes the problem...

rgds
-daniel

From: Sam Ravnborg <[email protected]>
Date: Sat, 24 Jun 2006 20:50:18 +0000 (+0200)
Subject: kbuild: fix make -rR breakage
X-Git-Url: http://www.kernel.org/git/gitweb.cgi?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=e5c44fd88c146755da6941d047de4d97651404a9

kbuild: fix make -rR breakage

make failed to supply the filename when using make -rR and using $(*F) to get target filename without extension.
This bug was not reproduceable in small scale but using:
$(basename $(notdir $@)) fixes it with same functionality.

---

scripts/Kbuild.include +5 -0
@@ -13,6 +13,11 @@ space   := $(empty) $(empty)
 depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
 
 ###
+# basetarget equals the filename of the target with no extension.
+# So 'foo/bar.o' becomes 'bar'
+basetarget = $(basename $(notdir $@))
+
+###
 # Escape single quote for use in echo statements
 escsq = $(subst $(squote),'\$(squote)',$1)
 
scripts/Makefile.build +1 -1
@@ -117,7 +117,7 @@ $(real-objs-m:.o=.lst): quiet_modtag := 
 $(obj-m)              : quiet_modtag := [M]
 
 # Default for not multi-part modules
-modname = $(*F)
+modname = $(basetarget)
 
 $(multi-objs-m)         : modname = $(modname-multi)
 $(multi-objs-m:.o=.i)   : modname = $(modname-multi)
scripts/Makefile.host +4 -2
@@ -80,8 +80,10 @@ obj-dirs += $(host-objdirs)
 #####
 # Handle options to gcc. Support building with separate output directory
 
-_hostc_flags   = $(HOSTCFLAGS)   $(HOST_EXTRACFLAGS)   $(HOSTCFLAGS_$(*F).o)
-_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o)
+_hostc_flags   = $(HOSTCFLAGS)   $(HOST_EXTRACFLAGS)   \
+                 $(HOSTCFLAGS_$(basetarget).o)
+_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
+                 $(HOSTCXXFLAGS_$(basetarget).o)
 
 ifeq ($(KBUILD_SRC),)
 __hostc_flags	= $(_hostc_flags)
scripts/Makefile.lib +3 -3
@@ -82,12 +82,12 @@ obj-dirs	:= $(addprefix $(obj)/,$(obj-di
 #       than one module. In that case KBUILD_MODNAME will be set to foo_bar,
 #       where foo and bar are the name of the modules.
 name-fix = $(subst $(comma),_,$(subst -,_,$1))
-basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(*F)))"
+basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
 modname_flags  = $(if $(filter 1,$(words $(modname))),\
                  -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
 
-_c_flags       = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o)
-_a_flags       = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
+_c_flags       = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(basetarget).o)
+_a_flags       = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
 _cpp_flags     = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F))
 
 # If building the kernel in a separate objtree expand all occurrences
scripts/Makefile.modpost +1 -1
@@ -72,7 +72,7 @@ $(modules:.ko=.mod.c): __modpost ;
 # Step 5), compile all *.mod.c files
 
 # modname is set to make c_flags define KBUILD_MODNAME
-modname = $(*F)
+modname = $(basetarget)
 
 quiet_cmd_cc_o_c = CC      $@
       cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE)	\
#1 lore raw
Quoted 2 lines · Daniel Ritz

reverting the attached patch fixes the problem...

Michal, can you also confirm that just doing a simple revert of that one commit makes things work for you?

Sam, if I don't hear otherwise from you, and Michael confirms, I'll just revert it for now, and you can figure out how to fix it without breakage?

Linus

#2 lore raw
Quoted 8 lines · Linus Torvalds
Quoted 2 lines · Daniel Ritz

reverting the attached patch fixes the problem...

Michal, can you also confirm that just doing a simple revert of that one commit makes things work for you?

Yes I can confirm that.
(http://www.ussg.iu.edu/hypermail/linux/kernel/0606.3/0827.html)

Quoted 6 lines

Sam, if I don't hear otherwise from you, and Michael confirms, I'll just revert it for now, and you can figure out how to fix it without breakage?

Linus

Regards,
Michal

Signature · 3 lines
Michal K. K. Piotrowski
LTG - Linux Testers Group
(http://www.stardust.webpages.pl/ltg/wiki/)
#3 lore raw
In reply to Linus Torvalds
Quoted 11 lines · Linus Torvalds
Quoted 2 lines · Daniel Ritz

reverting the attached patch fixes the problem...

Michal, can you also confirm that just doing a simple revert of that one commit makes things work for you?

Sam, if I don't hear otherwise from you, and Michael confirms, I'll just revert it for now, and you can figure out how to fix it without breakage?

I will try to find time during the weekend to track down the cause of this.
But by reverting said patch you also have to revert:
566f81ca598f80de03e80a9a743e94b65b4e017e

This is the patch where make -rR is enabled and that one initally caused problems for ia64.

Sam

#4 lore raw
Quoted 15 lines · Sam Ravnborg
Quoted 9 lines · Linus Torvalds
Quoted 2 lines · Daniel Ritz

reverting the attached patch fixes the problem...

Michal, can you also confirm that just doing a simple revert of that one commit makes things work for you?

Sam, if I don't hear otherwise from you, and Michael confirms, I'll just revert it for now, and you can figure out how to fix it without breakage?

I will try to find time during the weekend to track down the cause of this.
But by reverting said patch you also have to revert:
566f81ca598f80de03e80a9a743e94b65b4e017e

Quoted 5 lines

This is the patch where make -rR is enabled and that one initally caused problems for ia64.

Sam

this little something on top (instead of reverting the patch) also fixes the problem for me. because the module name depends on the name of module.mod.o it's necessary to call basename twice on that, otherwise the name ends up being module.mod

maybe we could also define basetarget in Kbuild.include as:

	basetarget = $(basename $(basename $(notdir $@)))

but that might be too much...dunno

scripts/Makefile.build +1 -1
index 3cb445c..e66f6dc 100644
@@ -117,7 +117,7 @@ quiet_modtag := $(empty)   $(empty)
 $(obj-m)              : quiet_modtag := [M]
 
 # Default for not multi-part modules
-modname = $(basetarget)
+modname = $(basename $(basetarget))
 
 $(multi-objs-m)         : modname = $(modname-multi)
 $(multi-objs-m:.o=.i)   : modname = $(modname-multi)
scripts/Makefile.modpost +1 -1
index e83613e..17f3d31 100644
@@ -72,7 +72,7 @@ # Declare generated files as targets for
 # Step 5), compile all *.mod.c files
 
 # modname is set to make c_flags define KBUILD_MODNAME
-modname = $(basetarget)
+modname = $(basename $(basetarget))
 
 quiet_cmd_cc_o_c = CC      $@
       cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE)	\
#5 lore raw

Review

Quoted 4 lines · Daniel Ritz

# Default for not multi-part modules

(quoted diff) +1 -1
-modname = $(basetarget)
+modname = $(basename $(basetarget))

Is there some way to make it clear _what_ the suffix we expect to remove actually is in GNU make? Ie the "shell" kind of "basename" logic.

Ie, I'd personally be happier with a

	modname = $(basename $(basetarget) .mod)

kind of thing (yeah, this obviously does _not_ work)

Gah. I've happily been trying to avoid having to know all the GNU Makefile magic. Sam, does Dans patch make sense and can you explain what went wrong? I'd happily revert the revert and instead use Dans patch, I just want to understand it..

Linus

#6 lore raw
Quoted 11 lines · Linus Torvalds (on Tue, 27 Jun 2006 18:15:46 -0700 (PDT)) wrote:

Review

Quoted 4 lines · Daniel Ritz

# Default for not multi-part modules

(quoted diff) +1 -1
-modname = $(basetarget)
+modname = $(basename $(basetarget))

Is there some way to make it clear _what_ the suffix we expect to remove actually is in GNU make? Ie the "shell" kind of "basename" logic.

Quoted 5 lines

Ie, I'd personally be happier with a

	modname = $(basename $(basetarget) .mod)

kind of thing (yeah, this obviously does _not_ work)

modname = $(patsubst %.mod,%,$(basetarget))

should do it (untested).

#7 lore raw
Quoted 14 lines · Keith Owens
Quoted 13 lines · Linus Torvalds (on Tue, 27 Jun 2006 18:15:46 -0700 (PDT)) wrote:

Review

Quoted 4 lines · Daniel Ritz

# Default for not multi-part modules

(quoted diff) +1 -1
-modname = $(basetarget)
+modname = $(basename $(basetarget))

Is there some way to make it clear _what_ the suffix we expect to remove actually is in GNU make? Ie the "shell" kind of "basename" logic.

Ie, I'd personally be happier with a

Quoted 8 lines
Quoted 3 lines
	modname = $(basename $(basetarget) .mod)

kind of thing (yeah, this obviously does _not_ work)

modname = $(patsubst %.mod,%,$(basetarget))

should do it (untested).

yep, works fine.

#8 lore raw
In reply to Keith Owens
Quoted 8 lines · Keith Owens
Quoted 5 lines · Linus Torvalds (on Tue, 27 Jun 2006 18:15:46 -0700 (PDT)) wrote:

Ie, I'd personally be happier with a

	modname = $(basename $(basetarget) .mod)

kind of thing (yeah, this obviously does _not_ work)

modname = $(patsubst %.mod,%,$(basetarget))

Sorry to come in so late on this; this email's been sitting in my outbox for a week. Here's a mildly simpler alternative:

modname = $(basetarget:.mod=)

A slightly more flexible alternative:

modname = $(basetarget:%.mod=%)

Cheers,
Kyle Moffett