From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 1705333FE09 for ; Fri, 24 Apr 2026 07:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777016325; cv=none; b=rCXK8mpXs1erOOp+hiShEuZQd1mX00ywwPsfYENscoqLFMo2yFL2ZLCwPYlsTOwyDxAOdDSRuxfm3aP09YhAgXmRLNHN3OflR5Nt0hnDVGn37PTOso6PXts3Gleojkb9BGfPbN+8OdvRGmqM9gfH0DjfZWpS0AYOkphqTavuqYw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777016325; c=relaxed/simple; bh=mHz+R6Go5I5me/zDcuB6k6hfFc4UJE85JMkHZ3syYxo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SmJvSncXQ3NWAs89rveAWPUnYlAnSFU7BfcSGOANVZQM8tqJ/lxtaZDlDCTHp85UYhIXlenMSsTAU6bEpreO7nr43qgiZ1BB3BWmKKbW0EI/k3Ji/vCbwQ7EZpwQXLPutKiSpiwJdPbTYMuGJllRcl+8Xtf7Wujp3WHiko/Tq7o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=bEF5YWsZ; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="bEF5YWsZ" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-48a563e4ef7so40090735e9.0 for ; Fri, 24 Apr 2026 00:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1777016316; x=1777621116; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7sRCoE676JeZHeB3B8L45JxboYFG9w4g6sbDNRxrI1Y=; b=bEF5YWsZrJTBhkXTaiepPe9TFKQ00e2PtzeGwYWHKS6/dw0Ry9JSUrmu2tuIiZ4uFU KXeNNk+CKEZdlL27ciWv7q+QceJl7hMYOVvC509qH7V+PipZzF136ghhjrm81Cu8U0ca X63L4UVx6/zlmOL4eDGTAxOtaE8olZSnXBXqlaZoN+029azm/BV4qiZzMiZNQGI1f2AM F8ny/bjGcoMra6lcNM/Q9CQ8yxnVdSW95EHecbdiTOAE+QLyaSNW5YBJfOtdQl29Cd5O 0g/8Xm8ztwBxc0V60zFPI/hgSHlNHpTAkLTDQj9xdjkx02RQVxAospZaWRAleXxF3OEk 1jBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777016316; x=1777621116; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7sRCoE676JeZHeB3B8L45JxboYFG9w4g6sbDNRxrI1Y=; b=b4jfQMjL6ux5Wrs/WjVzJohzalC71JU+XvXJYRnOlHET2Khzam+TmiKcMnvVlv43Ng prgk7o/cXsrWyM/vAY2H67f5vap+BaINh/A/W8XKGN1qp6Tp8b1TTlZVhH9BmK94ka/r gdeTJSHAcZjTmO3BPIb0dbLh8/1K28cbb/wEkqIw19YQPK5LPjVOQ0/nDo53ZoPRnjY8 kDetFEW+I1brNBhJfwpZSGXJs55931en1gJojuJIxAdhQlVQWgRq9Muvb3K+dYNJ+hoI padxWNr6sROPpdvMIJoIT0au7ZC8A66smph0s8+DambstjTkpaAIhgFcCJ83gnNJgy64 yClg== X-Forwarded-Encrypted: i=1; AFNElJ/JzGOexULnd1FDscJ/sDPs2vK2aieBkqp1sx4c52eOy+auRgRr1Cx3WJuVB3OPo2Shwv1Pd9qiwN9bqLw=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/K6yCc+SNIuyJLIA67pLC8IWhEMPwfDgsIkvTCJFVS8r4/Yu2 lnoNSAdONdkF9iGYEN19qKxKeJyEADlyYogIs8Y+/9GO1VWI81jXcjRvMDUP32fzwv8= X-Gm-Gg: AeBDiesu61CHOnarct8QCEYDTBuca93LzVsCtq+tae9jFxoNlb1eLHb6t2/PeJtNlN0 2cgwpK/4fTjmJIi1t/MNBa8YZS6EO4V5LvKXbGRR12Ak85/DgpOMGxL7w0adO+f02062+mQvFP6 xuPRqyBB17FKi8v/mYS+ZXj3Hn2rX4L3IZdAUQyZgiDmXklqJunmDV8bKzuF1hctVD7Fr9ESxD6 4wR0/mIdIfVOP5+PuMs+8X2e7r0gZqRzk4lSy2MuEJucifJt/d5xpD+RRI44U1uPbiItGzpumE6 cYYfID9Ec1TkMglnfEOba2RgskHKe77PuRZlHa11uT6Z4WD8ixzEva1lghzgfAIdhANX+UgGbyd /cVlWl1kQD3GWQ/AM+GZl5yQisYIyWCfvFHWpH8R31jwzneGdVswd5L+HnTOjKEPK4LmWjvencp AGkhak4zk1cTfBsVzqq7osecQnbYN8/agA25mJLE3jegkmXiQ= X-Received: by 2002:a05:600c:6206:b0:48a:599a:3716 with SMTP id 5b1f17b1804b1-48a599a3bfamr155991265e9.23.1777016315877; Fri, 24 Apr 2026 00:38:35 -0700 (PDT) Received: from localhost (109-81-17-171.rct.o2.cz. [109.81.17.171]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc0f82bbsm979447725e9.3.2026.04.24.00.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 00:38:35 -0700 (PDT) Date: Fri, 24 Apr 2026 09:38:34 +0200 From: Michal Hocko To: Minchan Kim 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 Thu 23-04-26 16:43:48, Minchan Kim wrote: > On Thu, Apr 23, 2026 at 09:17:39AM +0200, Michal Hocko wrote: > > On Mon 20-04-26 14:47:04, Minchan Kim wrote: > > > 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. > > > > I do not follow. Why cannot you simply do this > > I misunderstood your point. Do you mean this? > > https://lore.kernel.org/linux-mm/20260421230239.172582-4-minchan@kernel.org/ > > There are more details to figure out. Yes, there are couple of details to iron out. The existing reaping has some hard requirements in place. I am all for relaxing those where possible (ideally without much of special casing for this specific use case) but this is much more viable solution than KILL_MRELEASE you are introducing here. Keep in mind that fundamentally this should be a really as simple as trigger exit_mmap after sending SIGKILL. We are reusing a large part of oom_reaper functionality because it was comfortable but if there are constrains that stand in the way and they make no sense for this usecase then do not sick with them. -- Michal Hocko SUSE Labs