Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp823612iob; Fri, 13 May 2022 13:39:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrJcCBT3ldfQyZu4ajggKK/OxSgBo8fszcF5Ecfuol3UGfqbMEYx5cI866SofIHdXu4a4C X-Received: by 2002:a17:907:d16:b0:6f8:c054:29ac with SMTP id gn22-20020a1709070d1600b006f8c05429acmr5909484ejc.96.1652474396283; Fri, 13 May 2022 13:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652474396; cv=none; d=google.com; s=arc-20160816; b=mUafStgtg3X0YAsz6IHbseXgHLMKv8dS6Yo94Yn5Gk/JbvClB7gqRnhVwrUruQ30Le f0pMza+wElZK9YvpMiyWjrEuaWadby0AUyjaRIvUG2Tvyw0CFQ/ck0Y0lSF6gSgz/48o 19T22nhutXLA7q1tVfpvhiSkfLZza+MzByErwk4YlQt2NMJzJbSyHRkAXShtzcofOhHq PF/y0Y6u3If83hDE6VTEIiFFLjI3l2kLZOXBVIdGC7pjPTPNYk8iIJToqQR7rOSIjbg4 jqEsXXuhJ1uJ5vs6nA2CdU+XqhcXXnckTFdB6R5qmI4X/Yj44XTY92nPMn5Ltd7Mrs9m JRFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=kEZ/s8hRwnKElcMcEnnpj6KQgCa+qm0GjS2AdJ8yL9o=; b=NL5/OWjEaorakwdYIyLyXiitwEZkYazajoG5Phgt7Pp+3M3rKBwbDqHvN2Nll56oFa eNlcS9UidJQXSv+4448HP8ADYOHfrhg/fKlQzCWDFAACo1w3b3xx/jw/7b0ls/t6uLmc sGhgDnq/9Vpa/dUhhbqx2uhcg1kdMtyiVn1cFfmc2i9K2TCCD7mBN/Q6Pi3Tn0SMeAuI jDL8XiFCwlPtDM/f+ZWlcLZ9qMJSXrGHc8UE+srqcwW2iO5AbUzhWpObtgXuSQIeQRjZ VoiwMVYwmDkxOtdWNxx/jguecF04Z8tPjr4/bA/wc+pT3OmheUMMVIoJOr/zc7X40bu+ 5big== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=E0qQdpXw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gr19-20020a170906e2d300b006f3a817a503si3115530ejb.816.2022.05.13.13.39.30; Fri, 13 May 2022 13:39:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=E0qQdpXw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244510AbiEKWd4 (ORCPT + 99 others); Wed, 11 May 2022 18:33:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232399AbiEKWdy (ORCPT ); Wed, 11 May 2022 18:33:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2B3F6D960 for ; Wed, 11 May 2022 15:33:52 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 9914AB82407 for ; Wed, 11 May 2022 22:33:51 +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-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?