Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp656707pxv; Thu, 15 Jul 2021 12:39:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyilJWeuUQNfFDZzCXaIbodm/LSmRDiumbeSNG8c8A9Ve5A2+6xae1bbk2CJrGAU/RLIk5G X-Received: by 2002:a17:906:7151:: with SMTP id z17mr7508460ejj.166.1626377946235; Thu, 15 Jul 2021 12:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377946; cv=none; d=google.com; s=arc-20160816; b=0OCLNVI4zbMqlNnLb7CjIbDbintpq7L/i2U6T7eHZUT1dzZiK9nlw973LoOmN1305a l//PwFVe2LY1KsF1I2zwWprtwFB6GaenracOyZZOttNP3e4xQjmj5y/AyEwJ3bKzNlfe EcEfMEM5domek0OnaUMedt47YukiAUpaog+bANMmHzuIReSeF5+VXEUa23oxer6kyoZZ NVTIJx9GyNRe8NnXotsJeEJNbE/kBpu2HurW0iB2wTaQnCrkUdstW1qZAH/GPeHXcKxf AnKRUgH+tYsTNX2tgFLBk6lNnL6UX3vgZdDfhmgvcD57dYoEv5WDmQSvgqKaRJn8G39J SpcA== 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=pV5DyYw2NFgLQ3335f/WSoUsDVZcdm3Aat8pPbjlbd9HtvTKYLQ282yxakHvDqh5VR uAbR/o0TUkDXvZdQOuNuy2cqW9OdtgqYrYuXTzCA6qEoZUFtZTmQcj/3tNDFx0w8zkVG Kocnn3u27FpBBq2pSkW/+TaeiXZpW+X14KeC1Oe1+Sx/c3O9S26Aw2UPZpsyfROnOUe9 Cp1JY3pyEk/qWso4vyUioo4/36w89K40QXZATM8qNTga/Xpz0TTYjjRUoyBJ13BSMW9/ XLm9Pgh9YQjTOmPx6v+R2W7lT707iPA2ZH80YSA+5Smm9ua6J3Ab1m/vOJ2Q9kROiYTl cpiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bis8855M; 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 8si7521327eje.741.2021.07.15.12.38.43; Thu, 15 Jul 2021 12:39:06 -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=bis8855M; 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 S241460AbhGOTde (ORCPT + 99 others); Thu, 15 Jul 2021 15:33:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:51020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242219AbhGOTLW (ORCPT ); Thu, 15 Jul 2021 15:11:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 806C7613D1; Thu, 15 Jul 2021 19:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376106; bh=3vY8jkLEb5T5wUhD3hW2OPPBQIV5VgHI3/oaBlcpP+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bis8855MHXg3XZLFf6Uf6geS0SocC7s2is+xvXXt3IOqZyDfSVVxwBVaU4NcNs0ju veWDWj0ZIS2gv1O70/kubAcPEd7WXuF7Y4nor/XEGyzfzBBeJsu/2DGrHGpTFsIrsj 07a8aYzQQdt46mdUis1A3qZEtAs7NGI+uf4rzjog= 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.13 130/266] MIPS: add PMD table accounting into MIPSpmd_alloc_one Date: Thu, 15 Jul 2021 20:38:05 +0200 Message-Id: <20210715182636.755148723@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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