NetBSD Problem Report #48367

From dholland@macaran.localdomain  Wed Nov  6 02:07:05 2013
Return-Path: <dholland@macaran.localdomain>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 71486A6174
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  6 Nov 2013 02:07:05 +0000 (UTC)
Message-Id: <20131106001055.727206E255@macaran.localdomain>
Date: Tue,  5 Nov 2013 19:10:55 -0500 (EST)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@NetBSD.org
Subject: make(1) fails to parallelize in subdirs
X-Send-Pr-Version: 3.95

>Number:         48367
>Category:       bin
>Synopsis:       make(1) fails to parallelize in subdirs
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 06 02:10:00 +0000 2013
>Closed-Date:    Sun Aug 24 09:29:51 +0000 2014
>Last-Modified:  Sun Aug 24 09:29:51 +0000 2014
>Originator:     David A. Holland
>Release:        NetBSD 6.99.23 (20130911)
>Organization:
>Environment:
System: NetBSD macaran 6.99.23 NetBSD 6.99.23 (MACARAN) #19: Wed Sep 11 20:37:54 EDT 2013 dholland@macaran:/usr/src/sys/arch/amd64/compile/MACARAN amd64
Architecture: x86_64
Machine: amd64

/usr/bin/make:
     $NetBSD: crt0.S,v 1.3 2011/07/01 02:59:05 joerg Exp $
     $NetBSD: crt0-common.c,v 1.13 2013/01/31 22:24:25 matt Exp $
     $NetBSD: crti.S,v 1.1 2010/08/07 18:01:35 joerg Exp $
     $NetBSD: crtbegin.S,v 1.2 2010/11/30 18:37:59 joerg Exp $
     $NetBSD: arch.c,v 1.63 2012/06/12 19:21:50 joerg Exp $
     $NetBSD: buf.c,v 1.25 2012/04/24 20:26:58 sjg Exp $
     $NetBSD: compat.c,v 1.93 2013/09/02 19:26:42 sjg Exp $
     $NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $
     $NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $
     $NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $
     $NetBSD: hash.c,v 1.19 2009/01/24 10:59:09 dsl Exp $
     $NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $
     $NetBSD: main.c,v 1.224 2013/09/04 15:38:26 sjg Exp $
     $NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $
     $NetBSD: parse.c,v 1.191 2013/08/28 21:56:49 sjg Exp $
     $NetBSD: str.c,v 1.34 2012/03/03 23:16:47 dholland Exp $
     $NetBSD: suff.c,v 1.70 2013/05/18 13:13:34 sjg Exp $
     $NetBSD: targ.c,v 1.57 2012/06/12 19:21:51 joerg Exp $
     $NetBSD: trace.c,v 1.11 2008/12/28 18:31:51 christos Exp $
     $NetBSD: var.c,v 1.184 2013/09/04 15:38:26 sjg Exp $
     $NetBSD: util.c,v 1.53 2012/06/04 22:45:05 sjg Exp $
     $NetBSD: strlist.c,v 1.4 2009/01/24 11:59:39 dsl Exp $
     $NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $
     $NetBSD: lstAppend.c,v 1.14 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstAtEnd.c,v 1.13 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstAtFront.c,v 1.13 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstClose.c,v 1.11 2006/10/27 21:37:25 dsl Exp $
     $NetBSD: lstConcat.c,v 1.16 2008/12/13 15:19:29 dsl Exp $
     $NetBSD: lstDatum.c,v 1.13 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstDeQueue.c,v 1.14 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstDestroy.c,v 1.16 2008/12/13 15:19:29 dsl Exp $
     $NetBSD: lstDupl.c,v 1.16 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstEnQueue.c,v 1.13 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstFind.c,v 1.15 2009/01/23 21:58:28 dsl Exp $
     $NetBSD: lstFindFrom.c,v 1.15 2009/01/23 21:58:28 dsl Exp $
     $NetBSD: lstFirst.c,v 1.12 2008/12/13 15:19:29 dsl Exp $
     $NetBSD: lstForEach.c,v 1.13 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstForEachFrom.c,v 1.17 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstInit.c,v 1.12 2008/12/13 15:19:29 dsl Exp $
     $NetBSD: lstInsert.c,v 1.14 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstIsAtEnd.c,v 1.13 2008/02/15 21:29:50 christos Exp $
     $NetBSD: lstIsEmpty.c,v 1.11 2008/12/13 15:19:29 dsl Exp $
     $NetBSD: lstLast.c,v 1.12 2008/12/13 15:19:29 dsl Exp $
     $NetBSD: lstMember.c,v 1.13 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstNext.c,v 1.12 2008/12/13 15:19:29 dsl Exp $
     $NetBSD: lstOpen.c,v 1.12 2008/12/13 15:19:29 dsl Exp $
     $NetBSD: lstRemove.c,v 1.14 2008/12/13 15:19:29 dsl Exp $
     $NetBSD: lstReplace.c,v 1.13 2009/01/23 21:26:30 dsl Exp $
     $NetBSD: lstSucc.c,v 1.13 2008/12/13 15:19:29 dsl Exp $
     $NetBSD: lstPrev.c,v 1.3 2008/12/13 15:19:29 dsl Exp $
     $NetBSD: crtend.S,v 1.1 2010/08/07 18:01:34 joerg Exp $
     $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:35 joerg Exp $

>Description:

Make sub-jobs no longer parallelize in some cases. It isn't clear yet
exactly which cases or why. This is definitely a regression, in case
anyone was wondering.

I discovered this in a make from 20130911; the problem persists in
today's make (20131105).

A pkgsrc make binary from August 2012 that I had lying around is not
affected.

>How-To-Repeat:

Unpack the following, then do

	cd muck
	make -j8 all		(does not parallelize)
	make -j8 all2		(does parallelize)

Whether it's parallelizing or not is readily distinguished because of
the per-job target name headings in the output -- there should be one
for each of the ten echo jobs in the subdirectory.

begin 600 muck.tgz
M'XL(`+N&>5(``^W504^#,!0'<*[V4[P#6>"RO992=)X\>#+[$`@ED!5(-HE?
MWT*FAQDU2P::^/]=7FD)E/QY:3L4^V!FS)HS9E\S8U+EZ^2]3F.I5&(23I3.
M_+R4FM,@G7MCH^'XDA^(@K+NG<N[\JO[7FMKW1(;6E;K\]^T^:P_P27Y2Z7'
M_)4?(/\%?.2_V>5[6S7.7O\=+)G--_E+:<[SUZQ,P-??RF?_//_C\+R]%V)=
M]0=JJ.E(DJ*$-*5D**-;NB/)8KR+JKX/HR86I[H5-[:H>PH;L;9=Z1\@Q&]_
M#5QJZO_Y6G_R4__[Q?/S/Y$R0_\O0.3.^4Z.BI+&4X!6*PJCW</38QR+<4WY
@Q=,$^4MT.`````````````````#`'_4&=W+D30`H``!6
`
end

>Fix:

no idea yet.

>Release-Note:

>Audit-Trail:
From: Andreas Gustafsson <gson@gson.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Wed, 6 Nov 2013 22:47:29 +0200

 I'm auto-bisecting this.
 -- 
 Andreas Gustafsson, gson@gson.org

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Wed, 6 Nov 2013 23:53:50 +0000

 On Wed, Nov 06, 2013 at 08:50:00PM +0000, Andreas Gustafsson wrote:
  >  I'm auto-bisecting this.

 neat, thanks :-)

 -- 
 David A. Holland
 dholland@netbsd.org

From: Andreas Gustafsson <gson@gson.org>
To: gnats-bugs@NetBSD.org, sjg@NetBSD.org
Cc: 
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Thu, 7 Nov 2013 13:04:44 +0200

 Using an automated binary search, I have now narrowed down the time
 when the problem started to this commit by sjg:

   2013.06.05.03.59.43 sjg src/usr.bin/make/job.c 1.173

 -- 
 Andreas Gustafsson, gson@gson.org

From: "Simon J. Gerraty" <sjg@juniper.net>
To: Andreas Gustafsson <gson@gson.org>
Cc: <gnats-bugs@NetBSD.org>
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Thu, 7 Nov 2013 08:42:39 -0800

 Thanks - will take a look

 On Thu, 7 Nov 2013 13:04:44 +0200, Andreas Gustafsson writes:
 >Using an automated binary search, I have now narrowed down the time
 >when the problem started to this commit by sjg:
 >
 >  2013.06.05.03.59.43 sjg src/usr.bin/make/job.c 1.173

From: Andreas Gustafsson <gson@gson.org>
To: "Simon J. Gerraty" <sjg@juniper.net>, dholland@eecs.harvard.edu
Cc: <gnats-bugs@NetBSD.org>
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Thu, 7 Nov 2013 19:30:17 +0200

 Simon J. Gerraty wrote:
 > The makefile is wrong.

 I will leave it to dholland to respond to this since it's his PR;
 I just did the bisection.
 -- 
 Andreas Gustafsson, gson@gson.org

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Thu, 7 Nov 2013 18:24:55 +0000

 On Thu, Nov 07, 2013 at 05:35:00PM +0000, Andreas Gustafsson wrote:
  >  Simon J. Gerraty wrote:
  >  > The makefile is wrong.

 Where did this come from? It's not in gnats, nor has it appeared in
 any of the usual places poorly-directed gnats mail goes.

  >  I will leave it to dholland to respond to this since it's his PR;
  >  I just did the bisection.

 All right: how is the makefile wrong? My first reaction is "bollocks".

 -- 
 David A. Holland
 dholland@netbsd.org

From: "Simon J. Gerraty" <sjg@juniper.net>
To: Andreas Gustafsson <gson@gson.org>
Cc: <gnats-bugs@NetBSD.org>
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Thu, 7 Nov 2013 09:03:58 -0800

 The makefile is wrong.
 According to make(1) you need .MAKE on targets which are supposed to
 pass on the jobs queue.

 What's really odd is that all2 "works"
 If you add .MAKE to all:

 make -j8 all 
 --- all ---
 (cd mack && make)
 --- foo1 ---
 --- foo2 ---
 --- foo3 ---
 --- foo4 ---
 --- foo5 ---
 --- foo6 ---
 --- foo7 ---
 --- foo8 ---
 --- foo4 ---
 echo 4
 4
 --- foo9 ---
 --- foo6 ---
 echo 6
 6

 etc.

 As per log change in 1.173 fixes a serious decriptor leak, 
 which is probably why the makefile in question may have previously
 worked.

 On Thu, 7 Nov 2013 13:04:44 +0200, Andreas Gustafsson writes:
 >Using an automated binary search, I have now narrowed down the time
 >when the problem started to this commit by sjg:
 >
 >  2013.06.05.03.59.43 sjg src/usr.bin/make/job.c 1.173
 >
 >-- 
 >Andreas Gustafsson, gson@gson.org

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Thu, 7 Nov 2013 18:48:47 +0000

 On Thu, Nov 07, 2013 at 06:35:00PM +0000, Simon J. Gerraty wrote:
  >  The makefile is wrong.
  >  According to make(1) you need .MAKE on targets which are supposed to
  >  pass on the jobs queue.

 That is not and never has been true:

      .MAKE     Execute the commands associated with this target even if the -n
                or -t options were specified.  Normally used to mark recursive
                make's.

 I cannot see anything else in the man page which documents additional
 behavior for .MAKE.

 Furthermore, few if any deployed makefiles will have this tag
 everywhere.

 Please fix the behavior; it is a serious regression. 

 -- 
 David A. Holland
 dholland@netbsd.org

From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Thu, 7 Nov 2013 19:49:21 +0000

 On Thu, Nov 07, 2013 at 06:35:00PM +0000, Simon J. Gerraty wrote:
 > The following reply was made to PR bin/48367; it has been noted by GNATS.
 > 
 >  The makefile is wrong.
 >  According to make(1) you need .MAKE on targets which are supposed to
 >  pass on the jobs queue.

 IIRC you should only need to use ${MAKE}.

 The 'problem' is probably that when running:
 	(cd mack && $(MAKE))
 the change tries to stop it passing the job token pipe fds into the shell.

 	David

 -- 
 David Laight: david@l8s.co.uk

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Thu, 7 Nov 2013 19:31:07 +0000

 On Thu, Nov 07, 2013 at 07:25:00PM +0000, David Laight wrote:
  >  On Thu, Nov 07, 2013 at 06:35:00PM +0000, Simon J. Gerraty wrote:
  >  > The following reply was made to PR bin/48367; it has been noted by GNATS.
  >  > 
  >  >  The makefile is wrong.
  >  >  According to make(1) you need .MAKE on targets which are supposed to
  >  >  pass on the jobs queue.
  >  
  >  IIRC you should only need to use ${MAKE}.
  >  
  >  The 'problem' is probably that when running:
  >  	(cd mack && $(MAKE))
  >  the change tries to stop it passing the job token pipe fds into the shell.

 That doesn't explain why it works if run via all2.

 But I'm assuming sjg understands what he did and can fix or revert it...

 -- 
 David A. Holland
 dholland@netbsd.org

From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Thu, 7 Nov 2013 20:15:48 +0000

 On Thu, Nov 07, 2013 at 07:35:01PM +0000, David Holland wrote:
 > The following reply was made to PR bin/48367; it has been noted by GNATS.
 > 
 > From: David Holland <dholland-bugs@netbsd.org>
 > To: gnats-bugs@NetBSD.org
 > Cc: 
 > Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
 > Date: Thu, 7 Nov 2013 19:31:07 +0000
 > 
 >  On Thu, Nov 07, 2013 at 07:25:00PM +0000, David Laight wrote:
 >   >  On Thu, Nov 07, 2013 at 06:35:00PM +0000, Simon J. Gerraty wrote:
 >   >  > The following reply was made to PR bin/48367; it has been noted by GNATS.
 >   >  > 
 >   >  >  The makefile is wrong.
 >   >  >  According to make(1) you need .MAKE on targets which are supposed to
 >   >  >  pass on the jobs queue.
 >   >  
 >   >  IIRC you should only need to use ${MAKE}.
 >   >  
 >   >  The 'problem' is probably that when running:
 >   >  	(cd mack && $(MAKE))
 >   >  the change tries to stop it passing the job token pipe fds into the shell.
 >  
 >  That doesn't explain why it works if run via all2.

 I bet make is only closing fd it opens.
 The make process that runs ${MAKE} all will be passed the job pipe
 fds - and I bet it doesn't make them close-on-exec.
 So all of it's children will find the job pipe.

 	David

 -- 
 David Laight: david@l8s.co.uk

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48367: make(1) fails to parallelize in subdirs
Date: Fri, 8 Nov 2013 08:08:21 +0000

 On Thu, Nov 07, 2013 at 07:50:00PM +0000, David Laight wrote:
  >  >  That doesn't explain why it works if run via all2.
  >  
  >  I bet make is only closing fd it opens.
  >  The make process that runs ${MAKE} all will be passed the job pipe
  >  fds - and I bet it doesn't make them close-on-exec.
  >  So all of it's children will find the job pipe.

 That's probably it.

 -- 
 David A. Holland
 dholland@netbsd.org

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48367 CVS commit: src/usr.bin/make
Date: Wed, 16 Jul 2014 11:33:41 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Wed Jul 16 15:33:41 UTC 2014

 Modified Files:
 	src/usr.bin/make: job.c make.h parse.c

 Log Message:
 PR/48367: David A. Holland: Mark possible submake nodes so that we can
 avoid closing the job pipe on exec for them in order to make recursive
 makes work in parallel.


 To generate a diff of this commit:
 cvs rdiff -u -r1.176 -r1.177 src/usr.bin/make/job.c
 cvs rdiff -u -r1.92 -r1.93 src/usr.bin/make/make.h
 cvs rdiff -u -r1.194 -r1.195 src/usr.bin/make/parse.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 24 Aug 2014 09:29:51 +0000
State-Changed-Why:
Christos's commit fixed the overt problems I was seeing.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.