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 X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A95BDC4338F for ; Sat, 7 Aug 2021 02:21:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3B44361167 for ; Sat, 7 Aug 2021 02:21:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3B44361167 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9E3058D0001; Fri, 6 Aug 2021 22:21:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9930B6B0071; Fri, 6 Aug 2021 22:21:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A9368D0001; Fri, 6 Aug 2021 22:21:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6E8C36B006C for ; Fri, 6 Aug 2021 22:21:50 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 038661F232 for ; Sat, 7 Aug 2021 02:21:49 +0000 (UTC) X-FDA: 78446683980.09.815D8F0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 945C070148EC for ; Sat, 7 Aug 2021 02:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628302909; 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=Q+7cG7xhRyIP8KFqGqqBfTmxfpmvZcxdghzXKqssv0Y=; b=MhZPj45bEBg7ronpsKDD6fbpYKPc8czUTnZuYARW52UTX89RL1tjiyar4p0C+3yOBre+H1 vIm96N86G0sV3thfMBIFx5SLJ2KQzVXlHweCUypl4tagfwNKhsJkitkyPteBYtE4igJ7xF XFCSijwnvUdY2IGD5plyekIbiB8rY1U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-8-PwD0IpJLOpqWA9RHngli0g-1; Fri, 06 Aug 2021 22:21:47 -0400 X-MC-Unique: PwD0IpJLOpqWA9RHngli0g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 587521853025; Sat, 7 Aug 2021 02:21:46 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.22.16.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46CF627C47; Sat, 7 Aug 2021 02:21:41 +0000 (UTC) From: Nico Pache To: linux-mm@kvack.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org Cc: hannes@cmpxchg.org, npache@redhat.com, aquini@redhat.com, shakeelb@google.com, llong@redhat.com Subject: [PATCH v2] vm_swappiness=0 should still try to avoid swapping anon memory Date: Fri, 6 Aug 2021 22:21:29 -0400 Message-Id: <20210807022129.8842-1-npache@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 945C070148EC Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MhZPj45b; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf27.hostedemail.com: domain of npache@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=npache@redhat.com X-Stat-Signature: 1ebimzz53ug56ari5eok65swfkaffxrq X-HE-Tag: 1628302909-136260 Content-Transfer-Encoding: quoted-printable 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: Since commit b91ac374346b ("mm: vmscan: enforce inactive:active ratio at = the reclaim root") swappiness can start prematurely swapping anon memory. This is due to the assumption that refaulting anon should always allow the shrinker to target anon memory. Add a check for swappiness being >0 before indiscriminately targeting Anon. This does not completely disable swapping, but rather tames the refaulting aspect of the code that allows for the deactivating of anon memory. A similar solution may be possible in the get_scan_count() part of the code, which determines the reclaim pressure for each LRU; however I believe that kind of solution may be too aggressive, and not allow other parts of the code (like direct reclaim) from targeting the active_anon list. This way we stop the problem at the heart of what is causing the issue, with the least amount of interference in other code paths. Furthermore, shrink_lruvec can modify the reclaim pressure of each LRU, which may make the get_scan_count solution even trickier. Changelog: -v2: made this mem_cgroup specific so now it will work with v1, v2, and no cgroups. I've also touched up my commit log. Signed-off-by: Nico Pache --- mm/vmscan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 4620df62f0ff..89d4e84011b7 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2909,8 +2909,9 @@ static void shrink_node(pg_data_t *pgdat, struct sc= an_control *sc) =20 refaults =3D lruvec_page_state(target_lruvec, WORKINGSET_ACTIVATE_ANON); - if (refaults !=3D target_lruvec->refaults[0] || - inactive_is_low(target_lruvec, LRU_INACTIVE_ANON)) + if (mem_cgroup_swappiness(sc->target_mem_cgroup) && + (refaults !=3D target_lruvec->refaults[0] || + inactive_is_low(target_lruvec, LRU_INACTIVE_ANON))) sc->may_deactivate |=3D DEACTIVATE_ANON; else sc->may_deactivate &=3D ~DEACTIVATE_ANON; --=20 2.31.1