From patchwork Fri Apr 29 13:35:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 12832022 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 0B24EC433F5 for ; Fri, 29 Apr 2022 13:37:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95B1F6B0073; Fri, 29 Apr 2022 09:37:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E2706B0074; Fri, 29 Apr 2022 09:37:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 735306B0075; Fri, 29 Apr 2022 09:37:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 62F1E6B0073 for ; Fri, 29 Apr 2022 09:37:56 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 35EBB26AD7 for ; Fri, 29 Apr 2022 13:37:56 +0000 (UTC) X-FDA: 79410019752.21.B51C077 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf27.hostedemail.com (Postfix) with ESMTP id 492994002F for ; Fri, 29 Apr 2022 13:37:54 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id s14so7160323plk.8 for ; Fri, 29 Apr 2022 06:37:55 -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=PDb352oR+7/T20U1mOURtFBi5DeN+iddATN1VUBhapY=; b=M4jKPxmu6lHLcuN2g3BJoI5FkuKhJPRPks8ERBsNxVTHX3vhgtEMdYENdfW7JcqHwT yIH289VoRZXsV1Haj1Czsaw7RvMgfpNlIK48fcm+b7NNl/oeI7592UtbcrVGAto3j8qC VAobCLwT2x5h91yk+I7lMpecP96Ie33InH4JS0EJJehK9pIzs5ACN6H54/tw0aIyHkt/ wfJfNrXbInpX6Uxy8tB2TVaoW38mmPPuQ4fg2KMeUpipyE6IjHJ7eHpciSWTRoh6yjhe peT1zi4IDbHb6FzrmQ0mld9hn0zaB46duAeGKxPzmtH5lzBQefASzBL34t5JOt4uPvRq 1WyQ== 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=PDb352oR+7/T20U1mOURtFBi5DeN+iddATN1VUBhapY=; b=wA6OkBwjYoPEoR2mpBRr6OpkYquQIJHrRorYds4+2ydea9QYls56bsOX2QgFtcaw8l UXVR3t6Bdwj85wBXrCI/UeGdH+vqapGvYuIDgwYQ5HXloKRe28Rleo//McDKBh/MsEdW uVz+aYkPDv1LQuITydUZox+mnnyCwKtXx4r4iKu2BpAwiuSmBqCuOTqh1A3fdhryZ798 YosMhM6bVS35cNfU3du8u5OOR1O54yfM9jzEluELZKP6r9ZAM3VpWv3GtEeAqAw6GSnc uzLx0kzupg3FVzND4eFvh3e5ZJYtjafifVvMePABagS19WBtx3eJEjXSlDmVcDegEiFX ZTJA== X-Gm-Message-State: AOAM533H+BqikfIKgW5THxVHON4LEgcWt4si5Uyv0uR1ZwYEqYzByiJk Hdr7ZVVCxxBgLBQAsVU7fX5c5g== X-Google-Smtp-Source: ABdhPJxuA4t7O9ORj9b40GN2GlWOmbbs1FpQC2BMOlij9ue4QgL40/Ximfv1xZWE9b9PeECFx/EvXA== X-Received: by 2002:a17:90a:e510:b0:1d8:39b3:280b with SMTP id t16-20020a17090ae51000b001d839b3280bmr4062679pjy.142.1651239474777; Fri, 29 Apr 2022 06:37:54 -0700 (PDT) Received: from localhost.localdomain ([139.177.225.240]) by smtp.gmail.com with ESMTPSA id m8-20020a17090a414800b001d81a30c437sm10681977pjg.50.2022.04.29.06.37.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 06:37:54 -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 17/18] x86/mm: add x86_64 support for pte_ref Date: Fri, 29 Apr 2022 21:35:51 +0800 Message-Id: <20220429133552.33768-18-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: p4cgwjnq8b9zte7iuhydjrwzy7a4ffyz X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 492994002F X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=M4jKPxmu; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf27.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.182 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com X-HE-Tag: 1651239474-725544 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_ref hooks into routines that modify user PTE page tables, and select ARCH_SUPPORTS_FREE_USER_PTE, so that the pte_ref code can be compiled and worked on this architecture. Signed-off-by: Qi Zheng --- arch/x86/Kconfig | 1 + arch/x86/include/asm/pgtable.h | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index b0142e01002e..c1046fc15882 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -34,6 +34,7 @@ config X86_64 select SWIOTLB select ARCH_HAS_ELFCORE_COMPAT select ZONE_DMA32 + select ARCH_SUPPORTS_FREE_USER_PTE config FORCE_DYNAMIC_FTRACE def_bool y diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 62ab07e24aef..08d0aa5ce8d4 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -23,6 +23,7 @@ #include #include #include +#include extern pgd_t early_top_pgt[PTRS_PER_PGD]; bool __init __early_make_pgtable(unsigned long address, pmdval_t pmd); @@ -1010,6 +1011,7 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte) { page_table_check_pte_set(mm, addr, ptep, pte); + track_pte_set(mm, addr, ptep, pte); set_pte(ptep, pte); } @@ -1055,6 +1057,7 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, { pte_t pte = native_ptep_get_and_clear(ptep); page_table_check_pte_clear(mm, addr, pte); + track_pte_clear(mm, addr, ptep, pte); return pte; } @@ -1071,6 +1074,7 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, */ pte = native_local_ptep_get_and_clear(ptep); page_table_check_pte_clear(mm, addr, pte); + track_pte_clear(mm, addr, ptep, pte); } else { pte = ptep_get_and_clear(mm, addr, ptep); } @@ -1081,7 +1085,8 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, static inline void ptep_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { - if (IS_ENABLED(CONFIG_PAGE_TABLE_CHECK)) + if (IS_ENABLED(CONFIG_PAGE_TABLE_CHECK) + || IS_ENABLED(CONFIG_FREE_USER_PTE)) ptep_get_and_clear(mm, addr, ptep); else pte_clear(mm, addr, ptep);