From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64DD7C433EF for ; Wed, 11 May 2022 22:33:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE7016B0074; Wed, 11 May 2022 18:33:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA4456B0075; Wed, 11 May 2022 18:33:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5E876B0078; Wed, 11 May 2022 18:33:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 96EC46B0074 for ; Wed, 11 May 2022 18:33:52 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 574FC20657 for ; Wed, 11 May 2022 22:33:52 +0000 (UTC) X-FDA: 79454915904.24.632D658 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 542AE1A00A8 for ; Wed, 11 May 2022 22:33:43 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EC5E961D0E; Wed, 11 May 2022 22:33:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFA2CC340EE; Wed, 11 May 2022 22:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1652308430; bh=l5qFeU21BOfqAOWsHedlR70rZJGoWr8PVojCgih54Vg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=E0qQdpXwKqZt4VQ8QtuYDJYdmrU4nqF54uXos8Hp+ArLkuDDpuFhwCqGAOiDQUDe8 Q0B135DWSLeXVdxy35CIgMrXzSZGP8BFjS814Efs3ScCVEHB9A3cTlpQML0S8d3oJy 3C8Ja1KWE8pfVJW6qzHe42sJlIEcScKZfDDpdswo= Date: Wed, 11 May 2022 15:33:49 -0700 From: Andrew Morton To: Minchan Kim Cc: LKML , linux-mm , Suren Baghdasaryan , Michal Hocko , John Dias , Tim Murray , Matthew Wilcox , Vladimir Davydov , Martin Liu , Johannes Weiner Subject: Re: [PATCH v4] mm: don't be stuck to rmap lock on reclaim path Message-Id: <20220511153349.045ab3865f25920dce11ca16@linux-foundation.org> In-Reply-To: <20220510215423.164547-1-minchan@kernel.org> References: <20220510215423.164547-1-minchan@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 542AE1A00A8 Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=E0qQdpXw; spf=pass (imf19.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-Stat-Signature: te1sifrgj1rcz3pwti1ky6n8d1df4p5c X-HE-Tag: 1652308423-264715 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 10 May 2022 14:54:23 -0700 Minchan Kim wrote: > The rmap locks(i_mmap_rwsem and anon_vma->root->rwsem) could be > contended under memory pressure if processes keep working on > their vmas(e.g., fork, mmap, munmap). It makes reclaim path > stuck. In our real workload traces, we see kswapd is waiting the > lock for 300ms+(worst case, a sec) and it makes other processes > entering direct reclaim, which were also stuck on the lock. > > This patch makes lru aging path try_lock mode like shink_page_list > so the reclaim context will keep working with next lru pages > without being stuck. if it found the rmap lock contended, it rotates > the page back to head of lru in both active/inactive lrus to make > them consistent behavior, which is basic starting point rather than > adding more heristic. > > Since this patch introduces a new "contended" field as out-param > along with try_lock in-param in rmap_walk_control, it's not > immutable any longer if the try_lock is set so remove const > keywords on rmap related functions. Since rmap walking is already > expensive operation, I doubt the const would help sizable benefit( > And we didn't have it until 5.17). > > In a heavy app workload in Android, trace shows following statistics. > It almost removes rmap lock contention from reclaim path. What might be the worst-case failure modes using this approach? Could we burn much CPU time pointlessly churning though the LRU? Could it mess up aging decisions enough to be performance-affecting in any workload? Something else?