diff mbox

btrfs-progs: Add dependencies explicitly to fix a parallel build issue

Message ID 1379466661-27973-1-git-send-email-rongqing.li@windriver.com (mailing list archive)
State Under Review, archived
Headers show

Commit Message

li rongqing Sept. 18, 2013, 1:11 a.m. UTC
From: Roy Li <rongqing.li@windriver.com>

The dependencies of "all: version.h" or other similar ones can not
fix the parallel build failure, only reduce the times; In fact,
many *.o files require version.h file.

	#grep '#include "version.h"' ./ -r
	./btrfs-corrupt-block.c:#include "version.h"
	./btrfs.c:#include "version.h"
	./btrfs-image.c:#include "version.h"
	./cmds-filesystem.c:#include "version.h"
	./btrfs-show-super.c:#include "version.h"
	./btrfs-select-super.c:#include "version.h"
	./cmds-restore.c:#include "version.h"
	./btrfs-find-root.c:#include "version.h"
	./mkfs.c:#include "version.h"
	./btrfs-zero-log.c:#include "version.h"
	./btrfs-defrag.c:#include "version.h"
	./cmds-chunk.c:#include "version.h"
	./btrfstune.c:#include "version.h"
	./btrfs-calc-size.c:#include "version.h"
	./btrfs-map-logical.c:#include "version.h"
	./cmds-check.c:#include "version.h"
	./btrfs-debug-tree.c:#include "version.h"

Signed-off-by: Roy Li <rongqing.li@windriver.com>
---
 Sorry, The patch [btrfs-progs: fix parallel build] sent by me on Sep 3
can not fix the build failure, when build enough times on a 16 core cpu,
the build failure happens again, so I refix it again.


 Makefile |    6 ++++++
 1 file changed, 6 insertions(+)

Comments

Eric Sandeen Sept. 18, 2013, 1:51 a.m. UTC | #1
On 9/17/13 8:11 PM, rongqing.li@windriver.com wrote:
> From: Roy Li <rongqing.li@windriver.com>
> 
> The dependencies of "all: version.h" or other similar ones can not
> fix the parallel build failure, only reduce the times; In fact,
> many *.o files require version.h file.
> 
> 	#grep '#include "version.h"' ./ -r
> 	./btrfs-corrupt-block.c:#include "version.h"
> 	./btrfs.c:#include "version.h"
> 	./btrfs-image.c:#include "version.h"
> 	./cmds-filesystem.c:#include "version.h"
> 	./btrfs-show-super.c:#include "version.h"
> 	./btrfs-select-super.c:#include "version.h"
> 	./cmds-restore.c:#include "version.h"
> 	./btrfs-find-root.c:#include "version.h"
> 	./mkfs.c:#include "version.h"
> 	./btrfs-zero-log.c:#include "version.h"
> 	./btrfs-defrag.c:#include "version.h"
> 	./cmds-chunk.c:#include "version.h"
> 	./btrfstune.c:#include "version.h"
> 	./btrfs-calc-size.c:#include "version.h"
> 	./btrfs-map-logical.c:#include "version.h"
> 	./cmds-check.c:#include "version.h"
> 	./btrfs-debug-tree.c:#include "version.h"
> 
> Signed-off-by: Roy Li <rongqing.li@windriver.com>
> ---
>  Sorry, The patch [btrfs-progs: fix parallel build] sent by me on Sep 3
> can not fix the build failure, when build enough times on a 16 core cpu,
> the build failure happens again, so I refix it again.
> 
> 
>  Makefile |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index c43cb68..a7c259c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -81,6 +81,12 @@ endif
>  	@echo "    [CC]     $@"
>  	$(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<
>  
> +btrfs-corrupt-block.o btrfs.o btrfs-image.o cmds-filesystem.o:version.h
> +btrfs-show-super.o btrfs-select-super.o cmds-restore.o:version.h
> +btrfs-find-root.o mkfs.o btrfs-zero-log.o btrfs-defrag.o cmds-chunk.o:version.h
> +btrfstune.o btrfs-calc-size.o btrfs-map-logical.o cmds-check.o:version.h
> +btrfs-debug-tree.o:version.h
> +
>  %.static.o: %.c
>  	@echo "    [CC]     $@"
>  	$(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(STATIC_CFLAGS) -c $< -o $@
> 

I think this can be done more cleanly, I'll send a patch.

-Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
li rongqing Sept. 18, 2013, 1:55 a.m. UTC | #2
On 09/18/2013 09:51 AM, Eric Sandeen wrote:
>>   	@echo "    [CC]     $@"
>> >  	$(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(STATIC_CFLAGS) -c $< -o $@
>> >
> I think this can be done more cleanly, I'll send a patch.
>
> -Eric
>
>

Thanks, expect your patch


-Roy
David Sterba Sept. 18, 2013, 2:51 p.m. UTC | #3
On Wed, Sep 18, 2013 at 09:11:01AM +0800, rongqing.li@windriver.com wrote:
> From: Roy Li <rongqing.li@windriver.com>
> 
> The dependencies of "all: version.h" or other similar ones can not
> fix the parallel build failure, only reduce the times; In fact,
> many *.o files require version.h file.
> 
> 	#grep '#include "version.h"' ./ -r
> 	./btrfs-corrupt-block.c:#include "version.h"
> 	./btrfs.c:#include "version.h"
> 	./btrfs-image.c:#include "version.h"
> 	./cmds-filesystem.c:#include "version.h"
> 	./btrfs-show-super.c:#include "version.h"
> 	./btrfs-select-super.c:#include "version.h"
> 	./cmds-restore.c:#include "version.h"
> 	./btrfs-find-root.c:#include "version.h"
> 	./mkfs.c:#include "version.h"
> 	./btrfs-zero-log.c:#include "version.h"
> 	./btrfs-defrag.c:#include "version.h"
> 	./cmds-chunk.c:#include "version.h"
> 	./btrfstune.c:#include "version.h"
> 	./btrfs-calc-size.c:#include "version.h"
> 	./btrfs-map-logical.c:#include "version.h"
> 	./cmds-check.c:#include "version.h"
> 	./btrfs-debug-tree.c:#include "version.h"
> 
> Signed-off-by: Roy Li <rongqing.li@windriver.com>
> ---
>  Sorry, The patch [btrfs-progs: fix parallel build] sent by me on Sep 3
> can not fix the build failure, when build enough times on a 16 core cpu,
> the build failure happens again, so I refix it again.

I'm running make -j all the time but haven't seen the build fail due to
missing version.h for a long time. With this patch or the previous one
or with Eric's, all fine. The generated dependency files contain
version.h so make has complete information how to order the rules.

The dependency files are generated by an implicit rule .c -> .o.d, so
there should be no problem for any of the files listed above.

If you think the patch "btrfs-progs: fix parallel build" does not help
much I'll drop it.


david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
li rongqing Sept. 22, 2013, 1:06 a.m. UTC | #4
On 09/18/2013 10:51 PM, David Sterba wrote:
> On Wed, Sep 18, 2013 at 09:11:01AM +0800, rongqing.li@windriver.com wrote:
>> From: Roy Li <rongqing.li@windriver.com>
>>
>> The dependencies of "all: version.h" or other similar ones can not
>> fix the parallel build failure, only reduce the times; In fact,
>> many *.o files require version.h file.
>>
>> 	#grep '#include "version.h"' ./ -r
>> 	./btrfs-corrupt-block.c:#include "version.h"
>> 	./btrfs.c:#include "version.h"
>> 	./btrfs-image.c:#include "version.h"
>> 	./cmds-filesystem.c:#include "version.h"
>> 	./btrfs-show-super.c:#include "version.h"
>> 	./btrfs-select-super.c:#include "version.h"
>> 	./cmds-restore.c:#include "version.h"
>> 	./btrfs-find-root.c:#include "version.h"
>> 	./mkfs.c:#include "version.h"
>> 	./btrfs-zero-log.c:#include "version.h"
>> 	./btrfs-defrag.c:#include "version.h"
>> 	./cmds-chunk.c:#include "version.h"
>> 	./btrfstune.c:#include "version.h"
>> 	./btrfs-calc-size.c:#include "version.h"
>> 	./btrfs-map-logical.c:#include "version.h"
>> 	./cmds-check.c:#include "version.h"
>> 	./btrfs-debug-tree.c:#include "version.h"
>>
>> Signed-off-by: Roy Li <rongqing.li@windriver.com>
>> ---
>>   Sorry, The patch [btrfs-progs: fix parallel build] sent by me on Sep 3
>> can not fix the build failure, when build enough times on a 16 core cpu,
>> the build failure happens again, so I refix it again.
>
> I'm running make -j all the time but haven't seen the build fail due to
> missing version.h for a long time. With this patch or the previous one
> or with Eric's, all fine. The generated dependency files contain
> version.h so make has complete information how to order the rules.
>

I want to know how many cores your cpu has? I can not reproduce it on
my 2 cores cpu, but it always happens when run on a server which is
a 16 cores cpu and "make -j20"


> The dependency files are generated by an implicit rule .c -> .o.d, so
> there should be no problem for any of the files listed above.
>

Do you means the below:

.c.o:
         $(Q)$(check) $<
         @echo "    [CC]     $@"
         $(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<


-Roy



> If you think the patch "btrfs-progs: fix parallel build" does not help
> much I'll drop it.
>
>
> david
>
>
David Sterba Sept. 23, 2013, 12:26 p.m. UTC | #5
On Sun, Sep 22, 2013 at 09:06:39AM +0800, Rongqing Li wrote:
> I want to know how many cores your cpu has? I can not reproduce it on
> my 2 cores cpu, but it always happens when run on a server which is
> a 16 cores cpu and "make -j20"

Depends on what you call a core, I've tested this on a box with 8 cpu
cores and 64 logical cpus. I can clearly see that the build is stalled
for a few moments at '[SH] version.h' before it proceeds to '[CC] ...'.

> >The dependency files are generated by an implicit rule .c -> .o.d, so
> >there should be no problem for any of the files listed above.
> 
> Do you means the below:
> 
> .c.o:
>         $(Q)$(check) $<
>         @echo "    [CC]     $@"
>         $(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<

Rather

%.o.d: %.c
        $(Q)$(CC) -MM -MG -MF $@ -MT $(@:.o.d=.o) -MT $(@:.o.d=.static.o) -MT $@ $(AM_CFLAGS) $(CFLAGS) $<

the .o.d files are included at the end of Makefile, I'm not completely
sure that they get included before the .c.o rule is processed. That way
the .o.d files would be empty and the dependency on version.h missing.

david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Makefile b/Makefile
index c43cb68..a7c259c 100644
--- a/Makefile
+++ b/Makefile
@@ -81,6 +81,12 @@  endif
 	@echo "    [CC]     $@"
 	$(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c $<
 
+btrfs-corrupt-block.o btrfs.o btrfs-image.o cmds-filesystem.o:version.h
+btrfs-show-super.o btrfs-select-super.o cmds-restore.o:version.h
+btrfs-find-root.o mkfs.o btrfs-zero-log.o btrfs-defrag.o cmds-chunk.o:version.h
+btrfstune.o btrfs-calc-size.o btrfs-map-logical.o cmds-check.o:version.h
+btrfs-debug-tree.o:version.h
+
 %.static.o: %.c
 	@echo "    [CC]     $@"
 	$(Q)$(CC) $(DEPFLAGS) $(AM_CFLAGS) $(STATIC_CFLAGS) -c $< -o $@