From patchwork Sun Jan 31 00:11:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 12057459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 325FEC433DB for ; Sun, 31 Jan 2021 00:16:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C2B2864E15 for ; Sun, 31 Jan 2021 00:16:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2B2864E15 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 035E26B0078; Sat, 30 Jan 2021 19:16:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F07996B007B; Sat, 30 Jan 2021 19:16:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB87B6B007D; Sat, 30 Jan 2021 19:16:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id B5B936B0078 for ; Sat, 30 Jan 2021 19:16:18 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 84B87180AD830 for ; Sun, 31 Jan 2021 00:16:18 +0000 (UTC) X-FDA: 77764153236.15.plot34_0100603275b5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 63C241814B0C7 for ; Sun, 31 Jan 2021 00:16:18 +0000 (UTC) X-HE-Tag: plot34_0100603275b5 X-Filterd-Recvd-Size: 4860 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Sun, 31 Jan 2021 00:16:17 +0000 (UTC) Received: by mail-pf1-f172.google.com with SMTP id t29so9063546pfg.11 for ; Sat, 30 Jan 2021 16:16:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JWcbdOnCHMci4gKmimhTyGECgzNX5SMoV5I4t1mnNZ0=; b=kGy8P8tEiPGFpNiMdALVuLcPBAKB5uzpz08ljdIJlFrJ3V1V4HWknbD805k1tUI0zq 5bOA5gbhW77cDC3aRozEAUTAoZvPJeo+5njDt9+GhpD1RuGVjoAsMOzLlgAd3oPpcKsz oAhtOZqt784wu/H4bdG0X5Ad02xITuDE8bxQLlAkx8rMNdeCJb1j4DMgc28ObRF1MTU6 UJVw9bnewbKW+tGZYJpjcYbgwmGxrF6Fun7V30BY53BAfi+Q666601tb+6ZFxzdTN/8T +dsz79Iaipj0knSCa1Wgsxxzd2Ps/UWLt76tMMSW19kR3a4j4ApKxGhMZux70qA60K/g p+lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JWcbdOnCHMci4gKmimhTyGECgzNX5SMoV5I4t1mnNZ0=; b=DYwpHNdom8hG52UyZw1+c+YSr7ZXhkkHAbnFxQBn4mwk7O36rTDfUMluV/QBCPvlYB 0N5oiJQxXOyVUS5VjxqLxnXmOqsjvC6v7xbrcdTkcpyMDCHNi3rpMlvYW41E+/7kGIfg rHcGgr15sgbFG7BzIiuy30qZlFcP8qGUmisB16XUdEyaA+F2AcgDzQP+quNYjTKcokVe NYL13Gz1ON/MuwHUYxx1HNqSK4wq3mhMsSiN5ertCcc1p7gjKtYTUtIhK7DFTnz1h5SH Zh7Pw53ALTL6PWauVub/JTsejCcRvW/AWIjt5j8PWN36o4CWDmICsanEN3V0RpwzsgHn xkfw== X-Gm-Message-State: AOAM530/aEV7ae/Wm7ibcPUROcuZPEf+g8XGl5VVUfVLd/VhyR1H8OH5 /i/uO1G4qiqw7YJtV2VI3Wukkv+nfNk= X-Google-Smtp-Source: ABdhPJxQY7yUiw79HkzXnSgtQxnTcWCyetEnB5yzFncWaRDkeWefmPRQgZcLK7ZQuCV+QkDOmqmirQ== X-Received: by 2002:a62:8f96:0:b029:1b7:75a9:a8b7 with SMTP id n144-20020a628f960000b02901b775a9a8b7mr10430610pfd.28.1612052176690; Sat, 30 Jan 2021 16:16:16 -0800 (PST) Received: from sc2-haas01-esx0118.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id e12sm13127365pga.13.2021.01.30.16.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jan 2021 16:16:16 -0800 (PST) From: Nadav Amit X-Google-Original-From: Nadav Amit To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Nadav Amit , Andrea Arcangeli , Andrew Morton , Andy Lutomirski , Dave Hansen , Peter Zijlstra , Thomas Gleixner , Will Deacon , Nick Piggin , Yu Zhao Subject: [RFC 10/20] mm: add pte_to_page() Date: Sat, 30 Jan 2021 16:11:22 -0800 Message-Id: <20210131001132.3368247-11-namit@vmware.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210131001132.3368247-1-namit@vmware.com> References: <20210131001132.3368247-1-namit@vmware.com> MIME-Version: 1.0 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: From: Nadav Amit Add a pte_to_page(), which is similar to pmd_to_page, which will be used later. Inline pmd_to_page() as well. Signed-off-by: Nadav Amit Cc: Andrea Arcangeli Cc: Andrew Morton Cc: Andy Lutomirski Cc: Dave Hansen Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Will Deacon Cc: Nick Piggin Cc: Yu Zhao --- include/linux/mm.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index ecdf8a8cd6ae..d78a79fbb012 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2161,6 +2161,13 @@ static inline spinlock_t *ptlock_ptr(struct page *page) } #endif /* ALLOC_SPLIT_PTLOCKS */ +static inline struct page *pte_to_page(pte_t *pte) +{ + unsigned long mask = ~(PTRS_PER_PTE * sizeof(pte_t) - 1); + + return virt_to_page((void *)((unsigned long) pte & mask)); +} + static inline spinlock_t *pte_lockptr(struct mm_struct *mm, pmd_t *pmd) { return ptlock_ptr(pmd_page(*pmd)); @@ -2246,7 +2253,7 @@ static inline void pgtable_pte_page_dtor(struct page *page) #if USE_SPLIT_PMD_PTLOCKS -static struct page *pmd_to_page(pmd_t *pmd) +static inline struct page *pmd_to_page(pmd_t *pmd) { unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1); return virt_to_page((void *)((unsigned long) pmd & mask));