From patchwork Fri Apr 29 13:35:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 12832012 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 0CD04C433EF for ; Fri, 29 Apr 2022 13:37:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 90F106B0072; Fri, 29 Apr 2022 09:36:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8BC096B007E; Fri, 29 Apr 2022 09:36:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7AACE6B0080; Fri, 29 Apr 2022 09:36:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 6C0676B0072 for ; Fri, 29 Apr 2022 09:36:59 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4CC29206FA for ; Fri, 29 Apr 2022 13:36:59 +0000 (UTC) X-FDA: 79410017358.22.807A89B Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by imf23.hostedemail.com (Postfix) with ESMTP id EBA1914003A for ; Fri, 29 Apr 2022 13:36:51 +0000 (UTC) Received: by mail-pg1-f170.google.com with SMTP id bg9so6540280pgb.9 for ; Fri, 29 Apr 2022 06:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZTHv+EobGmd8CLqrN8ICsD/Gd2+vakaEN+AZqfml/As=; b=Pp9YaWXF+keaVk+3vcFs3ST1OD3cYkcjwDO13WpXirW65DJ5bV24lriyyZ3gSCtH1t ZrexZP4eqVpM+sJIbrDvAV6PHKPMjCYED8+24O1lxhFn2leYX3+FUdT0xJMzmNoM8vHu R6U2/6kf69dP6xXUieWIdERPGU8JMCKVGGHds1fcYgNFcNtGAn1c/kHvsWaE3iNCkYA5 RqdeoXcJZMaW+VrHTPiE0q4Zx8NLKhMbg/05XMpQP+Fif3YIpIK9cdVZGsJrI8deD15+ Yk+iY23SxB+rz3MFcApWicRPxvVoXsv2GXFFrxlXAOr0Z2k4Bv9kbswt9Pf2UaM2ubmN BZag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZTHv+EobGmd8CLqrN8ICsD/Gd2+vakaEN+AZqfml/As=; b=XTCi8KGVp/mrVs432XFmiPYLf27c/5cEqWtIk8ir0ikfUKO6iZLD7iXMvGoqWbj76u pg9alhE/2AqWp+gnvCjH8DtCdi1t0Y3SYsnrimp1ujxjmZIiFmkDi/YIGNoCK/JCmMqa 1WqQRQ5M6jAHqw4yS/D8SFPNkdLwB0HY4P63csXyU3XKMBhoW5Nu0mpHz82XopexJsaL Mb/fYZ918SSQQj9CF4FQ99kBG78RJ3JwkLfLo/A8zMMiyZHaPCAr09BK7QGc7dPQG6qC Lq6u1qqQDF9gYTpxFignJKlsvc8UECkQReP9ZF3UrjIlQpr5DF1+z45xB6Da+KYjAeLe i1oA== X-Gm-Message-State: AOAM531LftuUf925aKvZaRzFRkKNENDfJhzTNTN0apiL5qMCIdGBfeg3 0asMgD2qk7fEbMcZtYfKnPYT2w== X-Google-Smtp-Source: ABdhPJxQ/VkMVyn4Qp+z5Cb9ljljtE8dhgkTNUvvkMORdefL3XrTmyDghPgZGP75wajseTIiF7sh1Q== X-Received: by 2002:a63:290:0:b0:3aa:8b8b:1a3d with SMTP id 138-20020a630290000000b003aa8b8b1a3dmr31635992pgc.208.1651239417928; Fri, 29 Apr 2022 06:36:57 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.240]) by smtp.gmail.com with ESMTPSA id m8-20020a17090a414800b001d81a30c437sm10681977pjg.50.2022.04.29.06.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 06:36:57 -0700 (PDT) From: Qi Zheng To: akpm@linux-foundation.org, tglx@linutronix.de, kirill.shutemov@linux.intel.com, mika.penttila@nextfour.com, david@redhat.com, jgg@nvidia.com, tj@kernel.org, dennis@kernel.org, ming.lei@redhat.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, songmuchun@bytedance.com, zhouchengming@bytedance.com, Qi Zheng Subject: [RFC PATCH 07/18] mm: add pte_to_page() helper Date: Fri, 29 Apr 2022 21:35:41 +0800 Message-Id: <20220429133552.33768-8-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20220429133552.33768-1-zhengqi.arch@bytedance.com> References: <20220429133552.33768-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Stat-Signature: fdqmf6q7ti695bojixxrd4ha6e97zd1g X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EBA1914003A Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Pp9YaWXF; spf=pass (imf23.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.215.170 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspam-User: X-HE-Tag: 1651239411-915043 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: Add pte_to_page() helper similar to pmd_to_page(), which will be used to get the struct page of the PTE page table. Signed-off-by: Qi Zheng --- include/linux/pgtable.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 0928acca6b48..d1218cb1013e 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -85,6 +85,14 @@ static inline unsigned long pud_index(unsigned long address) #define pgd_index(a) (((a) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) #endif +#ifdef CONFIG_FREE_USER_PTE +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)); +} +#endif + #if USE_SPLIT_PTE_PTLOCKS #if ALLOC_SPLIT_PTLOCKS void __init ptlock_cache_init(void);