Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3260728lfo; Mon, 23 May 2022 00:13:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF5MmS8CWvXClgxTgBY7Eu4HeKWyhuBzx/iMcJrp5qlMn/v9+gQ6IHMy4pOLRoDgvydr7C X-Received: by 2002:a17:90b:3903:b0:1df:d0b4:3b54 with SMTP id ob3-20020a17090b390300b001dfd0b43b54mr24211160pjb.40.1653290001419; Mon, 23 May 2022 00:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653290001; cv=none; d=google.com; s=arc-20160816; b=IBg2jaT2v2aZ4DIU8FCuVp+lbR0Y/+qGSddZXUIcAOzhKhj7SMr5hN5vNvQAUTlkk5 0qzCyfAsFPzgUqd12z/LWkWmevl9VcqOp4shdAzSE4hqenTIP847R7ezZp4Cn26fQ92M r9Lgv1N4YScoKEiUF6hcJscFjm8H/IpGCM/ZtLHW4yh6QbtH5AUg2Q5zw891dnfreY4Z wE1w38W2uRjfCTwDICaTBQUNQlszG47jl7ivq+InufH56s7jqON5CM5sNHxilYZWy2WK u7/WEHWgjy4lqgNQhZS3FXZK9v9bBXuPfJntRcu7FsMdlCyMiQedTVhwqLrJ3uCAUTYd EyrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mGwVn8RHselKV0air8yMqpzaEEJKFNShOYXjybSXJNI=; b=u9iforIloifQ2l9P8/rhTHxFAhkbe4qFIRxWZSdq2W743MMqScmuafVSFThH+GUdET HsKrV/6WB1x62dPaY6q5xj2qSL2Vzzw3XEn8uE5Zbolpns5d/HNBbmBsblONBIMdtesV LVGGEpC1ngLvsSlqpZNvULwDgX4wF4cjHR68YAtvXkl50CxMTuCHXzrkRxAoqVNv5b0q t/RkAkhQ/emXBCW4ks8si35jyGc8pVbDu3BafMqIDkDCXrlH8t0/Zmwk8zwNYsP39e8L R3s4BtI32MgIIWhc5bFd0fPGt3mNqBGiwkZfDl+sfnJ4H6r1yGAvGVrtPGa3JJNevz+o qoYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GGS28zJ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b11-20020a056a000ccb00b00512e59d9bf9si14249214pfv.296.2022.05.23.00.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:13:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GGS28zJ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D12ED12770; Sun, 22 May 2022 23:31:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243962AbiESSag (ORCPT + 99 others); Thu, 19 May 2022 14:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243955AbiESSac (ORCPT ); Thu, 19 May 2022 14:30:32 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6861AED8E2 for ; Thu, 19 May 2022 11:30:24 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id i1so5510684plg.7 for ; Thu, 19 May 2022 11:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mGwVn8RHselKV0air8yMqpzaEEJKFNShOYXjybSXJNI=; b=GGS28zJ2n2buwhhkptrcMlxiv/ufYgHyGsbryhRNp3gNf94fakNVd+3CP6VO6oLiHO 4SPYQzlz8D9i7daFH1molB3QLlP8VJ/KGVCqbJdr02oaQEhcJBj2pVKDWpWDArmB1RSD CRYwCc8aQufDQCLI7pILGztuHJIzcNKBGVJWgEftXS2StQPkocMb57XlZsjqHSwS4OMd +bG6y9kcYZyWesa+NUzWt8dNKs/eco+x43uzhC2YKiCA0psA6d+JlXlW1z/QlBflv5kZ GCPSFju9p6WrOej/yIx5CFC+SUa79W/LYShld15IKoIBlf8GOQLD2qKoL7G5U6lxjhHq P+fQ== 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=mGwVn8RHselKV0air8yMqpzaEEJKFNShOYXjybSXJNI=; b=B5FtFylg06rza2Eb2Vs54YQbB6FnNlcfOuNyCLVsmr/nZhUjfj0gshiu7JHWDyOcaz mhRPnrmZHNGuq98wPaaB3tham3GTX3dbosCN5hKRGjg4jBVtCc8OhSTPlrWne2pwB/RC PClDetVNr7zd2y9/ZZ3D/f4auPdlvcnRUmsodoEdVyhQCIB/7ZgMn7rkQCVwDIKgmVOK ngi9hg3q3TXTinoVAV1g8WiOZlXLEO7dUl6kQf/G80bm9fYVrbNcgkMWzzunev15jiBX HdA8ONLNg+9Exd2bZbYWHDWrhoybRqNGUKVDKm4tm87oVZbT5/h8cdpQIFrU6QbmqH08 LBuQ== X-Gm-Message-State: AOAM533NUBhk/tgy7nh9v1ama+builVSqHxdelywv5kTccI3jLFG/Fni Sx7kOGiwHeE7GRRQo+TV884= X-Received: by 2002:a17:902:da90:b0:15e:adc2:191d with SMTP id j16-20020a170902da9000b0015eadc2191dmr5907894plx.134.1652985023806; Thu, 19 May 2022 11:30:23 -0700 (PDT) Received: from archlinux.localdomain ([140.121.198.213]) by smtp.googlemail.com with ESMTPSA id z5-20020a63e105000000b003c14af505f6sm3884674pgh.14.2022.05.19.11.30.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 11:30:23 -0700 (PDT) From: Chih-En Lin To: Andrew Morton , linux-mm@kvack.org Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Christian Brauner , "Matthew Wilcox (Oracle)" , Vlastimil Babka , William Kucharski , John Hubbard , Yunsheng Lin , Arnd Bergmann , Suren Baghdasaryan , Chih-En Lin , Colin Cross , Feng Tang , "Eric W. Biederman" , Mike Rapoport , Geert Uytterhoeven , Anshuman Khandual , "Aneesh Kumar K.V" , Daniel Axtens , Jonathan Marek , Christophe Leroy , Pasha Tatashin , Peter Xu , Andrea Arcangeli , Thomas Gleixner , Andy Lutomirski , Sebastian Andrzej Siewior , Fenghua Yu , David Hildenbrand , linux-kernel@vger.kernel.org, Kaiyang Zhao , Huichun Feng , Jim Huang Subject: [RFC PATCH 3/6] mm, pgtable: Add ownership for the PTE table Date: Fri, 20 May 2022 02:31:24 +0800 Message-Id: <20220519183127.3909598-4-shiyn.lin@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220519183127.3909598-1-shiyn.lin@gmail.com> References: <20220519183127.3909598-1-shiyn.lin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce the ownership for the PTE table to prepare the following patch of the Copy-On-Write (COW) page table. It uses the address of PMD index to become the owner to identify which process can update its page table state from the COW page table. Signed-off-by: Chih-En Lin --- include/linux/mm.h | 1 + include/linux/mm_types.h | 1 + include/linux/pgtable.h | 14 ++++++++++++++ 3 files changed, 16 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 9f44254af8ce..221926a3d818 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2328,6 +2328,7 @@ static inline bool pgtable_pte_page_ctor(struct page *page) return false; __SetPageTable(page); inc_lruvec_page_state(page, NR_PAGETABLE); + page->cow_pte_owner = NULL; return true; } diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 8834e38c06a4..5dcbd7f6c361 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -221,6 +221,7 @@ struct page { #ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS int _last_cpupid; #endif + pmd_t *cow_pte_owner; /* cow pte: pmd */ } _struct_page_alignment; /** diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index f4f4077b97aa..faca57af332e 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -590,6 +590,20 @@ static inline int pte_unused(pte_t pte) } #endif +static inline bool set_cow_pte_owner(pmd_t *pmd, pmd_t *owner) +{ + struct page *page = pmd_page(*pmd); + + smp_store_release(&page->cow_pte_owner, owner); + return true; +} + +static inline bool cow_pte_owner_is_same(pmd_t *pmd, pmd_t *owner) +{ + return (smp_load_acquire(&pmd_page(*pmd)->cow_pte_owner) == owner) ? + true : false; +} + #ifndef pte_access_permitted #define pte_access_permitted(pte, write) \ (pte_present(pte) && (!(write) || pte_write(pte))) -- 2.36.1