From patchwork Tue Sep 15 12:59:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11776545 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 69A9314B7 for ; Tue, 15 Sep 2020 13:04:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 20E3820829 for ; Tue, 15 Sep 2020 13:04:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="UCioyFq/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20E3820829 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 A0100900041; Tue, 15 Sep 2020 09:04:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9B26C90004C; Tue, 15 Sep 2020 09:04:14 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82ACE900041; Tue, 15 Sep 2020 09:04:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id 6D41790004C for ; Tue, 15 Sep 2020 09:04:14 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2A5348249980 for ; Tue, 15 Sep 2020 13:04:14 +0000 (UTC) X-FDA: 77265314028.30.leaf72_491654c27111 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 52DA7180B44A0 for ; Tue, 15 Sep 2020 13:04:10 +0000 (UTC) X-Spam-Summary: 1,0,0,30c9c6a9910a3eb0,d41d8cd98f00b204,songmuchun@bytedance.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1539:1568:1711:1714:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3866:3867:4385:5007:6120:6261:6642:6653:6737:6738:8784:10004:11026:11473:11658:11914:12043:12048:12297:12438:12517:12519:12555:12895:12986:13069:13161:13229:13255:13311:13357:13894:14181:14384:14721:21080:21444:21451:21627:30054,0,RBL:209.85.214.193:@bytedance.com:.lbl8.mailshell.net-66.100.201.201 62.2.0.100;04yf95t7f8ihq3drah43j411qkkk5ycd1wkop995rfndj4iny9n4ei4xtuf8gyw.5ag3pmdrsbm9gs5p8sos1qg1mw911nxob458fddhrt49ey439noix4wkkhdge86.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: leaf72_491654c27111 X-Filterd-Recvd-Size: 4339 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Sep 2020 13:04:03 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id x18so1310181pll.6 for ; Tue, 15 Sep 2020 06:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jiL3ii4AJU2Njj/y/vFrTYFZ6QNs3Srg45f1FwlIOSw=; b=UCioyFq/nMf2pfW7YzyCEcx4LL4/jL1jJUkht2xjt+BMHebuzK/UKImXusybczC6tr hTRa9/L+br3pbdNipbSH20dV6etCd7/zplLBClKqkOe4p99jl807aGZocuBegTAKWegT qW2M0vOxaqwVOFS01ltZ94MXkaAN3yu7UcDSaUKd6lyuAbXXcRx6JaBNLO4WCBHrONrQ mI/sHDT9Q2NI5W8AOCu7XWmJSS7/IKrSpKT5OJnmwubKGNTLD2TMr7GFNW3wXS1xr9xB kQBgwh1xu2xzg1c75B4nGCznnkOnVs7OKDaGcFSPjqv8srW2nRfVyrrMT3OMOu6XNeyH 5Zqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jiL3ii4AJU2Njj/y/vFrTYFZ6QNs3Srg45f1FwlIOSw=; b=YHvZ8y0hEwFWWbIE5VNmwHN7Y8rcJYBFs/sclk5mg+1PZ989mCPlJljHzR7+vLln8Y acvK+u39cN7yAM7SzBgbNXnCfoitxWf2g6gScxGU3ek221oDq6wfVRsybqf2tcsOsIDK 0+X6pl69L+FOD04QT4OPOjPRXCJwmSByLHzWHdKu/9JtsN3GvwStDkQHygculqIECQCZ d20lwugZoDIbUrCtiMIw8egkyYf3j3Mv+ArMAcO6IAgBNqFjHNy6Kyhi0YvfAvKhk3GY lsbzfqY3fvDmnv24tGMY/GepUHWwCJq0e+Ll3aEbRLX/0ZYcBe0NW/1l9C/kKgQgeOoJ 7xCw== X-Gm-Message-State: AOAM5301zL/3CDAwFTkRKDH6u0TBm+TsSR4YKCP69Y1eqxpA/rJivKy/ CJKwSG6LguEFMX27M+BWzPntMg== X-Google-Smtp-Source: ABdhPJzDjZ5u/kFp3j7KzOYJwm3WjE591cWhOwkG8OQSFmLJnogu52u+8IhXbjfuzBZdoCwfGeOYwQ== X-Received: by 2002:a17:902:9887:b029:d1:e626:788d with SMTP id s7-20020a1709029887b02900d1e626788dmr1206774plp.53.1600175043242; Tue, 15 Sep 2020 06:04:03 -0700 (PDT) Received: from localhost.bytedance.net ([103.136.220.66]) by smtp.gmail.com with ESMTPSA id w185sm14269855pfc.36.2020.09.15.06.03.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 06:04:02 -0700 (PDT) From: Muchun Song To: corbet@lwn.net, mike.kravetz@oracle.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, rdunlap@infradead.org, oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, almasrymina@google.com, rientjes@google.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Muchun Song Subject: [RFC PATCH 24/24] mm/hugetlb: Add BUILD_BUG_ON to catch invalid usage of tail struct page Date: Tue, 15 Sep 2020 20:59:47 +0800 Message-Id: <20200915125947.26204-25-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20200915125947.26204-1-songmuchun@bytedance.com> References: <20200915125947.26204-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 52DA7180B44A0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: There are only `RESERVE_VMEMMAP_SIZE / sizeof(struct page)` struct pages can be used when CONFIG_HUGETLB_PAGE_FREE_VMEMMAP, so add a BUILD_BUG_ON to catch this invalid usage of tail struct page. Signed-off-by: Muchun Song --- mm/hugetlb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e66c3f10c583..63995ba74b6b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3994,6 +3994,8 @@ static int __init hugetlb_init(void) #ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP BUILD_BUG_ON_NOT_POWER_OF_2(sizeof(struct page)); + BUILD_BUG_ON(NR_USED_SUBPAGE >= + RESERVE_VMEMMAP_SIZE / sizeof(struct page)); #endif if (!hugepages_supported()) {