From nobody Fri Apr 17 22:31:13 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B626C43334 for ; Thu, 21 Jul 2022 07:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232319AbiGUHIN (ORCPT ); Thu, 21 Jul 2022 03:08:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232057AbiGUHIJ (ORCPT ); Thu, 21 Jul 2022 03:08:09 -0400 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20E4277A4E for ; Thu, 21 Jul 2022 00:08:05 -0700 (PDT) Received: from SHSend.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by SHSQR01.spreadtrum.com with ESMTPS id 26L77AB4031705 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Thu, 21 Jul 2022 15:07:10 +0800 (CST) (envelope-from zhaoyang.huang@unisoc.com) Received: from bj03382pcu.spreadtrum.com (10.0.74.65) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 21 Jul 2022 15:07:10 +0800 From: "zhaoyang.huang" To: Andrew Morton , Johannes Weiner , Joonsoo Kim , Zhaoyang Huang , , , Subject: [RFC PATCH] mm: set cache_trim_mode when inactive ratio is undesired Date: Thu, 21 Jul 2022 15:06:48 +0800 Message-ID: <1658387208-20065-1-git-send-email-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.0.74.65] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 26L77AB4031705 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhaoyang Huang Undesirable inactive file ratio could be observed under some scenarios(such= as large number of mapped file access) and hardly recover during a certain per= iod of time, which could be a result of tight criteria judgement of cache_trim_= mode, which demand both of none-thrashing and inactive_is_low simutaneously and l= ead to the mode as SCAN_FRAC or SCAN_EQUAL when scanning lru. Signed-off-by: Zhaoyang Huang --- mm/vmscan.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index f7d9a68..8e84fe6 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2663,6 +2663,23 @@ static bool inactive_is_low(struct lruvec *lruvec, e= num lru_list inactive_lru) return inactive * inactive_ratio < active; } =20 +static bool inactive_is_high(struct lruvec *lruvec, enum lru_list inactive= _lru) +{ + enum lru_list active_lru =3D inactive_lru + LRU_ACTIVE; + unsigned long inactive, active; + unsigned long active_ratio =3D 2; + unsigned long gb; + + inactive =3D lruvec_page_state(lruvec, NR_LRU_BASE + inactive_lru); + active =3D lruvec_page_state(lruvec, NR_LRU_BASE + active_lru); + + gb =3D (inactive + active) >> (30 - PAGE_SHIFT); + if (gb) + active_ratio =3D 1; + + return inactive > active_ratio * active; +} + enum scan_balance { SCAN_EQUAL, SCAN_FRACT, @@ -3198,7 +3215,8 @@ static void shrink_node(pg_data_t *pgdat, struct scan= _control *sc) * anonymous pages. */ file =3D lruvec_page_state(target_lruvec, NR_INACTIVE_FILE); - if (file >> sc->priority && !(sc->may_deactivate & DEACTIVATE_FILE)) + if (file >> sc->priority && (!(sc->may_deactivate & DEACTIVATE_FILE) + || inactive_is_high(target_lruvec, LRU_INACTIVE_FILE))) sc->cache_trim_mode =3D 1; else sc->cache_trim_mode =3D 0; --=20 1.9.1