From patchwork Mon Feb 5 14:10:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 196843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp921107dyb; Mon, 5 Feb 2024 06:46:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1cD4EtBolccBmHcYFWiej/N2ENr7f7Rm/umYyeM1waI7fqYXftyt9CmDl4Mhi0hkVv3Qj X-Received: by 2002:a05:6e02:491:b0:363:81b8:bb1a with SMTP id b17-20020a056e02049100b0036381b8bb1amr9203098ils.22.1707144390154; Mon, 05 Feb 2024 06:46:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707144390; cv=pass; d=google.com; s=arc-20160816; b=NPbS8n5OV/Q8HyCe2Pj7CJmpuqWOofUKyHnKGYKAuXpq9NqwGwcamEfrdSOjxniU7I Nu9ZNvWqG4DH0gV1Gx5uhoQHehDsPWjdkCdNcmtExyDLIb65ofpc1RxLCZlViOxFPl92 dQ5qalQbSDPJtVSka6eb+kBLPPRhN1sutbREcyOIurwFaaycc9MymfMJx4ti3Iyb5rhu 0I4pz+InuHCkidXzxrd4v+gVu2Nn1Akx1J1rG3Xg/lvLHIiBjg8N7G5UC4huIFDTtShM dDg1kWazW+Fyd//Bln9aRPTNhKXMsUasiuNd+I5mAZDo98sXCm6uOdMEloJFC40uudNn 1rkA== 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=gjFMaGeg0tSbAHrrpJqixRvm8sviT7v0IDbKr1o51po=; fh=yMLhLtBmralXcfv2DbpUBxFtihkMY0/O8dyGBPwiLfA=; b=oZD59er+2gqe1l9EhKyLtUWdEei3dwZFKFZIc1KYnqpowTdlAgn1F9xqkIco0YlHmp tmQzEshnmaOfjnTEAj05LUALx5oWkwBGnm0r4Ri6FLgXq8jalJKnPVMmkKzAWGOD9L9n 0GzDwTp8YSO/aHqVcy/A4zEKdYTnUADEMn3sVgp7Q1duApuIDBhihDcaBAwcVJBEVmlS 3nruDCLpfA2mu7UPEkl0qPpAIVG36iKE+Zpm3dtWS+otqUpOBIsdPktFEo3WbuETGvFZ AbA6MdzQ3wvXU0wU4VTUCJcwFXEM59bYiBzLEReLq9/ndCkv/y4FhEHPGddauw65rUcl sYZw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IxfE3DA8; 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-52788-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52788-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCWdc2u02bMK4HXZ1/xJIhNACcyt7XVId1Cqpydil+Vn8ZCe8b6teX/HVRdfwQJNaeAjNW2vYyew7XySIwSdM85s2FqWmg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k191-20020a636fc8000000b005ce021f4418si6049083pgc.524.2024.02.05.06.46.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 06:46:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52788-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IxfE3DA8; 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-52788-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52788-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A5690B22ACB for ; Mon, 5 Feb 2024 14:12:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8612328E22; Mon, 5 Feb 2024 14:12:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IxfE3DA8" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 5FC512377D for ; Mon, 5 Feb 2024 14:12:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707142336; cv=none; b=gR6GkKH1cM0PyTUwluhbnjZ4eEPUs9SVUcjZtCnHjjwoA9D9+AQBks3dGy5a5Sy6PlNfBa5Vrx04VDpv292z+R8wM71HFbUTZlGddsbFPjz+PYVrLebyqKKIIlfQVjdqQ8alsYjiN/S7UH9aIg2op9NZJJXMWPeBhkaEZ73LMY0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707142336; c=relaxed/simple; bh=Gd3Qd4h4a246Azi/ANHT+FzV2dp0eLicHjFsnJCn974=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=YjnPRteoq03CsGvio/X8xJcUrZzNmKSkl8XYLMt+RfqPFg3U39S1zwatH+AM50x8OHplMXt+O2vgyS47kALSrbedlgtjAjLqkWnuNACnL2fpR/85WXmAHBnVhzV7vFdI0LDViVD0YiffLOg/LH5UfkQn89yjrcmIeF0BDV/LXEM= 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=IxfE3DA8; arc=none smtp.client-ip=170.10.129.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=1707142334; 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=gjFMaGeg0tSbAHrrpJqixRvm8sviT7v0IDbKr1o51po=; b=IxfE3DA8ApvD4CLko1upMfUmYzodQHXCyJsh/ckzcYLdoleikoZP5gnAWrmqiVupCWiIer SyW5yObSbOYCZ0ej9BRcfBA7dsRnPwBhVT11pWG+uNpWLmRROCo/CVeNmc1R651t9q7glv xFKonp4f2WJ47kDJPOlj2dMQidcWhOI= 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-445-DJtLC7HiPYugwAdIqul-fg-1; Mon, 05 Feb 2024 09:12:08 -0500 X-MC-Unique: DJtLC7HiPYugwAdIqul-fg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 25427101366D; Mon, 5 Feb 2024 14:12:08 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.165]) by smtp.corp.redhat.com (Postfix) with SMTP id AB29C492BC6; Mon, 5 Feb 2024 14:12:06 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 5 Feb 2024 15:10:52 +0100 (CET) Date: Mon, 5 Feb 2024 15:10:50 +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: <20240205141050.GA16278@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790069779825213626 X-GMAIL-MSGID: 1790070635993991108 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. 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)); } /*