Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2425965rdb; Mon, 5 Feb 2024 06:21:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfTQXr9zmDzwMLiwMvsY8+5HxC3jG3o+hGR4u0G49K8bcGeyh2SJwdQClFBExTpuc0MqeK X-Received: by 2002:aa7:c986:0:b0:55e:bc29:6fcb with SMTP id c6-20020aa7c986000000b0055ebc296fcbmr4622667edt.10.1707142880925; Mon, 05 Feb 2024 06:21:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707142880; cv=pass; d=google.com; s=arc-20160816; b=jVTCZfLl40IENaCRiTeuQkyNj6vr59Phl2lklaX6OSSIE1ghuHZGNx87nZC789DDa/ Z4LQnqCcrYEWUv7CndY3DQQNsvwhfMmde27XNxB1YcwqL7ZYVOn/3qisCx3uolCIgVTc LTU3UPvBTdwD/3bOOfeUp5stLKqvNLJzVxE0JnE50o4QnCA5MbIMmuB6CUl7xvxzaWoj +zr0aZYxPG+7WGCXriePhZd+bZMBtizoNX6QYOy2bfJkMmGxvl49bmwj0qp9YcQerprx xCcRiBIvEa92uRvVvFS273gqaww8A7HKtxmYt4h5WDvZTxt+z70UIqsbfg5BxazWiU/+ pTeA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date:dkim-signature; bh=11pxIPHjBBl92wQMC3DFzCqQJYEHlgWDIYJq9X2o8Gc=; fh=0TiyksyPmTftk7SM+6cIqy0HK4cfU7/b7bjG/vPKD6I=; b=xgJPaAjPfhC+DcJV7X3FBvYHZOuN03OuHtG/ez+fZbi9Tlt1FDM7H4+j5YAhPIBVef yE078KjQOILCzCBzZdoW1uB3NYTRcpFrKjHyF1rTRZSS5/MQxoFdnUq4yyqqWN/ifSnJ eoUYg/c+S7+NLc77CmkzErO9WpFL7+Qxi60Ob2LNorhZAAPjZgyzRP2fJ6xS7CnIr+7A UT1VbVPe3103G14VdEnhqw85LUVTrzFLYD4/aYhEkZ3J/p4VoeOVVwBdHLU1ZnpVtTa0 BuM94IYRJGbeZ4Kb4eL+kgfBJ36y+C9/ycIgAb0Vzw8EqsB5btaxkrIgvgJvBabw0Y0m toQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="a/gSCdSr"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-52798-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52798-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCUerX1Xutj+kbzUb7Dudv+nJvlsGoPcvE2W6KS8ecIX4GlCQkIx3BAc5c5uvyXFRgv0jIwMZf5IomB8IyvGeK5aGfTELrKFOfyQCQHuVA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bl20-20020a056402211400b0056054177f7fsi1688165edb.635.2024.02.05.06.21.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 06:21:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52798-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="a/gSCdSr"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-52798-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52798-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8D4861F26140 for ; Mon, 5 Feb 2024 14:15:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9F5424B5B; Mon, 5 Feb 2024 14:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="a/gSCdSr" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8241A2374E for ; Mon, 5 Feb 2024 14:15:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707142513; cv=none; b=L/jhz5xJIpfnWayL5BZpw878M1H4eDTi/W2yqIwlnto5Pd1hIaM4laW5cHRgI67fnOi+71y0Gp9dufWCp36aEt+9GPXfUrMZJAIIcAR4euMl3hw7cjWAzdx1CM2gfoBv10q6WJ83oG7mfyoFXE9/bXptaW6LgBo4DG+XUS45fzM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707142513; c=relaxed/simple; bh=iqDeabfWw4JAl1GsXp6xX7i80knJmS9R0n4Vk6rDw10=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=FVnFVL/WGooTJUWq/Qt8uKuNKESHajtxCM8fLj9MUsymVEUrJXiQmrl28Ra05Z3VRQUPk4O5QLIlZPQWhNLr7gfm5iT5Wy8I6al6dRemRJ5yZMJJgk1Ki9qcg9vbSQACIfypIoqEZd5Tyb+LhlQGdwnwvYqj4mRIZy6r+w18Wy8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=a/gSCdSr; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707142510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=11pxIPHjBBl92wQMC3DFzCqQJYEHlgWDIYJq9X2o8Gc=; b=a/gSCdSruePTTeg4NkAWMk0n2XnKuYdqvmFKp4jGl5bXCxvLWduVwxRDKeWpcYIcY3Mnm0 as1A3/b6lXooSn04G9Il14HOgaNfEBQtuQ53RHKrcb+Jv4e1VodogscGfmIJ1/C/dGxHE/ dciO8LWdptfKlt/Ui5qu5p6eCbnrzu0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-WEhRXOPpNoGlqpJ5BlKlMw-1; Mon, 05 Feb 2024 09:15:06 -0500 X-MC-Unique: WEhRXOPpNoGlqpJ5BlKlMw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50C2EB42B26; Mon, 5 Feb 2024 14:15:06 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.165]) by smtp.corp.redhat.com (Postfix) with SMTP id 1979C2166B31; Mon, 5 Feb 2024 14:15:04 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 5 Feb 2024 15:13:50 +0100 (CET) Date: Mon, 5 Feb 2024 15:13:48 +0100 From: Oleg Nesterov To: Christian Brauner Cc: Andy Lutomirski , "Eric W. Biederman" , Tycho Andersen , linux-kernel@vger.kernel.org Subject: [PATCH] pidfd: change do_notify_pidfd() to use __wake_up(poll_to_key(EPOLLIN)) Message-ID: <20240205141348.GA16539@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 rather than wake_up_all(). This way do_notify_pidfd() won't wakeup the POLLHUP-only waiters which wait for pid_task() == NULL. TODO: - as Christian pointed out, this asks for the new wake_up_all_poll() helper, it can already have other users. - we can probably discriminate the PIDFD_THREAD and non-PIDFD_THREAD waiters, but this needs more work. See https://lore.kernel.org/all/20240205140848.GA15853@redhat.com/ Signed-off-by: Oleg Nesterov --- kernel/signal.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 9b40109f0c56..c3fac06937e2 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2021,11 +2021,12 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type) void do_notify_pidfd(struct task_struct *task) { - struct pid *pid; + struct pid *pid = task_pid(task); WARN_ON(task->exit_state == 0); - pid = task_pid(task); - wake_up_all(&pid->wait_pidfd); + + __wake_up(&pid->wait_pidfd, TASK_NORMAL, 0, + poll_to_key(EPOLLIN | EPOLLRDNORM)); } /* -- 2.25.1.362.g51ebf55