Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2926463lqo; Tue, 14 May 2024 13:49:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX786YZ0SszE2BAeeM2mhpdDczhAoPJoNCrue1fq16v9ll+dKOBa/Ca+lBpXvyLaGq+gt+0M/j2c//Jas0kwS18zREz3gKp8ZL6rntilQ== X-Google-Smtp-Source: AGHT+IGVLY35A34Zbdr1UwP93KMVNsCEZo98jpkcgfADpIBWVT8WTcjwtzI7q56lYgG/JD3V54h6 X-Received: by 2002:ac8:5dca:0:b0:43d:f633:473d with SMTP id d75a77b69052e-43dfdbb84acmr168993021cf.60.1715719750426; Tue, 14 May 2024 13:49:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715719750; cv=pass; d=google.com; s=arc-20160816; b=sawIO8e7bpXEgXj91J/Keojvbm5Vn3XGlspTpkjTBxTKR5oeKh0kLDb6jDUWagzZDH SHRfcZkNU/wDdkh714U3Gn8M/AyCZlsU0x+NmBtyG4fVVwvLAPxohDkyNlzJlMed4b0q AdDiNhzh2SmfPntdvmraeVH+mRxYDv96RquBAlXs31vkiMAyThPr6euc6bLG4R+lCTvx 05JngbhhXosvxf0dMCRozwtRyBt/Ej2ErWMHC1IHbxox/ImJIOeS4GLCD36PNhCDZLJs DhbiQOeVfAQPxvZYb2ux0RqH012qw2hmJ2jXM+mccaVNtBoY9trmi8w2Tl7KQttqdmkr pjBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=vjO7VnrroqxxgnD3OiMZO9Nx30PMYAUaL1ENaC7gzp0=; fh=wQZjxWyNqy59N7O5sqyAXwfaAnfZp4hy3tYk5nvoHRc=; b=O84o6usAICsHg5nNHgLQq2w4TyRgFLQbVTZIqHTixUgrMHBveWRDOFmp8Rk+cfVEPx V02uiLd18ipv13YNV6nKwwpXvvnsHenNd8Nt5b9zeVdca0F/WEdPgubiv/WV4S+Gs+KP RV7np7QYzEdV90PdKEtSFxR9MN6cny+fPgWqcmkQWPSXGl2y5BC3dRY1Fzd+9Sg4Kr4D X4Ev4hiQQZMaHi4CjGA21Suvc7SGqy65GpQvWU/P1seTmyhdVuepUsnmmxExSsELt61S lqUBbrmgD9ssbIFrSp5vMXptbmehZW7fiCPfTX6VyYqd7sieYFk/PIq/WvdGHTl39cr2 BVlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=OGQpwThJ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-179155-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179155-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df566f9c4si128721161cf.245.2024.05.14.13.49.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 13:49:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179155-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=OGQpwThJ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-179155-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179155-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 29AA91C2115C for ; Tue, 14 May 2024 20:49:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D274517BB2E; Tue, 14 May 2024 20:49:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="OGQpwThJ" Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (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 9A9921DFD1 for ; Tue, 14 May 2024 20:48:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715719741; cv=none; b=QJfrpBGFMSLbZVoy7DZbTR1dOv3tPloZDmGnrlj0QQ+fHvka34idSKzkql2Xrqlth6QJ56ykvYO8IPSAm5DzJL/Qq9QLv67O4GV79ccZ/7UYb7GC/AHtndqxm0PyTAjjkDu/scSYFCMibPTME1kx3/cMZfJBUA1yLSnCNdVg+Lg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715719741; c=relaxed/simple; bh=+kC3x8SXXb0no0oRx22C1RCk9ERpR8hzu7TzSlw8wEA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Bei6XDjck1LhfmywWD/vzpzEj5Xxzbma2uulMg6ZI0hP+WMp9PVOcW3AeWwQeTT8eKrfAxsKz5ZS9m030xdN0BMqkBkwJNHjZqjTTIOfPaeStX+bCRBfn8A4GNnYsWUdqlyAV7O2j8DX/okOyVk6Z09NXmy6czFe2g28F+/6154= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=OGQpwThJ; arc=none smtp.client-ip=91.218.175.188 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: Tue, 14 May 2024 13:48:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715719737; 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: in-reply-to:in-reply-to:references:references; bh=vjO7VnrroqxxgnD3OiMZO9Nx30PMYAUaL1ENaC7gzp0=; b=OGQpwThJqbh+faErC9luLSfbckj35Wc0Ehw3+nSaXp9SeE7K4BbMHDB74xYP0iRy49c8iV 0FPeMy9LX1E2pl9GAgAFJ4KQq6jO9kP2IghKENNjf3jOeLwUzPt5S7bt2ZGWSeumNApQDp KHHP+Ef5Nqvk58wjoPRIH+AgL9SKHUQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Johannes Weiner Cc: Andrew Morton , Michal Hocko , Roman Gushchin , Rik van Riel , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH] mm: vmscan: restore incremental cgroup iteration Message-ID: References: <20240514202641.2821494-1-hannes@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=us-ascii Content-Disposition: inline In-Reply-To: <20240514202641.2821494-1-hannes@cmpxchg.org> X-Migadu-Flow: FLOW_OUT On Tue, May 14, 2024 at 04:26:41PM -0400, Johannes Weiner wrote: > Currently, reclaim always walks the entire cgroup tree in order to > ensure fairness between groups. While overreclaim is limited in > shrink_lruvec(), many of our systems have a sizable number of active > groups, and an even bigger number of idle cgroups with cache left > behind by previous jobs; the mere act of walking all these cgroups can > impose significant latency on direct reclaimers. > > In the past, we've used a save-and-restore iterator that enabled > incremental tree walks over multiple reclaim invocations. This ensured > fairness, while keeping the work of individual reclaimers small. > > However, in edge cases with a lot of reclaim concurrency, individual > reclaimers would sometimes not see enough of the cgroup tree to make > forward progress and (prematurely) declare OOM. Consequently we > switched to comprehensive walks in 1ba6fc9af35b ("mm: vmscan: do not > share cgroup iteration between reclaimers"). > > To address the latency problem without bringing back the premature OOM > issue, reinstate the shared iteration, but with a restart condition to > do the full walk in the OOM case - similar to what we do for > memory.low enforcement and active page protection. > > In the worst case, we do one more full tree walk before declaring > OOM. But the vast majority of direct reclaim scans can then finish > much quicker, while fairness across the tree is maintained: > > - Before this patch, we observed that direct reclaim always takes more > than 100us and most direct reclaim time is spent in reclaim cycles > lasting between 1ms and 1 second. Almost 40% of direct reclaim time > was spent on reclaim cycles exceeding 100ms. > > - With this patch, almost all page reclaim cycles last less than 10ms, > and a good amount of direct page reclaim finishes in under 100us. No > page reclaim cycles lasting over 100ms were observed anymore. > > The shared iterator state is maintaned inside the target cgroup, so > fair and incremental walks are performed during both global reclaim > and cgroup limit reclaim of complex subtrees. > > Reported-by: Rik van Riel > Signed-off-by: Johannes Weiner > Signed-off-by: Rik van Riel Reviewed-by: Shakeel Butt