From patchwork Mon Aug 7 23:04:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13345295 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 1AD0DC04E69 for ; Mon, 7 Aug 2023 23:05:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DA86940010; Mon, 7 Aug 2023 19:05:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88AEB940008; Mon, 7 Aug 2023 19:05:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72C80940010; Mon, 7 Aug 2023 19:05:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5B608940008 for ; Mon, 7 Aug 2023 19:05:43 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2BF5D1A0B86 for ; Mon, 7 Aug 2023 23:05:43 +0000 (UTC) X-FDA: 81098842566.04.FCA0C1D Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) by imf06.hostedemail.com (Postfix) with ESMTP id 59EC418000D for ; Mon, 7 Aug 2023 23:05:41 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=aasPlAtm; spf=pass (imf06.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691449541; a=rsa-sha256; cv=none; b=hvKN7yGGZHnwUlBGKkwDbDRxSDape83yORcwMiu8FmaFXqqphUm/eUmwTfFq8LFw3WyBk/ Ovc6bglCU3OiZSonpnpa4XvB9x6M/noq4wYaYlJx9VXohXiVS2yERnMvxPaqBXj8tY+XC4 vkE9BHFMI/SXbVOY1zkXopO5zzZrVkw= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=aasPlAtm; spf=pass (imf06.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691449541; 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=XBjJ/e2vPX4j94DTkAO9XQqqbwuOMqryYrtpznFEgGY=; b=Ndg5yNtRpxWslUGJ6KE/kHdtLUJi4XJ/Yp5jAj7hJ5jbnA6Zc7n7AqGHwpZiXY0MsdfK+q lGrlnsOo6fC+om5R2nEixBoRUJzzhANWDCDoDIP2gNdUesJPCHvvQsfvuRCow83Q0SwSjW btIAE1qdDHT44DPajYgSwOEk9c59fX0= Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-d16889b3e93so5396147276.0 for ; Mon, 07 Aug 2023 16:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691449540; x=1692054340; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XBjJ/e2vPX4j94DTkAO9XQqqbwuOMqryYrtpznFEgGY=; b=aasPlAtm5Pcd0yp6duryP473IaipZJS0bWZ4Z8XEGwFlj43AOqpIIC6FhirKlPve9C F1vUSIrLW1oYFLLrLilYCJzqaLsw1rmRGBb+Z5eKzeBY0HVz8f1HGASCxMQ2qqkeDt1/ NUUsoQwBHF6NBLlkSQcHcy9LC4jgcOdJmOlAy/6h3iyfEMCFdLo7Fk1Bu4KWGLpiNsE1 KzSFxNl6DRl46MY838sL7FF+wIJkc1YVhg5kJdFIQoWHplt5NksftMQPYk7wCakllMw/ EceX3OKTdEGMJ4GdFrkX3TffvwqD7i/AFN0kCIklmMB/JORnudk4URx0r/bcoO+F1Yl1 rD5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691449540; x=1692054340; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XBjJ/e2vPX4j94DTkAO9XQqqbwuOMqryYrtpznFEgGY=; b=Y/i3G38F8SwrX9LE8E95dYJ1bujcbMj4Mt/Mg91XSmAhiYQTSIG4soL6QX8zYgs6oN Td3G0eO2FUMTD/h7NxsXWbsJppPZWrt0dtZt6u982FavR37QknZZtumpoDqki2Yaor7v SNFnFDQK6Lq7k2VTd2p+pejEqWYupo6cd2L9GS5IxFmF0adPmodnFZ4bRdQ/dDQRvxT2 bVwXZdytC6U0r8A8kUF1IRLxElyTJ+nNOgisc9Nm770MzrU/t8E9mqFvsIIEOiHggEVD qaH42y0sJGPuSf7W85Mh2rvdhqsTC1yolxTxq3uh9Eew75cNdIXH+HMMCdQkr3odlmrA YpDA== X-Gm-Message-State: AOJu0YwmNeBFexl2jC7f1USXR87pJZDvYgm5+q8xA9RTr8yeAeo0A7Vp wz7omVpfp8H8WxfKhNop2gk= X-Google-Smtp-Source: AGHT+IEw8LfaxYvauKrU5QG8lz4qzDMmMrsNvSvomqfZDfXz4mmURgWJbxHCG9LEh9h57v96do4e4w== X-Received: by 2002:a25:8251:0:b0:cb9:41ad:8938 with SMTP id d17-20020a258251000000b00cb941ad8938mr12329076ybn.3.1691449540449; Mon, 07 Aug 2023 16:05:40 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id d190-20020a25cdc7000000b00d3596aca5bcsm2545203ybf.34.2023.08.07.16.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 16:05:40 -0700 (PDT) From: "Vishal Moola (Oracle)" To: Andrew Morton , Matthew Wilcox Cc: linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, Hugh Dickins , "Vishal Moola (Oracle)" , Mike Rapoport Subject: [PATCH mm-unstable v9 11/31] mm: Create ptdesc equivalents for pgtable_{pte,pmd}_page_{ctor,dtor} Date: Mon, 7 Aug 2023 16:04:53 -0700 Message-Id: <20230807230513.102486-12-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230807230513.102486-1-vishal.moola@gmail.com> References: <20230807230513.102486-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 59EC418000D X-Stat-Signature: stmu7dnixeexppfodcayoqpmbjc5mn4e X-Rspam-User: X-HE-Tag: 1691449541-823136 X-HE-Meta: U2FsdGVkX1/eJrY29opr1RjTXv7PSchb0tp4X8QCiSq6g8c1+0mfGtq/1dpNSAjmS2fmiLuxm3uOJylGkCqFY4glJGRBmO38QJRthoy9sCw8P4jSHbl8i58SkWwmlDvasAVXFa8uKamtDin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tCgR+BAFpu9VcOwZHwg+OcjsWZ6/F3xYBDt0rL0fqCDNYIvV64/GlW9Taf94r+pNuxdUFTu1KUBof8ReDiPM30417AE9BEmseFc9Un16824xJEZBmWtLMbD66rmUNvWbmIwxdSQVnZ7VNuX2uRgnihxa7JOScP0o9urGqDYYB+oStggHndH04tCIVhr4/NDLXoPCATYHXAGTb9OL/kCGbKDv7m9JA4rTftTwqN/9GAwJ2NHQ6a4lUOSsg/IyYYzD+jGMNEnK7dnodMbw2Qump1cOWbKIieHlMPzVCKSYWaGRfeJBQ3KiIc6zHptI0c1srRX/foDQ/ixbD5dl1khJ4VZf7c8aQfNumyukgBI2uvKaixGU2N1omuIYlPx/T1EQ9jwZzyrsWABfOZaBGD/r45faus= 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: Create pagetable_pte_ctor(), pagetable_pmd_ctor(), pagetable_pte_dtor(), and pagetable_pmd_dtor() and make the original pgtable constructor/destructors wrappers. Acked-by: Mike Rapoport (IBM) Signed-off-by: Vishal Moola (Oracle) --- include/linux/mm.h | 56 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 94984d49ab01..6310e0c59efe 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2921,20 +2921,34 @@ static inline bool ptlock_init(struct ptdesc *ptdesc) { return true; } static inline void ptlock_free(struct ptdesc *ptdesc) {} #endif /* USE_SPLIT_PTE_PTLOCKS */ -static inline bool pgtable_pte_page_ctor(struct page *page) +static inline bool pagetable_pte_ctor(struct ptdesc *ptdesc) { - if (!ptlock_init(page_ptdesc(page))) + struct folio *folio = ptdesc_folio(ptdesc); + + if (!ptlock_init(ptdesc)) return false; - __SetPageTable(page); - inc_lruvec_page_state(page, NR_PAGETABLE); + __folio_set_pgtable(folio); + lruvec_stat_add_folio(folio, NR_PAGETABLE); return true; } +static inline bool pgtable_pte_page_ctor(struct page *page) +{ + return pagetable_pte_ctor(page_ptdesc(page)); +} + +static inline void pagetable_pte_dtor(struct ptdesc *ptdesc) +{ + struct folio *folio = ptdesc_folio(ptdesc); + + ptlock_free(ptdesc); + __folio_clear_pgtable(folio); + lruvec_stat_sub_folio(folio, NR_PAGETABLE); +} + static inline void pgtable_pte_page_dtor(struct page *page) { - ptlock_free(page_ptdesc(page)); - __ClearPageTable(page); - dec_lruvec_page_state(page, NR_PAGETABLE); + pagetable_pte_dtor(page_ptdesc(page)); } pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp); @@ -3032,20 +3046,34 @@ static inline spinlock_t *pmd_lock(struct mm_struct *mm, pmd_t *pmd) return ptl; } -static inline bool pgtable_pmd_page_ctor(struct page *page) +static inline bool pagetable_pmd_ctor(struct ptdesc *ptdesc) { - if (!pmd_ptlock_init(page_ptdesc(page))) + struct folio *folio = ptdesc_folio(ptdesc); + + if (!pmd_ptlock_init(ptdesc)) return false; - __SetPageTable(page); - inc_lruvec_page_state(page, NR_PAGETABLE); + __folio_set_pgtable(folio); + lruvec_stat_add_folio(folio, NR_PAGETABLE); return true; } +static inline bool pgtable_pmd_page_ctor(struct page *page) +{ + return pagetable_pmd_ctor(page_ptdesc(page)); +} + +static inline void pagetable_pmd_dtor(struct ptdesc *ptdesc) +{ + struct folio *folio = ptdesc_folio(ptdesc); + + pmd_ptlock_free(ptdesc); + __folio_clear_pgtable(folio); + lruvec_stat_sub_folio(folio, NR_PAGETABLE); +} + static inline void pgtable_pmd_page_dtor(struct page *page) { - pmd_ptlock_free(page_ptdesc(page)); - __ClearPageTable(page); - dec_lruvec_page_state(page, NR_PAGETABLE); + pagetable_pmd_dtor(page_ptdesc(page)); } /*