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: 13079041 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 051E1C4167B for ; Wed, 21 Dec 2022 18:10:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8428E8E0005; Wed, 21 Dec 2022 13:10:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D7208E0001; Wed, 21 Dec 2022 13:10:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5764D8E0003; Wed, 21 Dec 2022 13:10:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3F4488E0001 for ; Wed, 21 Dec 2022 13:10:03 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0BB801A0CF5 for ; Wed, 21 Dec 2022 18:10:03 +0000 (UTC) X-FDA: 80267102286.04.54DDE7D Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf29.hostedemail.com (Postfix) with ESMTP id 360AA12000B for ; Wed, 21 Dec 2022 18:09:59 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nkDePdtC; spf=pass (imf29.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671646200; a=rsa-sha256; cv=none; b=XthaCWCkAIYvmOX35eLeHcbfvdjXoUT4LOgDtTneZngVYkjb0z5jlqU/i5DBGgSRh3XhEq N1h4l0EHCHohyV/QlUnfD4sIJ7i1Fo/bb7j9Nb1huvMYI/2Ypd6hBl1TAxLGciydfc/MxF vpZTHjoJTTl5kGFQq5dgKU4PlvAOHRk= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nkDePdtC; spf=pass (imf29.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671646200; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3PmJb6CIEqNY6rS2poozpptUa/GTiPJRR/qxOS9Vnc0=; b=vroqs2ajFPZYd/2geuXX9+lp0GMNApB7yuQ5f/GAlWMtLVki205BWrzVe8dQYgEG5ymb7v 4NgeKB3U77ACekGebXnpsH5pY0NAh9E0EiSs8aty6Th4Yyi4xb42wunWxQjzNtAKDt3YVj A8kEhiHdjkpB+kDThAHQAd2zBhG8y7Y= Received: by mail-pj1-f42.google.com with SMTP id n65-20020a17090a2cc700b0021bc5ef7a14so2885523pjd.0 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=8D9ilH+L/2n+meDUIcqSoAbNv7Qq74x8oneLMXTSwXaptLno2ocA7KqqK2kc0LY/yc Cg3o8GkeV/XzJZf7csep45MUi4osc03kVv4RG2o/29Eh9z3FhrsA4cvQ1bnD4SGqzLjP nVgvzdn1+Iba1MuaAzGnVWrIXz3xidweTzuHtWWTyQsSNO/BtxYsVeQvOdHkXcFdUxRG PeLWAI/3YEhd2eJ0ekqLfJ2FCxh5VYjsnb4s8o6KofFXAMZsw7OSCK+tC3yLJNzxyk0T mybw30h1Zoqzlzc30V4gr3VQvZUQiF5pQ0UVYPr2Lspz8B2KyHQiR2CMNF3Z/GKdHd4V Z41g== X-Gm-Message-State: AFqh2ko3NWBK65jbck9ifT+KP3FjyfKGSeyBofDELFF9v8mtAV7prdZ7 YmNgiS9L0HErZLxxPjCnoEScLDOcMqIWZQ== X-Google-Smtp-Source: AMrXdXtca0fMprEg2pyoicfMqzT5In5Towl3radcXSD/IZnbSgXS2K9Z4XEmJtw7RR7DJxDDggCraQ== 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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 360AA12000B X-Stat-Signature: xjtu3mhtsomhabiq1dmhndb7xs93szhs X-HE-Tag: 1671646199-39642 X-HE-Meta: U2FsdGVkX1+/WckILo5WorPABQKEr5iRKXVOn2d0R0AZrt7uDnjXYtPlvMDYXGebTjsKM2BmWLY+fU/rAoq34POG0j2+5jMU4QpD4/WYeEvY9TEePaQwTPETEdZltmWnoXFvog8MadKGYgISer72HjgaajSuAP6TAchk2WOzAlw7R2AZvtSm+XupXlZEsCu7M7VP7T8HkgPMAlEXffJem1NY0nFFkz6JQKx7Fx/MN1S2EuNyL1TiC6g1bNtNpmB4mpCpWFtYUnMSwEcLEMw/AV//D5tJSiyfinPbxOZyXLVELi7Wf6sz2rpi2RHf1B98AP6QPBuCFGKDId8zLXxO7gPQiX4lvqFzdDDUKikWBBCeAIIfb6/SkL6aPFEiDbEHyq6FJvO/TEh94QiluJdlYS3TfMjd1CRUyPe3kQtIIUzOZR+s1o4dt9LnZiTsRzgFe6iteQM8yyQZKYwDlg/1Q9sjHisXa1K9lDs7msMwGCBdO74tJwpTTP2UDgJsTJxMhyXy/B7sDPJhJNpJ6xuI+RAotNA6Qtbeuh5zsB8YuJWYITpZq+fUFAVRndUoVXliqo0G6WUUJfX1ClBd/ossl8zBnsR9z3FkTfEkXXMqQdTJo0HUy2mjKNqIZtUR8HIhSna5B0NE3AUC7A+5ZZhXj51LrUKH4D3K4skAGAOjnXoP3BPfmntFZ86LCGZiyle7PJxLJRSFkWZ1tt/iaOEDCOJe5tXtj+8yEaRs8PfyEEE1iLCJJ0sZdBovqSo1uPmkfLuxwVngn6VoeeSTj7U12snzLObZzkW80u4XBQHTOBNENuOVxCZK41n5+46kynPm6ZWAAlBaS7StaZdMgVOKvkyNsXcPGqzAS88HV2aBOUnWl3/PLjbcCkpe8Bha701Yx508FxVpRGendKRVCEtq0Xb5F9P83ohxmWyidvkEUdM7qtH/15hgbNHlTxJMY03cD7sUpEWTD2AWMvNPegP FjSxstw3 QZAXcJcb0fEp51nBXkmAn7n3SDieDJFCu+YEVTnAxKQPARvfJni9lG3spFK+dePWNWeBTu/3pH7bfm34PSGLooqmmf13nAiUXenDobKJdr5qq8asKMM3sYGUBvQGOEO4mieTaVzFusfzUTtWFbvSEVc+s2hswFxFvzzIoCpHZ+ibFStzNzOuMB2eO3UXsYFU0CXcS3UaHmxSXqZ1pwV9LBWHI+5SzZq73mg5Opbez9j3sRlsT6fifVq3dg2CnxBoJzUwTj6IX1FvpZRhV1K14OueqxQ== 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 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: 13079042 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 4D7DFC4332F for ; Wed, 21 Dec 2022 18:10:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2F998E0003; Wed, 21 Dec 2022 13:10:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BDEF88E0001; Wed, 21 Dec 2022 13:10:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E8598E0006; Wed, 21 Dec 2022 13:10:03 -0500 (EST) 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 79CD18E0003 for ; Wed, 21 Dec 2022 13:10:03 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2726FA07CB for ; Wed, 21 Dec 2022 18:10:03 +0000 (UTC) X-FDA: 80267102286.08.9CCA562 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf05.hostedemail.com (Postfix) with ESMTP id 4E65F10002A for ; Wed, 21 Dec 2022 18:10:01 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=idgtJWZU; spf=pass (imf05.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671646201; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=V90+BfZtK1slvLn1n1Jx1RIzI90mSXqsrWzPZLU3PF8=; b=CXXXHp91QYDbVItisGUHUQDNoQNyUNHKcIu5VyOA1Yi2ENAwNaLHaRdHWVJX1ryGKNCA7t UCT6/4PIGkLdPBxtimEu/meqdVrDaNBRU2VI8K/hnDWXR35jqKhA8Ld8YQ/L5PtzGScH2E 4Xpad/YfHPMUVLgV9NPA1PTE2zP10ws= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=idgtJWZU; spf=pass (imf05.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671646201; a=rsa-sha256; cv=none; b=kP/l8K9j0rqQNEruZ+JcZHc3+fWCIYT4SA4Hb1uoheDZdvWf4+ogJPYJYGUOnY8TfcG+MW hGePibis+zmMzJFcBG5ZZv7sW7xdIYVJBsmMTIasdekczk1tOC0O56lu1NvTAFTfjfSOpc vKLCDTvc466JsvzMfhwneWQAs2190kI= Received: by mail-pj1-f47.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso3193072pjt.0 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=t/azLBtihbfDODLrj1frb2uhbrdLs89LVpSrvF+IvVuUMhvDqU3DvTPKhZoW3frKaU RgPE6cj1ZYwaqPd+MgjnSCG7C3yBfaZmWywfioVeFjcvKzLXORVyxZNA3Mdi/cweLK3y JDgpg5UnAV507cyngqxs31XB2tmNy1id9TuLca34vTHqLpU1XkAPgnMkZ4cy6wopJbFj 6d+PIbcqxSG2CvYFMdqIcn7C9ppX7e5wQm6TLePOcI8U4mnSl240NxUmhNyKVZqjBdAQ NjUpIczDqEDofwrtWa0obeCIdoIYirKytZeT7D0zsRHPX/yf3aYfaj6700MoeumjM3SU +mqA== X-Gm-Message-State: AFqh2krTcVDFk91rk0r+x/IM72DdgysMfOuAIZdfR9u4fCU/sFQkAZ9d 5HSPPQxdDjOOfzP687/AGXeEe8CneXcYKQ== X-Google-Smtp-Source: AMrXdXubRnPot5zpMhDyHPp0OTNzVi5od2gLZPVrt/vb+U6VUKCE5XuBc6Z5YFmHx3I3sJn0Vkn8+Q== 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4E65F10002A X-Rspam-User: X-Stat-Signature: bkhugiwi817xoz5j1a7tds4fi77cpopd X-HE-Tag: 1671646201-216709 X-HE-Meta: U2FsdGVkX19CP/KJ09FLCobh1QqbwBTZuH4+AXhNeFnGx9uKQ6BHRpMiWjoSWRmus788OPp0whNGQ/tEZ4kgNLQBmPzWIGRZKi3BK7Eo0ZuooRWR3EC/HadZY5Ix8QEjd/IObZSq8Xe1PsWRgYCIB3slb4A4HpWVZLj2wU8sCH3Uyj54R4flqOOnz8rhS8IDMWgrK9hvXMi3acIn5kJAl2VTO1MWDApH0O6yg9mjF2BwTm05RbcO+fhRPSUzvJ9UxCJ5i/0enaVCDiTJtV/W+3IUmmqZ6zGvVexBNCga73eHilwCN2yRaiRc6R2W+JDVAYu5D6g+GUHf7EHzVW3GueArQX88+kZrt2zjlk6fQiiAUIM4091tU9RpqZ4MZpyz/9un8r2jfuk+FPhW7CfuG9xF1Q5cjEr2/rlkyLUVTqyB9trnEFvLiScM/wlhtbwtRMOSBGTL2bItimBNq8AMLhJqLHwruYSQrQ8X1HDOjl/MgwVFlySJrbmlEls3sR2YdkkjxRyRWEA3I0/CPdYei715iokgJBZC3XSAPsBi0Gx+jDKP8Orpn/nPLrXStNZXeHlM3Tb6OG+AmTSxYeF1PwNbIl2H9JMT0Nfd2T9/Bn6YNST8niuL1rsyJFRPPviWlFeSFUOLvFRMpUhALgED6GLHugAf1zwYRCS+AZb2MkCSAqA13xLi+OX1m0j+v/UNEnvAXm3VgNVSMVKMP/JNZ7jaXSGM+Pz6d33kBGq5hDzyjLpul/Iz268EF/1Qa7hzAmlk7Mveq3Pd7B12IjtutOXzqUNVUpnpj3A/3QvCQIYGDpkXwXH1MurFmXl2xt+mLh64wX5QIXtQtGYF/Td8ydHMbC5j5f6HzVWSEMO/s1isf7CQ+IsTkHhv54gtQLDY3zfdS/j4v/pwLWIF7GPYrb8glObDS9OfihG6D1gOhpGrWOVDV+biYhvqymd3E2QlwJbOqtJ98s9DWtJhj7r XikhtRQT X+KkTQnXQx/HL3uxHbU84++MOswv20a6I0gvbn1csgvySuIIVlsU291KKWTimCI66dq9ur6bccR34S3xM3mGqZpOZXBvSdshX0q0DnxOnhTmlszNEZkos3/D6QIuMSXcxXRtOhzTPlUhuMQhh0Eh2e5j0A0RHqtTiyXPknLVzCZzQVaO5Kglpe9HtSFYbpW8F7SrUiPza/SZUNfT3YFOV/vBYkkNNabpLBCwMPj6ghemkoGCJtcksLOQabTI2tTYwcleI6QVp3/2D1/dmpTmSvIC21A== 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: 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: 13079043 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 DD42AC4167B for ; Wed, 21 Dec 2022 18:10:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 810788E0006; Wed, 21 Dec 2022 13:10:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7997B8E0001; Wed, 21 Dec 2022 13:10:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 661968E0006; Wed, 21 Dec 2022 13:10:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 424DD8E0001 for ; Wed, 21 Dec 2022 13:10:04 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 15F3E1C654F for ; Wed, 21 Dec 2022 18:10:04 +0000 (UTC) X-FDA: 80267102328.20.4D376EE Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf10.hostedemail.com (Postfix) with ESMTP id 5369CC0005 for ; Wed, 21 Dec 2022 18:10:02 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Kg1XMQEX; spf=pass (imf10.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671646202; a=rsa-sha256; cv=none; b=d7qUwzZgm8WtabOAI/Ts4BBWPfzlRo9IaEV5AAFmjHcuXrK+h4Ig0lVTd5xaq9XPFeuLY4 cGXLUCrF07f9wJtQZ0hKv2FxjNjU1y6col8phyS/3RQJ7YX75pYiJAlgkdh1yuCU2awo0a +21D21Aql7SCeDBbmZTGsY1wlTJ5lmw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Kg1XMQEX; spf=pass (imf10.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671646202; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FV2WgQnkGF47aHXwNmitYREK9VpntY4pGASooxA0vsY=; b=DzmH9XyDZIRxbw4CjIgpZdRHtQw3y38PfBpB0bFueR8wU5QRLSWWbDQW5kGLPnGDBqevxB FJaegNScGsrh82VWwRv72uFhBdBvIGS7ZzUXmVuFAmfdUkLxf+NbXccAEsiyJznbJXNnY9 kAjAMyhkmTnuaiwpqCGUhB+BieKE500= Received: by mail-pl1-f172.google.com with SMTP id d3so16273923plr.10 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=g6IiBXlXU2vWYCFxAaSsD2NI1JLf4FyOZQtPRxEVOqNy1NqlVZLqd0QfXwIfXK1Zui 9YKdA2l24EpfSBxQQaWoCKkhYZu2Nqu3j+r6dbm1N6eyjO0ZIvF+eSUKG4nVqiWFoZ+t n5w0bRaig8GIACms46lIkSsddCQm/jFyxT7iUyIaqCnGQG61fOxbGz3J1RHjb70oMytd s5QVG/9WXLWGlqnU3bZlPwOzrog6nKijUuafSWfLTOWmZ0GOi3d9mCiPi6cHrC4PVI5u CYCumeQP0lqoy5TFgxpNFFQMQ22DoVL1gSKBvtV0u370HVXNedUAGcnMte3krUVribzE VbXQ== X-Gm-Message-State: AFqh2krzkpP/WLcgqeVvdyabV3ZDkKNEwPrOGoNYotLmZF5c7byLTyyu 3n7SRryg3mTrzHJn+QRh84pTR3xBiVhBag== X-Google-Smtp-Source: AMrXdXu5VDOIqKGM3A+JT0KCVz3Bkip3v+cF2w+L6Cyr9LUNlLEY5S39vnlLyv1Nvgic1ZQTYgvR9Q== 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-Rspam-User: X-Rspamd-Queue-Id: 5369CC0005 X-Rspamd-Server: rspam01 X-Stat-Signature: 5g3t7nxmteuqcffkpfhw6dbxodu6mote X-HE-Tag: 1671646202-408857 X-HE-Meta: U2FsdGVkX18/ZxRYTLSeLzv+iqvreFqKbmGe6WBac3P97zxN9b3RhWREdAwlBStz0dmB7K1x7kSlcv8t5XEs7fWeEwK94bw/UodmAannEzfuj+7r5SYeF9UDPbj5YBWPaMLu36q8jTmk/PwWVyvnpgXil/MOYWASmCoXEKu6L+k90ymcD+3uUc3+1PGXtyH2qQ17J/wpV+z5WgPPWfZ01oshNfubwQxA/VHxEcjGG6fwM0D5iYC9+Q93wkleT8tMXd8eVJ7KVeVwPKbT+eqU77iKBFtmZOGm1fpmeLXS37DQ0H8374+EdRiGwoLdsAmH3N9P26T4dkWqYJRSua6NqDqG/0k/AY8Hw4jJ6DZFKfhJUxDEKBN3XrGiaX+CoiQGe+lcR8tk9ivOKEW5J92bIU9kwkeYYbGZt5+4eQ/q7Npscs56a/WhUVHrHKvcKP79q/mgw2f/C6xKUXZNWRSfpVtTC9aEoYRIwAP/wVh2WuESjFi9rlpWDtyXLh4cnJe2s9uLQk6aKX7GanYVvL9swoFUrsfiU4dwSySjJRl7AOblvEdgQ4CdPi57NZbp+u0X7NDTkrobnxBqz2NmjW3JtrLCGUJB+lz5qpmwlmW5V6rTqUapOyWFNdVAgKp8zCEN6ECxYkjGmOhHRUCH6rfXJp66nnKSln/HkrV0/6oqhU2QTOYXuLp696m08rU+PMSYVqUvs5NByRISdUBdIjaRxBWz5bZYWS1Df5/OrZwYjEeIegW0Pp+DySdkIEcT8uvkqMEo3ycIGqHQBIYbmNhxS8LczAJN/vLTTSBrCNWPAh2KuzTlrzCCG4K/Ez30N0TGK8pdTr5FMsCI+ozkjbQdrtPJRf3E6qQsKk33eBPJhCE1C3edzIp5wO/0BLn5YQO1JSfJLfd8iG4n5fTkZGodotgRyY30aDo+SlGpgZ4k/ERZPruuWToRJ7sN7SeVvcsQSr391vIwefin5M/s7sW kwgl6M66 /V9a84QfhKHXd/iYllVV+tgspjXpPhMRDhr50mRQwnomfDPZv0trmPXQHVvHh3OzFdQ1NYRJTIKy9KmAcFczDJuX9gbqx5CXMJBO8dHCQ26jOH/XhHzTQyr/3qAyhNgWoY+ZIpk9LyJkKDcMCFYvGoNgpsB/PMA6bSvDkJ33VLfFpZNCILyLG5Mys2CLbVG3SrKADx3R244h+rb2mzlpQMnZ0ZoJGl6y05X1kWIwq6Lea1GfdzmKB+AduXObKCilDOGZz1Td3QadbPKnTaXWcjN5Jvw== 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: 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: 13079044 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 A82EAC4332F for ; Wed, 21 Dec 2022 18:10:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBC798E0007; Wed, 21 Dec 2022 13:10:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ACF848E0001; Wed, 21 Dec 2022 13:10:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 799A48E0007; Wed, 21 Dec 2022 13:10:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 60F508E0001 for ; Wed, 21 Dec 2022 13:10:05 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3BC0E1A034F for ; Wed, 21 Dec 2022 18:10:05 +0000 (UTC) X-FDA: 80267102370.06.1566D3E Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf15.hostedemail.com (Postfix) with ESMTP id 97F86A000C for ; Wed, 21 Dec 2022 18:10:03 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SVH+DMt9; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671646203; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IxCbMv7vN+MZYskgQiQXZaUsiwZjC8DQb1oWsEzg+wg=; b=72OjCyiB1108fY3qd1Wu5596sMZdvGiMcJJJbXnv7saiwg8Z89tVJTks8x23FEM78mkJIk 6DSY2kSi8uyCHmqd5oD8JlJRQtTZDpeTBL19jIl/H+zlqSUWCuDVEFntNOhdI9igx6TyZj FRbnBz3NoTjESCAmVDOdOybG0o8oeZU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SVH+DMt9; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671646203; a=rsa-sha256; cv=none; b=Hhohl/Zj+OtS2mFVLXbaAaUPTR6TSA11tL4IyA+lbSIHLSXbTFXt07xruiKodLCLXpPPWC CpZfCrPWUH0W1TOWLM5Tt7iFfl78G0H6C/oXECm0BZ1355nz5zzmFoSdm4zPwQiJA2nyVm 4Oq7WxFv5QsFwQrB7OrHQeAVnxOLdWo= Received: by mail-pj1-f47.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so2850496pjm.2 for ; Wed, 21 Dec 2022 10:10:03 -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=wpQ8ZqvO+P5KrjgMVztvMHzmRFwY6bpb/TgvkNdWlsidDA6ZrvFt9XN2FljhPNOg4w llg34dPVoP3eNk1GuRbIHrz4UZ/ve+QWU9gwiBLU0jnHWducY1A/PxuJEXJy5f/iydsJ 5qT4sKINdmq4Z3Z4pBouUTYLF3URX7yHFEGvt40v7enoIZBJF6xoLTNqAaSrXjDlQytg e1jUD3kPVqVsuoz+rujlosIHhHYeJdwr5Z/IvqO9Zs4Pw1jAIEzF4OV549yemvabpodw 1L7m/vxKFTduwVXA39EGHu4mNJMbMtlrG0p/DqLOY1TV0917GTioxbUoDxrJQpfPd84c E7dw== X-Gm-Message-State: AFqh2kpR6GdZxTsWryXj4W7yFmPj3w07/E29FuiLJRQ3BoI+00ZPg9AD 81SlyWBQmgJ4y3ls69AJbgd+sylOBREnHQ== X-Google-Smtp-Source: AMrXdXu7sLHZOSQkUqGfVCYqV1RGYszssajWNznlILD5f7tvBuIfHAUntNoH41lSWlaha/5S+8g8uQ== 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 97F86A000C X-Rspam-User: X-Stat-Signature: uncj9dq193wia7ht1kfoafqc3shffotj X-HE-Tag: 1671646203-513413 X-HE-Meta: U2FsdGVkX1+KDJMDGc/1sjMXkfmXGwcFYLwOcq8ADrVVTbpbV/KsE6uxfelUt1P2pwCcC91u2GDVjnKZe+m/EilbEh+yNSwbbP2pz8fDGXtegtYF5R7Vx6Nqh6cWMIZzKKqpAH6j7OIqTXmmQM6/ED4Fr2opcVxtsD03TV9EISBAF3CaVybv92XSRLNb53+m0NGchjEw2ERkoMlD3W4EEuMzqVvPOAbhnJe/sBEfYObi9MAKvu1G8tzsD4QXmzRyCXFI6BDsbXE2fqtSQZTO0IUEFxXSCQA6piZawpxyOpiB1rZFSGt7Uo98khbhPPKRxkjbLxptokHPNhyohTIP7e3VOgala53l00RqeO7OaqWDoPd+P2DbnJnSoTTDhtOjGUtlsuOFchi+qOu8G9vwAhrlDJydct3waHe1jNnxFDSCZWsDqY19A2kVyMISmDsi3AUZTG8NroJGaYNZ1PWzYhPrBWqiWKkxwei4i3t0s9V8+NiDWl5VZ9rRp8SpDXiEARe4zUuNhHAm7HNEb4GHve7pjecDdp1LEmtO2ZaFD8zPEiY6CsACoNKRT8Ztkkaj1yvs811nAJDqbA3jqO/2e5UpSfGH4DrngbSWU2z1k9aRRH4L3KQnq4mYEux6YXtfvTUTG0fMW/pafMc0f5TysVJ/vbxAtx2Zs7hA86/MUOv4f0b1OcsVkpGbAJKj3XLA8gcw8olBbCCENARtIfJcpbfVWQ4JuHZLWIfiWoqAKzQkYWMkvHbERehUGxHdYMdE2vjzvRhoIGC5yQe/k9FajdiYRxyIj6qG7ATesxhzNlhwHz23LxoKWDN7I/c2VxMbULCpowVwbNyHQvCoFpGStgOhXNfOyKl6J2iOwzp2uV+YPfW0qsx0AFOCwGP+MisvSGjDuM4iREbjX3RSlsjgBDKmC3vDA6AeDLgGXlI4+Y+wB9D71jCOIJT0rLkfevwGqcfeuZBuFng/7/WS2VF PICAryfp K8LpE7gxzRfCGeuwJpE8wcxAd9GWOZEOfZ/rrllMMB1gqW/asubg22fDZSLj8a5GEezHT9k/ofw91noT9H6HPSr4eCcpjaJV5XwLLf3e5+kitC+uHItzBrZW7rF0mMf1/lrpV0EsN8jPBBAf6D/4FMMBqMYNLvGAh8MonaNXcw3i08/oEwZFAPqYXfVl41uNJrlT7BjmEplDV0NHLV38Gfn8dDgZbD1+9MJXCp/Iw8IJsX/CMosP9kZaXR/6KwMufayVWsS/r1eb1BgHehL/M4FDG4Q== 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: 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;