From patchwork Thu Sep 26 05:06:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13812799 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 B1936CCFA15 for ; Thu, 26 Sep 2024 05:07:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2236A6B009E; Thu, 26 Sep 2024 01:07:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D3286B009F; Thu, 26 Sep 2024 01:07:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C1EF6B00A2; Thu, 26 Sep 2024 01:07:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E205B6B009E for ; Thu, 26 Sep 2024 01:07:15 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 84A5F1607CB for ; Thu, 26 Sep 2024 05:07:15 +0000 (UTC) X-FDA: 82605705630.20.646F75B Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by imf05.hostedemail.com (Postfix) with ESMTP id DBB2B100008 for ; Thu, 26 Sep 2024 05:07:11 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.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=1727327072; 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:content-transfer-encoding:in-reply-to: references; bh=La0m+DeaQzkiOOP9/q7s4w7200U93bHyvhlZfX5XERc=; b=dyASx1oNpKjlOLXAG0qcHFSLkigRUFsbm5YBtOjbP5/1CQ/ygMW6K7FRBo8ee1LelKVm18 tImDAdkVucmJTMFdzS8BAACVHo71Ikf77AmdybDon1/gvh0tMvLte5wcHHKkgLKmz4wqap 24XbHsQzwJNBczCQFrSJF4l/Qyf+NNQ= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727327072; a=rsa-sha256; cv=none; b=2PbwWah7fJOTUT8cp4QJWAI3z7FOa68o4WqSmYKSvs9pOZw0vPU2FzA1C59rQPR5VC70vf ThXblCswB6F4fAuc5sHz1AC1Q6vDVO5dCW3cjTWcCHJqpT+tfx5OQT4AMqN0V4RQLOF+jz p3iUlNyIKxj/zipyy7RN5Yuip7Yg0sE= Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 48Q56wbN046190; Thu, 26 Sep 2024 13:06:58 +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 4XDhG81T1sz2QHlsf; Thu, 26 Sep 2024 12:59:12 +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; Thu, 26 Sep 2024 13:06:56 +0800 From: "zhaoyang.huang" To: Andrew Morton , David Hildenbrand , Matthew Wilcox , Yu Zhao , , , Zhaoyang Huang , Subject: [PATCHv2] mm: migrate LRU_REFS_MASK bits in folio_migrate_flags Date: Thu, 26 Sep 2024 13:06:47 +0800 Message-ID: <20240926050647.5653-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 48Q56wbN046190 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: DBB2B100008 X-Stat-Signature: 15cap7an8xsnxgr7dz95dh918zt46k4p X-Rspam-User: X-HE-Tag: 1727327231-811901 X-HE-Meta: U2FsdGVkX1/NHKTvhvYCOqPIuYGSX9zvqMQVo6HIW0p/Mdbz4FDWHFNmu4OcVZI3xIU2g00X3HXWECH3DDTG4OpSBZIiP0eFygIaj69U/yRTxqYP5xD4Qkjw3dTwtPjP9p0flPob8FUjVVIftoe1c1dWUJ5TY2aGHl4ASRTYViQfIW8sBx2s6zRLDiTnuvn6BNZshtEmA+b1HFNRATIyYpGXNrBguevCS15kL8eqSY44miswV2dNh6657g4U7FKJal8EY/nagIYUNBFuS86eRaYYK+AYLkOMSq0cxnepUGa/Tk/FymQSf0JyrIt3weT70LoWQJKpE4VnYUHnQ7U9cOjgT4HEtGRuKtS+sGhe7gEKeJFhw4/uuHuD2FyYp0dd1y8j74//j/9ZN/PWAeta9YolOJcURsk4n7ghLAeoRCJbfB5zGf3BlPttsrcjNT08YfMFrZU2lqAhsjOLfUB1RdolAHfqZAiibZB1ZzIynF4PAfderYAWMcybAd9OG6u5Wut3zbUyxGmZqLjAvRz/uwPEX9AZK6ULNO+FbFIDnKm0OtcEf/nwycdUIaqIYLRDaEolxCZubFpdrHbXpisPsf7+DA1FIc1O34+rpDcgR4Q7LvPp7eae+qI/cnrDyVAcgQpFQGDjQyT1LYnEUOKqJWSdjwj+JPKMulvMKOi9gG32ff17mH3ZPD/HdxqHQcKSByEIzLOY8VqnE7T1jWK0oSfoW4SfUi2E/hDJSQ/p8IK7Bsodnbs33Rrmku9MadMlrxHQeJXKN/Jt8lylzEFm4s1EPlo1yMp4vIcVpP4m7yWgpWcVIlvnP4pS08Xat2s1Fb0eRbUlD0r8cXSd3gLJiBgZm7FkovtcxPaIXywSV/kRZ4MnKleFpawztuXbiiStCzRPK0HYIBk4FVCivmzP3k1M7PngnnoIyAQs/ndcVXe4HXHss+TWJNXRn7gI9Q2DMboqBaUdyJ+CxgICHKu ZYnj+Jiu BwxOJflKkmiwMBl7N2d0fwvBaIYY3+JjLLKLbiWwl1lnJrFvp35GqdQPWuadZvlKcQWBGfH5dEWw5vbwd/2YHHM7VCbShJ+A/26iIMDuLrF/vPHbpV6sNAX/O0h4uIHzIrrSqE8QPohhNUEj2k20a7ykFLUO7Kxrt3mHXxXmU7oxgvZI5BTt/WJUMXDZQGN2fGctCnLkrqILLj0gYJezfqWFtgQ== 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: List-Subscribe: List-Unsubscribe: From: Zhaoyang Huang Bits of LRU_REFS_MASK are not inherited during migration which lead to new folio start from tier0 when MGLRU enabled. Try to bring as much bits of folio->flags as possible since compaction and alloc_contig_range which introduce migration do happen at times. Suggested-by: Yu Zhao Signed-off-by: Zhaoyang Huang Acked-by: David Hildenbrand --- v2: modification as Yu Zhao suggested --- --- include/linux/mm_inline.h | 10 ++++++++++ mm/migrate.c | 1 + 2 files changed, 11 insertions(+) diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index f4fe593c1400..6f801c7b36e2 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h @@ -291,6 +291,12 @@ static inline bool lru_gen_del_folio(struct lruvec *lruvec, struct folio *folio, return true; } +static inline void folio_migrate_refs(struct folio *new, struct folio *old) +{ + unsigned long refs = READ_ONCE(old->flags) & LRU_REFS_MASK; + + set_mask_bits(&new->flags, LRU_REFS_MASK, refs); +} #else /* !CONFIG_LRU_GEN */ static inline bool lru_gen_enabled(void) @@ -313,6 +319,10 @@ static inline bool lru_gen_del_folio(struct lruvec *lruvec, struct folio *folio, return false; } +static inline void folio_migrate_refs(struct folio *new, struct folio *old) +{ + +} #endif /* CONFIG_LRU_GEN */ static __always_inline diff --git a/mm/migrate.c b/mm/migrate.c index 923ea80ba744..60c97e235ae7 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -618,6 +618,7 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio) if (folio_test_idle(folio)) folio_set_idle(newfolio); + folio_migrate_refs(newfolio, folio); /* * Copy NUMA information to the new page, to prevent over-eager * future migrations of this same page.