From patchwork Wed Dec 21 18:08:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 35472 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3670633wrn; Wed, 21 Dec 2022 10:14:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXtjiiizb58cefKR4dBZXumnueI/TEywD/fmySwEZCCjUxzdw4aCFlmSct2048PkknJum2VK X-Received: by 2002:a50:fc92:0:b0:46a:8d6:fefb with SMTP id f18-20020a50fc92000000b0046a08d6fefbmr2161182edq.42.1671646456584; Wed, 21 Dec 2022 10:14:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671646456; cv=none; d=google.com; s=arc-20160816; b=NYtkEaaoEd3aQnINhX0AqPz3avzYJ/oRnHsEQKwjaVMc1YIqLVJMyibvWJC8T78pcf MF5f92vRYHcNL4S6SnO16dT2UVtUkgu9ev3QOuWJqVvmbuiCxLNMIuNuPldpGQsENw46 YOsSttMYfzj7BmpDi6Gh3dP4Z1C3oDZsbhtfKZsrR1s3o5u3p2iy55F1lvu1qo0CjZqH EcSvDNqp4nWhZP44TqYGr2lqcW3js2Linymzo0bxzexJoOTqCO8AFewaSlCFVQ2sP5V1 n5JHZ714YIZDQ8GJxZ9VY8H7yVajgRdOkZREFNFgwGi55xeCaI3zB+AqAX5mXBqBOxQq eULg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3PmJb6CIEqNY6rS2poozpptUa/GTiPJRR/qxOS9Vnc0=; b=cNv3jcHMnUtLUyq0c72kKjX6nyUg8MvkYj8XBgjOwBoPrjmPjgwuD0Jyb1Hbp+S1mC +EC9XCMdtQXVV7xdzGV1mqfQuomQYaIuy8IQziwIrvoaWXkmRZMjof4tjlxIaMTka3PD Nd/dwpG04bMAzNjNfmJKw/KQDUNCGO1OQ8SQXCpCY+p9GAc8d2avAPp++VgRoBZnzk6J W4WvX1qbta1ssc1bsDorT+qEKaumoxAeaTO9ez5/S+BG0w/fsee+nmol8JqCN4zfq/qH C6AWBYmgpoDzZNIR+98fKTdiTnFukMK41elgUWXSRDz2U5a2vNVE3kVaIpELsyXg+nOm ofyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nkDePdtC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v6-20020a056402348600b004627d582888si15257204edc.24.2022.12.21.10.13.52; Wed, 21 Dec 2022 10:14:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nkDePdtC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234589AbiLUSKG (ORCPT + 99 others); Wed, 21 Dec 2022 13:10:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbiLUSKA (ORCPT ); Wed, 21 Dec 2022 13:10:00 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77DD7252B1 for ; Wed, 21 Dec 2022 10:09:59 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id v23so11292865pju.3 for ; Wed, 21 Dec 2022 10:09:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3PmJb6CIEqNY6rS2poozpptUa/GTiPJRR/qxOS9Vnc0=; b=nkDePdtCIPB0JT+k15LKJQpvT/NCX++WS8dNEXwSceLOrvzJbV5KnFSi/Q69IbR9m3 pz0bbEASdkL5ZdY4gNIep4yTOxDqQn+6P2mNirIanQro8qY4+EtQs7/dTqDX5lFIhZ/n TAj3GOz59idRv9VjUz6+R5EikvGTM60+tFyZa7Efn6m94pwClx9r/IkHOqsvbxOBTehN 2j8mpE/fJEO71UEk6LCm68MCU5C3Szk13jN/lj+xzg73aRLX4FQNK8M1K67QCFEsH8Ww rfmAhg4rTRNPdQSkZ0GXgSLs9nXLKoZKuvw6ULiCzpmc618r3bMtR9tPRASbUks1tuQx uUKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3PmJb6CIEqNY6rS2poozpptUa/GTiPJRR/qxOS9Vnc0=; b=Zgzd3TMrTGAC1csYLjRziBZ7Ti0Y4Hv2AR3gioiRasaxyo8B+ZSDa1WApqd/WupfTz UD+6aAi/8SQCBuGJSDzPrxgSxwAQoY9uGMfCygYj4s1DGQ2cD+tiEU6tHWNwUQLbDOwa HlpRnkOCuaDbgxbAGTb3b4h2EuG2CZszQzP6LKLEC4VQUu6Ii/0c0Bdcs5+48K60Sj9A 0ZmboYM4NUCs9ns/e4VIxaf+VJ5RA7b9RG1/aD2uwk7Eirp26PLeIvHYDWpoSRHGaJRP U5ZNHPwoydZQe2zmuwNk20kXFZAQSDNb6uMNFFOeR4IDOj93cuTM/bAgJpk+RvsK46Oa kq5w== X-Gm-Message-State: AFqh2kpT9TMTRkK+XGsqGdUrOvIxfz/nUzjXo5kgBUy4k8wFuSpsWKyP 7EdcOgCYGswjvC6Zla6G+iU= X-Received: by 2002:a17:90a:fd09:b0:219:c40:e3c with SMTP id cv9-20020a17090afd0900b002190c400e3cmr2632387pjb.33.1671646198887; Wed, 21 Dec 2022 10:09:58 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::a55d]) by smtp.googlemail.com with ESMTPSA id e26-20020a63745a000000b00477bfac06b7sm10110732pgn.34.2022.12.21.10.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 10:09:58 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sj@kernel.org, willy@infradead.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 1/4] mm/memory: Add vm_normal_folio() Date: Wed, 21 Dec 2022 10:08:45 -0800 Message-Id: <20221221180848.20774-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221180848.20774-1-vishal.moola@gmail.com> References: <20221221180848.20774-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752848354667675155?= X-GMAIL-MSGID: =?utf-8?q?1752848354667675155?= Introduce a wrapper function called vm_normal_folio(). This function calls vm_normal_page() and returns the folio of the page found, or null if no page is found. This function allows callers to get a folio from a pte, which will eventually allow them to completely replace their struct page variables with struct folio instead. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 2 ++ mm/memory.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index ff46dcab2004..d29bfae4b71f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1968,6 +1968,8 @@ static inline bool can_do_mlock(void) { return false; } extern int user_shm_lock(size_t, struct ucounts *); extern void user_shm_unlock(size_t, struct ucounts *); +struct folio *vm_normal_folio(struct vm_area_struct *vma, unsigned long addr, + pte_t pte); struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, pte_t pte); struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, diff --git a/mm/memory.c b/mm/memory.c index 37d1763c4d47..4000e9f017e0 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -625,6 +625,16 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, return pfn_to_page(pfn); } +struct folio *vm_normal_folio(struct vm_area_struct *vma, unsigned long addr, + pte_t pte) +{ + struct page *page = vm_normal_page(vma, addr, pte); + + if (page) + return page_folio(page); + return NULL; +} + #ifdef CONFIG_TRANSPARENT_HUGEPAGE struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t pmd) From patchwork Wed Dec 21 18:08:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 35473 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3671069wrn; Wed, 21 Dec 2022 10:15:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXtHa+NzCL3tDtpKMo/giQh+k134hSjZtN/9eiVtoBDWe1C40xZ0b0y+VadM3CuiW/wS/joL X-Received: by 2002:a05:6402:1119:b0:472:46bf:fb3c with SMTP id u25-20020a056402111900b0047246bffb3cmr5535895edv.35.1671646511507; Wed, 21 Dec 2022 10:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671646511; cv=none; d=google.com; s=arc-20160816; b=KrTJ7Xm2BqUnmKTWB30Y3sP/he2kpudXemS6AL7pCINnBK4xTeC2ciuy+EsmFk6ISW r7rlcxiAg/Sn7UKmBGQVnP6dOOvTNE6siornqRoC6s3NfDrlEPo1LxytKUfrQ/Utf0jX F7SZzwKpSOBXnqMdXNhIx8xFVLC34VTlfAKdIwCX79eKEwty0SS5joX0aFE7vHLyg6JF VREw3m143T0NavkUYBjUQNhVMUtyA/7nDv191bgaN1umHDpInus7VJz/+36MQgZ4E+Nj I7Iu0jyTLnAXM5zTVEeJvZbD242uhgcVEbfXuKPO98y0HflxoR2jD8VwC5KEBT5Awe5C oQPg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V90+BfZtK1slvLn1n1Jx1RIzI90mSXqsrWzPZLU3PF8=; b=MEFW0M7yJ6cxSMFkISbOtelzCdM4vpmpH7+kWIbefMF4qwPZ6vwzXBwiHNPyUhI28M SkNiDVxZ9YTjlwn7/3X2y+xILgjCVhsOK/QlTmo8mdpy0lc+WgMUszu4zwjXqJwm4H3r J+wqDH9DI2mvJcDSfTD8tLm7lU2kZd5gVQfXLUlVumBwzKyhWQHuuLaFsruXAngsBkiS vcWe6MrvCzERnlCuXvKYiynjaJWNd5bRswKbQ0BpAPHvMbJqvHpMa9Qm5W/MMNnDxQmq 6Av3OyMiuANd9tnbfyyo1AeEkuzdbKBBGSSi2ZftmLJvDXCLH8gBctBtivuIwu1kFqaO HIsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=idgtJWZU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vw9-20020a170907a70900b007aedb84056csi1671104ejc.718.2022.12.21.10.14.44; Wed, 21 Dec 2022 10:15:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=idgtJWZU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234636AbiLUSKI (ORCPT + 99 others); Wed, 21 Dec 2022 13:10:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbiLUSKB (ORCPT ); Wed, 21 Dec 2022 13:10:01 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 858E9252AA for ; Wed, 21 Dec 2022 10:10:00 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id k88-20020a17090a4ce100b00219d0b857bcso2855468pjh.1 for ; Wed, 21 Dec 2022 10:10:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=V90+BfZtK1slvLn1n1Jx1RIzI90mSXqsrWzPZLU3PF8=; b=idgtJWZU6cXL8auQ5suH1EAlK2iOZX3Y/jKu/mNOZua5+aWbsw51hqTcyRM4Nh2OOB lIKT1uam8nzXBWXebN9JokPLVjBrVByu9Zw/5eU+Wi3xiXKqxd07Q3LuIYo45eVOKasK mGNbB9QfNxPeTkWrUnEQBMDIarluZ7WItM3qk6RsVRp2ivxASFV4CgCjERRAFEW0++rt KRFaw31a5udcVll9o4BxJ1YkyovfEAOfGF3WzX3q/fZTyZDsiFwEocQbbwahXxpNA6Wz xFl1ImHFXxYf7psocCMqL7In5Jh/aghKIznStF2vEp7T0TREjVepbMTM0KjSrnzORygY +ZBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V90+BfZtK1slvLn1n1Jx1RIzI90mSXqsrWzPZLU3PF8=; b=rp552+sczrnEx6mAof+5Z2XDmcGQRI97wRwHUlmgjSjIgnvPWO29790iHe/xfkwJ+8 HgQ/qc3uBL1DV5ELBXcyXBYGpAVtVpf5jaNVdE+L3j6st56jknn44THVcqwItAiLdJ9r mWuNUvzu8l4xuv198O3StluSCjZBQcjgVWL/bU74CuLsnXhoWNsPJyjgeay5tsYX4rcS HBk7LC7Kv0d1K8mCBv8tpsPBiWYy4BfDL/18Jizxw2hTRwGeU0iZOjzc5AucJe2GH1l/ WTW8H9l2uviJKcjSN9OF+0aJlf40tzASka0pZwA9ip8NBrsVpANm9Sjqn4003XZkuIIS mtGg== X-Gm-Message-State: AFqh2krktOQ9aZVBT4tNxOOKpJVjDyfc+8YsP1v4icrma9SPyAAuRMpM tNfq9MZIljmcxdVJiqxNDdY= X-Received: by 2002:a05:6a20:1a84:b0:a7:89fd:884c with SMTP id ci4-20020a056a201a8400b000a789fd884cmr3628709pzb.11.1671646199957; Wed, 21 Dec 2022 10:09:59 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::a55d]) by smtp.googlemail.com with ESMTPSA id e26-20020a63745a000000b00477bfac06b7sm10110732pgn.34.2022.12.21.10.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 10:09:59 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sj@kernel.org, willy@infradead.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 2/4] madvise: Convert madvise_cold_or_pageout_pte_range() to use folios Date: Wed, 21 Dec 2022 10:08:46 -0800 Message-Id: <20221221180848.20774-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221180848.20774-1-vishal.moola@gmail.com> References: <20221221180848.20774-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752848412235235703?= X-GMAIL-MSGID: =?utf-8?q?1752848412235235703?= This change removes a number of calls to compound_head(), and saves 1729 bytes of kernel text. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- mm/madvise.c | 98 ++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 7b7549a54a6d..851d977b9b03 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -345,8 +345,8 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, struct vm_area_struct *vma = walk->vma; pte_t *orig_pte, *pte, ptent; spinlock_t *ptl; - struct page *page = NULL; - LIST_HEAD(page_list); + struct folio *folio = NULL; + LIST_HEAD(folio_list); bool pageout_anon_only_filter; if (fatal_signal_pending(current)) @@ -375,26 +375,26 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, goto huge_unlock; } - page = pmd_page(orig_pmd); + folio = pfn_folio(pmd_pfn(orig_pmd)); - /* Do not interfere with other mappings of this page */ - if (page_mapcount(page) != 1) + /* Do not interfere with other mappings of this folio */ + if (folio_mapcount(folio) != 1) goto huge_unlock; - if (pageout_anon_only_filter && !PageAnon(page)) + if (pageout_anon_only_filter && !folio_test_anon(folio)) goto huge_unlock; if (next - addr != HPAGE_PMD_SIZE) { int err; - get_page(page); + folio_get(folio); spin_unlock(ptl); - lock_page(page); - err = split_huge_page(page); - unlock_page(page); - put_page(page); + folio_lock(folio); + err = split_folio(folio); + folio_unlock(folio); + folio_put(folio); if (!err) - goto regular_page; + goto regular_folio; return 0; } @@ -406,25 +406,25 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, tlb_remove_pmd_tlb_entry(tlb, pmd, addr); } - ClearPageReferenced(page); - test_and_clear_page_young(page); + folio_clear_referenced(folio); + folio_test_clear_young(folio); if (pageout) { - if (!isolate_lru_page(page)) { - if (PageUnevictable(page)) - putback_lru_page(page); + if (!folio_isolate_lru(folio)) { + if (folio_test_unevictable(folio)) + folio_putback_lru(folio); else - list_add(&page->lru, &page_list); + list_add(&folio->lru, &folio_list); } } else - deactivate_page(page); + deactivate_page(&folio->page); huge_unlock: spin_unlock(ptl); if (pageout) - reclaim_pages(&page_list); + reclaim_pages(&folio_list); return 0; } -regular_page: +regular_folio: if (pmd_trans_unstable(pmd)) return 0; #endif @@ -441,33 +441,33 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, if (!pte_present(ptent)) continue; - page = vm_normal_page(vma, addr, ptent); - if (!page || is_zone_device_page(page)) + folio = vm_normal_folio(vma, addr, ptent); + if (!folio || folio_is_zone_device(folio)) 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. */ - if (PageTransCompound(page)) { - if (page_mapcount(page) != 1) + if (folio_test_large(folio)) { + if (folio_mapcount(folio) != 1) break; - if (pageout_anon_only_filter && !PageAnon(page)) + if (pageout_anon_only_filter && !folio_test_anon(folio)) break; - get_page(page); - if (!trylock_page(page)) { - put_page(page); + folio_get(folio); + if (!folio_trylock(folio)) { + folio_put(folio); break; } pte_unmap_unlock(orig_pte, ptl); - if (split_huge_page(page)) { - unlock_page(page); - put_page(page); + if (split_folio(folio)) { + folio_unlock(folio); + folio_put(folio); orig_pte = pte_offset_map_lock(mm, pmd, addr, &ptl); break; } - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); orig_pte = pte = pte_offset_map_lock(mm, pmd, addr, &ptl); pte--; addr -= PAGE_SIZE; @@ -475,16 +475,16 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, } /* - * Do not interfere with other mappings of this page and - * non-LRU page. + * Do not interfere with other mappings of this folio and + * non-LRU folio. */ - if (!PageLRU(page) || page_mapcount(page) != 1) + if (!folio_test_lru(folio) || folio_mapcount(folio) != 1) continue; - if (pageout_anon_only_filter && !PageAnon(page)) + if (pageout_anon_only_filter && !folio_test_anon(folio)) continue; - VM_BUG_ON_PAGE(PageTransCompound(page), page); + VM_BUG_ON_FOLIO(folio_test_large(folio), folio); if (pte_young(ptent)) { ptent = ptep_get_and_clear_full(mm, addr, pte, @@ -495,28 +495,28 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, } /* - * We are deactivating a page for accelerating reclaiming. - * VM couldn't reclaim the page unless we clear PG_young. + * We are deactivating a folio for accelerating reclaiming. + * VM couldn't reclaim the folio unless we clear PG_young. * As a side effect, it makes confuse idle-page tracking * because they will miss recent referenced history. */ - ClearPageReferenced(page); - test_and_clear_page_young(page); + folio_clear_referenced(folio); + folio_test_clear_young(folio); if (pageout) { - if (!isolate_lru_page(page)) { - if (PageUnevictable(page)) - putback_lru_page(page); + if (!folio_isolate_lru(folio)) { + if (folio_test_unevictable(folio)) + folio_putback_lru(folio); else - list_add(&page->lru, &page_list); + list_add(&folio->lru, &folio_list); } } else - deactivate_page(page); + deactivate_page(&folio->page); } arch_leave_lazy_mmu_mode(); pte_unmap_unlock(orig_pte, ptl); if (pageout) - reclaim_pages(&page_list); + reclaim_pages(&folio_list); cond_resched(); return 0; From patchwork Wed Dec 21 18:08:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 35474 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3671302wrn; Wed, 21 Dec 2022 10:15:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXszA6YAi4AhGDZ0UXdYnWm2t3qXZ1AvWuLIkiNS+F705WsvPeGFAJ6REuy1QzFJfjxnVAh0 X-Received: by 2002:a05:6402:194b:b0:45c:834b:eb44 with SMTP id f11-20020a056402194b00b0045c834beb44mr2928598edz.15.1671646540642; Wed, 21 Dec 2022 10:15:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671646540; cv=none; d=google.com; s=arc-20160816; b=GrWBHTtikFt/MY3PXQsNTcRwDFR7LucKih1H92TqEdlfenIhgPA0aEnwLLwVn3qHn1 7G9/NNWnY/Gd2wSaCrqWN2PfacQhO5iQ9lYrOIM12Dh1oiNgtKvSY8Kkw/aCvx/he3J8 5H6msFaKPxHSEqrYfZpVlY+mKcto63WJxbyK0Pv0o5sV3goY9TQ52OwKPepSaJ1pLfBi gCfgZ7kOs3806okh+V1znN1i6eM6H7T7iCOI0iHq7jId5oAf0WT5Ad5Qik4bzvjTh6Q5 r7MvlCxOSjoBofUx3NNGttZGFHzbMNMFuzrvIcO3sbC++6QKnpUHIdtsZJW71IbyhSXl euPA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FV2WgQnkGF47aHXwNmitYREK9VpntY4pGASooxA0vsY=; b=RtQB/5Nfh43XYTv9W8dmtXiPZjkx+LVCD3Z7hpYVSlBmn0PDg9xz4TcE0lCWKD3kj/ eONQuym2qVDSnHafZjdT9VIbXdTGcLTYY9BQ7k1uYKLBdgohGhoNlAxbqsK7OC/SK7+6 6fXwc+D0nTjk4fAez5k7iEygHcmUz6oLJ23AbxDM3vk+xQ8V+zdfbkF76SD/EbE5A7XQ 6siqdQtxZM8pen6w4JgZEhFt2eF5ghzrzdESnAjMkn75bhyD+0KPCartZMmYYxwC3Bqb bhINQLclDO3L0Esjysp9+wAONTt8bYaF2/rEIh6bTMURSOU0NhR71huestcdQuTBdpIr JzNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Kg1XMQEX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t18-20020a1709063e5200b0078d2a99972fsi11515363eji.316.2022.12.21.10.15.16; Wed, 21 Dec 2022 10:15:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Kg1XMQEX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234665AbiLUSKM (ORCPT + 99 others); Wed, 21 Dec 2022 13:10:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234489AbiLUSKF (ORCPT ); Wed, 21 Dec 2022 13:10:05 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FD12252AC for ; Wed, 21 Dec 2022 10:10:01 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d15so16303653pls.6 for ; Wed, 21 Dec 2022 10:10:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FV2WgQnkGF47aHXwNmitYREK9VpntY4pGASooxA0vsY=; b=Kg1XMQEXGj1P5eOMqXh9QBRNWX72E0HNrH5TCgKFnOpXQ2PKPJ/sz6VxqwbRyP/31V MEmCQ6M7lOfXMYadzVs6SjgDmAss0zjsmJK+uqicKnmQ9sdkMbv2Ozm+wTTKQB8ApVST qq80B8WfhDV5+VU0L4rDCOu8K1aHQgwVp4S65V4p5WDwKqRzhkAxDvZFe797MPsGnHxP Ju6eeykfM32/T1VluTLvZsUJWDesdEtZMnarwoMvG+YbjVXTJM3LBa7W/XXgkEshQssx +VSCbILH93R98OybhCiHIVOpLPyUmZHjaoADCn3LxYw9gPFLuWf1FUY6p2QDR1t71LWv W+Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FV2WgQnkGF47aHXwNmitYREK9VpntY4pGASooxA0vsY=; b=U6xi2wecfRe0B5NInEK+Xtj6UIeSvT5IcM9C5Y6Ii18G/O59HgyK/nKHuOgeeK97lX AwOB4WSK9pquoUPso+dnHnMPWkiznkSE/gf0BLiC3aMmMcTOhHC1WmKJIZEESv0+PgXm /n6DMEN4sbgZosdTTJPAxq2GV8GbUrjNP+ZnUxjhiQFfkcS59XyvvzvR7mADGp+wPHUD FQcqTKvqEAkCSJOeejpLQjQpneo9B0/KKKa3QkAE+nwLGPg8lbHK07lv5S0nWjZpPJJo pfPx69WnzsVo673bgzI/ZXcfWi+ppPZ2Vd4pfovo10X2uXn4TWKG9cFVQuOVnR3dRPzh ebSg== X-Gm-Message-State: AFqh2koKm0lD08nHDbeKvq/UqZAXnttuG6vkBmEiAuKVWNSx4jk3TrtC F/jz1NfTt/oMcbVODtLwsbQ= X-Received: by 2002:a05:6a20:d38c:b0:af:a276:2f94 with SMTP id iq12-20020a056a20d38c00b000afa2762f94mr3868375pzb.35.1671646201070; Wed, 21 Dec 2022 10:10:01 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::a55d]) by smtp.googlemail.com with ESMTPSA id e26-20020a63745a000000b00477bfac06b7sm10110732pgn.34.2022.12.21.10.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 10:10:00 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sj@kernel.org, willy@infradead.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 3/4] mm/damon: Convert damon_pa_mark_accessed_or_deactivate() to use folios Date: Wed, 21 Dec 2022 10:08:47 -0800 Message-Id: <20221221180848.20774-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221180848.20774-1-vishal.moola@gmail.com> References: <20221221180848.20774-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752848442678759779?= X-GMAIL-MSGID: =?utf-8?q?1752848442678759779?= This change replaces 2 calls to compound_head() from put_page() and 1 call from mark_page_accessed() with one from page_folio(). This is in preparation for the conversion of deactivate_page() to folio_deactivate(). Signed-off-by: Vishal Moola (Oracle) Reviewed-by: SeongJae Park Reviewed-by: Matthew Wilcox (Oracle) --- mm/damon/paddr.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index ebd1905eed6f..884c8bf18b12 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -283,21 +283,23 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { struct page *page = damon_get_page(PHYS_PFN(addr)); + struct folio *folio; if (!page) continue; + folio = page_folio(page); - if (damos_pa_filter_out(s, page)) { - put_page(page); + if (damos_pa_filter_out(s, &folio->page)) { + folio_put(folio); continue; } if (mark_accessed) - mark_page_accessed(page); + folio_mark_accessed(folio); else - deactivate_page(page); - put_page(page); - applied++; + deactivate_page(&folio->page); + folio_put(folio); + applied += folio_nr_pages(folio); } return applied * PAGE_SIZE; } From patchwork Wed Dec 21 18:08:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 35475 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3671331wrn; Wed, 21 Dec 2022 10:15:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXvWkS+YlXNrSC7kX7wuEeLrjl7WAKJXqXowptqFqnxbeMHYu0mR2f8sdRADhW+WxXFrpJLp X-Received: by 2002:a05:6402:34f:b0:461:57c1:84ea with SMTP id r15-20020a056402034f00b0046157c184eamr2481816edw.3.1671646543345; Wed, 21 Dec 2022 10:15:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671646543; cv=none; d=google.com; s=arc-20160816; b=hsqZzV21WUZJIEl9UG0jjAXzthLzk1dPPEgZ6X5u1AbFBmVkx/84NpFvfwPrKwkPE5 P3Y9ZKjj99GsAAdQtyOcXvjFVqNO5iWnJC+P1PyOcW+kDSW/B9gmaPBKgNT4w1t2ZBl3 +rWs7iHC55PLemzRXn68EtmJvVJP2+CIG1HKOckwab6tWjMdQwp1pEcI1/gmbszvrUGV 1NRv0zN0861HNCd/YP4bcFbepxpViEG0WAYJwOktAlb5LSPf2aWl816H8zaRGaFmQz7N aEaoTurg97gvTGgLet6tzyAVdEuxhfpcnEaDZx4IXA347A7PzlzDNKb1yvnf1gjrNChc gBsA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IxCbMv7vN+MZYskgQiQXZaUsiwZjC8DQb1oWsEzg+wg=; b=vjxM/fmFtOy26rGaxoYYECO7GS15Qlk2ZbIW0e7EPrYlPL5R/IJlIOsDm4z//Yi7KH QhL8lMCwcwO98WI7S2MgTLNOPXCDFLXCeF3sVr9wF723UmTb++o0QieRb9VO+HKb0Ugh ITBJgYJwoPPT+w0obkuyUSNg4I1acg5CwhQezvgvtZsotTZ6KcLMBas3zLKYweGwswFc E9iiAYQT/Kr+ZnvzOqbvSBL752HH9cWER+MDPwqIsJXHTgGs6pFSKxN2f1eVW34Uv2yo Tn1+4R1CKElVuPZvZluBbou6qKvhdCUw15DKPLLHbZ+KugHB4F8diuL1GvZg4Q8v+rLT xS0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SVH+DMt9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a056402275300b0045a1dbedd92si19054528edd.35.2022.12.21.10.15.19; Wed, 21 Dec 2022 10:15:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SVH+DMt9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234677AbiLUSKQ (ORCPT + 99 others); Wed, 21 Dec 2022 13:10:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234553AbiLUSKF (ORCPT ); Wed, 21 Dec 2022 13:10:05 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBDD4252AA for ; Wed, 21 Dec 2022 10:10:02 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id 4so16313991plj.3 for ; Wed, 21 Dec 2022 10:10:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IxCbMv7vN+MZYskgQiQXZaUsiwZjC8DQb1oWsEzg+wg=; b=SVH+DMt9Og+wCpl3/C5BsDiXi0R8onKGMrhpkd4hAlX8bvnTiVKmDxskppX9IQkPrD 8Sd4evv36aHQ13uRz8HuvrhsBcWuFhUALcpXcURwBX6tiFSJpCU0wdSdBmhHkx7XIrr/ JyVRdZoqnokcrqk6Trie7l/7hWBpcvarMU2OLhZ6kJiKEYRNdIksrOfLjFawMwNn6O2p jCmneIA6JP/TtPv5fncfMTNDHOeJ+bi0Qpz3foORBcwYPuBPLReKoQaHUJw3l+w3OALk SUx0tixRN0rcqO5jTqxXfiyWmYW2jH8GSWHBLkGTNVr9roslowxH0YAB3zgJLd+OW8R5 o8Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IxCbMv7vN+MZYskgQiQXZaUsiwZjC8DQb1oWsEzg+wg=; b=LNEgupzLEKj9ZPQUCngFf7UJOfTyBBbVX4PDfKqiVzShFfbyZD2iNLGtTJDtqf1Nrq Qh3o9auFepcZf5B513/rGIYc+bDSAQwdftLsLARhhTvq83m6NFMqMqwGRWluJk4w7sPB 5jMYOdjO0t7sXoDvm9cMuJfGdC5c6uR4eFGWR8ZafJXbyXlUEDQf2mB96ZfGpoqsc0+3 KZLQ3M6lUahKOTawJaB8Xko8K01vk43DzEl5wkeNr7kZv78DjIOkp9ARVqTNmQGE17iP RBMR1b1obuUe5SzB9kQF2x9sw7JwLljAa8MVugs+mSvNvHGrMpJJ4I43K0PNX3wNDsAJ GfKg== X-Gm-Message-State: AFqh2krfAk604eBFH+1XdeefmQ+tyRHWSDio/UYTEe0ZtUk27Z+s4RgS XCMNTgnDQUxGZwHUJkdejfM= X-Received: by 2002:a05:6a20:2a09:b0:ac:44ab:33fa with SMTP id e9-20020a056a202a0900b000ac44ab33famr3315612pzh.37.1671646202232; Wed, 21 Dec 2022 10:10:02 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::a55d]) by smtp.googlemail.com with ESMTPSA id e26-20020a63745a000000b00477bfac06b7sm10110732pgn.34.2022.12.21.10.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 10:10:01 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sj@kernel.org, willy@infradead.org, "Vishal Moola (Oracle)" Subject: [PATCH v4 4/4] mm/swap: Convert deactivate_page() to folio_deactivate() Date: Wed, 21 Dec 2022 10:08:48 -0800 Message-Id: <20221221180848.20774-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221221180848.20774-1-vishal.moola@gmail.com> References: <20221221180848.20774-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752848445475058245?= X-GMAIL-MSGID: =?utf-8?q?1752848445475058245?= Deactivate_page() has already been converted to use folios, this change converts it to take in a folio argument instead of calling page_folio(). It also renames the function folio_deactivate() to be more consistent with other folio functions. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: SeongJae Park --- include/linux/swap.h | 2 +- mm/damon/paddr.c | 2 +- mm/madvise.c | 4 ++-- mm/swap.c | 14 ++++++-------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index f965786710b0..209a425739a9 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -401,7 +401,7 @@ extern void lru_add_drain(void); extern void lru_add_drain_cpu(int cpu); extern void lru_add_drain_cpu_zone(struct zone *zone); extern void lru_add_drain_all(void); -extern void deactivate_page(struct page *page); +void folio_deactivate(struct folio *folio); void folio_mark_lazyfree(struct folio *folio); extern void swap_setup(void); diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 884c8bf18b12..6334c99e5152 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -297,7 +297,7 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( if (mark_accessed) folio_mark_accessed(folio); else - deactivate_page(&folio->page); + folio_deactivate(folio); folio_put(folio); applied += folio_nr_pages(folio); } diff --git a/mm/madvise.c b/mm/madvise.c index 851d977b9b03..025be3517af1 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -416,7 +416,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, list_add(&folio->lru, &folio_list); } } else - deactivate_page(&folio->page); + folio_deactivate(folio); huge_unlock: spin_unlock(ptl); if (pageout) @@ -510,7 +510,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, list_add(&folio->lru, &folio_list); } } else - deactivate_page(&folio->page); + folio_deactivate(folio); } arch_leave_lazy_mmu_mode(); diff --git a/mm/swap.c b/mm/swap.c index 5e5eba186930..e54e2a252e27 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -733,17 +733,15 @@ void deactivate_file_folio(struct folio *folio) } /* - * deactivate_page - deactivate a page - * @page: page to deactivate + * folio_deactivate - deactivate a folio + * @folio: folio to deactivate * - * deactivate_page() moves @page to the inactive list if @page was on the active - * list and was not an unevictable page. This is done to accelerate the reclaim - * of @page. + * folio_deactivate() moves @folio to the inactive list if @folio was on the + * active list and was not unevictable. This is done to accelerate the + * reclaim of @folio. */ -void deactivate_page(struct page *page) +void folio_deactivate(struct folio *folio) { - struct folio *folio = page_folio(page); - if (folio_test_lru(folio) && !folio_test_unevictable(folio) && (folio_test_active(folio) || lru_gen_enabled())) { struct folio_batch *fbatch;