From patchwork Wed Jan 26 18:36:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12725596 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 C2034C2BA4C for ; Wed, 26 Jan 2022 18:36:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8CD76B0074; Wed, 26 Jan 2022 13:36:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E3C2D6B0075; Wed, 26 Jan 2022 13:36:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C19806B008A; Wed, 26 Jan 2022 13:36:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id ADAD26B0074 for ; Wed, 26 Jan 2022 13:36:42 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 641DA8249980 for ; Wed, 26 Jan 2022 18:36:42 +0000 (UTC) X-FDA: 79073294244.18.499D165 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) by imf11.hostedemail.com (Postfix) with ESMTP id 0230C4003B for ; Wed, 26 Jan 2022 18:36:41 +0000 (UTC) Received: by mail-qv1-f54.google.com with SMTP id t7so685322qvj.0 for ; Wed, 26 Jan 2022 10:36:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=NIQdhozYZQYwJuXanYTpSkQiAWCcpJhyfoG58pHCslA=; b=Bo3Fdqy4H5CvO8zl5pomEkR1gp3x8MwUzxy7Z5HKmiSyjdlsmqjAhR00ywO5pAO3x4 uNdiT3FyK6gp2JqbGiSd/Q2PthIYWdhPSdAn5TOjaihu46l72mfeiNMyhA7dutVKxnFC wA+rf72VjD8j3THQUhwX2QykoPzF+4MFSz1Y3IID6oxp2xlAXoMzoIpb0MJF9DKU6SnM xOgftlP8LGcFpqOtobCRLgW+R/1Ngani8djbZ77zWs9MEs9OHHcuEOJ5C1cSxMkRCd16 eGxndmGbnEooWd/kaYhc+on4vEHAeG6wRjeebLrkxHZo73GVcyyxKk2j8j8Ue86rPdzi 9RKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NIQdhozYZQYwJuXanYTpSkQiAWCcpJhyfoG58pHCslA=; b=u6R0oUMsejJB6lV3CmXIUzqZh6AN0AkdXCyCQI2aexSYV2yG7QFtinMfCuwVBRAaRK wMP6A/znuvfAU+jDVr++M/20XwKpkHEP4utsPWzpkR6XRBUdP/o9MICggwbBCIm7X6FK F7N7zIZPOS9zV+B0gXBa0iazf1dVz/48DIYjBLz0bF0S6GfE4CstSHUBZQpCu74I4PGn NymcfdPgiA4uDXsr4ymFnM+PwoHXhU74HMyd1PIskJFeKAifAC353rfPOpOYkrlBrXjm QYi1WWlO2JjHyoDTlIdfI4BfsH+qcpPnnHOOdyMAWq47fPIJmk47oYPbs3hfLyQFgzYh nx6g== X-Gm-Message-State: AOAM532+uH+ecel5t77H0qJpoDv2NU8NyEpMIlss9iN9t9LL/JFPXtck nsxlAQUeaGp6QXcZoJY6Hgk9Fg== X-Google-Smtp-Source: ABdhPJyuNmP3Wf47MQITz51h0tip2WfX44XPte2EplKCXHLqfSHCHJVpHfQJ5NtwUc2OxyfaeImh2w== X-Received: by 2002:a05:6214:1874:: with SMTP id eh20mr1050qvb.13.1643222201356; Wed, 26 Jan 2022 10:36:41 -0800 (PST) Received: from soleen.c.googlers.com.com (189.216.85.34.bc.googleusercontent.com. [34.85.216.189]) by smtp.gmail.com with ESMTPSA id h9sm26226qkp.75.2022.01.26.10.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 10:36:40 -0800 (PST) From: Pasha Tatashin To: pasha.tatashin@soleen.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, rientjes@google.com, pjt@google.com, weixugc@google.com, gthelen@google.com, mingo@redhat.com, will@kernel.org, rppt@kernel.org, dave.hansen@linux.intel.com, hpa@zytor.com, aneesh.kumar@linux.ibm.com, jirislaby@kernel.org, songmuchun@bytedance.com, qydwhotmail@gmail.com, hughd@google.com, ziy@nvidia.com, anshuman.khandual@arm.com Subject: [PATCH v4 2/4] mm/page_table_check: use unsigned long for page counters and cleanup Date: Wed, 26 Jan 2022 18:36:35 +0000 Message-Id: <20220126183637.1840960-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog In-Reply-To: <20220126183637.1840960-1-pasha.tatashin@soleen.com> References: <20220126183637.1840960-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 0230C4003B X-Stat-Signature: p3dog6xf59k4kad6fz5gqwr6d78373t4 Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=Bo3Fdqy4; dmarc=none; spf=pass (imf11.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.54 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com X-Rspam-User: nil X-HE-Tag: 1643222201-33536 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: For the consistency, use "unsigned long" for all page counters. Also, reduce code duplication by calling __page_table_check_*_clear() from __page_table_check_*_set() functions. Signed-off-by: Pasha Tatashin Reviewed-by: Wei Xu Acked-by: David Rientjes --- mm/page_table_check.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/mm/page_table_check.c b/mm/page_table_check.c index 7504e7caa2a1..c61d7ebe13b1 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -86,8 +86,8 @@ static void page_table_check_clear(struct mm_struct *mm, unsigned long addr, { struct page_ext *page_ext; struct page *page; + unsigned long i; bool anon; - int i; if (!pfn_valid(pfn)) return; @@ -121,8 +121,8 @@ static void page_table_check_set(struct mm_struct *mm, unsigned long addr, { struct page_ext *page_ext; struct page *page; + unsigned long i; bool anon; - int i; if (!pfn_valid(pfn)) return; @@ -152,10 +152,10 @@ static void page_table_check_set(struct mm_struct *mm, unsigned long addr, void __page_table_check_zero(struct page *page, unsigned int order) { struct page_ext *page_ext = lookup_page_ext(page); - int i; + unsigned long i; BUG_ON(!page_ext); - for (i = 0; i < (1 << order); i++) { + for (i = 0; i < (1ul << order); i++) { struct page_table_check *ptc = get_page_table_check(page_ext); BUG_ON(atomic_read(&ptc->anon_map_count)); @@ -206,17 +206,10 @@ EXPORT_SYMBOL(__page_table_check_pud_clear); void __page_table_check_pte_set(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte) { - pte_t old_pte; - if (&init_mm == mm) return; - old_pte = *ptep; - if (pte_user_accessible_page(old_pte)) { - page_table_check_clear(mm, addr, pte_pfn(old_pte), - PAGE_SIZE >> PAGE_SHIFT); - } - + __page_table_check_pte_clear(mm, addr, *ptep); if (pte_user_accessible_page(pte)) { page_table_check_set(mm, addr, pte_pfn(pte), PAGE_SIZE >> PAGE_SHIFT, @@ -228,17 +221,10 @@ EXPORT_SYMBOL(__page_table_check_pte_set); void __page_table_check_pmd_set(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd) { - pmd_t old_pmd; - if (&init_mm == mm) return; - old_pmd = *pmdp; - if (pmd_user_accessible_page(old_pmd)) { - page_table_check_clear(mm, addr, pmd_pfn(old_pmd), - PMD_PAGE_SIZE >> PAGE_SHIFT); - } - + __page_table_check_pmd_clear(mm, addr, *pmdp); if (pmd_user_accessible_page(pmd)) { page_table_check_set(mm, addr, pmd_pfn(pmd), PMD_PAGE_SIZE >> PAGE_SHIFT, @@ -250,17 +236,10 @@ EXPORT_SYMBOL(__page_table_check_pmd_set); void __page_table_check_pud_set(struct mm_struct *mm, unsigned long addr, pud_t *pudp, pud_t pud) { - pud_t old_pud; - if (&init_mm == mm) return; - old_pud = *pudp; - if (pud_user_accessible_page(old_pud)) { - page_table_check_clear(mm, addr, pud_pfn(old_pud), - PUD_PAGE_SIZE >> PAGE_SHIFT); - } - + __page_table_check_pud_clear(mm, addr, *pudp); if (pud_user_accessible_page(pud)) { page_table_check_set(mm, addr, pud_pfn(pud), PUD_PAGE_SIZE >> PAGE_SHIFT,