From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f68.google.com (mail-dl1-f68.google.com [74.125.82.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92AE43E5ECB for ; Wed, 3 Jun 2026 03:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.68 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780456283; cv=none; b=MTNewPSnH81pil4h4aXoq/2sE0zp+C9fSnXHpJYNgnhjHJAGa5abtnLUVw9dYXiXFUl5Mys6JdqTqXQU3VMGpYZVB27meWRoswhmU+bB7EP9WYn7vWWHezEoqCgRE3AamlyDFGJ18nxIYMIGRpa0ZLRLn48c5nnHKK/PyA4I+no= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780456283; c=relaxed/simple; bh=JRNH2XRTEkYHJTv63VfJNzHKgkwnq+3D+tuw5gxbqRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=COm9JVdaHzs2EaLvruPw93JwvLMkt0rwnltD0CdyNfavWi6eTB9oXSXuW0tSBJ3DRj+R9kutc6VLjuT7KHDr/+91g0RoTE8cYSBY+LgEfgF2Wy1P5BmLsH0+qA5RRpxKpRIF2yXt1iUVqB4k1WfDvEhFMIwLGzRyflMnhjUfZTU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=irVJQrWo; arc=none smtp.client-ip=74.125.82.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="irVJQrWo" Received: by mail-dl1-f68.google.com with SMTP id a92af1059eb24-137dd3af345so3028230c88.0 for ; Tue, 02 Jun 2026 20:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780456281; x=1781061081; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JRNH2XRTEkYHJTv63VfJNzHKgkwnq+3D+tuw5gxbqRo=; b=irVJQrWodeTBWC0sJDzWmneqBCFIey96xh0nlfQGi5E3nExei5CeqJgrXd+gBqzqBT lHIAQmZRo+uiBsQlpb7H+YDN3rmGx0wi6jS1A7o4RNF/WFqqyG9dt35uWREgoL6XVkpI yOHrfIC6e7L57WMz0DUNbmNXba2EtneRUKbghOv8re0ont90wR8N3EVmtVu8ZXmmFYp1 ujoHy74VKoAPh5Ao9YYk0kG0BA/4CG/y88ITkZGcE9R8XpImaykEIS+de9Sffy08kJTL /fRzDbyxcF8kvxE5/7ELlJS8lyRg4JUpRCZHdfQpnsw6jGibIZ33mMVB5IKrCgQT+ADA iMdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780456281; x=1781061081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JRNH2XRTEkYHJTv63VfJNzHKgkwnq+3D+tuw5gxbqRo=; b=lGyEfSmpmUst+9xSteAwpfUHTAl7K2m9Lj8Q4p0eEwjw9HILMLyH0+/sN+lusXraS/ eTFG9VIudfwU/NndWaF85bVZnzVWbzrRIw+tW9Fi1vlkxchcQhmVChU7kFkwZRGxAw9G +X3UxJsE4WEhefeBiANOXTk7y5fE/24p0iODeAEiToIMj+DZGonOPl1Wq6CgQZSIMdEg g23S3Mc4RAFtD3O63oGcyPMtg62iqTWtAJktY95qnnvkJbk+m4rLTf0VCX8UmoVQfXfm jX6PqNvu9MPQlDWCIlMjDr3TAOPHqht3Zoq/gECLdmJB5Ej8nAYwAOXjNBO5oEtGvMZa aRCw== X-Forwarded-Encrypted: i=1; AFNElJ/7TGj7EoKMOy4TBQOl70oB8zkUwAY1BhbBAXvs3+SQguNXUvoo7TihW+dg3y7EmHFOJ3rzIvEMG+idBfE=@vger.kernel.org X-Gm-Message-State: AOJu0YyHLitQPPGGa7DnPsOrtJehJTe11ZjolbZToiiQQGjhQq1HLFFv bvDFQGYlJHBqYoZseKy8SymbuDzcPCsoE33TCdgDdX5tWP+mE9z/6NPe X-Gm-Gg: Acq92OEhRSM88fxbCxtr24kS9JK4sQwBhcPT8XkPR/Vqz9p3kxXGqL13+6oJraaBvQJ kMH9SGoPJ7FyUhQ8cGTKYdIA5Y10BgCCvlSc1d7hTd8+GtWTJI2XtiDdmAf3C2bH5r81siQorJ3 5hx6sfkNIYMlSO74oipOB8AIru8YjngYv1SIC43PeLTGnG67O8ALTDOLTJ44+ehrvYdH6GROnII Bx9ECaLhIScFP/LltA8KPPmgkhbTLYkgQNXvfvraKDIIG/XC3EG0w9rlsjJVFUk2JS157H97j/7 fAUfOa7jEa6s2OFmJEx0J3U2c0RgGFbrZR56TmyFCsa3ndWfRRCtjuB6RejrLW05rmnE5TULOHw FcxXh1dcGI9Z6euVApLDqb2VP+b0b0pmBQmPa9wRMBWW+gUUEJSZQe1A85FwLdyP5tcRWl6gsI7 gOO4Wml6DLQrTfUAQHDbLmjjdDHa3AQw== X-Received: by 2002:a05:7022:6089:b0:12d:de3f:d84e with SMTP id a92af1059eb24-137f6c47322mr494802c88.39.1780456280477; Tue, 02 Jun 2026 20:11:20 -0700 (PDT) Received: from anonyme ([2605:52c0:2:2f27:be24:11ff:fe89:6f0f]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-137f554f732sm1029020c88.12.2026.06.02.20.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 20:11:20 -0700 (PDT) From: AnonymeMeow To: brauner@kernel.org Cc: amir73il@gmail.com, jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/2] fanotify: allow reporting pidfds for reaped tasks Date: Wed, 3 Jun 2026 11:11:17 +0800 Message-ID: <20260603031117.20950-1-anonymemeow@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260603001516.26234-3-anonymemeow@gmail.com> References: <20260603001516.26234-3-anonymemeow@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sashiko said that pidfs_register_pid() can fail under memory pressure, since it allocates memory using GFP_KERNEL without a way to pass in __GFP_NOFAIL. This can cause fanotify_alloc_event() to silently drop the event even when the group has an unlimited queue length. Should we make pidfs registration best-effort instead and still return the allocated event if pidfs_register_pid() fails? But IMO this will make the API semantically ambiguous. If the kernel guarantees that the event pid is registered with pidfs when pidfd reporting is requested, then a later FAN_NOPIDFD or -ESRCH can only be caused by the task being invisible within the reader's pid namespace. But if we allow best-effort registration, the event may still carry a pinned struct pid, but pidfs registration may have failed due to memory pressure. If userspace reads the event after the task has been reaped, it still gets a FAN_NOPIDFD or -ESRCH due to failed pidfs registration caused by memory pressure, IMO this should be reported as a -ENOMEM instead of -ESRCH. But currently it seems we don't have a good way to register the pid with __GFP_NOFAIL or __GFP_RETRY_MAYFAIL, so what would be the preferred approach to handle this situation?