From patchwork Wed Sep 25 03:02:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13811562 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 34526CF9C69 for ; Wed, 25 Sep 2024 03:02:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F9776B0089; Tue, 24 Sep 2024 23:02:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8AA036B008C; Tue, 24 Sep 2024 23:02:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7988C6B0092; Tue, 24 Sep 2024 23:02:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5C6BA6B0089 for ; Tue, 24 Sep 2024 23:02:56 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F0944140769 for ; Wed, 25 Sep 2024 03:02:55 +0000 (UTC) X-FDA: 82601763510.29.9A8D1C4 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by imf09.hostedemail.com (Postfix) with ESMTP id 2A007140010 for ; Wed, 25 Sep 2024 03:02:52 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf09.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727233242; 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=Cwp3nhJmEOvLDZWBCne7YKhZIxFf4Aan+Pc2K3CO9g4=; b=zj70lvlm2ERPSkIDfhfct+/Na7ZkhIr527tDtSGxZxXpicwxwVV7t881CtQrIhhMjLOPw6 Sbd7fBHiaTE1fIiNOStIE2XcwvEciA3DN6xc16s/7oXD0MhGXVAmQMIcMDvdXom0B4pWvU AmiZmvcAJ69Cz9pLRXgXWDCgu8xfTGI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727233242; a=rsa-sha256; cv=none; b=iqXndRLj/rmoxHAqDy9Y1O7daQ3TwUq5lZCvXB1BNUsT+yA2sz3PBzEdVelNStbayfxua/ T3Av4BjSKd1lcGKcOVG3K0EEDKCxqqDGa6VNFxKE5z0a7RYZZsnl+XzaIgGrRb0kNXrOZ2 i9JpzwZwhBrY1402xlEf9K6Stgfj3Kg= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf09.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 48P32ahN055927; Wed, 25 Sep 2024 11:02:36 +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 4XD1Y72yJFz2NZbG3; Wed, 25 Sep 2024 10:54:51 +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; Wed, 25 Sep 2024 11:02:33 +0800 From: "zhaoyang.huang" To: Andrew Morton , David Hildenbrand , Matthew Wilcox , Yu Zhao , , , Zhaoyang Huang , Subject: [PATCH] mm: migrate LRU_REFS_MASK bits in folio_migrate_flags Date: Wed, 25 Sep 2024 11:02:25 +0800 Message-ID: <20240925030225.236143-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: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 48P32ahN055927 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2A007140010 X-Stat-Signature: bfxfjnba8fsbfpwshdc3p5dutyj78nha X-Rspam-User: X-HE-Tag: 1727233372-226988 X-HE-Meta: U2FsdGVkX1/gPWm80uCxf10iWoHqzyFU0OuXX2HlzVuAZrCZa7I2pbQaGJFvRzG8VgUMRCw44KrFkgdeqlANo7200lZCTwIvqnoNoZ559pUm16iOdeOc/6Of/IMT1ypoUUOK5E7idlIPLjQtDhebOY6AbKsxBaTWaxw1uR0ZEs4eBD5KdcDHQ0Wv8e0dv9a4anYDm/350nODtGW8eGPwmb8Fs8IaOWsNDYhFtDh2Hpsx4HNZx4SU3x43NHeBwDLTgp6t4A2VO8MuYOlC1T8DtSAEJ8XF/4UU4TFsu11yCOj/F5ak/yxiN2ul+puHxZvGKLyxdRjQAdlD7Jaz89hiw3PgkCvz9A6pTDkJ8tfWKKMkLZqClT/SJ7qWBfGfTViZBUdWObMwbeW+rxu21xgWysg+j9IR47DCO29dxaQ7y28CxcFXeuKgex1ujZJ2uCKOZLsF6CfX7kKMW+5eqhZzGPk8B0EXNiyQcXQRCsGpAY70x1BV4U8nR5GS3llbYyHsQJAUtuNaJlGNZjvWe4zPUrTFHguBgWW5AIHSYb2zqqY97H/pjYYELcwtnmjTJuDXXBZ1TVzMooc2syPx5Su8avkHtateYcecggl4AENEuuo6+0GrB0Rxq6tJgfethNX6h/RgZO5w+CxYs7sl/aPMLd92BYfJo1mTTHX4qEKQpTS/r/sQM4Sl67f4eMOCcs/AS0QGhzaLXekpJqvAF09LL4ouJKcTgKrZC9hT+oWJQCbLYGdNer6luoOFTepZiJHH+JwfZf+q25ypa7DniG5mI/iGsqBQRYUHb04vv2yWALZIvQxxFdbMfWnHSfa/HRzkgoWnAKLQWkzITMTfEVzR8EmdxyHd+mKuiRd9OFlBwX6PNoN1urYl2nWOgSxQLNwSXfLyuz/o7RlTvjdOFq8zOTX23EfPUdfqcF3QAeJPUhkOAPcY2u3N6Agc14R6M51Vt+hrunBK4c64HPBU3kS Vm/Fk+zc coEACzN3hAbqhh1hnle0bBwzcpEK/7lHO7l9+nc+CzU3+OCYhdjmMi0/ozcxofpcobe4CbiXSBi20hRLVnEoEz1fdpkfhSgwuYRFbScmQWFu7xhZfnXEtb+Qhua1pAPPN98DjupcgBGTl8MXjw+ZkN70XDTV2OkS4573TdpHaeArrNdVvJvczK2uLbmZtZ0Q+ixUJboAqEDyavuvVLti0bZQlMRaPtHK+RFKsQaRcUaBb1sOjR4IkUE2GJA== 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. Fix this by migrate the bits domain. Signed-off-by: Zhaoyang Huang --- include/linux/mm_inline.h | 8 ++++++++ mm/migrate.c | 1 + 2 files changed, 9 insertions(+) diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index f4fe593c1400..ecf07a2a8201 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_folio, struct folio *folio) +{ + unsigned long refs = READ_ONCE(folio->flags) & LRU_REFS_MASK; + + set_mask_bits(&new_folio->flags, LRU_REFS_MASK, refs); +} #else /* !CONFIG_LRU_GEN */ static inline bool lru_gen_enabled(void) @@ -313,6 +319,8 @@ static inline bool lru_gen_del_folio(struct lruvec *lruvec, struct folio *folio, return false; } +static inline void folio_migrate_refs(struct folio *new_folio, struct folio *folio) +{} #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.