Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2991588lqo; Tue, 14 May 2024 16:37:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXepIECtWuhLsrcDMmT2MIOUeonAEo8/2Wb8nW4+4B7HNn9x8XZCV4jvhDgvxVRRSJXusZB7PnQteOCXq2shSdnZag6OcTfwr9Cy/KRSA== X-Google-Smtp-Source: AGHT+IHwdMhDF1wXxIDhwrwmo3fNz3m2PvzNAeeP+PKk1Slv7rCi+YVAhJ1Ry4R045EcS+U9f2PS X-Received: by 2002:a05:6a00:2d02:b0:6f3:ebb3:6bc6 with SMTP id d2e1a72fcca58-6f4e02ac63dmr15253778b3a.10.1715729827876; Tue, 14 May 2024 16:37:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715729827; cv=pass; d=google.com; s=arc-20160816; b=NF4GPaXWP221ctTMu10C4v1aPs3gciALks4WhgpvJd0iswXpI36oMGEyVYz07TOqXZ vEu3+XHA8RFsP29G24OGHP/eW38zq+MhfeKTC453r8Hi5owKxewa7C+1uvSlCnvmY1Oy /98guoawaopHrkGKDwx5/7j4AkIYOH3BMf0eH+JcsiCt7tJW2ixaO/3v/gJnJwkD2ljT jHkeExGkK/EvvZpP+UQn5ngWCrmot0xmKOu4fBb4P3WHaZ5dWen2zjwpbg+yyg3WoLq4 lGgcRGF8azFXVOaG0szPDnpJilbk5gRl3InxiOsOqRv9xNyFG45Sun+kL/uALtebREYW 3Byg== 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=QGeu7E7YtU64Es+FXJxCc3GogLv/cEp8pF/frLRvsxw=; fh=McbYPl/9Lk/rcEqktb9I2Dt8LcVHrvw49JB+ByAuYw0=; b=LMx6TIoUsW1rtKQA6+h0yB8erDD0SCaiK5fReQg+/Cwq064yV2Q2mzToj5jw12cPrL YzX/7+VzbQtQxL5BDIQHfgejprTqkz8sznu/3eoho5jGfYxqeJtOeW3oKw4ZFdsqfOzS f/GQvaQ1pLt3/oW2wWgjPgsoQWRvGFYUW+8IkZPcXSUdSeymz1nVQoPXnaSUfVF/ZnLs pNjUouAwn3GIcq91MP1xI6o0Ixv7DEqLg5ibPcqO+wf8WKlFpSE+XwEhSoJMOHgJSmOZ dMcpmsvWiR2Gu6aKGb/q+H8KG5msinIxbnNsvbzSVFZbi8tBZhlpJbH1K+xhIHxi2A52 tZeg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ia9TWNR6; 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-179260-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179260-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b1f064si9447231b3a.225.2024.05.14.16.37.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 16:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179260-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ia9TWNR6; 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-179260-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179260-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7EF2E2822D0 for ; Tue, 14 May 2024 23:37:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4D9D182CA8; Tue, 14 May 2024 23:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ia9TWNR6" Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (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 9AC7C13D619 for ; Tue, 14 May 2024 23:36:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715729819; cv=none; b=oItoIMTjKeYec5D1rG56QG6EIShigpjZdxUuZ+nVsc8nHkHpXW004Y98GKcWNgGvQSRBQtlvPnrVYaY+UGG4r1n7+2L8BqcQNNuHGPPeNLgguMJrJELzMUACFWpsmuwFVC/FWokJsQ+YH2cKvmG/nXC7no6E6qm27/FknBXNRPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715729819; c=relaxed/simple; bh=52SPuKOsw1lbaFiybwD05AI4uDArZnOo9RtFjz5jCFg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RS3sAt/oNQ0usiME7OG8uFwqyIYywu/9uLvpfdj2diJuBwtbAjUvTnY2OLOVKnJARSm/3wkdaqlFKFS5UeFmqUUKIjZXmnz4CRbWcTf7RGB/CqMOqZmnf9nx3ztep0wim7VI8nag0pVido2VA31FJkxvvOlZih+GzUCA90mwnbQ= 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=ia9TWNR6; arc=none smtp.client-ip=95.215.58.183 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 16:36:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715729814; 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=QGeu7E7YtU64Es+FXJxCc3GogLv/cEp8pF/frLRvsxw=; b=ia9TWNR6cK0XgiL91oaEYNnsvY8LIynRf33KCN9kTNxOQLhTvTuZX6AIqh9dqUWc0SOO3D lEn4JEcU1aa4TH6gewXNp/j53gmNvYEpXX3py4Wj7xtH0vXAut0Isjc0m7/48vWNgySInp jVB+5339DuiYFwz1X9Xt6FK3oV/EerY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Johannes Weiner Cc: Andrew Morton , Michal Hocko , Shakeel Butt , 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 Looks really solid. Reviewed-by: Roman Gushchin Thanks!