From patchwork Wed Nov 10 08:40:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 12611605 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 077FAC433FE for ; Wed, 10 Nov 2021 08:42:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AF16E6134F for ; Wed, 10 Nov 2021 08:42:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AF16E6134F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 50C636B0082; Wed, 10 Nov 2021 03:42:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4BBD46B0085; Wed, 10 Nov 2021 03:42:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 384D46B0087; Wed, 10 Nov 2021 03:42:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0186.hostedemail.com [216.40.44.186]) by kanga.kvack.org (Postfix) with ESMTP id 28D596B0082 for ; Wed, 10 Nov 2021 03:42:17 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E000C7CB4C for ; Wed, 10 Nov 2021 08:42:16 +0000 (UTC) X-FDA: 78792378672.26.E3358BE Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf24.hostedemail.com (Postfix) with ESMTP id 8E46CB0000B2 for ; Wed, 10 Nov 2021 08:42:16 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id y14-20020a17090a2b4e00b001a5824f4918so1223011pjc.4 for ; Wed, 10 Nov 2021 00:42:16 -0800 (PST) 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=7ATw7hUTYZVQ0DwLa45RdRSrYNXHKuwCC3S5w4hY8zw=; b=cmfLwBU+Bm1CpzzA7YTIcjiVMZz4yqSlGwDAaFsgZGEl8L+xs0oT0q9kk5aEnq3nQw LOKt0Q4WxyBf7NuRLEdrDbMmyLLWjO5liJ8HjxmxNZzQwIs+Ij8/0ZAMiK40I2sKlFnY /5drhIPFmigd72gQT+hDVW9zUYeUpkWQU+sZ5y+K+yfDY46srQAHN3xRiPUQ+Cl6ZchI NIjc/Z5FOHtNxC1evaMqQoL8oH3GairafCktj7psqIoxN5lISzTj3TtM/YmXgSJhIlzL H4FeMwgGqf3zJJQk4i9KRerKfmx8NYf+NAzyw+kUN0eM1/op1FLq0hYk/Y9Hs2gQOYEU Lbdw== 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=7ATw7hUTYZVQ0DwLa45RdRSrYNXHKuwCC3S5w4hY8zw=; b=SMx6RZ4b3DxyqkZPWdkrljLcoIXZSXxTatIACSz6mi5uJzrEgcFArUJNchCY+VkfHn IcW9brTVR2+dtakfMOlKMb+4Y6gs6zWrlKV2Rpt1aJgvHXbGZ4AcTPPjRPD9yB32YHG6 FJKqsZE6sEbLWJb0PPVm1Ksn+d2g4XIeM10vEO5d9AFsV9wa7m8JJEEPTj9XhZu71TYQ vuv4eZQdwb3jsa2JbGi6Nbza94WQsEv9P3U5QLJvIsMYrqnwOeoEeYB47mKIps1EsMmM FCvcuhhPB3HSN/EACZvZQoRkQAFhRD+uQuqspQwWT5KPm0cD+kmoRX8AmCfFOtejiTIN Ip1Q== X-Gm-Message-State: AOAM531/vuxRX5KjDytRLw1t3n4Leq10TNPGtLMncRw1M6XDHUIOfFGE hiQcD908lwTl4CdbZdQm1giDWA== X-Google-Smtp-Source: ABdhPJwUSwvt3YOuBif1YVBS93VA3jBoJ7dOJ/5jXBZrZeGVyM6Fxna7uL3ysN+eFkr3A5oGtXJTpQ== X-Received: by 2002:a17:902:e9c6:b0:141:c588:99b2 with SMTP id 6-20020a170902e9c600b00141c58899b2mr14187337plk.63.1636533735736; Wed, 10 Nov 2021 00:42:15 -0800 (PST) Received: from C02DW0BEMD6R.bytedance.net ([139.177.225.251]) by smtp.gmail.com with ESMTPSA id v38sm5485368pgl.38.2021.11.10.00.42.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Nov 2021 00:42:15 -0800 (PST) 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 Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, songmuchun@bytedance.com, zhouchengming@bytedance.com, Qi Zheng Subject: [PATCH v3 08/15] mm/pte_ref: initialize the refcount of the withdrawn PTE page table page Date: Wed, 10 Nov 2021 16:40:50 +0800 Message-Id: <20211110084057.27676-9-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20211110084057.27676-1-zhengqi.arch@bytedance.com> References: <20211110084057.27676-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 8E46CB0000B2 X-Stat-Signature: fd1w1bfku5x81chbzii3ddah3jfutd9k Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=cmfLwBU+; spf=pass (imf24.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1636533736-254980 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000011, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When we split the PMD-mapped THP to the PTE-mapped THP, we should initialize the refcount of the withdrawn PTE page table page to HPAGE_PMD_NR, which ensures that we can release the PTE page table page when it is free(the refcount is 0). Signed-off-by: Qi Zheng --- mm/pgtable-generic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c index 4e640baf9794..523053e09dfa 100644 --- a/mm/pgtable-generic.c +++ b/mm/pgtable-generic.c @@ -186,6 +186,7 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp) struct page, lru); if (pmd_huge_pte(mm, pmdp)) list_del(&pgtable->lru); + pte_ref_init(pgtable, pmdp, HPAGE_PMD_NR); return pgtable; } #endif