Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11104965ybi; Thu, 25 Jul 2019 10:04:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzppzuBG60FHIp0rhDROMa5yRhcMvVw49Qpf/RXOxFe7X0qIYwxh+MPkJJBIh4PfftJYQ8t X-Received: by 2002:aa7:84d1:: with SMTP id x17mr17646195pfn.188.1564074272453; Thu, 25 Jul 2019 10:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564074272; cv=none; d=google.com; s=arc-20160816; b=RjEDS5NcGiF9hTzepl8TqKE+GF+36Q2scw9xEncQEWa5pLfQvM0AAuLrKe+FOX9/vC /e5pipB1L4FsvyJifN2x4EG8dQ0MVNbYeqXTj2qxHTIp5lOWz0ujRrYx2cMvukM1O/OJ q+ZHlukWczfgVm5uu1VpWmexxR3tOh7yuDQEpuBjiS12JxuH/eXBateDHIM82+FLfSp4 /Agk4GqxUcT0McO+uy4lVXVzz90EikGG41YisyCEeu5nlPhzkGBQyWnNfxbBhnwjRw2y dzTRmEH0UAvHakxcbW40OLlXpUCeRli7u4iW7jxpQ78ni+ufmFIBrLbJxaapDyWzSrbq H6lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9aKNcQbqtSEQ2QLViWMxlIXutxeIxOIYk6E7Syx9R3M=; b=QUuq9sKjLbg9lveFw3hXciNs/L+GIwQ3Kei6mPtMqh+CEOuFWihKI+M0EWgyndFjIJ mbkvLke60Hg5lDTKbMitNFeVV4ob73HHaP1CFICy5949t0drbx0IGz7GSVn9Miu8dg4R 9nFoqenST4N9Q+PjLItpstaQA4wgSSb8JEnjOTSLG/ozSp86jcfxRC4r+6DCWrDtIcpY dCkrGOjIfzPvnEdHdg0jTG0uk4+N+v5Se+aqMY0gnbn5XJbEB0KvEYTCtnKYncDh5PgO q4kCFZL8ix/mTLApZff7SAH+AS1S6H3kA3t2FzTqVQq0KW0ReXLPXQLpDS5JY3Gafchv +Mcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=HzJjnq8I; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x185si19854335pfx.243.2019.07.25.10.04.16; Thu, 25 Jul 2019 10:04:32 -0700 (PDT) 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=@brauner.io header.s=google header.b=HzJjnq8I; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728144AbfGYM0z (ORCPT + 99 others); Thu, 25 Jul 2019 08:26:55 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:38118 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727890AbfGYM0z (ORCPT ); Thu, 25 Jul 2019 08:26:55 -0400 Received: by mail-ed1-f65.google.com with SMTP id r12so15268213edo.5 for ; Thu, 25 Jul 2019 05:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9aKNcQbqtSEQ2QLViWMxlIXutxeIxOIYk6E7Syx9R3M=; b=HzJjnq8ICgDrR/7Xt9pOiXw5RVUlib1TORuUxu71HvMJqO65/Ux6jTfikdMemxdpXs xFB0F/XS/GROuLQWSgIn2x9kn5aWhHaQWsS8cmP+5v21cBaEOV391x1lc/EP2gfOdFwM 2Vuhy4xdru8Z3/6rvFqVnx0F+ShoAKvnJmHJYKdk+CK2Q2zSwzDo4NAg0J83Vn8RKwMO napUZgvr/ZqSc5Sm4vU5FKroJjmMGEn/1ctbCa8Iqi0bp+cKh5D5l2TQuhfESD+ZlwLy DjgBv9l3jBj+1KHDP9CQEXJ0x9Pml9WH+WdNCariBSFYNSwP3XuzOvmrukVquHywW4nl K0ug== 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:user-agent; bh=9aKNcQbqtSEQ2QLViWMxlIXutxeIxOIYk6E7Syx9R3M=; b=HKwqok0J0C9PEQl/KxiSw0sbTkZcFOrltY8LumPmzV93pjQTRkkUCM/naw2QJa5fbC 4nw1Uv5vTD2LpTmquYrGe7QNLSqe+DOKcWV13n08Kq/t5X54ZhF4/rtIaOLmOkic+Rtb 6yZ4RRR5bocACeb1L32EG2MFLyYKk+29+myCh3buo2rbwzngcm7h2Db88U8uLTy/3Ckq hgTiDY074RYwUhEiB9TR4GngpDlRL+2vhsKwLSYb7u6kkh4faVkpLuc7H1Ssiv/nSS7z Zg3Rowv/OIXgSUE1i8VjEUBZnJ+h5LzqdXBwAaiv5R3lXINRbLV7VGimEMVA0tLBGk8O ZNvg== X-Gm-Message-State: APjAAAUzBrv7Ug+aOn5ENZSy//u4ft8bOMn0VpweStf98bIq/lg984sF oyZcQ8F0q/NEdRloEYR7RQs= X-Received: by 2002:a17:906:28c4:: with SMTP id p4mr68122099ejd.181.1564057613670; Thu, 25 Jul 2019 05:26:53 -0700 (PDT) Received: from brauner.io (ip5b40f7ec.dynamic.kabel-deutschland.de. [91.64.247.236]) by smtp.gmail.com with ESMTPSA id t13sm13350326edd.13.2019.07.25.05.26.51 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 25 Jul 2019 05:26:52 -0700 (PDT) Date: Thu, 25 Jul 2019 14:26:51 +0200 From: Christian Brauner To: Oleg Nesterov Cc: linux-kernel@vger.kernel.org, arnd@arndb.de, ebiederm@xmission.com, keescook@chromium.org, joel@joelfernandes.org, tglx@linutronix.de, tj@kernel.org, dhowells@redhat.com, jannh@google.com, luto@kernel.org, akpm@linux-foundation.org, cyphar@cyphar.com, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, kernel-team@android.com, Ingo Molnar , Peter Zijlstra , linux-api@vger.kernel.org Subject: Re: [PATCH 4/5] pidfd: add CLONE_WAIT_PID Message-ID: <20190725122650.4i3arct5rpchqmyt@brauner.io> References: <20190724144651.28272-1-christian@brauner.io> <20190724144651.28272-5-christian@brauner.io> <20190725103543.GF4707@redhat.com> <20190725104006.7myahvjtnbcgu3in@brauner.io> <20190725112503.GG4707@redhat.com> <20190725114359.GH4707@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190725114359.GH4707@redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 25, 2019 at 01:43:59PM +0200, Oleg Nesterov wrote: > Or. We can change wait_consider_task() to not clear ->notask_error if > WXXX and the child is PF_WAIT_PID. > > This way you can "safely" use wait() without WNOHANG, it won't block if > all the children which can report an even are PF_WAIT_PID. > > But I do not understand your use-cases, I have no idea if this can help One usecase (among others listed in the commit message) are shared libraries. P_ALL is usually something you can't really use in a shared library because you have no idea what else might be fork()ed off. Only the main program can use this but none of the auxiliary libraries that it uses. The other way around you want to be able fork() off something without affecting P_ALL in the main program. The key is that you want to be able to create child processes in a shared library without the main programing having to know about this so that it can use P_ALL and never get stuff from the library. Assume you have a project with a main loop with a million things happening in that mainloop like some gui app running an avi video. For example, gtk uses gstreamer which forks off all codecs in child processes which are sandboxed for security. So gstreamer is using helper processes in the background which are my children now. Now I'm creating four more additional helper processes as well. Now, in my (glib, qt whatever) mainloop on SIGCHLD some part of the app is checking with WNHOANG and finds a process has exited. It's cleaning this thing up now but it's not a process it wanted to clean up. The other part of the app is now doing waitid(P_PID, pid) but will find the process already gone it wanted to reap. I hope I'm expressing this well enough.