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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 ED4B2C433E0 for ; Wed, 24 Feb 2021 09:43:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7190564E85 for ; Wed, 24 Feb 2021 09:43:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7190564E85 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B1A986B0006; Wed, 24 Feb 2021 04:43:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ACB2F6B006C; Wed, 24 Feb 2021 04:43:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 992996B006E; Wed, 24 Feb 2021 04:43:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0110.hostedemail.com [216.40.44.110]) by kanga.kvack.org (Postfix) with ESMTP id 8531B6B0006 for ; Wed, 24 Feb 2021 04:43:33 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 432C1A772 for ; Wed, 24 Feb 2021 09:43:33 +0000 (UTC) X-FDA: 77852673906.02.5CEE5A3 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf28.hostedemail.com (Postfix) with ESMTP id A138B2000391 for ; Wed, 24 Feb 2021 09:43:32 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1614159811; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EdANJnLlcHdxyT/mwFy+OimQhvEQG9gfr4G0prGzmwI=; b=Xsev2XBNSB8PqSBtco9KgKVJSEIwz9tqHR774OM/6ZQmmj+tB4T4fV+VZ+cHDCLHMEwKcm KbmnzO5SBFmc5e4WYuTtEzNsSxefrdN84HhSicpLkFHCCJgoEqY8DgGPqiegpdKLZLvMpb GAwtoz5Kt9VFjuKJQBSlFU3FOV5pOhY= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 70879AE05; Wed, 24 Feb 2021 09:43:31 +0000 (UTC) Date: Wed, 24 Feb 2021 10:43:30 +0100 From: Michal Hocko To: Mike Kravetz Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Gerald Schaefer , Oscar Salvador , Muchun Song , Heiko Carstens , Sven Schnelle , Andrew Morton Subject: Re: [PATCH] hugetlb: fix uninitialized subpool pointer Message-ID: References: <20210223215544.313871-1-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210223215544.313871-1-mike.kravetz@oracle.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A138B2000391 X-Stat-Signature: h7torziftdj9i8t73xhkowmrka5acfuc Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf28; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614159812-465288 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 23-02-21 13:55:44, Mike Kravetz wrote: > Gerald Schaefer reported a panic on s390 in hugepage_subpool_put_pages() > with linux-next 5.12.0-20210222. > Call trace: > hugepage_subpool_put_pages.part.0+0x2c/0x138 > __free_huge_page+0xce/0x310 > alloc_pool_huge_page+0x102/0x120 > set_max_huge_pages+0x13e/0x350 > hugetlb_sysctl_handler_common+0xd8/0x110 > hugetlb_sysctl_handler+0x48/0x58 > proc_sys_call_handler+0x138/0x238 > new_sync_write+0x10e/0x198 > vfs_write.part.0+0x12c/0x238 > ksys_write+0x68/0xf8 > do_syscall+0x82/0xd0 > __do_syscall+0xb4/0xc8 > system_call+0x72/0x98 > > This is a result of the change which moved the hugetlb page subpool > pointer from page->private to page[1]->private. When new pages are > allocated from the buddy allocator, the private field of the head > page will be cleared, but the private field of subpages is not modified. > Therefore, old values may remain. Very interesting. I have expected that the page->private would be in a reasonable state when allocated. On the other hand hugetlb doesn't do __GFP_COMP so tail pages are not initialized by the allocator. > Fix by initializing hugetlb page subpool pointer in prep_new_huge_page(). > > Fixes: f1280272ae4d ("hugetlb: use page.private for hugetlb specific page flags") This is not a stable sha to refer to as it comes from linux next. > Reported-by: Gerald Schaefer > Signed-off-by: Mike Kravetz Acked-by: Michal Hocko I think this would be worth a separate patch rather than having it folded into the original patch. Thi is really subtle. > --- > mm/hugetlb.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index c232cb67dda2..7ae5c18c98a7 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1465,6 +1465,7 @@ static void prep_new_huge_page(struct hstate *h, struct page *page, int nid) > { > INIT_LIST_HEAD(&page->lru); > set_compound_page_dtor(page, HUGETLB_PAGE_DTOR); > + hugetlb_set_page_subpool(page, NULL); > set_hugetlb_cgroup(page, NULL); > set_hugetlb_cgroup_rsvd(page, NULL); > spin_lock(&hugetlb_lock); > -- > 2.29.2 > -- Michal Hocko SUSE Labs