Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp629497pxv; Thu, 15 Jul 2021 11:57:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHE0mPW5dboj+GfUqKl7IZ/yHlP7NcYcc4eO0KdoYZetwjXjuSUOKFtOQZIWFTL7Akf+as X-Received: by 2002:a17:906:f294:: with SMTP id gu20mr7198561ejb.292.1626375468512; Thu, 15 Jul 2021 11:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375468; cv=none; d=google.com; s=arc-20160816; b=mSLxDmtCwGdYYQFzdEo/ICZ3x3ZTDqlcxVaGeEai49VGRmHkvxbg+XqOXtTmTHAwUQ 8d+26Khn+VJ9tDVq/PuTulMAxLiO0/RhJx1EdFlj+b+rhuXGykuNbz3BQMEBTf24yfRZ xGWX03sgOPu04fuQZVsaU9Pr34OKgTs/rkaWfU//dCL2P4aXpFkhfEpQd+dA+J/o/y1F xEvbvXpltxvybKVrljCUNteM/sOj2B+Iq1sqOhI4Nv1lD4pA2J8U9ul0cdLt7sGVG18G sMO+bYgHaO2Zv/iLFn4AumiJyXCBR5t0xRAoQ6DE7FATWMFAhwEfnrWQqRiwG1a/9g/p NS7Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IXp+ZPL+/uHUUYI+GopKUEsu+SGyN3o+I8482UPfE10=; b=Pst4TV3V7tRuIP4zvfQ+M8N+1rR6KMDiOOKdkkkE0cBpsHqswwTyuxE01dC65vAN0e wMmT7EE4aqOMJ2FwpHye/u1lD7jI10EvpBi7/gq8URn5eQ2oI7PapbnD6eoZnzobl60p 4wQnj9NfuZyM77yXDLSxsaS5w9aihQ62b0Y8hC0cCYoRUpFX/HvMm7P6FDnVTYmvfJd5 j+SQUPf0lB0f+XIFQgMKKwOsUMAKSqeZLZe5n/nfxv4WLLEro4RemGTTla5cbQpAw9Eg Bzgv4MoIQR8RmCATXf1QVxggD9FW9dli8DLiN1W26l4VqS5Iu3wPIEW0ww4m5jiWPbRn f79w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jZMVvwlT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s22si8026760edr.67.2021.07.15.11.57.25; Thu, 15 Jul 2021 11:57:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jZMVvwlT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236763AbhGOS6s (ORCPT + 99 others); Thu, 15 Jul 2021 14:58:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:52350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239588AbhGOSwL (ORCPT ); Thu, 15 Jul 2021 14:52:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C3FC3613E0; Thu, 15 Jul 2021 18:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374957; bh=3vY8jkLEb5T5wUhD3hW2OPPBQIV5VgHI3/oaBlcpP+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jZMVvwlTtexTbCAszcky9gv5Ub5yIVJ5ifnEj1GURy5LXHOocjmwMqaspMmhUSQ3T 4n26cch7bdOVQGNSOmHMwqX3RLK6nAAHBGJamYgnxTJCDWZA3eVSh4/7yCcZxFbxqc uAumrpc/KwYMV4de9B5HWreSa48XrfAw5ZGZDNZk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Huang Pei , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 5.10 096/215] MIPS: add PMD table accounting into MIPSpmd_alloc_one Date: Thu, 15 Jul 2021 20:37:48 +0200 Message-Id: <20210715182616.287897032@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huang Pei [ Upstream commit ed914d48b6a1040d1039d371b56273d422c0081e ] This fixes Page Table accounting bug. MIPS is the ONLY arch just defining __HAVE_ARCH_PMD_ALLOC_ONE alone. Since commit b2b29d6d011944 (mm: account PMD tables like PTE tables), "pmd_free" in asm-generic with PMD table accounting and "pmd_alloc_one" in MIPS without PMD table accounting causes PageTable accounting number negative, which read by global_zone_page_state(), always returns 0. Signed-off-by: Huang Pei Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/include/asm/pgalloc.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h index 8b18424b3120..d0cf997b4ba8 100644 --- a/arch/mips/include/asm/pgalloc.h +++ b/arch/mips/include/asm/pgalloc.h @@ -59,11 +59,15 @@ do { \ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) { - pmd_t *pmd; + pmd_t *pmd = NULL; + struct page *pg; - pmd = (pmd_t *) __get_free_pages(GFP_KERNEL, PMD_ORDER); - if (pmd) + pg = alloc_pages(GFP_KERNEL | __GFP_ACCOUNT, PMD_ORDER); + if (pg) { + pgtable_pmd_page_ctor(pg); + pmd = (pmd_t *)page_address(pg); pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table); + } return pmd; } -- 2.30.2