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 X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A86CAC433E1 for ; Tue, 25 Aug 2020 08:53:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5F7232071E for ; Tue, 25 Aug 2020 08:53:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hg6Syniz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F7232071E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D5F3E6B0099; Tue, 25 Aug 2020 04:53:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE6F56B009A; Tue, 25 Aug 2020 04:53:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD65C8E0007; Tue, 25 Aug 2020 04:53:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0178.hostedemail.com [216.40.44.178]) by kanga.kvack.org (Postfix) with ESMTP id 9FE9F6B0099 for ; Tue, 25 Aug 2020 04:53:35 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5756D8248047 for ; Tue, 25 Aug 2020 08:53:35 +0000 (UTC) X-FDA: 77188477590.21.stick85_200c2302705a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 33A00180442C2 for ; Tue, 25 Aug 2020 08:53:35 +0000 (UTC) X-HE-Tag: stick85_200c2302705a X-Filterd-Recvd-Size: 8816 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Aug 2020 08:53:34 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id t6so12866027ljk.9 for ; Tue, 25 Aug 2020 01:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EtDubTWcya3bFNIMWt5cpovVHx+/aPFuncLPAlV9+q8=; b=hg6SynizBYW+QsJT+XYq5YMt+Nz9cUWGDuKfmhI4lW4tNZLzeavZKk99fUlOfxyi3K Xpd9KmZG48QT9+r1neCW3o7qMudIsjtFIcM+bIzkTcE0TIoXL7AZY/DZKfPQR6q4aStp Aw+O8kqksFZnlvLi/ts/FSdbod4DZn/D/i4Qc69TTNj3r3FB9Qm9KBePALuNWpXltBOL JMeBNp+Td70msn2CiW6D4fci8cxU8LWo/wVPF7q5RLXfyryBurHJYXOfm0AZ/jKgjGtO DfnjUAUme1d/Scto+d5AOyLGFXsAirGuVKhAWnINjL+U6DbWPP2d6wikmR8RyiRxUw40 imMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EtDubTWcya3bFNIMWt5cpovVHx+/aPFuncLPAlV9+q8=; b=ZXP7a+hC8mOL3MDPIptE2Fk4tnYU3QP8+fD4I8PO3I/VeXZD9RvTyhBJIboT6QS2Ss voTu11nBupLPGKfeI6FEs8Ns8VN7IeM/t+PlmIa/phPL+ACUwPzIYGG6bEYiLz4s17Z9 QIud9eDhVjBDimUgA/nKpsIgG52fw7npc2wPEoPtEFwWTrBpy5botmYFdkB1A5sjTEFk TyWDcfrbKzn0xKvpnvWt9jGffdxv2/R78HvC2mdnyHbiauJ6TS61pKo2e5Lfoqb4ztgR HvJ/vNENgVA1x3uCqjc09ZbdKzgJL1O4I1155Av1r21lFw5uJsw+Jb9ZF+Or4JzUNCVm ySfQ== X-Gm-Message-State: AOAM530Nj1r6KT1EOZWeAJFwfiKfcrTkgJ3M9QRTYMydHOkoKaojLL/K hNC3kzzSaU/KrG9sCzoDkjSvpK/5P97jzGNYQcdulA== X-Google-Smtp-Source: ABdhPJzgd8VhaITc7beto8F5Oa1lQp4WYJZVsedInRAxlBWhJv7ZxzqrbHw+79LvHxCSjX2KcL7GkSO6u2tVrErxAxM= X-Received: by 2002:a2e:920c:: with SMTP id k12mr4632919ljg.29.1598345613076; Tue, 25 Aug 2020 01:53:33 -0700 (PDT) MIME-Version: 1.0 References: <20200824110645.GC17456@casper.infradead.org> <20200825083119.GA69694@linux.ibm.com> In-Reply-To: <20200825083119.GA69694@linux.ibm.com> From: Anders Roxell Date: Tue, 25 Aug 2020 10:53:22 +0200 Message-ID: Subject: Re: BUG: Bad page state in process true pfn:a8fed on arm To: Mike Rapoport Cc: Naresh Kamboju , Matthew Wilcox , linux-mm , Linux-Next Mailing List , open list , lkft-triage@lists.linaro.org, Andrew Morton , LTP List , Arnd Bergmann , Russell King - ARM Linux , Stephen Rothwell , Catalin Marinas , Christoph Hellwig , Andy Lutomirski , Peter Xu , opendmb@gmail.com, Linus Walleij , afzal.mohd.ma@gmail.com, Will Deacon , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 33A00180442C2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: On Tue, 25 Aug 2020 at 10:32, Mike Rapoport wrote: > > On Tue, Aug 25, 2020 at 01:03:53PM +0530, Naresh Kamboju wrote: > > On Mon, 24 Aug 2020 at 16:36, Matthew Wilcox wrote: > > > > > > On Mon, Aug 24, 2020 at 03:14:55PM +0530, Naresh Kamboju wrote: > > > > [ 67.545247] BUG: Bad page state in process true pfn:a8fed > > > > [ 67.550767] page:9640c0ab refcount:0 mapcount:-1024 > > > > > > Somebody freed a page table without calling __ClearPageTable() on it. > > > > After running git bisect on this problem, > > The first suspecting of this problem on arm architecture this patch. > > 424efe723f7717430bec7c93b4d28bba73e31cf6 > > ("mm: account PMD tables like PTE tables ") > > > > Reported-by: Naresh Kamboju > > Reported-by: Anders Roxell > > Can you please check if this fix helps? That fixed the problem. Cheers, Anders > > diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h > index 9415222b49ad..b8cbe03ad260 100644 > --- a/arch/arm/include/asm/tlb.h > +++ b/arch/arm/include/asm/tlb.h > @@ -59,6 +59,7 @@ __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr) > #ifdef CONFIG_ARM_LPAE > struct page *page = virt_to_page(pmdp); > > + pgtable_pmd_page_dtor(page); > tlb_remove_table(tlb, page); > #endif > } > > > Additional information: > > We have tested linux next by reverting this patch and confirmed > > that the reported BUG is not reproduced. > > > > These configs enabled on the running device, > > > > CONFIG_TRANSPARENT_HUGEPAGE=y > > CONFIG_TRANSPARENT_HUGEPAGE_MADVISE=y > > > > > > -- Suspecting patch -- > > commit 424efe723f7717430bec7c93b4d28bba73e31cf6 > > Author: Matthew Wilcox > > Date: Thu Aug 20 10:01:30 2020 +1000 > > > > mm: account PMD tables like PTE tables > > > > We account the PTE level of the page tables to the process in order to > > make smarter OOM decisions and help diagnose why memory is fragmented. > > For these same reasons, we should account pages allocated for PMDs. With > > larger process address spaces and ASLR, the number of PMDs in use is > > higher than it used to be so the inaccuracy is starting to matter. > > > > Link: http://lkml.kernel.org/r/20200627184642.GF25039@casper.infradead.org > > Signed-off-by: Matthew Wilcox (Oracle) > > Reviewed-by: Mike Rapoport > > Cc: Abdul Haleem > > Cc: Andy Lutomirski > > Cc: Arnd Bergmann > > Cc: Christophe Leroy > > Cc: Joerg Roedel > > Cc: Max Filippov > > Cc: Peter Zijlstra > > Cc: Satheesh Rajendran > > Cc: Stafford Horne > > Signed-off-by: Andrew Morton > > Signed-off-by: Stephen Rothwell > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index b0a15ee77b8a..a4e5b806347c 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -2239,7 +2239,7 @@ static inline spinlock_t *pmd_lockptr(struct > > mm_struct *mm, pmd_t *pmd) > > return ptlock_ptr(pmd_to_page(pmd)); > > } > > > > -static inline bool pgtable_pmd_page_ctor(struct page *page) > > +static inline bool pmd_ptlock_init(struct page *page) > > { > > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > > page->pmd_huge_pte = NULL; > > @@ -2247,7 +2247,7 @@ static inline bool pgtable_pmd_page_ctor(struct > > page *page) > > return ptlock_init(page); > > } > > > > -static inline void pgtable_pmd_page_dtor(struct page *page) > > +static inline void pmd_ptlock_free(struct page *page) > > { > > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > > VM_BUG_ON_PAGE(page->pmd_huge_pte, page); > > @@ -2264,8 +2264,8 @@ static inline spinlock_t *pmd_lockptr(struct > > mm_struct *mm, pmd_t *pmd) > > return &mm->page_table_lock; > > } > > > > -static inline bool pgtable_pmd_page_ctor(struct page *page) { return true; } > > -static inline void pgtable_pmd_page_dtor(struct page *page) {} > > +static inline bool pmd_ptlock_init(struct page *page) { return true; } > > +static inline void pmd_ptlock_free(struct page *page) {} > > > > #define pmd_huge_pte(mm, pmd) ((mm)->pmd_huge_pte) > > > > @@ -2278,6 +2278,22 @@ static inline spinlock_t *pmd_lock(struct > > mm_struct *mm, pmd_t *pmd) > > return ptl; > > } > > > > +static inline bool pgtable_pmd_page_ctor(struct page *page) > > +{ > > + if (!pmd_ptlock_init(page)) > > + return false; > > + __SetPageTable(page); > > + inc_zone_page_state(page, NR_PAGETABLE); > > + return true; > > +} > > + > > +static inline void pgtable_pmd_page_dtor(struct page *page) > > +{ > > + pmd_ptlock_free(page); > > + __ClearPageTable(page); > > + dec_zone_page_state(page, NR_PAGETABLE); > > +} > > + > > /* > > * No scalability reason to split PUD locks yet, but follow the same pattern > > * as the PMD locks to make it easier if we decide to. The VM should not be > > > > > > > > > > - Naresh > > -- > Sincerely yours, > Mike.