From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 502DBC10F13 for ; Sun, 14 Apr 2019 18:19:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A1FF206B7 for ; Sun, 14 Apr 2019 18:19:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555265973; bh=kD9vRivbEosoyxFlKSbrIsvAO+FzctUz9vxzFkyWS54=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=fPB9R/ZcSzgIC8fKuliqTR33wBaz8q0qW9xrrojJTc1rEhY6DEVitBw9RRiQPE2TA Shu+8ZYN7oq1NOzWntcevyZ7CVfvZ7ujXbxMvAHgIUqWg+O3ooEfi9Uas6AiHT0Zup QXisIP3/S7ARgq1FHm6IsSWB66KQIPQk+YqFLSK8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbfDNSTc (ORCPT ); Sun, 14 Apr 2019 14:19:32 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:46357 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726147AbfDNSTb (ORCPT ); Sun, 14 Apr 2019 14:19:31 -0400 Received: by mail-lf1-f65.google.com with SMTP id k18so2348772lfj.13 for ; Sun, 14 Apr 2019 11:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rAOJ4gAe+OR7+mGTTcB5DjuHBGEuf3sWqHZ+6DRVhDM=; b=IWtuEiNTXexwh0uZNYAhtk3ZlvBUjrkVq/rEkIKLKM68UfCOeb9vHLMInngaW23uig 7lTMl2vXgev7U476As4L2qQ3n2ZV3z4W2duYNPvGHihZPlmeyDJtb+6NbntpEtZou0Kt gMd59HDv29GLZe15Vu1tA5ydNDeyIUYeoQ+vc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rAOJ4gAe+OR7+mGTTcB5DjuHBGEuf3sWqHZ+6DRVhDM=; b=Z4usFx3bU0yhpWXDRPyfFiP0HjmhlIVPDjbWguzDob2VIWct1R4EAqbfSh7Pb03W8U QO5ES2dCG24mx5apuXDJ7/i0Azq2SrBY5iz76ynDAL+e51TheuZwYEbmRq5+nuiBt/Qs 6ZK91jWH0DokCjCUHwh2AGr2JAFcIk919Tf1M/cwZ+q9MUW94xiB28jO9Af/iNg3WNTK JOBPEG+8BfwgUxKYba65bHqRNYx94PkVaBzu66bFbK/reuS/k/tLoqYswuvkLTW9XrjO gwXT0WQ/5SjR7j4r5kxriB1St28MJXBgtscK0YAaLqzfHi4fsP6h1DMEidvoUblrtgG5 4mcg== X-Gm-Message-State: APjAAAUA9TWKeIBx6Xb1XH4UtPeaptxPqrHGv/S0WGVCrGMotisxwqc6 At2AVyVfspv9apWwlLTudthGUKi8CYE= X-Google-Smtp-Source: APXvYqzcLoZNLWppQwg+jAT25bS9Zr1RxpyoGFZ1S1b8VDGc3Lc8waVimkq7U4oap/VygShT7eLHmg== X-Received: by 2002:a19:ae11:: with SMTP id f17mr36348407lfc.12.1555265968787; Sun, 14 Apr 2019 11:19:28 -0700 (PDT) Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com. [209.85.208.170]) by smtp.gmail.com with ESMTPSA id r1sm9647002lfm.7.2019.04.14.11.19.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Apr 2019 11:19:27 -0700 (PDT) Received: by mail-lj1-f170.google.com with SMTP id f23so13522161ljc.0 for ; Sun, 14 Apr 2019 11:19:26 -0700 (PDT) X-Received: by 2002:a2e:9597:: with SMTP id w23mr30960447ljh.111.1555265966460; Sun, 14 Apr 2019 11:19:26 -0700 (PDT) MIME-Version: 1.0 References: <20190411175043.31207-1-joel@joelfernandes.org> In-Reply-To: From: Linus Torvalds Date: Sun, 14 Apr 2019 11:19:10 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RFC 1/2] Add polling support to pidfd To: Andy Lutomirski Cc: "Joel Fernandes (Google)" , LKML , Steven Rostedt , Daniel Colascione , Christian Brauner , Jann Horn , Suren Baghdasaryan , Alexey Dobriyan , Al Viro , Andrei Vagin , Andrew Morton , Arnd Bergmann , "Eric W. Biederman" , Kees Cook , Linux FS Devel , "open list:KERNEL SELFTEST FRAMEWORK" , Michal Hocko , Nadav Amit , Oleg Nesterov , Serge Hallyn , Shuah Khan , Stephen Rothwell , Taehee Yoo , Tejun Heo , Thomas Gleixner , Tycho Andersen Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Fri, Apr 12, 2019 at 2:33 PM Andy Lutomirski wrote: > > Are you sure? I admit I'm not all that familiar with the innards of > poll() on Linux, but I thought that the waitqueue only had to survive > long enough to kick the polling thread and did *not* have to survive > until poll() actually returned. That is *not* true by default. You can do that, but you need to make sure that your wakeup function is one that removed itself from the wait queues. You can do that with DEFINE_WAIT(name), which uses autoremove_wake_function(), or by using your own auto-removing wakeup function together with DEFINE_WAIT_FUNC() or init_waitqueue_func_entry(). But the default wake function does not remove on wakeup, and you'll have to be around until poll() itself tears down all the tables. In particular, the normal "poll_wait()" will use __pollwait, which does: init_waitqueue_func_entry(&entry->wait, pollwake); and pollwake() (which is thus what gets called at wake time) will not remove anything from the wait queue. So no, by default your wait queue has to stay around for the duration of poll() (ie the duration of the file descriptor, since poll() gets a reference to it). You *can* play games with pollwait functions (and with wait functions in general), but by default you should consider the wait function to stay around. Linus