From patchwork Fri Jan 18 23:49:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10771839 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 D007313B4 for ; Fri, 18 Jan 2019 23:49:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEF1F2FAC8 for ; Fri, 18 Jan 2019 23:49:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2DD92FAD5; Fri, 18 Jan 2019 23:49:31 +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 4CE8F2FACF for ; Fri, 18 Jan 2019 23:49:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D5418E002C; Fri, 18 Jan 2019 18:49:29 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9835F8E0002; Fri, 18 Jan 2019 18:49:29 -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 8728B8E002C; Fri, 18 Jan 2019 18:49:29 -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 466398E0002 for ; Fri, 18 Jan 2019 18:49:29 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id l76so8666305pfg.1 for ; Fri, 18 Jan 2019 15:49:29 -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=PNBeKHz1K18j1ynvMYUdNKwEn6HgE/2SnxEQ4pyjqtM=; b=AtFTTx72FWWIDMOGG2gknKzQzC8UQWolDwLQMQ5IUYn8f04xCAxwd4EM3QYzbpIQEI jAzl127Svq0D/EnRNxb/0wbPvhDhO1LAZ28Fw7mQsVwZHC5UVhZXH+nt/8oJ6D7hZ4Fz M569N6VFjvN+z+b4bgFWzGpcgDpQg2V/oSBk5ltY31I+ZypmSgdvWpzTyTGorZ5I/fzU hMy0pl+5DrtmcxJuxLovvTgdeuVqWgsFl4L7j0yCWeSgtTUXtQ6R8HdyZDkd/I6YG5je RF10pDZKJeQMZqdOFFFV85yi88nqqiLXvot8XuUj3PhpMbLikHfriRY5W8Hy9tfUa+uk imBA== X-Gm-Message-State: AJcUukcavarMmEWmWHt9YsN1T6nQL0W/bTpBMKOWwA4/wBN2NX/KiAXI bdy3yhuFk/m6W+9iTa4rlEugTA2FpYol8wUq6T8bZEZ8XY0WoM7sf6+23k5i0RtxWF7QMVwLhi7 DVaWkBwqZiDc3BNPpuU5nROVdsXeaYnpDop8vR9SZlcqoh43N9Dt10LGQsTenkDtmFUOLDoL+FR 1OGSIfPvF3/YbDKu6/I1rq1/2ckOc+/MdI78XFZicqc8gUdoiq6i+3vBfTSN4sJdg48JQWav+G6 lV6ogpQ9J59cTAUuo6jZyUf271qR9knxQEjl0UdyDb2LuURwogpd9N0yCwf90RrrIu/t3TbWYnL fSGyfMUHQ9Gce4RpE5EzCtCkzaYkNQclID4ZlcIOyulxFRTNQx1O80DIJFLKJsAyY91srtwA0+M E X-Received: by 2002:a17:902:9047:: with SMTP id w7mr21222298plz.270.1547855368715; Fri, 18 Jan 2019 15:49:28 -0800 (PST) X-Received: by 2002:a17:902:9047:: with SMTP id w7mr21222265plz.270.1547855367757; Fri, 18 Jan 2019 15:49:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547855367; cv=none; d=google.com; s=arc-20160816; b=Lrkp9/AquFNeKH06raBgT8QxPnlTeCQvb4xOCGeSIMudzO9rNnGIfkiTlr9625u7Oe +Y1hM2YTgmGm22MTeb82hJIweATjSop19mnM3wJTRiepYEsjwpakDjZMFjHA5GBRE5Kv xsyfuYWjlFt/zFkK8kQJt3N7kg8fnLWzDjLuQh7OLW7jOUVaMZwEoAYW16H6a2n/n8XN ADs3pfsQMmX/hmjdVWaerlQSdaDURBMNjZA/xNbNFLsR5PHNBrqSywM3GYhGyvozhoNn v8eOpBOHk1HVdwle1EVBkKWSO7enPH6whI3l++qj68k3hp/m9DCcTtSAvVnadCG5BAxz /KtQ== 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=PNBeKHz1K18j1ynvMYUdNKwEn6HgE/2SnxEQ4pyjqtM=; b=U3Wn612Aj/REnrwaPKIQ/xtRgF3DxY97WIKdiwYQWz1IrCHCtfKz7bwmkRsf/C7Jib UCt1gJPDPlwlRIBAzKde2CDk8lT0+pOXmF+JwdN/jntoixUbDhJqwxBY2aw3j0P7kvNP wH8KenfvCFcekdl/4YcCUk0oN3dv3TJoW27CRGashQs/4YsI/lM2/4F1KyQlxKIUc468 h+VMQjXWNNGr4ar/EA+a5LzTg/G/7fbHvzfRlYNqTxSDAsTtuosSx5nAHoIdznb/vZQs aZa0mfqs+xTD1QP4kA/8HOCQ5id5Nsv6z9ZxlEs2+JvLj6pywTHQrukYKdYdZXL+3fg0 KUyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BcSlpKWG; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@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 b60sor8856829plc.24.2019.01.18.15.49.27 for (Google Transport Security); Fri, 18 Jan 2019 15:49:27 -0800 (PST) Received-SPF: pass (google.com: domain of richard.weiyang@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=BcSlpKWG; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@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=PNBeKHz1K18j1ynvMYUdNKwEn6HgE/2SnxEQ4pyjqtM=; b=BcSlpKWG8agUOXUnPXPLvHWOAdpNEisqAXhs0sucg2fUTU9yNOqbpW8stcrzIFGaC9 G2XfWiLBD1pRgi/+lI9mZF/RX7OvZVuWWNaV+UG6cCbncyZBqpx72fewRdhCgFitMD1Z 10cGr5noLAg+mHwVG4w0fCydWF6gtq4QpF4j1SH8+67PFapsU/arAy7MlgH2iVmA3Axv xfNS2Stmqd0if/TsfkQy+Q7h/MxiSypb0EUuX3GyFGvzjzL2CqjodXpufbIhotQaUx8T 4qzTL9UgAvFe5uJUviXNpgBcf5JYgj6o84WYT5ffU+exv6ONmh8WUwwkHKbY/NFJTvh9 zj4g== X-Google-Smtp-Source: ALg8bN7OipCmxSeWy7mLW+CYMpDuDwW1a9FBUVYqPFzERKTDCweMKto8Q6UNJJedAPiBVxLoZqfxYg== X-Received: by 2002:a17:902:a03:: with SMTP id 3mr21191989plo.112.1547855367114; Fri, 18 Jan 2019 15:49:27 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id z8sm7065122pgg.62.2019.01.18.15.49.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jan 2019 15:49:26 -0800 (PST) From: Wei Yang To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, mhocko@suse.com, Wei Yang Subject: [PATCH] mm, page_alloc: cleanup usemap_size() when SPARSEMEM is not set Date: Sat, 19 Jan 2019 07:49:05 +0800 Message-Id: <20190118234905.27597-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 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 Two cleanups in this patch: * since pageblock_nr_pages == (1 << pageblock_order), the roundup() and right shift pageblock_order could be replaced with DIV_ROUND_UP() * use BITS_TO_LONGS() to get number of bytes for bitmap This patch also fix one typo in comment. Signed-off-by: Wei Yang --- mm/page_alloc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d295c9bc01a8..d7073cedd087 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6352,7 +6352,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, /* * Calculate the size of the zone->blockflags rounded to an unsigned long * Start by making sure zonesize is a multiple of pageblock_order by rounding - * up. Then use 1 NR_PAGEBLOCK_BITS worth of bits per pageblock, finally + * up. Then use 1 NR_PAGEBLOCK_BITS width of bits per pageblock, finally * round what is now in bits to nearest long in bits, then return it in * bytes. */ @@ -6361,12 +6361,9 @@ static unsigned long __init usemap_size(unsigned long zone_start_pfn, unsigned l unsigned long usemapsize; zonesize += zone_start_pfn & (pageblock_nr_pages-1); - usemapsize = roundup(zonesize, pageblock_nr_pages); - usemapsize = usemapsize >> pageblock_order; + usemapsize = DIV_ROUND_UP(zonesize, pageblock_nr_pages); usemapsize *= NR_PAGEBLOCK_BITS; - usemapsize = roundup(usemapsize, 8 * sizeof(unsigned long)); - - return usemapsize / 8; + return BITS_TO_LONGS(usemapsize) * sizeof(unsigned long); } static void __ref setup_usemap(struct pglist_data *pgdat,