From patchwork Fri Dec 7 04:53:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 10717431 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 2BBAC14E2 for ; Fri, 7 Dec 2018 04:53:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 096A42DE5F for ; Fri, 7 Dec 2018 04:53:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC27F2EBDD; Fri, 7 Dec 2018 04:53:37 +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 C7D652DE5F for ; Fri, 7 Dec 2018 04:53:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0B2E6B7C6C; Thu, 6 Dec 2018 23:53:31 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CB9FC6B7C6F; Thu, 6 Dec 2018 23:53:31 -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 BA9086B7C73; Thu, 6 Dec 2018 23:53:31 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 79D6D6B7C6C for ; Thu, 6 Dec 2018 23:53:31 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id k125so1771128pga.5 for ; Thu, 06 Dec 2018 20:53:31 -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=8Q0w6raUQ/4DUwGgxPCRaz9NBeSFDh5f0MTTYAkEtAg=; b=dTTXt4KEhoiIpT8CHwOcP0jW2brykCnlYzoT77BwZIPgZEHw04sj1NftGfYoFQnj+k Qdk0hPDwJOjM3saqY3MsvhL3f5H18x6FNgdseLWkebpHlzPf4fYdvsHUPfLJVv5wQCXL Gq/+W9T1xlYwrhtkHfAGp+AFtFe5hcI54Wbm8ax+siYVOsf0rehGOC8WIf2bYG/BlzqU BsT9wMbUNVM4Oi/hBV3LBRy9+rn+NXGS5OQSfxASU/4h2eb5V9hAwG/+RG/zD1s8p2QA 6SucP+ctWwyANkyn0SlQjhLPPQkuQac841v2DlrqCjDdrL9/bRVc0AHc8hWVvdZVDh48 vqYw== X-Gm-Message-State: AA+aEWaayMQBxNzP3x+dAaxSHxyG4yYjUO5VnYsZfI/J+hJB97uX7RXH nRoOBujoEbwYSsRh9OtqdH2zS9zJlJZeXXWyZSbBAaqZm5/itY6v4UN1SNfHe7WzNg5BFPwU4rx nmf4WzwkXpD2TvRA5SHVkGpix+dSwjycvmUoRVg63IZDAprxrbHT8gTQOQob3BdMCJ7jYScxEdF UzxMuEE6Javtf4zJ8kjPtOlltQ8GEwIJoRI4iNUMpGGHws62yWkFuozenTQo6A6FqOWrrhD6GmB pCgjRRvJs7xtTbLjFx94rQ7euRg5bjRKx7kl5kp0Rzvhzy7WbJKktis2uRosxSDDkZPi8225rZ4 dhCvL9YBEESVeBXQ6K07Ruuro/quwQzBejmCRqzawwpBBwvwE/CUZT9QxTREwpjG6NnykbnC/cY x X-Received: by 2002:a62:5b83:: with SMTP id p125mr849441pfb.116.1544158411111; Thu, 06 Dec 2018 20:53:31 -0800 (PST) X-Received: by 2002:a62:5b83:: with SMTP id p125mr849414pfb.116.1544158410103; Thu, 06 Dec 2018 20:53:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544158410; cv=none; d=google.com; s=arc-20160816; b=eK4eYPnNZwsuF/0V3UGbORgcMjdUDoGg7Elx4By4kOY1C5ZV7bFLX6jRpzLhHu9EAp QHa9xXvvcJwMMOkNa4x2XmTd/3Pg7gqO5rsEONbKzRRfZXLguAyD2XfwWbe4QuoFT8ZH vqkK8Pt04wOOFNChaZpmR+JdGJzqJlyoBr5kys5hsSFxl7AnSvyfCOKCcIuK+NDzqhb5 qvckuB84BC11g3es4TQzfD6f0VWJuvTZkwOKA8o72arQuQlxco7smfIbrcNuCVtDdGPf agtn912c7j7+WICiaKfchfX1LGnYEWIx1Z7v9uwLamDbzDmUNfgb5Cf0A9+zp/2FJPqD lgqA== 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=8Q0w6raUQ/4DUwGgxPCRaz9NBeSFDh5f0MTTYAkEtAg=; b=PGQsDpagoF6d96rCYoLPNu5eGtVIEhfIK/a1lW1P4s0txlmK/kffxrT1vrJe5A0UMI jWxMUn9+t+MGAotbOpuSEfis6uUz2/oWK+lQJDdCDmi9w26e73K+XhxXbLSXT1c49/uC WUHynFOEVuB2uP5crNHZxAFl3p/vxgriLmYq+D9+13cwRORFiMAKDVpIcpQRCgAdzwKV bvFbXB0pzw8ITXwuwO35y452MH9ScVYIIqxjlG+DuP9d0YnYc7TYV5WdvdU58QefuE1H NMGxzwvT+wIFDJuLKLOrjerYTe9XMFxd0w/Mkht6wz0X97u8JiaFszEIAdNW0jcQVuCu z6KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=q6YxKDj4; 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 73sor3536961plf.73.2018.12.06.20.53.29 for (Google Transport Security); Thu, 06 Dec 2018 20:53:30 -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=q6YxKDj4; 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=8Q0w6raUQ/4DUwGgxPCRaz9NBeSFDh5f0MTTYAkEtAg=; b=q6YxKDj4eAhdprGwJYDyKLwQr1CAbTxaGPqgCqs/CtUHh5YTtNax1Uq8OmiTo+xxZY 48Dx+Ab1SroaqlSOrgSUZ4AjCOjB+jwjnImZJcZdk/h7hYKch4qw5lp0g811vMveNIvX ADHTRTrEbNsgtUULCeMbYgvKBjBvCZ9uGROlJSHk15VduGiWxcSxQCClehoaLgVzqv7Y bDqpQhF27+QYXKDGWjVYiVIaNPkM/0AaAQTlL92WHiUi+jtjODkvnOrg59sUtY2PK6bK MKy/zrbpApp5WUX2fgb3HWU1mThKTi9HC/n9/dGOOdw74WQrMpC3/uzKZbzRECUE1aia mCsQ== X-Google-Smtp-Source: AFSGD/VFOc+RLzGaRDVQtPGf9xy8v0nNRI8FG3M55s8iHACczT/3acBb7jL6VnEMb8wmTES2YrigCw== X-Received: by 2002:a17:902:b112:: with SMTP id q18mr775904plr.255.1544158409282; Thu, 06 Dec 2018 20:53:29 -0800 (PST) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id v14sm2729180pgf.3.2018.12.06.20.53.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 20:53:28 -0800 (PST) From: Pingfan Liu To: linux-mm@kvack.org Cc: Pingfan Liu , Andrew Morton , Michal Hocko , Pavel Tatashin , Vlastimil Babka , Oscar Salvador , Mike Rapoport , Joonsoo Kim , Alexander Duyck Subject: [PATCHv2] mm/pageblock: throw compiling time error if pageblock_bits can not hold MIGRATE_TYPES Date: Fri, 7 Dec 2018 12:53:08 +0800 Message-Id: <1544158388-20832-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. Hence it requires some way to fix. 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 Cc: Andrew Morton Cc: Michal Hocko Cc: Pavel Tatashin Cc: Vlastimil Babka Cc: Oscar Salvador Cc: Mike Rapoport Cc: Joonsoo Kim Cc: Alexander Duyck --- include/linux/pageblock-flags.h | 5 +++-- mm/page_alloc.c | 3 ++- 2 files changed, 5 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..1a22d8d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -425,7 +425,8 @@ 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 - 1)); bitmap = get_pageblock_bitmap(page, pfn); bitidx = pfn_to_bitidx(page, pfn);