From patchwork Thu Dec 8 20:35:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13068865 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 A3032C4332F for ; Thu, 8 Dec 2022 20:35:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 449068E0006; Thu, 8 Dec 2022 15:35:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FA7A8E0001; Thu, 8 Dec 2022 15:35:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 189B48E0006; Thu, 8 Dec 2022 15:35:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 018458E0001 for ; Thu, 8 Dec 2022 15:35:10 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C75E71A0207 for ; Thu, 8 Dec 2022 20:35:10 +0000 (UTC) X-FDA: 80220293580.21.B3FEAEF Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 2C6931C0009 for ; Thu, 8 Dec 2022 20:35:08 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fvvYF98h; spf=pass (imf18.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=1670531709; 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=YC6lmTEI2DddOWPjuQmefmlclj4ZLY2oiewxsoGP1Vs=; b=hzdTHohW/mIeJm2qcs/ZsCvcLw2ltYJaRCH4v6J6Jr/Xv3hyb47ty2GYmznlZ6fqHNBF+s bCAiOzS/5qy7BcBVrJW5vurz6ADlIa886AUnCCKBDhR5v+vaGGnjG1S6Ej3t4j4m756Bpe YecjSJjm0X3a24m59JWcsAWZWKLf+4U= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fvvYF98h; spf=pass (imf18.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=1670531709; a=rsa-sha256; cv=none; b=yr5sKu9KtXlOULW6cbzZyBw6C7NURBZ+KEtKjVoVOTg5ldTx2005yMIL42xMpORHwg5MCX Tz54y3kwIHEmpYpQ/kgS4YXzF4TxPOdiA3MNVg2rLYNnehEzQtPTdM+jjx0FJ3ajRjvF+f /c50vo7iVLlbJe4oeJCEsebD0U3Plek= Received: by mail-pl1-f172.google.com with SMTP id m4so2684822pls.4 for ; Thu, 08 Dec 2022 12:35:08 -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=YC6lmTEI2DddOWPjuQmefmlclj4ZLY2oiewxsoGP1Vs=; b=fvvYF98hTiJGOMFMCMtIoAJFjddR3ZNFHwcDPozFhzpj20s5sT2JGxRa4/JsoWeSxR 27O4Hyx3dB8flhxlRct4WhUwoyuhQ4DZa0fBQViceKnlJwnt1M4STuay8S1ELwivT4W5 JnFuebtJ/6heRA7futibraynFvgPzx5EmJuSPiVNpscBAw1y+0HX2KpqZedNdKX+q9A2 G7EH4P2kHgqJ2MivIeUQpAIzYMbDFn5k7YjhM+D7xCoV9xRpKYOEzznz3w9NL3P1rsBw zHlmiEQdjCjKY6pWfRpw9uokV7ZAai9Fv9pxWmVWIiS+vtmSBZa5JyP1KGX34V0TBLnw 9lhw== 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=YC6lmTEI2DddOWPjuQmefmlclj4ZLY2oiewxsoGP1Vs=; b=4mvsVZKRgxLd2KM52KJlcgVMV+svcaool5eFu+zVREIu5+FzqyYQ0119fcJl8Wjr9h YF5pj/AKmI2PRieAqwBIX8zun84VBJ0uBIpdFpCdvmb8N5qXSEgnvq66GuE+nPblNDWV CF4y+DmECfwPOcBJor3YvwFJCZeSV32ph6LzLRjJHq8O95ijdnECF7QJeONzRENrYVZr vDqwR3eaBIcK96kJmhcPRxn3vc26CZgbvYS1nsYnFA+IuQZrQAgO6DdEn49ZNN6izxyI PIZFUC5YmBC7VNsfHpwlbP3i7C6oHP8LAdLj4LRilfvxPUIwwF6xXwzE8zs/aI7ijwmP G+Tw== X-Gm-Message-State: ANoB5pmr7USvHzGNtK7vuTjz+65vCXJRRykfZkbnDGju6wHNOYgLR7dA WHSLOawcn40EGcFQNc39+9fV3G/AO14= X-Google-Smtp-Source: AA0mqf5DoA93piz5CVF9XnFBz7DCsU5iv2lttlOp9VDYowFUmIgZu7ivcuR8M/O6WoSa+05bardiCQ== X-Received: by 2002:a17:902:6a8b:b0:186:fb8d:f4d3 with SMTP id n11-20020a1709026a8b00b00186fb8df4d3mr3201464plk.5.1670531707818; Thu, 08 Dec 2022 12:35:07 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id f5-20020a170902860500b00189951514c4sm16954349plo.206.2022.12.08.12.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 12:35:07 -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, "Vishal Moola (Oracle)" Subject: [PATCH v3 1/4] mm/memory: Add vm_normal_folio() Date: Thu, 8 Dec 2022 12:35:00 -0800 Message-Id: <20221208203503.20665-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221208203503.20665-1-vishal.moola@gmail.com> References: <20221208203503.20665-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2C6931C0009 X-Rspam-User: X-Stat-Signature: b956yh6wmkz6ajd3gcdxqreyr61a9ux6 X-HE-Tag: 1670531708-49841 X-HE-Meta: U2FsdGVkX1+Ete83Fg+NafLHqW9BXN0JNbwuqOHb+nftEueLW9btIQhn2PQhm5lQAFl1IsPXIFT51PzUf1fCoKnMwQAgxGdOOd9F6alBF9k5YOLAH8GOg7ykgcH2/Th8pkZ2RF0TtKzeLRpK/SEseNKWbvqM9PXgxLAtB/h0eEHzhE7Q/81AekSryEnJs1Ha+FxzfdUmbYCybULRQU1cjuncvpRsSonoHOBHakkO43I+EJG+Ja9KYjEhHEOqhao5V8VlgVoi+EDzBDVgseyILE0SkKgFDPijVZchRj0cmsZ8LiJTT4MoDbyKawPe1v0uVw7V+ASD/y3pheoTsw00goGDOPziRrwYQ7P0IuGiA1jd5jjJvxd2tsrnRXri6sA39nOEp2lGySWQX4HFVUXq5kJoIIMnn3GND+7S3hJLQ52AFrxK2chmD0A5cv9pqMvFTCZOptgUmK+1Ri5FICBjfuqWd5cGAH9Zv0qyzB0QzrZbsLzg31im04a0ojorNkf+6mhdogM+BginGi3KPVjukzm0PswBXUr44b5pgLqPvdR8xyHmjDPnzGrn5L3AdZZyZosWqudm28GT0rPcqBWyyJCPhodpMxiluVxBQyxet47ALwBu5Nb0/fb6zmYeyXXXQ+BGVG2+mJWHAG9AwJ8Nyo3dobmQo5VRIbtUn2v0EFz12GWtW2oFLkryuviFNvfhrcpaeFcFRy6ANHHBQF0BiFAM/KtUTstjewK1X0ChEYYOChWUZ2lxNaH5j/c5IPe5eplMFo7rVQhbUQxWCVavWFd9muWNY8yTOUx6XcYT79wcVW/u+oVefM0CN0xx9/+eoNk7+Ys8w46gNKl53TWIvCOPdLd0BBlkokul0e7i8fj1Yg1phyEcvZsGoQGozZnM+A4+ICG0zkIe4W/WFAAf6R9bm/2zUJ0ymuXbaeHnkwbEkDInfTg3bB/4g9l7wgVD0qWvtlhEuzoJCfrWcip SC04n0an 1h9xztOn46ymnEHNaZ5rjvPznV4G7BmwcD59MUkREXZSf8ZcKQqPIi2HL1JSo9LgbUQ/dX3/LAJCkGkvKhbbyRJv9/Jkzj632si3IChfn1K1UXVMwdG9B/AkiwyQpjtU1VpdmThBQi+979M3jsiSdF7WC5vUCzobKR/q0DrOyZPmqQ4erbw/6jAI6o+uNCx3oVFiEStcyeZ/AjAQDDQ8dXx70QGXUp6nsz7All5Iw2zVDnX8Jp4o46zo1xG1ThM/bZZShgiKzSMOb9UCMaEYI4aoXtA== 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 8bbcccbc5565..626ae0757bd3 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1860,6 +1860,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 f88c351aecd4..1247c19c516c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -672,6 +672,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)