From patchwork Tue Dec 27 12:27:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13082237 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 44663C4167B for ; Tue, 27 Dec 2022 12:11:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A707F8E0002; Tue, 27 Dec 2022 07:11:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A1FC78E0001; Tue, 27 Dec 2022 07:11:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E83E8E0002; Tue, 27 Dec 2022 07:11:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7B4138E0001 for ; Tue, 27 Dec 2022 07:11:39 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 53A8A140ACA for ; Tue, 27 Dec 2022 12:11:39 +0000 (UTC) X-FDA: 80287971918.28.4DB7AED Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf08.hostedemail.com (Postfix) with ESMTP id 08385160012 for ; Tue, 27 Dec 2022 12:11:36 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672143097; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2fkuctlSodU7Cmk622giu9MrtFu7Rzzp2rLbn7arjxU=; b=leec6MlSmhALeIFPwkUIm7CWVlRrGTfAT0yYqG4rs5E8Hp53bkeWovDQVTR4gYBVoRMJiP BaBQecq9aEfgycdxvldn0fiuNhs8pCuIiBqvl3EhJfCwqjruY/9OixuMxewV48UL437zTq cm7InwOX1V/IAF3pKY9w0l9stYySXGw= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672143097; a=rsa-sha256; cv=none; b=1JxVTbz0tuSbDN3MCIv9jt1AgLw079wAsg2RaTBKF6DdkTkRaG1yyr1B4NXvVzBZlhB6hH hMI1tmz8XN3udTsDbmS/y+5g8bSiwBpSY/PwoM/u09UEf4oxpZegO9MxAw5gC+lylW5q0l yKKCKT+F9/49n1vS/m2eeQPPix20v8Y= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NhD1T6H1GzJpTG; Tue, 27 Dec 2022 20:07:41 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 27 Dec 2022 20:11:33 +0800 From: Kefeng Wang To: Andrew Morton , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next v2 2/7] mm: damon: introduce damon_get_folio() Date: Tue, 27 Dec 2022 20:27:09 +0800 Message-ID: <20221227122714.161224-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221227122714.161224-1-wangkefeng.wang@huawei.com> References: <20221227122714.161224-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 08385160012 X-Stat-Signature: q3mksppzec9bcyxn8wpftt6gqojjehaf X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1672143096-431327 X-HE-Meta: U2FsdGVkX1/dT6Nt45SO+TM/Bb4FuSOXiOl0S+qvmKWYx7KbQEVvYB7MBa5w7tKXg7vNOVkK80VeGdnYaipTRBiAMDOtneipyIBmC2AXlLWdDzOdIh7jbH0L4reXfhc3ArwimBHXPaHeiu2tuyPjbOdKGco7J2hTus+JztQFoeGPcwLM4n4UKrrXMXc0xL4yw95ttidBm6/9cd6M9dXc3ZD9DX2084+CGdhGlSJnZKlxzk6GpXdglWKy1N4vCYBS8HBfp8v4+jB+ZdbPR8o8JboYZwItvbv67YKezGIbLcIaf1cNnYlRPZRhR2hcMBUM0s8mgIAOu6gyqBLtvMd4LTsI1q7p/YvpoNCEf8oya5GxGfHlSPZKmx7sWMGohOa2trmJwSjlNZgRm6LiY2lV0UF5Yv2s9f0NOrWyz/oNONTsbiJTwOEsjKbHw9NkV4BF1NqGmmu9fKNui8zP+/1Ac2gokC7buNGPQwjI1xbEWf4bjmk4qhugN2bHndw6bS0MTTKZGWr3wjsJrQzoGJSO/Q4bV0dTLSEwOgpvlFLCU7ar/bCw8b7ZY4nkgLPtAzejL+fohEf6IO41lqM1hxcJ++g0c3Uq0uFJ/UgFgxl2g5l2We0PcSZ74YkcjPEiKUy1GqKu+83Y519BhPCdSQkA42wJlWFhWzlmHl2ULfF4WIj36Yda9JTd26ESuUOckfgo1wwEtybICkTZVi69Op0E3fhEZuotUOlAX9m2VKRT6SQEWUSFAKgD+4Y+KKUCxsZnNCPvt23JQ3JA6K6HIZ4e9NoYJ5ZpSyh1ZDMuUVvnN9Ao4E9Ly+J/ZC1DUYwl6bpbnRGQnrI4C3NSzlICfCRMXpZ2WQ5i58Ahfs/nIoFg6QnFHj9vyWTWYhctIRVV3hr0HTT/tbP+dBHaPe37n1Bm1EQ/SclO9Y6s33bokfZ6+IFRYV0yl6ta4o/puPEdrK+AHTGrtPfxtFGa8+O7feQ d/CNE45H IRDTx 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: Introduce damon_get_folio(), and the temporary wrapper function damon_get_page(), which help us to convert damon related function to use folios, and it will be droped once the conversion is completed. Signed-off-by: Kefeng Wang --- mm/damon/ops-common.c | 14 ++++++++------ mm/damon/ops-common.h | 8 +++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c index 75409601f934..ff38a19aa92e 100644 --- a/mm/damon/ops-common.c +++ b/mm/damon/ops-common.c @@ -16,21 +16,23 @@ * Get an online page for a pfn if it's in the LRU list. Otherwise, returns * NULL. * - * The body of this function is stolen from the 'page_idle_get_page()'. We + * The body of this function is stolen from the 'page_idle_get_folio()'. We * steal rather than reuse it because the code is quite simple. */ -struct page *damon_get_page(unsigned long pfn) +struct folio *damon_get_folio(unsigned long pfn) { struct page *page = pfn_to_online_page(pfn); + struct folio *folio; if (!page || !PageLRU(page) || !get_page_unless_zero(page)) return NULL; - if (unlikely(!PageLRU(page))) { - put_page(page); - page = NULL; + folio = page_folio(page); + if (unlikely(!folio_test_lru(folio))) { + folio_put(folio); + folio = NULL; } - return page; + return folio; } void damon_ptep_mkold(pte_t *pte, struct mm_struct *mm, unsigned long addr) diff --git a/mm/damon/ops-common.h b/mm/damon/ops-common.h index 8d82d3722204..4ee607813981 100644 --- a/mm/damon/ops-common.h +++ b/mm/damon/ops-common.h @@ -7,7 +7,13 @@ #include -struct page *damon_get_page(unsigned long pfn); +struct folio *damon_get_folio(unsigned long pfn); +static inline struct page *damon_get_page(unsigned long pfn) +{ + struct folio *folio = damon_get_folio(pfn); + + return &folio->page; +} void damon_ptep_mkold(pte_t *pte, struct mm_struct *mm, unsigned long addr); void damon_pmdp_mkold(pmd_t *pmd, struct mm_struct *mm, unsigned long addr);