From patchwork Thu Jul 21 07:06:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 12924998 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 308E4C433EF for ; Thu, 21 Jul 2022 11:53:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5CC698E0001; Thu, 21 Jul 2022 07:53:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 57C9D6B0073; Thu, 21 Jul 2022 07:53:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 444888E0001; Thu, 21 Jul 2022 07:53:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 341176B0072 for ; Thu, 21 Jul 2022 07:53:16 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C00A58080C for ; Thu, 21 Jul 2022 07:07:57 +0000 (UTC) X-FDA: 79710227394.18.33F4F52 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by imf28.hostedemail.com (Postfix) with ESMTP id 4D894C0093 for ; Thu, 21 Jul 2022 07:07:54 +0000 (UTC) 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 ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658387277; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references; bh=1Zn7gAv+plNE84d3Soz8265N9ANy7lVx7YViQMfUpcU=; b=FvtAkt9JiNeOFYpB/sIkpAzaZJLRZ/LVjSAwCNyojA0Db0K2zDumyOUSggonbxiNvNrwZG utMkHywWzrIt1fLghR3s/d4YjwADLl50cOei3zAzo7on7LwqHu/zleSt6sEYTbjSmJ3epi xu707joREBJKZ0xZoT94KrYRdOiW5Ew= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658387277; a=rsa-sha256; cv=none; b=WKPsX3EAlrRHY0sU6fKBaasWpqbcP1GJdoqy0LCdX6+tF4b7B5I5CsxT20Nuu8FYZLhIFA vvjSJVH+kuGF52NMSi3uUMT5HWmp8GyRoT4RSMCrwtv8hFwTwPNnitkQHs9S8aohRLurXJ MwWicXlW1n43OEu0tDUCj92Ea27Ra34= X-Rspam-User: X-Rspamd-Queue-Id: 4D894C0093 Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com; dmarc=none X-Stat-Signature: 7zypybm3on31c6yy37oprjr54d3eu8t1 X-Rspamd-Server: rspam07 X-HE-Tag: 1658387274-219831 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: 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 period 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 lead 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, enum lru_list inactive_lru) return inactive * inactive_ratio < active; } +static bool inactive_is_high(struct lruvec *lruvec, enum lru_list inactive_lru) +{ + enum lru_list active_lru = inactive_lru + LRU_ACTIVE; + unsigned long inactive, active; + unsigned long active_ratio = 2; + unsigned long gb; + + inactive = lruvec_page_state(lruvec, NR_LRU_BASE + inactive_lru); + active = lruvec_page_state(lruvec, NR_LRU_BASE + active_lru); + + gb = (inactive + active) >> (30 - PAGE_SHIFT); + if (gb) + active_ratio = 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 = 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 = 1; else sc->cache_trim_mode = 0;