From mboxrd@z Thu Jan 1 00:00:00 1970 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 55D8BC02181 for ; Fri, 24 Jan 2025 07:58:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9FF728004B; Fri, 24 Jan 2025 02:58:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D4FA7280049; Fri, 24 Jan 2025 02:58:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3E7228004B; Fri, 24 Jan 2025 02:58:15 -0500 (EST) 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 A5E5B280049 for ; Fri, 24 Jan 2025 02:58:15 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4BE5C160EB4 for ; Fri, 24 Jan 2025 07:58:15 +0000 (UTC) X-FDA: 83041592550.06.1336A65 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf11.hostedemail.com (Postfix) with ESMTP id 938E64000F for ; Fri, 24 Jan 2025 07:58:13 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf11.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737705493; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4SZ8r7qFlS0Mj4juX144kv6kEssw1tik0bLEz+ZJuFE=; b=UoyVPjYwiJK3C+3m/2aiVpzvs+hjVHZNngb5oSwYkyhCD5k17l4sF6FTzAs6evS2T3v6M0 mM6uQSRVdzzmoCUaFvaia4jmrnRBVRwlcM+/z22gUoR2w3eSkk+9Ho8FWWyb3DXR/5Cn6h PnGIZJGPSpOaCTF0gdrpaM70RhznA8s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737705493; a=rsa-sha256; cv=none; b=zEMmAP+SY6YldYuaSvmhF6Z1nKcc3EAn6xbAQzevM3e5JahJqdWbAB2iw3WpdVhX9WVWHs BWX9EdV7K2tQNkUTDEp9av50xur6/ut1VEbwZ8yCkQ29gl3dPMSjIbgo119syzWaKpWI2Z LH12AoKWvrrWHtWRo1WZ9fysvq3O+0M= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf11.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C2952497; Thu, 23 Jan 2025 23:58:40 -0800 (PST) Received: from [10.57.95.170] (unknown [10.57.95.170]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D9EAD3F5A1; Thu, 23 Jan 2025 23:58:10 -0800 (PST) Message-ID: Date: Fri, 24 Jan 2025 08:58:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] s390/mm: Add missing ctor/dtor on page table upgrade To: Alexander Gordeev , Qi Zheng , Gerald Schaefer , Heiko Carstens Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton References: <20250123160349.200154-1-agordeev@linux.ibm.com> Content-Language: en-GB From: Kevin Brodsky In-Reply-To: <20250123160349.200154-1-agordeev@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 938E64000F X-Stat-Signature: 574jye5zhh67exeeuf3tantbt4pnf51j X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1737705493-459045 X-HE-Meta: U2FsdGVkX1+9RkKDUZuNwftZkjAta4+8AoCM1S1EgFq3VnWYTuObokO2vXgJzvVZ/azsyL03DbF2SXNfzwOS6cJVRpMvDqcNxjDMY/8YWkTsZA9uhJfDNkGGpUzqPvVFsCX8c9V2aK3YPLKy+Je6zN2KnCmSFGMbRlJsavypfEqz/UhcDmxHLIWsmBWxtPHOGrBSMhJbj0uWI8vy/funlOKUF7rycIueHMJ+ym3HQpp3afDM/Z5kRVCznwK0rbdstkRfG0FrPeiHJ4rrUSw04MJ1fOkV+trS2FQ6Hae6ekz/Fhbmz942BXoagCSploVmQaPkipiXhKwjjmAG5o3PYEGEqDRYh650UxH026piWGWe+Dbji61ijNT069Vae9L/yk5zxFQPj+5n9D/Mg6nVBVWFuH1DzVh+2LzMuoqJZPum4yy3afgdren8r40YnqgjYYdW6VhRMxQWb8VdW3kUn+BZSLh6TJZhrdzBqK6aFSD9nmqiWslhLopD6OZTLHBOe7ZQkbU/3LPu00GbFxpPId2GP3+Buh9ItLLvkoijmfyyITWpJnEmJxadNyqaMrDa7/4/emPb1plHfHeqbbFGboyr7DWlm1DlFcHBU3+QA58hcCnbfVP0byWI9GBh88FO8LW4eGpu7cXKGEGOpsk1mHA+8TAzJr+IqLJ+vB1CNmqH3TpsweqVNYaociCVEglenpvYqzHNDg9mZ1AGGjiRpdKDsFmKBWzHsjZFcn1yKT/Qi8KY+TJzboRsOMWaS6iEQCJPitvPuZ8UcmH30+LgVgnB+VRH5cdwNZMcLcISxve282B/K5SEA16zVJmqKKDG2aWnkZLd147acOoNa5krycVQoZWfQ/vt3sGYoZBLTqTFj0H03WrOIJ1BXDCh6NlY8ZpvmbRwJmeo5qX1C+BSt9SaESr6ytK8LIcSR67P6nDXB3Y6CGU8wH412KmJSKAzxhIWMfGxnCJx1WBfwC+ /QRy8MSI 2MJGFZc+7efC9hGwiyxJV0SiBbOLi4yHps/PSsv7nYlWdTSp6n05rEg7rEvez7ZRT3d/5QCAuI+bIitaLc0stfcDW9abHo/fjWEvoGiuOML+C9gGF3VXJ8jRyCR2CFej9Iq3UpmXZtxMXU/8QX5vvyPrlhI8ZIOnIq4d8wOQjPRUz5hvcONtD5fhp4qdTtGI5EzjF 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: List-Subscribe: List-Unsubscribe: On 23/01/2025 17:03, Alexander Gordeev wrote: > Commit 78966b550289 ("s390: pgtable: add statistics for PUD and P4D > level page table") misses the call to pagetable_p4d_ctor() against > a newly allocated P4D table in crst_table_upgrade(); > > Commit 68c601de75d8 ("mm: introduce ctor/dtor at PGD level") misses > the call to pagetable_pgd_ctor() against a newly allocated PGD and > the call to pagetable_dtor() against a newly allocated P4D that is > about to be freed on crst_table_upgrade() PGD upgrade fail path. > > The missed constructors and destructor break (at least) the page > table accounting when a process memory space is upgraded. > > Reported-by: Heiko Carstens > Closes: https://lore.kernel.org/all/20250122074954.8685-A-hca@linux.ibm.com/ > Suggested-by: Heiko Carstens > Fixes: 78966b550289 ("s390: pgtable: add statistics for PUD and P4D level page table") > Fixes: 68c601de75d8 ("mm: introduce ctor/dtor at PGD level") > Signed-off-by: Alexander Gordeev > --- > The patch is against: > > git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git next-20250123 > git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm mm-stable Thank you for putting together this patch! I was completely unaware of this "upgrade" path on s390. > --- > arch/s390/mm/pgalloc.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c > index a4e761902093..d33f55b7ee98 100644 > --- a/arch/s390/mm/pgalloc.c > +++ b/arch/s390/mm/pgalloc.c > @@ -88,12 +88,14 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long end) > if (unlikely(!p4d)) > goto err_p4d; > crst_table_init(p4d, _REGION2_ENTRY_EMPTY); > + pagetable_p4d_ctor(virt_to_ptdesc(p4d)); This block seems to be equivalent to p4d_alloc_one(), maybe it would be preferable to just call p4d_alloc_one() here to avoid further mismatches in the future (and reduce duplication)? > } > if (end > _REGION1_SIZE) { > pgd = crst_table_alloc(mm); > if (unlikely(!pgd)) > goto err_pgd; > crst_table_init(pgd, _REGION1_ENTRY_EMPTY); > + pagetable_pgd_ctor(virt_to_ptdesc(pgd)); I was hoping this might be equivalent to pgd_alloc() but it does not include a call to crst_table_init(). Since adding it would be apparently undesirable (having read the other thread), it seems reasonable to add the explicit constructor call. > } > > spin_lock_bh(&mm->page_table_lock); > @@ -130,6 +132,7 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long end) > return 0; > > err_pgd: > + pagetable_dtor(virt_to_ptdesc(p4d)); > crst_table_free(mm, p4d); Similarly, this could be a call to p4d_free(). - Kevin > err_p4d: > return -ENOMEM;