From patchwork Fri Oct 13 11:30:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 152509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1821115vqb; Fri, 13 Oct 2023 04:31:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAepOYidrUweiHZbBJ+yzwZgLyAdhSNqbBgjkCMAo2RR++eiT8e+MWd2eJ8ENsoqrAFEEz X-Received: by 2002:a17:902:e80a:b0:1c4:1e65:1e5e with SMTP id u10-20020a170902e80a00b001c41e651e5emr29683771plg.0.1697196670719; Fri, 13 Oct 2023 04:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697196670; cv=none; d=google.com; s=arc-20160816; b=mp+G7GXPF7JkXsIvN+xK0YQyBlqDJXObiCILPOqPcboQjK/SSPzmwlM4XKVvBtP/2x DXFmA/wbIpf3YvgK9B4QKdHIthTc6tVOrqAZdfWwa0C08rbLk0tw+Bl5fuffGNY5zDdL x4bC/HK3l6of5h/4ZzZjUedFeLQ+0aR6QYrC5o+UusXM5NPBhr3XHYEJqBei6KARjsa7 esRdujmIPoc/XrwO74h3rACRK2L0yEniAcpABLouV8fxlSmshxi3cPlB4/f1cl2lzLNC jkTfGifIsJR04wCS5yFPK9gXcSrpoKoELLR+nsOMSM03Hgc57+wZemB1XqjKtHy5VVn5 Rzxg== 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:to:from; bh=46g4yk1ucuwHds3pdyDAsghbkyMAc7JI8Rq622Pn70A=; fh=+nAGP6p5t7iU21GjUZgOKOSZW4B5X7PB/NV18/kheFw=; b=HLkpCfOBECp7agrOlvpoOY2+A41AiHLhhbWYT6EXmDqbc+xlZh1JuNsoJkhUqx4kHy TVAILr1PLW874hgYzxixkN1v/N6TQ6fwXgPKx7PWwHPzYJH5qyvTe+/3Mo4sgYbRqLXC qKUvy/lZ/yvXhDp1WwvrFbQqbFSt/bXAnAv81Ha10AsQqdBipe6ZWHXlGaf8ZHPH2xta IPduJ7J853LO0Ql7eY9I5F/lfMQ3pKooeykg8Ia1XN69NEP27/AX3+IphAaUJ4f0GQKz buXyXijFakVw8OLWJLNp3odGdnrKIZ3/Ez9rnrimKrXtO6VPyVSDkwzrq9dWHAqcCWU8 WjYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id t5-20020a170902a5c500b001c7545405b5si4170751plq.519.2023.10.13.04.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 04:31:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 69A2A809C935; Fri, 13 Oct 2023 04:31:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbjJMLat (ORCPT + 19 others); Fri, 13 Oct 2023 07:30:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230039AbjJMLar (ORCPT ); Fri, 13 Oct 2023 07:30:47 -0400 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68F21BF for ; Fri, 13 Oct 2023 04:30:42 -0700 (PDT) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 39DBUXrv083164; Fri, 13 Oct 2023 19:30:33 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4S6PN53R5wz2KWZZn; Fri, 13 Oct 2023 19:26:29 +0800 (CST) Received: from bj03382pcu01.spreadtrum.com (10.0.73.40) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 13 Oct 2023 19:30:31 +0800 From: "zhaoyang.huang" To: Andrew Morton , Matthew Wilcox , Johannes Weiner , Suren Baghdasaryan , Michal Hocko , Yu Zhao , , , Zhaoyang Huang , Subject: [RFC PATCH 1/1] mm: only use old generation and stable tier for madv_pageout Date: Fri, 13 Oct 2023 19:30:28 +0800 Message-ID: <20231013113028.2720996-1-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.0.73.40] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 39DBUXrv083164 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 13 Oct 2023 04:31:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779639696047892070 X-GMAIL-MSGID: 1779639696047892070 From: Zhaoyang Huang Dropping pages of young generation or unstable tier via madvise could make the system experience heavy page thrashing and IO pressure. Furthermore, it could lead to failure of tier's PID controller which affect normal reclaiming. I would like suggest skipping this pages in madv_pageout. Signed-off-by: Zhaoyang Huang --- include/linux/swap.h | 1 + mm/madvise.c | 12 ++++++++++++ mm/vmscan.c | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 493487ed7c38..d09c859ccc45 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -496,6 +496,7 @@ extern int init_swap_address_space(unsigned int type, unsigned long nr_pages); extern void exit_swap_address_space(unsigned int type); extern struct swap_info_struct *get_swap_device(swp_entry_t entry); sector_t swap_page_sector(struct page *page); +extern int get_tier_idx(struct lruvec *lruvec, int type); static inline void put_swap_device(struct swap_info_struct *si) { diff --git a/mm/madvise.c b/mm/madvise.c index 4dded5d27e7e..324d76096ca5 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -452,6 +452,18 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, if (!folio || folio_is_zone_device(folio)) continue; + if (lru_gen_enabled() && pageout) { + int gen = folio_lru_gen(folio); + struct lruvec *lruvec = folio_lruvec(folio); + int type = folio_is_file_lru(folio); + int refs = folio_lru_refs(folio); + int tier = lru_tier_from_refs(refs); + int tier_st = get_tier_idx(lruvec, type); + + if (gen > lru_gen_from_seq(lruvec->lrugen.min_seq[type]) + 1 + || tier > tier_st) + continue; + } /* * Creating a THP page is expensive so split it only if we * are sure it's worth. Split it if we are only owner. diff --git a/mm/vmscan.c b/mm/vmscan.c index 6f13394b112e..16900a8c13e0 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -5072,7 +5072,7 @@ static int scan_folios(struct lruvec *lruvec, struct scan_control *sc, return isolated || !remaining ? scanned : 0; } -static int get_tier_idx(struct lruvec *lruvec, int type) +int get_tier_idx(struct lruvec *lruvec, int type) { int tier; struct ctrl_pos sp, pv; @@ -5091,6 +5091,7 @@ static int get_tier_idx(struct lruvec *lruvec, int type) return tier - 1; } +EXPORT_SYMBOL_GPL(get_tier_idx); static int get_type_to_scan(struct lruvec *lruvec, int swappiness, int *tier_idx) {