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=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 25254C433DB for ; Wed, 24 Feb 2021 11:11:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6208264EC3 for ; Wed, 24 Feb 2021 11:11:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6208264EC3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 885636B0006; Wed, 24 Feb 2021 06:11:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 80DDF6B006C; Wed, 24 Feb 2021 06:11:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FDCF6B006E; Wed, 24 Feb 2021 06:11:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id 5A41B6B0006 for ; Wed, 24 Feb 2021 06:11:23 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2BE1D12C2 for ; Wed, 24 Feb 2021 11:11:23 +0000 (UTC) X-FDA: 77852895246.05.6C1FE79 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf01.hostedemail.com (Postfix) with ESMTP id D5F36200038E for ; Wed, 24 Feb 2021 11:11:19 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id z7so987772plk.7 for ; Wed, 24 Feb 2021 03:11:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vAKxjW8aVSXqFqWx4f3GRoI/AUfMwclY5/WIXe9xg20=; b=eMtl3I/NFjT2Y6XNR8VbwQqWB+0/pvmOd+Gu9gejW7FK5oNjcH6PCWbYgKDUlSJ8Lq QHlgHp8zhjE6agmTGG0kPHqiKn9BSTZze0BRGkgoSR6gTO6W+mbHvBLpQOBCHoc3ZP7q ZmcP8aUI9ZhLnvV0h4trYmT8+QmfCQ/UsMZVkqp3JeesqDVSX3wNxTr0ihjFStDFtwF3 EMV0xuGA6rZkRTyNy6rt+Sa0BfM713DH+mfADzQkBS8OrbPZxLvZqC/Yl+CftksTg1NL BPyUyeTSBjkMHMXorCl+Kb7BdpSgu8GxHBJHhexH4bJHinCErOdVex7alK2li2f1H4u+ mA+w== 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=vAKxjW8aVSXqFqWx4f3GRoI/AUfMwclY5/WIXe9xg20=; b=TVNXtY7pvU2uPAERZaL5zV2cVoq9FoPAeR3OuIxXfPyf4SpAZjqHd9ZLu8ZZHEYg3b oPxzAmRBSh+pRJP/RZMurhUpBCh7cwm7D3I3YiTfyHNaX2dFHCE6pm298vgTUC9ZSKP3 8Tgkk1iw/Id8Z+dKfGNqKCulkG2BjPUxY2kP4qmKKtHR6f9aIwBM7j51O15UtcIp0pyc aXPBt4Lr8BBCK0aljmIBCvAViNzMINjYP03Fye8+eKPDKyWz8UKqZobj6CLsae02/neo m1ntJkOLXTwypRiIg1tY4d6QzIcq2ngWP8N1/nVz3KcaDBMLsTBbJ+YCeDdIVyQdeMwO wqaQ== X-Gm-Message-State: AOAM532ZIYtILTm0zjaheB7/SByEivXvgvcFC/N39fIEK5OqTEJZLFuU TwpmQ3mV2sjDiG8zc/EUt8eL8rIGqupprZEwtlplLA== X-Google-Smtp-Source: ABdhPJyi8JLZm8Sa4P/gfDzgwCWFgJv+NI/R93nDiZML3L91yMZveEWGbhtavjmU6DxpKeqJeaPFJuDCAvmqRxXIfDY= X-Received: by 2002:a17:902:e54e:b029:e3:9f84:db8e with SMTP id n14-20020a170902e54eb02900e39f84db8emr31888446plf.24.1614165079161; Wed, 24 Feb 2021 03:11:19 -0800 (PST) MIME-Version: 1.0 References: <20210223215544.313871-1-mike.kravetz@oracle.com> In-Reply-To: From: Muchun Song Date: Wed, 24 Feb 2021 19:10:42 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] hugetlb: fix uninitialized subpool pointer To: Michal Hocko Cc: Mike Kravetz , LKML , Linux Memory Management List , Gerald Schaefer , Oscar Salvador , Heiko Carstens , Sven Schnelle , Andrew Morton Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D5F36200038E X-Stat-Signature: mtx9qp6mes14cm61bymgcxyu3p6dk5b1 Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=mail-pl1-f176.google.com; client-ip=209.85.214.176 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614165079-14592 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 Wed, Feb 24, 2021 at 5:43 PM Michal Hocko wrote: > > 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. It seems that the buddy allocator does not initialize the private field of the tail page even when we specify __GFP_COMP. > > > 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