From patchwork Sun Nov 8 14:11:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11889643 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 B8F0D14C0 for ; Sun, 8 Nov 2020 14:14:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7EC9A20760 for ; Sun, 8 Nov 2020 14:14:18 +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="NCpYibik" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EC9A20760 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 B1D8E6B0068; Sun, 8 Nov 2020 09:14:17 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ACD756B0073; Sun, 8 Nov 2020 09:14:17 -0500 (EST) 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 9E3AC6B0074; Sun, 8 Nov 2020 09:14:17 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id 7372F6B0068 for ; Sun, 8 Nov 2020 09:14:17 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 20661181AEF07 for ; Sun, 8 Nov 2020 14:14:17 +0000 (UTC) X-FDA: 77461445754.12.gun39_0e0a2cd272e4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id E9B5E180054E8 for ; Sun, 8 Nov 2020 14:14:16 +0000 (UTC) X-Spam-Summary: 1,0,0,a2904fbc6d2861e6,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:1711:1714:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3350:3865:3866:3867:3871:4321:4385:5007:6261:6653:6737:6738:8603:10004:11026:11473:11658:11914:12043:12048:12297:12438:12517:12519:12555:12895:12986:13069:13255:13311:13357:13894:14181:14384:14394:14721:21080:21094:21323:21444:21451:21627:30054:30070,0,RBL:209.85.214.195:@bytedance.com:.lbl8.mailshell.net-62.2.0.100 66.100.201.201;04yr3o5qnbtcpms4qctub7ndwjhjpyphxnwkypj9mewre7adcmbdxz1hy56ho44.ysd73f1coc85cx3ju7eoum5ucmcdt4xhjc9yf9ybdjbn7drff59tg33hty64574.k-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:68,LUA_SUMMARY:none X-HE-Tag: gun39_0e0a2cd272e4 X-Filterd-Recvd-Size: 4431 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Sun, 8 Nov 2020 14:14:16 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id t6so3252837plq.11 for ; Sun, 08 Nov 2020 06:14:15 -0800 (PST) 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=ENR30W+EQorPFupcfRUDbx6GljgYrLpkJikIXFtJu0Q=; b=NCpYibike1Vkd5HinU4cnqcgpw4ag8hM9Go2X7LHKTN0/j5OF+4dQIpP+Jk+NmmmdF FUokkNm9x+sDHmRECk50iMlxna64qhC6Z21XChzMLZRRjJN5N43DZkJKbxP66AZJKiJ+ CFVUU0M4DJfqWj1f6EjPKqVNmKJ1fKdyuWlMSRDk7re9cOS3G98R8ejo7mquqex20X8l c5pOhg4g4A7AxHCOjyNGbY4gdqrOxv0WKX2pm4otrYsmJspaejQjEWfJG0RMm9taKb4m AYO22TVlrmXu1jxTqVHbHC8rM3gSedj41YSiD5N6r9Z+wy0VaZKEvClkXL0ED7asFs7H md3g== 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=ENR30W+EQorPFupcfRUDbx6GljgYrLpkJikIXFtJu0Q=; b=o+7NTB7ecMgTsngIOI6I1NEPNKzl5cHa/xZ2zqVdTOhHYzY6zv5h9OLYZ5nZEerX7e CxelPyKO4Q+ErPWCCTxYCzK+bUCr3y5C0uNq1fi5Knzw/XXWtU+Ku3UYue6JAG+J8e30 ut1ZZuR/bjIatLtHeU/fQRYa1gsekfgZQCvXKHUxG7ErOwU9yiN7w2K7cduw0z1juSEi /H9nw/QGPU216oMB9stOn9r9q0Co2IPB9xll+lIYYaOcWA67UoQLNtUGP517IzrF7Fyv x2bA7mxU2NTd78xUFz2uXTleBuvfW4jMuId7bHEnHDF5d0PCw4sUovlZRe4F/aEryHCz BxDQ== X-Gm-Message-State: AOAM531NKAgt5FF50J8x+Lve83z7oTTcIrd3ZDZvzKbWZ83x55ztvMMQ EcH8y2Yz3i2+0usM6Gfn9xeWag== X-Google-Smtp-Source: ABdhPJxjfNCxml6yFxCnotzbO6De4Cg/809K0G4G2C2mRKpmxr6iMJoZs0AWKO0UXf47Ab41LgC7eA== X-Received: by 2002:a17:90a:c383:: with SMTP id h3mr8147517pjt.150.1604844855310; Sun, 08 Nov 2020 06:14:15 -0800 (PST) Received: from localhost.localdomain ([103.136.220.94]) by smtp.gmail.com with ESMTPSA id z11sm8754047pfk.52.2020.11.08.06.14.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Nov 2020 06:14:14 -0800 (PST) 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, willy@infradead.org, osalvador@suse.de, mhocko@suse.com Cc: duanxiongchun@bytedance.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Muchun Song Subject: [PATCH v3 15/21] mm/hugetlb: Add a BUILD_BUG_ON to check if struct page size is a power of two Date: Sun, 8 Nov 2020 22:11:07 +0800 Message-Id: <20201108141113.65450-16-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201108141113.65450-1-songmuchun@bytedance.com> References: <20201108141113.65450-1-songmuchun@bytedance.com> MIME-Version: 1.0 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: We only can free the unused vmemmap to the buddy system when the size of struct page is a power of two. So add a BUILD_BUG_ON to check the illegal case. Signed-off-by: Muchun Song --- mm/hugetlb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index ec0d33d2c426..5aaa274b0684 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3764,6 +3764,10 @@ static int __init hugetlb_init(void) { int i; +#ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP + BUILD_BUG_ON_NOT_POWER_OF_2(sizeof(struct page)); +#endif + if (!hugepages_supported()) { if (hugetlb_max_hstate || default_hstate_max_huge_pages) pr_warn("HugeTLB: huge pages not supported, ignoring associated command-line parameters\n");