From patchwork Thu Aug 25 10:10:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 12954472 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 34034C28D13 for ; Thu, 25 Aug 2022 10:12:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3F51940008; Thu, 25 Aug 2022 06:12:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C839940007; Thu, 25 Aug 2022 06:12:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84218940008; Thu, 25 Aug 2022 06:12:08 -0400 (EDT) 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 6F4C5940007 for ; Thu, 25 Aug 2022 06:12:08 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 498B141AD3 for ; Thu, 25 Aug 2022 10:12:08 +0000 (UTC) X-FDA: 79837699536.27.0208895 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf26.hostedemail.com (Postfix) with ESMTP id C5A22140016 for ; Thu, 25 Aug 2022 10:12:07 +0000 (UTC) Received: by mail-pl1-f177.google.com with SMTP id x23so18110093pll.7 for ; Thu, 25 Aug 2022 03:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=N/hACB6DJOnbW9YdcxCL4bYdw5iH8tr2HnsmRUbA/2k=; b=QK9DEIvE1XdTmyK0lBvfluXy8RYM/LAWM6lwGwePhGiIuALjqlWe153rtG2hWbimgP tADUbPJWllZwAGBl6q1qMoG7GiVV4Zxg5mCWYr5gpaptx+0cYenTa8MYu8BxylD1BYIR MuGpFgTWwlSreVJQ1YFHSoT6iayMMrkysAJwtTyc5sV4ffpifFreiRkvBdACM872Q6tU dkOoQSesVJHmEDw19sbAyC6q21uVp3rx9VXqWv5ZjPzjubyss70MeyGWM9AFYgnuU659 NiJrSv8GF1blOGvs/AogG2NrOnNaFsFxF+R6PRJfQ+I+YGspLrVxAViyyr0Bm4Nd080+ d75g== 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; bh=N/hACB6DJOnbW9YdcxCL4bYdw5iH8tr2HnsmRUbA/2k=; b=zkuigoXTHd/0SyDt5mkpSmaGFK3Zr6Ymj4GRNZD115TsoH2EE52RfW1LnoH0vwz+cQ aE6+MGLGJDGWwBPQtb80++i6aALr8BwOLELy/vhXROqwvehoA3JFzNFtzdDlQkVESRXG gAR/W9IjdLoGAjXrsG33J2mowZwi/vsfeImft485KZyP7u+HfzpK1EKcC/0Yr4ZjZx32 lSp0UdgPn2cspUT2FRpu7qx33MkRhZ19CZJbBFzuyk+1Ka6aAK17VZELrcgVGGIwtse4 8e9M2PuDV6+WfdMAqCeXTKYLL8UstyttR7pbKp0fVIG26VHXqMbAeRF5w1buDsZ0bBgC M0ww== X-Gm-Message-State: ACgBeo2BI1XHb6qxU3E44t1PYmRN4oWv8ENfNV2rMNKeEawDVyrlNBBa wYiUxjSYfHZrfl3WVo8VQSLvHA== X-Google-Smtp-Source: AA6agR5cOXU69J240S/HoYf6HtB5GQPmumANKU1IMKISK6IYS4mPO26cn0vvNtm0snnl5pnh+tc46Q== X-Received: by 2002:a17:90b:2496:b0:1ef:a94:7048 with SMTP id nt22-20020a17090b249600b001ef0a947048mr3877401pjb.244.1661422326951; Thu, 25 Aug 2022 03:12:06 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id b10-20020a170903228a00b001714c36a6e7sm8477581plh.284.2022.08.25.03.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 03:12:06 -0700 (PDT) From: Qi Zheng To: akpm@linux-foundation.org, david@redhat.com, kirill.shutemov@linux.intel.com, mika.penttila@nextfour.com, jgg@nvidia.com, tglx@linutronix.de, willy@infradead.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, muchun.song@linux.dev, Qi Zheng Subject: [RFC PATCH 6/7] x86/mm: add x86_64 support for pte_ref Date: Thu, 25 Aug 2022 18:10:36 +0800 Message-Id: <20220825101037.96517-7-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20220825101037.96517-1-zhengqi.arch@bytedance.com> References: <20220825101037.96517-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661422327; 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=N/hACB6DJOnbW9YdcxCL4bYdw5iH8tr2HnsmRUbA/2k=; b=eZdAf+eeA1Bso7AQ2e6Rz5uqBupBk7azeOrUSGeq83OMUwlBa9IQ6z23NZjPv1XxvjJ9rp CYYEeVyTdH0UzeJlrB/fBoRiyoJCNGbkniHdsKIg9k6LsgT59pciUsTHEkQMc0SfZJAMcR 5hSM1dEh4aahlYFKHr7qU0wX4Qm2lXI= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=QK9DEIvE; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf26.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661422327; a=rsa-sha256; cv=none; b=GURRpId1gIAKGCJMePah/9RCwIRF7xDrprvC4QQjMGpdlvfzHRsKrxyRF2rAOEWZlLwBx+ HtnTr+MQJwiaOz/zpYBviA3k+fmGtMj4WVuSOm0wg23nW8bykaqX+B4iAQvYXR42apWNss Wddk4bSZEDxG2D2CmZsMXMSf47pNBJ0= Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=QK9DEIvE; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf26.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com X-Rspam-User: X-Rspamd-Queue-Id: C5A22140016 X-Rspamd-Server: rspam10 X-Stat-Signature: 3fhh9gggtw9bciud7rhrxrg9u6r8zbxq X-HE-Tag: 1661422327-899982 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 | 4 ++++ include/linux/pgtable.h | 1 + 3 files changed, 6 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 52a7f91527fe..50215b05723e 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 44e2d6f1dbaa..cbfcfa497fb9 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); @@ -1005,6 +1006,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); } @@ -1050,6 +1052,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; } @@ -1066,6 +1069,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); } diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index c4a6bda6e965..908636f48c95 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -276,6 +276,7 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, pte_t pte = *ptep; pte_clear(mm, address, ptep); page_table_check_pte_clear(mm, address, pte); + track_pte_clear(mm, address, ptep, pte); return pte; } #endif