Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1947958rdb; Mon, 9 Oct 2023 07:56:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHH9Gqc4r0jQj0EfRAcmzXkIhBE1GC3TcDVPxVdC7bptT9nFhtIogR9nVlxHI3j2f35AiBj X-Received: by 2002:a17:902:ecc5:b0:1c6:e8d:29ea with SMTP id a5-20020a170902ecc500b001c60e8d29eamr15564914plh.60.1696863388024; Mon, 09 Oct 2023 07:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696863388; cv=none; d=google.com; s=arc-20160816; b=QVFq/WgLhMf3qhV5XRY1jN3outqMom2qcU3GjE3OMdZRQIz5Nbsd1BxRdK3K6sX2Q3 60gD3RWSPmgacayf0Wv3E0sirC2DDbcOjcqgF93LJUz38h4lpKsUFg4iSxRt56yCd6R3 0eCLlxf7PVhY1bx2NmhYHhL9yBxSBxs/VFfAbNra+9zZid5BCahoZzb6EA+rhcUvLoG3 nzV12Gg8QseLLZWueNUOQngBe/vlbvMgISql75Tz1qE3oIDVoBWZjzdTVyvsZOgwaupt GfDPzJUw2uFInA09IbA0iJCImpoG/icbA5ejKEKyBJF35B58+TpUTFqEb4KZG+vRnM2/ uBFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=fj3iSs9I07s+0bx1L727//TIOkD+aXcGIVkL4AdCGYI=; fh=n4m/uA9ipODxkat1frQpBrzGQQ929gRO4H/eS4tebdk=; b=h2Go7bxkO+BMdMO4ARLvrv2QOjCGjGj5JgOvrOC/ooZF4zNsmZpwgbT7JzLYo5iKvd LA4D+E+hhWA5jdgw4+kOs60ZCio7DRwaI2egz0iOAImMA2EC2SmJyE7wijcMjgvaP3ql +NjoCXDXrnpDUijn4rB0+Mq7zzeFXI83c5wDO+800CvG3AwXXsO7g6OApz6hFtm5P8K9 /0Ft2HCl+Xl/vvtQtpveFWBl4uc6p3ZgruoSj1/GH+77QkFXcO43APEgRjuESv5dzAPV xVmpkd8I1vxYBHz8plaEBhU3KLzZC7a0ZH8mlvl9AOklmzuZ6F+eC9aetSIncdb/rLLd EnJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="KmIeus//"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id w5-20020a170902ca0500b001c342073f76si9081442pld.323.2023.10.09.07.56.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 07:56:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="KmIeus//"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id B0AEF807D3FB; Mon, 9 Oct 2023 07:56:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234583AbjJIO4R (ORCPT + 99 others); Mon, 9 Oct 2023 10:56:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234598AbjJIO4O (ORCPT ); Mon, 9 Oct 2023 10:56:14 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08BD3100 for ; Mon, 9 Oct 2023 07:56:10 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3231df054c4so4324161f8f.0 for ; Mon, 09 Oct 2023 07:56:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1696863368; x=1697468168; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fj3iSs9I07s+0bx1L727//TIOkD+aXcGIVkL4AdCGYI=; b=KmIeus//Q8sGmvoh1TbSuAYzcsZRcTAO4FCYvGOvxZ1/r0RtgWS3yf6B/UAtZbhxro ICDhe3sgBqMB3oI1JqdRIKU0rZyUbEG+isDTxF2Xc8wZ1hsAb9BAw7PlLYleKARPBLAE ZUcJDsX+CrWYvQ9hzwvdoi4wlnlrNEpc43H5/P1y4aWKl73VJHrDrFUrS70fiTKm088P sz+tvYdBSWiBlK6mQrqSZifVl1oULMkZLj4lGNNNVl3jxN4jvTHi5YakxWSeK627QV0J YHucbBqtmv6HvP6vmWZW4yfib7j3C/zbeE72Ih72jZ5kchk7JMYMjGxzjiJDHd+49J5R P8sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696863368; x=1697468168; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fj3iSs9I07s+0bx1L727//TIOkD+aXcGIVkL4AdCGYI=; b=hcVhp3p0CQyi3u3ITiFyL3wLpRGN6gYBSJh/p4lxAhRDRSsjzFzCFhROhauWdznO/a 4EYUwEKVlluvqfh8B6OAzDTwJFl6uF5/f4ONo5VhRhlJtAl3p0EGS3URe4R07Tfx8UG5 uIbfxjMfb/CKixaB8PvVq4jr70Dtxilg+/c7daU+019aX5PuTgwpsrd+6DVxaM/w/YNr 61OQpvSl1iUtjj3qRzA8MRdtMyidprwkWItwrh0jgjn0HlOQIF8LPmgfs/dwqLkVJ4vK oBPugojSAR9wfzrgVvn8bFyxFh+h3kT/nh8wNRQUDYwwFGMZB5vYXD5F/MTYvcUrYTrS LOVQ== X-Gm-Message-State: AOJu0Yx4y+Q8ZCyD9u7nkUc3SGi76eiMnvw3n/Ddv/yWKtJpCOKbxa4U 7p6GgrqI/rMjCeBq3h22QOxx6w== X-Received: by 2002:adf:fb0b:0:b0:31f:c1b5:d4c1 with SMTP id c11-20020adffb0b000000b0031fc1b5d4c1mr12721447wrr.35.1696863368447; Mon, 09 Oct 2023 07:56:08 -0700 (PDT) Received: from localhost.localdomain ([2a02:6b6a:b5c7:0:c1b1:1479:6449:a1ff]) by smtp.gmail.com with ESMTPSA id g7-20020a5d5407000000b00327df8fcbd9sm9965173wrv.9.2023.10.09.07.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 07:56:08 -0700 (PDT) From: Usama Arif To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, muchun.song@linux.dev, mike.kravetz@oracle.com, songmuchun@bytedance.com, fam.zheng@bytedance.com, liangma@liangbit.com, punit.agrawal@bytedance.com, Usama Arif Subject: [PATCH] mm: hugetlb: Only prep and add allocated folios for non-gigantic pages Date: Mon, 9 Oct 2023 15:56:05 +0100 Message-Id: <20231009145605.2150897-1-usama.arif@bytedance.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 09 Oct 2023 07:56:25 -0700 (PDT) X-Spam-Level: ** Calling prep_and_add_allocated_folios when allocating gigantic pages at boot time causes the kernel to crash as folio_list is empty and iterating it causes a NULL pointer dereference. Call this only for non-gigantic pages when folio_list has entires. Fixes: bfb41d6b2fe148 ("hugetlb: restructure pool allocations") Signed-off-by: Usama Arif --- mm/hugetlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index f3749fc125d4..b12f5fd295bb 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3397,7 +3397,8 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h) } /* list will be empty if hstate_is_gigantic */ - prep_and_add_allocated_folios(h, &folio_list); + if (!hstate_is_gigantic(h)) + prep_and_add_allocated_folios(h, &folio_list); if (i < h->max_huge_pages) { char buf[32]; -- 2.25.1