Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2546732rdd; Fri, 12 Jan 2024 13:00:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNMejrESc+MZUWYrw2KDMQg8dqAMCGugI13H3PYTNBf5ICbtGL8zdNu38+hKPzVmBsJ5lm X-Received: by 2002:a17:906:5595:b0:a23:5939:759e with SMTP id y21-20020a170906559500b00a235939759emr2113965ejp.26.1705093224942; Fri, 12 Jan 2024 13:00:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705093224; cv=none; d=google.com; s=arc-20160816; b=xYq867luYAynaf/5LuCN8W7nDLZrBXjaS3wQAfUHOHiixcFHpqnIfN+W0r/rs/nIw/ yHbCIstKoUX/9RkTWVFipxQavAaJPcZ2UQUUaVAVwrXn0G6R1/TzjQAP/qocdCdaUCZn BdNQ/vfoIJJVHTfHH4OW/SBS8sV09syhv/6YjmB81Mg0BRb5xE7+QRS4o96bAkhNYmbG WMp/q/8BL/jH7EgHIjtD5PEoHVTJI88zrn9iWc4RMbkKzH9caGbDqhbIcI3Ph8bZgMyW rikh41/lFvykmE0SWtI9l+mhL/GS22GCbx++Ou4q7Irgq9E2SidP5FmT3B8+L7Udv58i 70Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:dkim-signature:date; bh=AB0MhXLRhT3Dw+J97a9ohvojU5mnHzEbf5k0cXw9MEc=; fh=/8sZdJnA7TokoQJB5tnIAKmD3pq4xlwT0/CkW9HN6QA=; b=QVLMfL6DBW7mbOcwsB/MAsvX0bAZDFZ6dTKzC/7t2pMYM4kmojNvlj74zwMXD72JV1 YaMqC6Vxak5orgkKfmGMPgQuOr9EzquDCUlGBnlwdAsih5sg7MRLu3JBou1XAJk5ZH+c /X7h3xQOk8CvbAEFV7X7xZy3GXb34OyxtVuxdzo9PAy/c9rui9eP0+bHroZDFxifUtww 7h2cRft26ViBtrBnsddV3g72Km9NMawf4kplwxd7peNXN3p6YmMgcZHIYd2sx9Yi2lSB eKEkA59rixALgq2uNmXVYaLLbzE6+vMFEjSY0YmYW/t2x9f4/Z+U2PKEju93SZR0E3ZZ T8PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=jCSIAizM; spf=pass (google.com: domain of linux-kernel+bounces-25036-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bk11-20020a170906b0cb00b00a27a2eece9dsi1683361ejb.553.2024.01.12.13.00.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 13:00:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25036-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=jCSIAizM; spf=pass (google.com: domain of linux-kernel+bounces-25036-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id A91671F22D3F for ; Fri, 12 Jan 2024 21:00:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D696168D7; Fri, 12 Jan 2024 21:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="jCSIAizM" Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (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 BB7D2168C6; Fri, 12 Jan 2024 21:00:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Fri, 12 Jan 2024 12:59:53 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1705093210; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AB0MhXLRhT3Dw+J97a9ohvojU5mnHzEbf5k0cXw9MEc=; b=jCSIAizMUFXd7/w/grgND+UVmxqA6uuDX+7U0FUaXe3p3HfY6GmGpUXKrUiubSDWFzT2S2 vSTx3JJxWzQksGIYsAEhP3kGxGh2xolezlaVponVMi7mFgseKDkrQ8SG+EUeGQL0KsRVKz 3Uvrxq3gVegobcOFauyvFxHH9/ofRXQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Shakeel Butt Cc: Johannes Weiner , Andrew Morton , Michal Hocko , Muchun Song , Tejun Heo , Dan Schatzberg , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: memcontrol: don't throttle dying tasks on memory.high Message-ID: References: <20240111132902.389862-1-hannes@cmpxchg.org> <20240111192807.GA424308@cmpxchg.org> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT On Fri, Jan 12, 2024 at 11:04:06AM -0800, Shakeel Butt wrote: > On Thu, Jan 11, 2024 at 11:28 AM Johannes Weiner wrote: > > > [...] > > > > From 6124a13cb073f5ff06b9c1309505bc937d65d6e5 Mon Sep 17 00:00:00 2001 > > From: Johannes Weiner > > Date: Thu, 11 Jan 2024 07:18:47 -0500 > > Subject: [PATCH] mm: memcontrol: don't throttle dying tasks on memory.high > > > > While investigating hosts with high cgroup memory pressures, Tejun > > found culprit zombie tasks that had were holding on to a lot of > > memory, had SIGKILL pending, but were stuck in memory.high reclaim. > > > > In the past, we used to always force-charge allocations from tasks > > that were exiting in order to accelerate them dying and freeing up > > their rss. This changed for memory.max in a4ebf1b6ca1e ("memcg: > > prohibit unconditional exceeding the limit of dying tasks"); it noted > > that this can cause (userspace inducable) containment failures, so it > > added a mandatory reclaim and OOM kill cycle before forcing charges. > > At the time, memory.high enforcement was handled in the userspace > > return path, which isn't reached by dying tasks, and so memory.high > > was still never enforced by dying tasks. > > > > When c9afe31ec443 ("memcg: synchronously enforce memory.high for large > > overcharges") added synchronous reclaim for memory.high, it added > > unconditional memory.high enforcement for dying tasks as well. The > > callstack shows that this path is where the zombie is stuck in. > > > > We need to accelerate dying tasks getting past memory.high, but we > > cannot do it quite the same way as we do for memory.max: memory.max is > > enforced strictly, and tasks aren't allowed to move past it without > > FIRST reclaiming and OOM killing if necessary. This ensures very small > > levels of excess. With memory.high, though, enforcement happens lazily > > after the charge, and OOM killing is never triggered. A lot of > > concurrent threads could have pushed, or could actively be pushing, > > the cgroup into excess. The dying task will enter reclaim on every > > allocation attempt, with little hope of restoring balance. > > > > To fix this, skip synchronous memory.high enforcement on dying tasks > > altogether again. Update memory.high path documentation while at it. > > > > Fixes: c9afe31ec443 ("memcg: synchronously enforce memory.high for large overcharges") > > Reported-by: Tejun Heo > > Signed-off-by: Johannes Weiner > > Acked-by: Shakeel Butt > > I am wondering if you have seen or suspected a similar issue but for > remote memcg charging. For example pageout on a global reclaim which > has to allocate buffers for some other memcg. You mean dying tasks entering a direct reclaim mode? Or kswapd being stuck in the reclaim path?