From patchwork Wed Dec 5 08:05:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 10713173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2BF2C14E2 for ; Wed, 5 Dec 2018 08:06:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E739293BB for ; Wed, 5 Dec 2018 08:06:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D55728FEC; Wed, 5 Dec 2018 08:06:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BF8A28FEC for ; Wed, 5 Dec 2018 08:06:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFC8C6B7346; Wed, 5 Dec 2018 03:06:20 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AABD66B7347; Wed, 5 Dec 2018 03:06:20 -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 99BCB6B7348; Wed, 5 Dec 2018 03:06:20 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 559056B7346 for ; Wed, 5 Dec 2018 03:06:20 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id h11so16184616pfj.13 for ; Wed, 05 Dec 2018 00:06:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=mEZiBi5hhU+kUiR4ZE7YnBvS2IP2/mkhsmXWXN0B0xg=; b=rZ0CPMXHyKumuzRiU9blb2pafqqs705mRzSOzquRh85pUQQhLSvy5Iw+2lavf9CSJQ CRD4hX1FLQ9UThX8EichqwfTIErApDTubWQtmQzJYBpoOSF1dhG3Xxd1h5f8fj0Ejhlv ny7vEkVndMU7Y+oKq+Sp8t9LH70G6idjo7VSOyF6yjnxMhBHxLetUkrXt5XmgaMnonEK 9W32PrsOgeQqhSny2V9i/N7iy+ANbayr0llJGGBRW/Yv+c/OCkF0be3GBKep9cXfuzBI jGnqujRTiutbJMv2PksRmvEvgOMQefrRpuAKior8RMW4i0gDv8cnlDjvkLCv0jlfBBff a0yw== X-Gm-Message-State: AA+aEWb2TB1uGaFxFrbwppK34o0TOfYgD7cCdwcqfiFgTlcAtEfclurg cCBPVIZBurdTMjzmyg+S8QLuAjTeMICsmYXlo2E0JQs409ZEMSNiP+07LVdixCeEQJ48GBmYSjM r7E5GI0UHAkynhzWTNMho6Tcyn1JSrS5ImULvjqFT0ZF1eXz1tvR4Wc/TcFB7AzIDtdGuF9DCgC U1erHrqAe7eF6MARpqEUJExMtjIjt0A5Ck359pgy6ktrL0BGgWOuJ9saj5LhxYcp04tw+G03CnN TMTIwu9TiSHozzrRn9xNZzQQzerNQUpuKpanWwyiN5hcM0CQ23YaheREaFUcCPMm3eQ0APZc5mu NyZPawEc5XnhtwCeCN0jNvmy7BOqa8OE9uCbsthc3mzb9lxbgWsL9H0zBXbYqKlPIQ8TTh5/E4h U X-Received: by 2002:a63:7d06:: with SMTP id y6mr19501718pgc.171.1543997179904; Wed, 05 Dec 2018 00:06:19 -0800 (PST) X-Received: by 2002:a63:7d06:: with SMTP id y6mr19501684pgc.171.1543997179193; Wed, 05 Dec 2018 00:06:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543997179; cv=none; d=google.com; s=arc-20160816; b=eBWAhFRCmIf1bt2YM3+RJD4Nd+d+QKbk0N01MyNy6bc5t9UUSDTnChQxlErjttZR12 V0PKypCBBJSV6nBTi89cPgo2Xk7SK0OYGKeml+oTUjDuU2bNseNwvzb+ijgHZSCiQyDy V2WOxeULRsctz3Korj4DWAvI+kjsj0tSSlSjJWgEQHAHfjVmAtiwNG4xXCBpeWUh0M3c GswTOkrNMblvj/P6liQa9GBAWkK6/jbeePUAoCKd8ucAMAQli131OwO9l1ftD5Qlm8Nx lFXNC80K/Bzmpn8Sjfke8Zgo204Y/1NNuFZpnrJWgcQBqkFNJUlusBT/kA79Asxv36d5 73BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=mEZiBi5hhU+kUiR4ZE7YnBvS2IP2/mkhsmXWXN0B0xg=; b=VuUAdmHtDFIqKangX24rDR2/XlSFiu1Acb2KHm7JWhioIDi9CKSl6BzTxO9NabWNhX tOs8X3HI9HCuErPopnDkuRaq5qT45yly/vOzH/9YGjnwQ45DkMRjfSG8yLG8jdmvR5Pv DZgGxPOf9h6S6a9jrES0q+Q+vJY4Gcm51lqg5rziWpmPr7U6Kt8xxsDbJA0WFQfA8b85 nPdfq9QSiFHmNehhvVdXf6zoznA78mNG54Jqzdw4zZC51cHKEb7rPk/GvPQnSpocjS51 eWp4tqTHq6PvCiCqZJFuc1sRHB3e4R/7iqKBbR/VeEuYksZvJX/p++w8ZKWxArs1fPdN FxrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gBH0TQis; spf=pass (google.com: domain of kernelfans@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=kernelfans@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z197sor24137758pgz.64.2018.12.05.00.06.19 for (Google Transport Security); Wed, 05 Dec 2018 00:06:19 -0800 (PST) Received-SPF: pass (google.com: domain of kernelfans@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gBH0TQis; spf=pass (google.com: domain of kernelfans@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=kernelfans@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=mEZiBi5hhU+kUiR4ZE7YnBvS2IP2/mkhsmXWXN0B0xg=; b=gBH0TQisTYYz9CFtxhZJxCDClBvoLTjhnSy9UMQMJLfUurPifANLA2PvenPUOhp2tU T8QNsK8YyheAmaUf5Oz3/xIA+OAZx+ztPsNWIjXL1oeiGN7xLQCWqx24+ablvxU3tK4z j4MqY6PnXnKarJ7hqcqfGOQv2bqogCoSfc6yp8Qf8Awd5Xunnh4ergfFX3pV51uquyV5 /Pd285FL5DjGupNZH7FLIiHFMKjNziOUN4b+OqIm74O/c+7EkIoK6n7mZgnSb28qlAFO JWUH/MaGZXlU83t0t5dbzbio43hjmAV/DqAR7Zt4E5ZsemSasvYu5keC4nwbQwnNDqVn A+FQ== X-Google-Smtp-Source: AFSGD/XjPdIr2DGqRth9NcfRhjt0+K8s+1105zUc+QAoB2QDEm8RcAzJNRH7mYn1S3Zyyq0Vlr+DMQ== X-Received: by 2002:a63:da45:: with SMTP id l5mr19860752pgj.111.1543997178518; Wed, 05 Dec 2018 00:06:18 -0800 (PST) Received: from mylaptop.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id l185sm21793238pfl.54.2018.12.05.00.06.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 00:06:17 -0800 (PST) From: Pingfan Liu To: linux-mm@kvack.org Cc: Pingfan Liu Subject: [PATCH] mm/pageblock: throw compiling time error if pageblock_bits can not hold MIGRATE_TYPES Date: Wed, 5 Dec 2018 16:05:55 +0800 Message-Id: <1543997155-18344-1-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 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: X-Virus-Scanned: ClamAV using ClamSMTP Currently, NR_PAGEBLOCK_BITS and MIGRATE_TYPES are not associated by code. If someone adds extra migrate type, then he may forget to enlarge the NR_PAGEBLOCK_BITS. NR_PAGEBLOCK_BITS depends on MIGRATE_TYPES, while these macro spread on two different .h file with reverse dependency, it is a little hard to refer to MIGRATE_TYPES in pageblock-flag.h. This patch tries to remind such relation in compiling-time. Signed-off-by: Pingfan Liu --- include/linux/pageblock-flags.h | 5 +++-- mm/page_alloc.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h index 9132c5c..fe0aec4 100644 --- a/include/linux/pageblock-flags.h +++ b/include/linux/pageblock-flags.h @@ -25,11 +25,12 @@ #include +#define PB_migratetype_bits 3 /* Bit indices that affect a whole block of pages */ enum pageblock_bits { PB_migrate, - PB_migrate_end = PB_migrate + 3 - 1, - /* 3 bits required for migrate types */ + PB_migrate_end = PB_migrate + PB_migratetype_bits - 1, + /* n bits required for migrate types */ PB_migrate_skip,/* If set the block is skipped by compaction */ /* diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2ec9cc4..537020f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -425,7 +425,7 @@ void set_pfnblock_flags_mask(struct page *page, unsigned long flags, unsigned long bitidx, word_bitidx; unsigned long old_word, word; - BUILD_BUG_ON(NR_PAGEBLOCK_BITS != 4); + BUILD_BUG_ON(order_base_2(MIGRATE_TYPES) != PB_migratetype_bits); bitmap = get_pageblock_bitmap(page, pfn); bitidx = pfn_to_bitidx(page, pfn);