Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3661768ybc; Thu, 21 Nov 2019 11:41:19 -0800 (PST) X-Google-Smtp-Source: APXvYqzpuPmmLk/76XY91iyg2QJT/0UvsKIJtazG1XamDuy5FUI6QBCx13DCSd6S/s5/0TX5ifFg X-Received: by 2002:adf:9d87:: with SMTP id p7mr13027926wre.11.1574365279265; Thu, 21 Nov 2019 11:41:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574365279; cv=none; d=google.com; s=arc-20160816; b=zOZjhEmLym2Z+MPEb6FANxeulSJUMszpbpG57M8orwz2XqUaLIWUKPWFt+NZzKaU4k i88uY09UxCJsGyJbRmBzle2cWkRr5TczRfFU8Vov5OYibL0LH04wnb5Zf78RG7Pn5xSW su+5DTGxBmJBrYJZbLL/z9+I4n/4KNNLhll+47GNNXVFxJBqdOdQDgtHCFMspiTecDw1 XOMZAeZjFxqPxRGK994ZhfCilhgv8pvNgLZbJ76n9qmi/hg6MSxOMtQ/YkEFlwV6yHdK uI4vWINk07UV0SsmsJAs6XbCFwyyjhVc62wXQNlGcXhs4Wr50cTIULbxHjefvttAxWCE GqUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=COatpzDuZgl9WMg8hp9kMY5ElrlJCYz6DmuSXPX+4MI=; b=uO6hmHPtrSB75u6MDl7gBD6GGasYo/unkQcHIguH8k/nENxVlxllgCRyLw/ymkuB5y k4tQMlZCJTwFdsRAvJrpWyr4BrMavvujJHW+7RL7K7Ce5L9NRGlsQ0QXD5TtXJ94yX0H q2vSh132IV7PT1KCjiYl9sMEqLKaViR9fA3gTatgZkYGwxkvnBfIt2Q6EmjM1Woim46Y rQMuF2cJdx6MdVwVagOHNzKTblLuQomgI85UE/P0w5GV4E0ILokTeNmo/l7kz9G5ReaP EBIiAJqmkVrfKybBHpStQrl6/qCkC7PWmw7Cb7f9jQsY82eoHfY6+CkolfXbi74k5WGc jC0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XMfzQIYt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d25si3239215edb.19.2019.11.21.11.40.54; Thu, 21 Nov 2019 11:41:19 -0800 (PST) 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=@chromium.org header.s=google header.b=XMfzQIYt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726546AbfKUTjH (ORCPT + 99 others); Thu, 21 Nov 2019 14:39:07 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:47070 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726658AbfKUTjH (ORCPT ); Thu, 21 Nov 2019 14:39:07 -0500 Received: by mail-pj1-f66.google.com with SMTP id a16so1935810pjs.13 for ; Thu, 21 Nov 2019 11:39:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=COatpzDuZgl9WMg8hp9kMY5ElrlJCYz6DmuSXPX+4MI=; b=XMfzQIYtZ59LpXSVL0ZsuREdO/zTlCEpjB3yrDBDcaEUp07a/rl9MG1vi8zsNQniFI EY26nphwA7xJfu/RQBhzFdqIgC5vy6jR7lMWx1+YO0LZvM3Rq7kJqBjSHxvvD+7SiwDF YoEbTBxvincX2cA/1K7Y11EdYqH2RY+fv7Uks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=COatpzDuZgl9WMg8hp9kMY5ElrlJCYz6DmuSXPX+4MI=; b=GKlEqT+4HcmmWqD8DOQZr5obRtH8wxkdcOTxNh3q3cD8TUnK069T/8wBNAXoQoLMz+ +7WzBQ+1gbXDsyQhv2b//9Za997WRzApQUeAomU1xbHW7wnEgqjLSL5ZnUeltI5azO0c h/9ivgRyq2vL3YwGyZw8mxrzacZxve1clmU/YyXwCg1IZBj4VfuMzYKJ6WKECiYyU2LY MSs/HEToixFJ7OyEmuCzU6LaGGAUa4lKDLK1ytBZOJsUIJGklcsd4RKY45QTbLR0uSdR ajPrD0/6+C+7sE1KZ3ZqzKhwAjMfzUlgJG1pspIZJBY3zcwGEWnpDM6AVfIU4N9gM6ME FZhw== X-Gm-Message-State: APjAAAVIcizrTox0EjRpEY5rLYwe5RT4aE1QLQXtrY8ZFduIpR4i4YGa 6Ym8oQEwaP3Z5y91ZfmC8FGvLg== X-Received: by 2002:a17:90a:23e2:: with SMTP id g89mr13232298pje.127.1574365145234; Thu, 21 Nov 2019 11:39:05 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id k13sm3978316pgl.69.2019.11.21.11.39.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 11:39:04 -0800 (PST) Date: Thu, 21 Nov 2019 11:39:03 -0800 From: Kees Cook To: Rasmus Villemoes Cc: Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] docs, parallelism: Rearrange how jobserver reservations are made Message-ID: <201911211122.02F3646@keescook> References: <20191121000304.48829-1-keescook@chromium.org> <20191121000304.48829-4-keescook@chromium.org> <656afebc-fc60-7502-40a3-52d2662c1d27@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <656afebc-fc60-7502-40a3-52d2662c1d27@rasmusvillemoes.dk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 21, 2019 at 09:09:37AM +0100, Rasmus Villemoes wrote: > On 21/11/2019 01.03, Kees Cook wrote: > > diff --git a/Documentation/sphinx/parallel-wrapper.sh b/Documentation/sphinx/parallel-wrapper.sh > > new file mode 100644 > > index 000000000000..a416dbfd2025 > > --- /dev/null > > +++ b/Documentation/sphinx/parallel-wrapper.sh > > @@ -0,0 +1,25 @@ > > +#!/bin/sh > > +# SPDX-License-Identifier: GPL-2.0+ > > +# > > +# Figure out if we should follow a specific parallelism from the make > > +# environment (as exported by scripts/jobserver-exec), or fall back to > > +# the "auto" parallelism when "-jN" is not specified at the top-level > > +# "make" invocation. > > + > > +sphinx="$1" > > +shift || true > > + > > +parallel="${PARALLELISM:-1}" > > +if [ ${parallel} -eq 1 ] ; then > > + auto=$(perl -e 'open IN,"'"$sphinx"' --version 2>&1 |"; > > + while () { > > + if (m/([\d\.]+)/) { > > + print "auto" if ($1 >= "1.7") > > + } > > + } > > + close IN') > > + if [ -n "$auto" ] ; then > > + parallel="$auto" > > + fi > > +fi > > +exec "$sphinx" "-j$parallel" "$@" > > I don't understand this logic. If the parent failed to claim any tokens > (likely because the top make and its descendants are already running 16 > gcc processes), just let sphinx run #cpus jobs in parallel? That doesn't > make sense - it gets us back to the "we've now effectively injected K > tokens to the jobserver that weren't there originally". I was going to say "but jobserver-exec can't be running unless there are available slots", but I see the case is "if there are 16 slots and jobserver-exec gets _1_, it should not fall back to 'auto'". > From the comment above, what you want is to use "auto" if the top > invocation was simply "make docs". Well, I kind of disagree with falling > back to auto in that case; the user can say "make -j8 docs" and the > wrapper is guaranteed to claim them all. But if you really want, the > jobserver-count script needs to detect and export the "no parallelism > requested at top level" in some way distinct from "PARALLELISM=1", > because that's ambiguous. Right -- failure needs to be be distinct from "only 1 available". > > + # Read out as many jobserver slots as possible. > > + while True: > > + try: > > + slot = os.read(reader, 1) > > + jobs += slot > > I'd just try to slurp in 8 or 16 tokens at a time, there's no reason to > limit to 1 in each loop. Good point. I will change that. > > +rc = subprocess.call(sys.argv[1:]) > > + > > +# Return all the actually reserved slots. > > +if len(jobs): > > + os.write(writer, jobs) > > + > > +sys.exit(rc) > > What happens if the child dies from a signal? Will this correctly > forward that information? As far as I understand, yes, signal codes are passed through via the exit code (i.e. see WIFSIGNALED, etc). > Similarly (and the harder problem), what happens when our parent wants > to send its child a signal to say "stop what you're doing, return the > tokens, brush your teeth and go to bed". We should forward that signal > to the real job instead of just dying, losing track of both the tokens > we've claimed as well as orphaning the child. Hm, hm. I guess I could pass INT and TERM to the child. That seems like the most sensible best-effort here. It seems "make" isn't only looking at the slots to determine process management. -- Kees Cook