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=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 4439EC432BE for ; Wed, 11 Aug 2021 14:25:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D86F7610CC for ; Wed, 11 Aug 2021 14:25:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D86F7610CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 447AE6B0071; Wed, 11 Aug 2021 10:25:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F6F88D0001; Wed, 11 Aug 2021 10:25:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E58A6B0073; Wed, 11 Aug 2021 10:25:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 0D9A76B0071 for ; Wed, 11 Aug 2021 10:25:24 -0400 (EDT) Received: from smtpin33.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A7FB31DE76 for ; Wed, 11 Aug 2021 14:25:23 +0000 (UTC) X-FDA: 78463022526.33.CB7B6AE Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by imf01.hostedemail.com (Postfix) with ESMTP id BE4905029D5D for ; Wed, 11 Aug 2021 14:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1628691922; x=1660227922; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=9YgSar484NeNBfbw/ejSJ4MnW1zeRnwCa6czWiKgnAg=; b=rVYx1gRtBZ8FpV159B8YI51hmyRVH6XSHZZTjJ25bWMEe/H63/ilbvzZ 904qGrqMqGc7TxtfF74x0v9il3JR6tAuHk6zo01DM6/9V1iIFSeeAoiOH a1Ls3VSE+28fEHijD4vu2Qr/aN3YUg5JWmv20Eg9j08LmC8T6fmXULe46 g=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-02.qualcomm.com with ESMTP; 11 Aug 2021 07:25:21 -0700 X-QCInternal: smtphost Received: from nasanexm03e.na.qualcomm.com ([10.85.0.48]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/AES256-SHA; 11 Aug 2021 07:25:18 -0700 Received: from [10.111.172.174] (10.80.80.8) by nasanexm03e.na.qualcomm.com (10.85.0.48) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 11 Aug 2021 07:25:17 -0700 Subject: Re: Linux-next: crash in alloc_huge_page() To: Mike Rapoport , Matthew Wilcox , Andrew Morton CC: David Hildenbrand , Mike Kravetz , Linux Memory Management List , Linux Kernel Mailing List References: <846c4502-3332-0d25-87f5-cb3b71afc38f@quicinc.com> From: Qian Cai Message-ID: <8379f7d5-5d89-ac37-be83-aaa185dd6c3c@quicinc.com> Date: Wed, 11 Aug 2021 10:25:15 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanexm03e.na.qualcomm.com (10.85.0.48) To nasanexm03e.na.qualcomm.com (10.85.0.48) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=rVYx1gRt; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf01.hostedemail.com: domain of quic_qiancai@quicinc.com designates 199.106.114.39 as permitted sender) smtp.mailfrom=quic_qiancai@quicinc.com X-Stat-Signature: jy763k6jzbsetzdx8943kw9mha3ixsk8 X-Rspamd-Queue-Id: BE4905029D5D X-Rspamd-Server: rspam05 X-HE-Tag: 1628691922-815595 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 8/11/2021 10:11 AM, Mike Rapoport wrote: > On Wed, Aug 11, 2021 at 04:06:18AM +0100, Matthew Wilcox wrote: >> On Tue, Aug 10, 2021 at 10:22:37PM -0400, Qian Cai wrote: >>> and the page->lru has an address fffffffffffffffc for some reasons. Does it sound like some error code >>> had not been handled properly and had been propagated here instead? I tried reverting a few recent >>> commits for mm/hugetlb.c and mm/memblock.c without luck so far. >> >> Yes, ff..fc is going to be at offset 8 from the actual address, so >> that's -12 and -12 is ... >> >> #define ENOMEM 12 /* Out of memory */ >> >> so something's returning ERR_PTR(-ENOMEM) instead of NULL. > > page is not initialized in alloc_buddy_huge_page_with_mpol() and after > commit 2cfa8b23744f ("mm-hugetlb-add-support-for-mempolicy-mpol_preferred_many-fix") we have Good catch, Mike! Pretty sure I missed to test that commit thought that was an old commit along with the rest of the mpol_preferred series. It is a dream that one day mm tree could like other subsystem trees where "git tag --contains" would work to indicate which linux-next tags contains a particular commit to tell the timeline of it. Right now, we have those commits ID always changed and commit date is meaningless for mm commits in linux-next. > > struct page *page; > > ... > > if (mpol_is_preferred_many(mpol)) { > gfp_t gfp = gfp_mask | __GFP_NOWARN; > > gfp &= ~(__GFP_DIRECT_RECLAIM | __GFP_NOFAIL); > page = alloc_surplus_huge_page(h, gfp, nid, nodemask, false); > > /* Fallback to all nodes if page==NULL */ > nodemask = NULL; > } > > if (!page) > page = alloc_surplus_huge_page(h, gfp_mask, nid, nodemask, false > > mpol_cond_put(mpol); > return page; > > so for !mpol_is_preferred_many() we return an uninitialized variable. > > This should fix it: > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 008662083fec..6337697f7ee4 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -2152,7 +2152,7 @@ static > struct page *alloc_buddy_huge_page_with_mpol(struct hstate *h, > struct vm_area_struct *vma, unsigned long addr) > { > - struct page *page; > + struct page *page = NULL; > struct mempolicy *mpol; > gfp_t gfp_mask = htlb_alloc_mask(h); > int nid; > >