From patchwork Wed Dec 5 09:19:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10713423 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 B46CD109C for ; Wed, 5 Dec 2018 09:19:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A59272C5F9 for ; Wed, 5 Dec 2018 09:19:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A4722C83D; Wed, 5 Dec 2018 09:19:29 +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 38C4C2C5F9 for ; Wed, 5 Dec 2018 09:19:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CFDC6B7391; Wed, 5 Dec 2018 04:19:28 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 657A96B7392; Wed, 5 Dec 2018 04:19:28 -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 4F90F6B7393; Wed, 5 Dec 2018 04:19:28 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 0C4C96B7391 for ; Wed, 5 Dec 2018 04:19:28 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id p15so16291579pfk.7 for ; Wed, 05 Dec 2018 01:19:28 -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:in-reply-to:references; bh=BVqn3ejMsnXU8GF1Zy+lf5FqzQCHqMEtU/61XXk/eLE=; b=Z0ONLV5doFYaKvlFo41BHfU+5PONQEkFQ7tEcEJg9YtGV3kvESbc+kwLKYMNUF2Cmo z/xk+aSVwUFsCRG6unqU7X+yjd6AzjbMB4Rq3ucj6pA/raUUabZnaJP+/TzLlC86KP3N QegY4Cc1wr2SxaYh2DN+3TUzlfzaTB4kD3ui5rJg6HlAZkNMnXPPwApwRMrUgghzv4lM FubesnZU2f1U4BWnlODDGfHsb85D0YlR3Wvmi+xYQe7CAt+bkiFLiZZtdeXxt0fkWsLr dwFFtkT+r0AySYEAw72OPATByZSD8+Ra5jysDLWJWxapKgyLZro8Lx7o+3qdM4hzsAOO zyew== X-Gm-Message-State: AA+aEWaLFfB+MLS9h1xgXBDb9SXGQo3GQVrZ7eoLJmnoQ5YcQhxa04GZ /5moJc8aX0SSgeWCMnnTnl1j16L5zg9FVVb7dQH3hoMTCDywXcdxIcPcE7iLinhi23rdnsfpVJf FWYezMCOquGFH7binvBh8nex1YEzExm1kWUwucdTDtQm1+iHm554BA/uqPHCJ87+9bKBuoV4n4c o3SSbwkG4HXn4wKdk3+4J7T34DY1kJstfhjYp5sQyT8NCmJNXmaAlfxneSyL7MlFgQuByc/KQ2g 1kP7XIFfW0luxgzaGAskM0wFlBiG9TLbRzkZ8JV4crGLMH6WD5t9la28t7MCdLPtv2O0X+DNM9V RIo4HgS+ST2TeoA07Qvtf2KgYZPd2BWEQm+0iel0VowFMNHpQuMsnpkrJUZGT2K3B5coc3pw28Q b X-Received: by 2002:a17:902:2468:: with SMTP id m37mr4545454plg.314.1544001567730; Wed, 05 Dec 2018 01:19:27 -0800 (PST) X-Received: by 2002:a17:902:2468:: with SMTP id m37mr4545415plg.314.1544001567110; Wed, 05 Dec 2018 01:19:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544001567; cv=none; d=google.com; s=arc-20160816; b=hzYRM0kVXqrv3/KychNkk/t9L7Yq3kD9lZoPjKJEwPJZkHG6Q5mVlERL5Kfu0pVCa6 fRbCPbNlCAMP/nXg3QLb7ae6IcAT3bSgzfEKSnuGTgEPTfn1viC7YQ9av/8hW3sSnrKl rBbET6agvWurhb40XH+Squ/xvMW4pFfWe3G7h8sY7n9Fp0aWizWPtausczMBg7xFSSx6 sdGmgkMc50WkbYAWu/qqW6SwoBQslUjoQnAHdxOsdju56quXNevh2uovDIzxCf0fCkxX JNeJRmxR+NEdpEWbGDuvaJJyjTm/osSFgAXhFaMm314MjiZjkAlJJ3+NdtljQwVLQ+S+ j5XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BVqn3ejMsnXU8GF1Zy+lf5FqzQCHqMEtU/61XXk/eLE=; b=KKhMBJ72s+eYLHHR7jvG1jb5JSlTd2jog3Zzf9cDC0/fNAbqXXJGhwVBYb+v4JdMfn /7J+N+PgnuZDg1lu/+ZACq4GYdwX4U2KX36B29v/ruR1eIyVmtIEiG8U5vkHqK0dS0V8 Vpm97Dh8Y1o1pnSK9xnyp04scoCOiFzXpGrPBEjT+Q+0SHWIEanq6VYoXKA+yniFNgiK FD3k0oDboVKdUUHvd7ojSFblW2k5uHaz7X/jUXyLnpdfz7Lbq52tNnInSw7+ruqYxcvr eWhDrXERsKM+6nxqEuEb6voRL9G/S2bnf/lFM133kU59H48jxTF2FzkZ2qRgGLOpGJYA MA+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Je4maN3T; 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 u6sor27288241pfj.10.2018.12.05.01.19.26 for (Google Transport Security); Wed, 05 Dec 2018 01:19: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=Je4maN3T; 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:in-reply-to:references; bh=BVqn3ejMsnXU8GF1Zy+lf5FqzQCHqMEtU/61XXk/eLE=; b=Je4maN3TXxN+6wfxMF6sxYDB9/fs35svDBdz9pNEcK8I1hXAEILwpO3TVEj/Njnzk5 fQMiCD9KlAbkxFEUbST5rPLD9L+J4LeQ2g5m8XNoqD2VIT8ANACz2mP4lNk0z2Nar76Y aIKkMVgPOYkYAwedWzbJFJy4ZCj0C0jcGnLfPj9foGos2Jv7MIxZKOal7NGoYD3rDCgL urVGTt6mkiP/9RSGvRLsfRXNbQDQ/uVw8h8Mrw+CiIAmSI3UoOFPqz4lhWxJ4MN+kmH9 WUkTTWU4g/AqQ9AfroKcgY8ZFxd9YgrrcDDu4EptI9UZHQIpMzkEbl5hJySFZ9K/9fbn h3Pw== X-Google-Smtp-Source: AFSGD/VrYgZ+W+/JtaiUD+ic6/2q3abmRQUvb245Z2m9+zJ4D1ZTCpqma3RiCD3qOY9ARnQJhjN2Nw== X-Received: by 2002:a62:5950:: with SMTP id n77mr23329435pfb.128.1544001566632; Wed, 05 Dec 2018 01:19:26 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id d129sm29691521pfc.31.2018.12.05.01.19.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 01:19:26 -0800 (PST) From: Wei Yang To: linux-mm@kvack.org Cc: mgorman@techsingularity.net, akpm@linux-foundation.org, Wei Yang Subject: [PATCH 2/2] mm, page_alloc: cleanup usemap_size() when SPARSEMEM is not set Date: Wed, 5 Dec 2018 17:19:05 +0800 Message-Id: <20181205091905.27727-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20181205091905.27727-1-richard.weiyang@gmail.com> References: <20181205091905.27727-1-richard.weiyang@gmail.com> 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 7c745c305332..baf473f80800 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6204,7 +6204,7 @@ static void __meminit 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. */ @@ -6213,12 +6213,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,