From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (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 693C71D63E6 for ; Wed, 15 Jan 2025 19:41:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736970099; cv=none; b=aQViUAxz1OH3/b42t22CQOacEhi+P9uxJBpjVHFV86Owu+z4aseRhUSGZWvWI9yRQMiegsfs5F2ek6v4BSverbHK+5gGRAhW1VsyQzC3hCk5C2JfhCl7ztUhA5ZWON8Tkdqxb1WotEV8sknLp7U2et9KW1KqpNEE/8SoRw4A9yE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736970099; c=relaxed/simple; bh=X79fQShG2win0Kg23ZMNAfHyL/M4PaoYCU5ajfjIgyI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=W+Dds5U3mDde4J+FwApy+OISm4aO8R8Hg1Bst8anOLNdg3Zl8pNCzHOyTD+g/k1P8B37s2Z0bXRtW9lH97PnNnNp7DVWGN23rWIn+/WJAG1THWok53cnQMCN2pMka4N7tTd9DQXi1usb70p7QwaFwgOytdj4bYNhJlLiuhvjmBo= 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=NpjH76wk; arc=none smtp.client-ip=209.85.208.44 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="NpjH76wk" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5d90a5581fcso203816a12.1 for ; Wed, 15 Jan 2025 11:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1736970096; x=1737574896; 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=3ZVNqrTwKIYDf4Bm8NNK5jPuTo2WMdjzDg2Q0uygxvA=; b=NpjH76wkqrBfvKJkqGH9//9ueHN18TRvKnHkgiO+gVUCAdb+oXnklWDqUJA9JSVp0c QUT0lgpNKep/eWomXY8ZjkORKkGBQ4AHYKooJjYQJR3ZuHGA+CMEbd1+8kUSO3KP/yd1 OmVanT9p5dWYaHK9VhMDJzdCHF8vc28fsOQ06GQeI2Er+4uzS8qzmuKlpLG37AcajzrX oLc64YR91KgnmMo5rwju+YztZ6zLja2zUM3gNmvp/cj4dxdysjf9W2orRzTNM02Zl5ql siP7TDys5CDSQ0DiX7jfInoucv4TFNLy7JVvE99qnMtcUopsq+59r00PX4sB6giMSVsm d5qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736970096; x=1737574896; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3ZVNqrTwKIYDf4Bm8NNK5jPuTo2WMdjzDg2Q0uygxvA=; b=WdrcJVY/PDLUgglO82QWE8tSfp0Ix4rCdH3r2lJZzLOOC41xNYllPydJ/0wmCMS+g7 FiDA6IP5LEyUXPGPC/iIDZ/Vt/u7J7Rm56+Y4fQZJGyvKlYAB50IgZrF6YwPiLj1U+hP 9ZeB2/2jfQmGi3p2kKvrWYENlT00ChujAi6vHaOYUamnlnxFjDlzltJINWvrX7UQ4Vhv 8iT59ZZzb+trCH7J7WS8zjVM7SC23JM12DIKPK7+3Ca2tXFFpolq12EaiG5Fmwfn1CZt mMSHWv9B/HcR49kIP9A8qQhL9vnnJzfYulUuwyrQISnOUGhoqYHRHo0Dc3i+qwvnOdzf /EGA== X-Forwarded-Encrypted: i=1; AJvYcCWQSRMKvwb6CYi5ZEJD7C3GCPuHEvRU8ZxreJd64xLd8AOrkCbofE6hgxySHU+iJdOd13BufRmVaOowKGg=@vger.kernel.org X-Gm-Message-State: AOJu0YzWFAihJs6cZ1y5fyayxjjXd24R8RS3WE+CBNwL4nuTaR9lzFs7 Y3nQpzXgKSV9rH12M4WRyTNCqOzYBUf3+mida6Ae3bEGHKWvICrushRhej1t2E4= X-Gm-Gg: ASbGncsW0XwIP5njj9f6WSHIoQDHaQYsQW1RpOKhpcugyMjpve5V4FrXOKbvRIsabd0 1thEGAbLRQakYbN+TEA2TeSV8v9Sg5D0j9rT/ecDupcsLYt8pxHMhNX67D/nPghasFDxFtYpdSB Dp+29iBw42g+3TQW7eMK5AcBW2IWDJXdsqBKftw7X1sQ1c9+Pg7+BZppVhHjaK+JZX7sSWf+mZP 93fDA2jL11an9Q9szA9RLmI+HXV3ikSfZO/cYYGfhyr1q96tkovzQPGlhmQq8YDlABQHg== X-Google-Smtp-Source: AGHT+IEQAuyjYMWDuvxbQji30YXDQg1tnXpQK7ijaXsvEZSUIwVzPcfJ06q+Oo+0/rOilCVxe3Nb/g== X-Received: by 2002:a05:6402:4307:b0:5d9:f362:1682 with SMTP id 4fb4d7f45d1cf-5d9f3621964mr8968077a12.24.1736970095771; Wed, 15 Jan 2025 11:41:35 -0800 (PST) Received: from localhost (109-81-90-202.rct.o2.cz. [109.81.90.202]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d9900c4326sm7629912a12.23.2025.01.15.11.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2025 11:41:35 -0800 (PST) Date: Wed, 15 Jan 2025 20:41:34 +0100 From: Michal Hocko To: Rik van Riel Cc: Johannes Weiner , Yosry Ahmed , Balbir Singh , Roman Gushchin , hakeel Butt , Muchun Song , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Nhat Pham Subject: Re: [PATCH v2] memcg: allow exiting tasks to write back data to swap Message-ID: References: <20250114160955.GA1115056@cmpxchg.org> <193d98b0d5d2b14da1b96953fcb5d91b2a35bf21.camel@surriel.com> <20250114192322.GB1115056@cmpxchg.org> <7a4e5591f45df455e6a485fc5400989569d3d22d.camel@surriel.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 In-Reply-To: <7a4e5591f45df455e6a485fc5400989569d3d22d.camel@surriel.com> On Wed 15-01-25 12:35:37, Rik van Riel wrote: > On Tue, 2025-01-14 at 20:42 +0100, Michal Hocko wrote: > > O > > I do agreee that a memory deadlock is not really proper way to deal > > with > > the issue. I have to admit that my understanding was based on ENOMEM > > being properly propagated out of in kernel user page faults. > > It looks like it kind of is. > > In case of VM_FAULT_OOM, the page fault code calls > kernelmode_fixup_or_oops(), which a few functions > down calls ex_handler_default(), which advances > regs->ip to the next instruction after the one > that faulted. OK, so we do not have the endless loop. Good. Sorry I didn't get to read through the fixup tables maze. Thanks for confirming. > Of course, if we have a copy_from_user loop, we > could end up there a bunch of times :) Yes, the robust list might have many elements and if each and every is swapped out then this can take a lot of time if the reclaim path is desperately retrying the whole reclaim. All that being said, does the change (partial revert) suggested by Johannes diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7b3503d12aaf..9c30c442e3b0 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1627,7 +1627,7 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, * A few threads which were not waiting at mutex_lock_killable() can * fail to bail out. Therefore, check again after holding oom_lock. */ - ret = task_is_dying() || out_of_memory(&oc); + ret = out_of_memory(&oc); unlock: mutex_unlock(&oom_lock); Or is the exit still taking unbearably too long? If yes maybe we can help to ENOMEM already killed and oom reaped tasks earlier? -- Michal Hocko SUSE Labs