From patchwork Wed Mar 18 17:42:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 6042401 Return-Path: X-Original-To: patchwork-linux-parisc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A2D889F399 for ; Wed, 18 Mar 2015 17:43:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C40C92034A for ; Wed, 18 Mar 2015 17:43:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF7F5200CF for ; Wed, 18 Mar 2015 17:43:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756698AbbCRRnV (ORCPT ); Wed, 18 Mar 2015 13:43:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50079 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756610AbbCRRnT (ORCPT ); Wed, 18 Mar 2015 13:43:19 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2IHgdZO003287 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 18 Mar 2015 13:42:40 -0400 Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2IHgdZn003124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 18 Mar 2015 13:42:39 -0400 Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id t2IHgcEm024147; Wed, 18 Mar 2015 13:42:38 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id t2IHgcGV024143; Wed, 18 Mar 2015 13:42:38 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Wed, 18 Mar 2015 13:42:38 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: "Kirill A. Shutemov" cc: "Kirill A. Shutemov" , linux-mm@kvack.org, linux-parisc@vger.kernel.org, jejb@parisc-linux.org, dave.anglin@bell.net Subject: [PATCH v2] mm: don't count preallocated pmds In-Reply-To: <20150318165313.GB5822@node.dhcp.inet.fi> Message-ID: References: <20150318161246.GA5822@node.dhcp.inet.fi> <20150318165313.GB5822@node.dhcp.inet.fi> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 18 Mar 2015, Kirill A. Shutemov wrote: > On Wed, Mar 18, 2015 at 12:25:11PM -0400, Mikulas Patocka wrote: > > > > > > On Wed, 18 Mar 2015, Kirill A. Shutemov wrote: > > > > > On Wed, Mar 18, 2015 at 11:16:42AM -0400, Mikulas Patocka wrote: > > > > Hi > > > > > > > > Here I'm sending a patch that fixes numerous "BUG: non-zero nr_pmds on > > > > freeing mm: -1" errors on 64-bit PA-RISC kernel. > > > > > > > > I think the patch posted here > > > > http://www.spinics.net/lists/linux-parisc/msg05981.html is incorrect, it > > > > wouldn't work if the affected address range is freed and allocated > > > > multiple times. > > > > - 1. alloc pgd with built-in pmd, the count of pmds is 1 > > > > - 2. free the range covered by the built-in pmd, the count of pmds > > > > is 0, but the built-in pmd is still present > > > > > > Hm. Okay. I didn't realize you have special case in pmd_clear() for these > > > pmds. > > > > > > What about adding mm_inc_nr_pmds() in pmd_clear() for PxD_FLAG_ATTACHED > > > to compensate mm_dec_nr_pmds() in free_pmd_range()? > > > > pmd_clear clears one entry in the pmd, it wouldn't work. You need to add > > it to pgd_clear. That clears the pointer to the pmd (and does nothing if > > it is asked to clear the pointer to the preallocated pmd). But pgd_clear > > doesn't receive the pointer to mm. > > I meant pmd_free(), not pmd_clear(). This should work fine. OK, here is the updated patch. From: Mikulas Patocka The patch dc6c9a35b66b520cf67e05d8ca60ebecad3b0479 that counts pmds allocated for a process introduced a bug on 64-bit PA-RISC kernels. The PA-RISC architecture preallocates one pmd with each pgd. This preallocated pmd can never be freed - pmd_free does nothing when it is called with this pmd. When the kernel attempts to free this preallocated pmd, it decreases the count of allocated pmds. The result is that the counter underflows and this error is reported. This patch fixes the bug by artifically incrementing the counter in pmd_free when the kernel tries to free the preallocated pmd. Signed-off-by: Mikulas Patocka Acked-by: Kirill A. Shutemov --- arch/parisc/include/asm/pgalloc.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-4.0-rc4/arch/parisc/include/asm/pgalloc.h =================================================================== --- linux-4.0-rc4.orig/arch/parisc/include/asm/pgalloc.h 2015-03-18 18:02:16.000000000 +0100 +++ linux-4.0-rc4/arch/parisc/include/asm/pgalloc.h 2015-03-18 18:03:26.000000000 +0100 @@ -74,8 +74,13 @@ static inline void pmd_free(struct mm_st { #ifdef CONFIG_64BIT if(pmd_flag(*pmd) & PxD_FLAG_ATTACHED) - /* This is the permanent pmd attached to the pgd; - * cannot free it */ + /* + * This is the permanent pmd attached to the pgd; + * cannot free it. + * Increment the counter to compensate for the decrement + * done by generic mm code. + */ + mm_inc_nr_pmds(mm); return; #endif free_pages((unsigned long)pmd, PMD_ORDER);