Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2845124pxa; Tue, 25 Aug 2020 05:07:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4oUGjB4dCfZxU5vC0eYwmhfW1pWo7LTmEOfXVfsOINJiksOvXiPnA37ZfAdAoqgWlfxen X-Received: by 2002:a05:6402:17b8:: with SMTP id j24mr9962343edy.105.1598357231405; Tue, 25 Aug 2020 05:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598357231; cv=none; d=google.com; s=arc-20160816; b=KJIa683UtHvTHvMIs5Aulq71lm6zP4ll6nTevMxF2qw/4XqA2DYERj/uuy0/vmH+E8 5OHqlRVY5bx8hiobYY/yPyl/LUW8QGORjcKQDgpzmj2edegF+zBDVX2wirxkdpAgRTEC mH7TeYv/I3gDBFx3TJKyUEbcGdZmPEzP0YpJ0tBTG5gF6ytODGCCej8D7dhSXMKRxlBG fK3itpTbY5YAppMGa69X8AOewWH2X8sIIn02KGrugRkIYXX7PmfVbcE0M/XxIaRJ2mrb cBDDSYT6z9HWIRi9vpTVN+r+8OXHfK6lz2tD4d2LLHzJFVVfveWy+1xfi5+p/m0GkTui cx9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EtDubTWcya3bFNIMWt5cpovVHx+/aPFuncLPAlV9+q8=; b=YKfzq+myjgEpHRgYNY9wuoFPzS2PNbixJ5BAhzn8T5cDnmjyQ4WyuPbJHklDUeZ8HM iqzfXdvJrRkxx0xXw2CmvQnrEMi759lGi4QQHh5cWwS9asULr0v1MmjKiCtYUlTghNvL IQx0maWfQKkuYJHdB50h3gFVcbjOQ9g1fqNoPb78Um/e+Tzj1e/vbcTOBHwEs+qsvSko Ar+orfiToBDZ8RyNW+KUqCdxO50eL8fETc3Y29NHBlwAIMR1uy4N9/ZBQ4hzes3pAkb3 4SVWHLo3f/QbdreUd39+ORNEMbVL1yvQcgTv78XmJE8nsuxWZwfCHhFkaVPGG1Bi2aQA zfbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hg6Syniz; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si8441063edj.5.2020.08.25.05.06.47; Tue, 25 Aug 2020 05:07:11 -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=@linaro.org header.s=google header.b=hg6Syniz; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728124AbgHYIxg (ORCPT + 99 others); Tue, 25 Aug 2020 04:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbgHYIxf (ORCPT ); Tue, 25 Aug 2020 04:53:35 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17470C061755 for ; Tue, 25 Aug 2020 01:53:34 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id h19so12873043ljg.13 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=QmsegusZPv1kSBR74eLZ9wphSlLxtEsfZflX9sepIElDDWfMz9EdxgKYnatnq2yjQk s+oQCQ8nq0eVfhMXOfz+mhjw8C9Otu8IZWB3m+g8IABzHdRjwzMZnVkmK36M9gYaIjql 2zmXknUKdFeu28qFLewmK157X6PacEPMiddbC74O3Y6rJZdTuf28P3ngP6sT9355/1Lm ByVyu7h1WLASfBSrzQ7L81+R5PTNiiE4AGut2Nun/Mn+dXy6LUkr0tHuO4aKFO4R54nP dSw1SP8fvY5bzINVzlYdRnKKzMFq+WasBcKYWhbP9uLcGzmstaPl5a9nuBVw54Jum9LN CI2A== X-Gm-Message-State: AOAM531gljSaNuj6Zm8Faaj2Q19oJ+WN6XdS7kqlM3mkep3hcF1qqN2v 0eo2E98YTQniY5JxhG/Mhm5PnQwWzs7cSEeEVzghqQ== 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.