Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2062465yba; Fri, 19 Apr 2019 11:21:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFJSm8UGwlcM9mGEmZDr7pCt6jvrXRAZZ/Vywo0dzq2FSYhmYe7icg5j9IBouegr2POoqA X-Received: by 2002:a17:902:820c:: with SMTP id x12mr5065770pln.199.1555698097538; Fri, 19 Apr 2019 11:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555698097; cv=none; d=google.com; s=arc-20160816; b=StXPMIl/WDlIg95QDF1FcsJX6SfqA3ThRYqzpafxBMR1HdZxfLh7E8goOJytAHLwFH pdpF/7ZxiagVf5A6GHjMljfxhuuc/U3rJqlkstraEChNetPWHNmFANLmm5sIqkYVMboE VpmvNp9jZS/Qod1bg2Jzee4DcXOn/N6pIvSUXd5EjO4WGGIr1BYENdb6NopUQRzsfNcP v0M+B5w7NmNYEu3fMwBtNVBiH+mnLeh6EKAM4P/HwfPkaAa5wM+zbj1A5+T8Q3CA9p2o 0yZVaXFmfhW7NYO6wq1NiVNKk/73p3cW3d0xdHPiglbDez3jxbErqrIqcXVQsKqrA/Bk o4xg== 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=pBOpjqSVRQcgDQIE5fFC46VuJi1oW5SikRV9Jte1vfo=; b=OBMRRX+BR1jbpR7DVX/MU3x0QaUK0XGGSo46+paXJdlVPRamn+VImeMC4g5kiGf5Qf xeJ03WDqGgiqAeIp9xjNGE6xf2vtfpXb65FMT9QdzzGLMEBUtsHewVqAK4GI5LU5GmOB /zU4OQ2Snn/TvkO4hL2fhbSKSDV0y+svAgiJvpGSY733CNlGHEFALLXUSREhvZTHSKMR EQ1EcAoeyhnA6g7AWsefQI3zYwU3ZMB0fu2kHF5PJl4k/3tz5XicqJjd50ngbXPJ1nL6 Vg/2jMBxUTqnzK/q6g0HjORyacaw7RdkXeRHSc4NjkOmNOk+UibuhEFYKDbURK6tvrvf S1Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=L1Yv37BB; 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 89si5946756pfs.243.2019.04.19.11.21.22; Fri, 19 Apr 2019 11:21:37 -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=@joelfernandes.org header.s=google header.b=L1Yv37BB; 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 S1727709AbfDSSUG (ORCPT + 99 others); Fri, 19 Apr 2019 14:20:06 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44203 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727676AbfDSSUE (ORCPT ); Fri, 19 Apr 2019 14:20:04 -0400 Received: by mail-pf1-f193.google.com with SMTP id y13so2868905pfm.11 for ; Fri, 19 Apr 2019 11:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pBOpjqSVRQcgDQIE5fFC46VuJi1oW5SikRV9Jte1vfo=; b=L1Yv37BBepAhyKYzKJlE13j25B5kCNPn2+XRnAenXKKgY9NwF4JLxdXQro+0ZbbSwQ GYKoSuWf/wQ8Bgeeh+ZrKVtSjSaR7HV87OL/IFJEHebVoiCGJYqtW04iDFBvEDwrpM9s AQ4+LDp0xIsqQ3jvW6wK06zOXivtsqBGt+014= 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=pBOpjqSVRQcgDQIE5fFC46VuJi1oW5SikRV9Jte1vfo=; b=tCKw7tLTlgf1Uon2NE3Ugv7mIQNf13ibigGM/aea1VhsgUS/qx/QanrtClzr5rk2PI Dx7+zxrNMw2QtDVrQLG/rHOGFWOdhnXYdcoAjdrxlrJJa5ODOAd5NHykodzRj1xbCmjV ync3seGlxBZn1FE7C60NVzkUo01ae837MOogxI+9WFO+oe21RyaXOzV/CeRL6CpzmwoO yzbAW3oqIBcq+59tN3dc/AJ8U1ebv0zUAKY7l1rMS2RFI3pPS9RLJxfCUEdNL7A2AUzX +jMa/r2JJGsMP2bA9viyPxl2yCuUyc9MSxlEu6UirVNJHv/d3DIoVVHeUnr8WuYPmYww /MNQ== X-Gm-Message-State: APjAAAVvRpGoIz4heRTsw5ynLxyC5rPV4jGwfEp+FQfKqi+mC4RYVwj4 2OtEMg32aeFujUt3F8ZZjxrMJg== X-Received: by 2002:aa7:8212:: with SMTP id k18mr5357059pfi.50.1555697581663; Fri, 19 Apr 2019 11:13:01 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id j20sm7036847pfn.84.2019.04.19.11.12.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Apr 2019 11:13:00 -0700 (PDT) Date: Fri, 19 Apr 2019 14:12:58 -0400 From: Joel Fernandes To: Oleg Nesterov Cc: linux-kernel@vger.kernel.org, luto@amacapital.net, rostedt@goodmis.org, dancol@google.com, christian@brauner.io, jannh@google.com, surenb@google.com, torvalds@linux-foundation.org, Alexey Dobriyan , Al Viro , Andrei Vagin , Andrew Morton , Arnd Bergmann , "Eric W. Biederman" , Kees Cook , linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, Michal Hocko , Nadav Amit , Serge Hallyn , Shuah Khan , Stephen Rothwell , Taehee Yoo , Tejun Heo , Thomas Gleixner , kernel-team@android.com, Tycho Andersen Subject: Re: [PATCH RFC 1/2] Add polling support to pidfd Message-ID: <20190419181258.GA251571@google.com> References: <20190411175043.31207-1-joel@joelfernandes.org> <20190416120430.GA15437@redhat.com> <20190416192051.GA184889@google.com> <20190417130940.GC32622@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190417130940.GC32622@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just returned to work today dealing with "life" issues, apologies for the delays in replying. :) On Wed, Apr 17, 2019 at 03:09:41PM +0200, Oleg Nesterov wrote: > On 04/16, Joel Fernandes wrote: > > > > On Tue, Apr 16, 2019 at 02:04:31PM +0200, Oleg Nesterov wrote: > > > > > > Could you explain when it should return POLLIN? When the whole process exits? > > > > It returns POLLIN when the task is dead or doesn't exist anymore, or when it > > is in a zombie state and there's no other thread in the thread group. > > IOW, when the whole thread group exits, so it can't be used to monitor sub-threads. > > just in case... speaking of this patch it doesn't modify proc_tid_base_operations, > so you can't poll("/proc/sub-thread-tid") anyway, but iiuc you are going to use > the anonymous file returned by CLONE_PIDFD ? Yes, I am going to be converting to non-proc file returned by CLONE_PIDFD, yes. (But I am still catching up with all threads and will read the latest on whether we are still consider proc pidfds, last I understand - we are not). > > > Then all you need is > > > > > > !task || task->exit_state && thread_group_empty(task) > > > > Yes this works as well, all the tests pass with your suggestion so I'll > > change it to that. Although I will the be giving up returing EPOLLERR if the > > task_struct doesn't exit. We don't need that, but I thought it was cool to > > return it anyway. > > OK, task == NULL means that it was already reaped by parent, pid_nr is free, > probably useful.... Ok I will add that semantic as well then. > > > Please do not use EXIT_DEAD/EXIT_ZOMBIE. And ->wait_pidfd should probably > > > live in task->signal_struct. > > > > About wait_pidfd living in signal_struct, that wont work since the waitqueue > > has to survive for the duration of the poll system call. > > That is why I said this will need the additional cleanup in free_signal_struct(). > But I was wrong, somehow I forgot that free_poll_entry() needs wq_head->lock ;) > so this will need much more complications, lets forget it... Ok np :) > > Also the waitqueue living in struct pid solves the de_thread() issue I > > mentioned later in the following thread and in the commit message: > > https://lore.kernel.org/patchwork/comment/1257175/ > > Hmm... > > 2. By including the struct pid for the waitqueue means that during > de_exec, the thread doing de_thread() automatically gets the new > waitqueue/pid even though its task_struct is different. > > this one? > > this is not true, or I do not understand... > > it gets the _same_ (old, not new) PIDTYPE_TGID pid even if it changes task_struct. > But probably this is what you actually meant, because this is what your patch wants > or I am totally confused. Yes, that's what I meant, sorry. > And note that exec/de_thread doesn't change ->signal_struct, so I do not understand > you anyway. Nevermind. Yes right, but the signal_struct would suffer from the waitqueue lifetime issue anyway so we can't use it. The current patch works well for everything. thanks, - Joel