Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3797207pxv; Mon, 19 Jul 2021 08:59:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyE29CkVTIEOuGktOmVM0vDXtM+4npawI6GvobdCm9Vp7I7Tm1PnD9IRAxPJo7egLTqqb9u X-Received: by 2002:a05:6638:3a1:: with SMTP id z1mr21956536jap.77.1626710388614; Mon, 19 Jul 2021 08:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626710388; cv=none; d=google.com; s=arc-20160816; b=LeAinMxXW5tPZZRhUZedyJm4fu+Ul/xcXn+cuJWDA9JQvLDmtKCLY6PG+HRo2fv8ah dJK0jNNhLUZVwFpaRtp4xeQH3Z50EgVCyO0B1BNLN/1s2+G76rYmwVTxNJfA26avkYiT UVNOtBXSsdZDDqyoW0DDWoFwMeiWrnRzbvLuLxsP0yjWWb7sLVwOYHOuZjhww6u2f0FC ElxyGhp8fkV/30z0VfruaXuPNu+nDaAfu76rB4AUyA+PnuLDbfYbp/fWXcZeHzzlqJSM iszHggmvDpVoNrpXfAaDvvu3H4Xt/4RGPb5bRG/FSKbwuY/s+g7D0a2Bdp5fFT0/Shh4 Z7EQ== 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=VHKhu6QxlTyS+Zth/89fvjV+a4aM5eOYLRT3OFqc+1U=; b=HxL0PNaUOz8UYOdKjXVFmV0dUfmj6Sq8WTvMey8bh1jGG/vcWPX3+kQ/MP624cDYQ2 1KRJue2bCf+3O20r/tJ8o4JB9guq1x7aNOc44wa7bhgnuGgKyHXXgmId6G8aJnRSsixK nflUde4bUL31qVnT9s2q3b7lym6ZaY32cF1KcZC+6ElF3rKSAa44fioRu2F5GJ8onPy0 37Z5huE5WnTif3sXsnMRn8byXI0xUahEaD+2r5vMYBshXy8/uvn91TtQrb1o02ujZ6j/ L/FSqxrGtPUvE97ow3Qzya6Ty6i3Z0mndk32qmjsjQS0GM8jS645IGCZ3v0IeXo9WYna CIrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Huum/aoM"; 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 i19si22423998jab.103.2021.07.19.08.59.36; Mon, 19 Jul 2021 08:59: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="Huum/aoM"; 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 S1346610AbhGSPRo (ORCPT + 99 others); Mon, 19 Jul 2021 11:17:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:36478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245390AbhGSOr1 (ORCPT ); Mon, 19 Jul 2021 10:47:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8BC2610D2; Mon, 19 Jul 2021 15:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626708201; bh=YLXnt5wG5jvESbfEUk+/masoINAD5jvQEUvbk327gPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Huum/aoMc9sb7uRCyCcmkltrjGKurCuIsk+6a7k8ZK6RbvF0Gu24c1+uLrSq0xfW4 sGW0whPfA/x0+/4f8IcZrRab1eNjqdpprHMNBNQYuKVnx6ouNqKYGw41PSrOp5RUiH 2VkFArK197/CwqK9vCnSC0DpEODMfw8SUgC+dQWM= 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 4.14 187/315] MIPS: add PMD table accounting into MIPSpmd_alloc_one Date: Mon, 19 Jul 2021 16:51:16 +0200 Message-Id: <20210719144949.056012137@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.861561397@linuxfoundation.org> References: <20210719144942.861561397@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 39b9f311c4ef..f800872f867b 100644 --- a/arch/mips/include/asm/pgalloc.h +++ b/arch/mips/include/asm/pgalloc.h @@ -93,11 +93,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