From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C6C46277029 for ; Mon, 20 Apr 2026 21:47:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776721626; cv=none; b=UssLpUfM/Awi7MAHmWzQtVwaHibNKMQkON1FRhrpfdfPXJkrFDSTVBuTCNDrUOE5bWqhMU6XdYO/wOoo1JP3nw1TCzSg61pdYWgYGRW1VCZM9clsLdVjMnSLqz+q98QW7wk9/mOzd8/JZjsaosPBj/q2twq0Qqjv2Rwp3GeGmIo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776721626; c=relaxed/simple; bh=k7xmzyZCP3cUzoavLHUHjt9yYXdF5Q3aObHP+orasFg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ukVGHrPw0MSZYf6regK4XOG8LAE89b78UX6aNmtt7Uzofo+hKs2nDLOb30PvS1VJsuvlwepV2gQkWN8/x7bR5vpZQuSfaMStfTYNjuuQnKEQPhyKhoP8mO6Nd6LX/KsBpODnJwaWA0959PIpb0hZNYGoRSPP+t/MwV68+kIUCfo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tVoTEZTI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tVoTEZTI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23709C19425; Mon, 20 Apr 2026 21:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776721626; bh=k7xmzyZCP3cUzoavLHUHjt9yYXdF5Q3aObHP+orasFg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tVoTEZTIXsi3M+dPWmV/s1NPuMSPyF9gklAGL1CM0QIEjfXZnb7VTj0BRjE5DJKhm XWDicYFMzz/WEZmAG0Sd30py43F9pGiXqnWX7RLUKnToIJG8J8PgH2lLDQZBlJf/pW XWlwrzc6RifOjcE6bGVTTe+nUOhRWiPLQctj8fFVGW5E2JIWFb87hQ4SJSSq3V8PXV Lx6aKzhXLisOdHnU2OTLb/6lfWSRPEdequYf7ljUm65wxm805J3hlPDeKx8V6Oaj0U oLOpOiGDxW+xtm5IWcMDzNTqDfcajKauT58TYKi+guXNB7MsPxZKG6k6DcFjUIuldh E8tBkmuk0MevQ== Date: Mon, 20 Apr 2026 14:47:04 -0700 From: Minchan Kim To: Michal Hocko Cc: Christian Brauner , akpm@linux-foundation.org, david@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, surenb@google.com, timmurray@google.com Subject: Re: [RFC 3/3] mm: process_mrelease: introduce PROCESS_MRELEASE_REAP_KILL flag Message-ID: References: <20260413223948.556351-1-minchan@kernel.org> <20260413223948.556351-4-minchan@kernel.org> <20260416-planktont-abwinken-b9499483b939@brauner> 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 In-Reply-To: On Fri, Apr 17, 2026 at 09:04:31AM +0200, Michal Hocko wrote: > On Thu 16-04-26 23:30:09, Minchan Kim wrote: > > If I send the SIGKILL first to satisfy the process_mrelease() requirement, > > we immediately run into the scheduling race condition where the victim can > > enter the exit path before the reaper can set the flag. > > Why don't you just grab the mm before you send the signal and then continue > with reaping? You just want to avoid a race where the victim manages to > process fatal signal, start its exit path and mrelease path losing that > race so you rely on the exit path, right? The problem is that process_mrelease() operates on a task obtained from a pidfd. Once the victim process receives the SIGKILL and enters the exit path (exit_mm), the kernel sets task->mm to NULL. Even if we could somehow hold a reference to the mm_struct beforehand, process_mrelease() would still fail because mm_struct via task returns NULL after exit_mm() has been called. Therefore, we cannot simply "grab the mm" before sending the signal and expect process_mrelease() to work after the victim starts exiting.