From patchwork Tue Dec 6 22:23:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Pache X-Patchwork-Id: 30523 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3087113wrr; Tue, 6 Dec 2022 14:46:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Os+fM1lK6FJXVxd1bhOgZ2iW4Xe+UV1wGfmZ5y7XP5+5BgmL4VLpPzHftlGvBA39eZuDB X-Received: by 2002:a62:e30b:0:b0:576:fde4:ca27 with SMTP id g11-20020a62e30b000000b00576fde4ca27mr10754827pfh.75.1670366799938; Tue, 06 Dec 2022 14:46:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670366799; cv=none; d=google.com; s=arc-20160816; b=N/wIbdzgjSV5XJN5KC/vrOBfilHEKlrHRw/8xzsTMz5FvN/b//ceMcVPHYMoLKO6Dg N6a2Um39TGY4wM7b/z6r1x4bmKAqKDimICUakOhW5EkTw2QpPBi34WAq/9WFM8ESLhwe UUR2LqQPIs0TG8ojeDNac+x/gbCF9ooPVPFZX3fa1NOys4NpvqYSr0Tjz49Y1HkpFu2H 2fQorY1B258Fnog0a3395+BI772sMKRQnacuev/VXMWir418PN21ua3q5rJSnZHg1XEZ mOY++FUOU3+JfnBo0XDd3DUl0oFG2aQQvRX/GI3+imPpmcykX47KwxdOVBhUA/D7fP3u kFqA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=KbcWN/Q2/pafQvgYCQFGwmhf/LUYY3gpOtuCCKoJbLI=; b=oqdrfQoawk4+RuHXYXlmEyMVl0MSker72mMdFuPlrjn2nvcZ9ZZhMulRw9gUKtfac9 YuIr/M5Cnm88O01bQ/80ftCQu9cGQv6+5R7ZmNam77B6MDii6i6zhl/igS2BcOdaZ/J3 BHAVrVNpcyRos1mqkJV2Imjfhaq8xRA/eMFCZHQEhIhstuQKDnSofTbAjcgyTnRV3Gvw 6tPLXvTIjTHQR80njaaQTC75fQ9EJzLG9Wco6/IbacLwij0Lj2mOAcbi5vsfKZ5ZcSs9 QCef2O7aeVzAHqind1Vi/eFAGwN59FIgctSvGay+QgX+hDASdPyAy/K+Hamp3iIO2mSi cyKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NdDfPqh4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a17090282c500b00179ec1d9eb4si14302267plz.112.2022.12.06.14.46.19; Tue, 06 Dec 2022 14:46:39 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=NdDfPqh4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229877AbiLFWYh (ORCPT + 99 others); Tue, 6 Dec 2022 17:24:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbiLFWYf (ORCPT ); Tue, 6 Dec 2022 17:24:35 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B99B230577 for ; Tue, 6 Dec 2022 14:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670365414; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=KbcWN/Q2/pafQvgYCQFGwmhf/LUYY3gpOtuCCKoJbLI=; b=NdDfPqh4EVTCN3l2AY8PgAyn61JceAbxbMuwoQqAvPA/aAsRskP78oR1aepzHCGsjwmiDk blsLy/pOCxAHIxVUe2iXiuvOAL+qlQNzaPCKr1BWr2EjCRiLnWHAgJLdK4R2lm0sf41jDV G7u7GDfMh+/4IeplTs69v0h3VIPw6fQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-317-r1vEH37-OeiFQN_UhFKpZg-1; Tue, 06 Dec 2022 17:23:30 -0500 X-MC-Unique: r1vEH37-OeiFQN_UhFKpZg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8FDE3811E67; Tue, 6 Dec 2022 22:23:29 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.22.11.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA56E2027061; Tue, 6 Dec 2022 22:23:27 +0000 (UTC) From: Nico Pache To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: riel@surriel.com, mhocko@suse.com, shakeelb@google.com, iamjoonsoo.kim@lge.com, vbabka@suse.cz, hannes@cmpxchg.org, akpm@linux-foundation.org, aquini@redhat.com, longman@redhat.com Subject: [RFC] vmscan: Scale file_is_tiny calculation based on priority Date: Tue, 6 Dec 2022 15:23:15 -0700 Message-Id: <20221206222315.37631-1-npache@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751506537849983811?= X-GMAIL-MSGID: =?utf-8?q?1751506537849983811?= Now that reclaiming anon memory is more prevelant (Johannes describes this well in commit f53af4285d77 ("mm: vmscan: fix extreme overreclaim and swap floods")), we've been seeing large bursts (sometimes in the order of multiple GiBs) of anon memory being reclaimed despite swappiness being very low (=1) and there being plenty of page cache remaining. Johannes commit f53af4285d77 ("mm: vmscan: fix extreme overreclaim and swap floods"), helped reduce these swap storms; however, it did not fully curb this effect. Under further investigation I noticed these swap storms correspond to the activation of file_is_tiny. file_is_tiny is being computed on a per-node basis, if reclaim drains the page cache on one node, and the scheduler is prefering new allocations on a separate node, file_is_tiny will remain elevated for a very long time, constantly draining anon from the node that is low on page cache. These burst of reclaim are also seen in the single node case, where once file_is_tiny=1, anon reclaim is too aggressive with a low swap value. Reduce these extreme bursts of anon reclaim by scaling the total_high_wmark down by the reclaim priority. This will activate file_is_tiny way less often, and for smaller bursts. Fixes: ccc5dc67340c ("mm/vmscan: make active/inactive ratio as 1:1 for anon lru") Fixes: 5df741963d52 ("mm: fix LRU balancing effect of new transparent huge pages") Signed-off-by: Nico Pache --- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 026199c047e0..0d288bb5354e 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2882,7 +2882,7 @@ static void prepare_scan_count(pg_data_t *pgdat, struct scan_control *sc) anon = node_page_state(pgdat, NR_INACTIVE_ANON); sc->file_is_tiny = - file + free <= total_high_wmark && + file + free <= (total_high_wmark >> sc->priority) && !(sc->may_deactivate & DEACTIVATE_ANON) && anon >> sc->priority; }