From patchwork Mon Feb 1 08:23:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12058365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F05EC433DB for ; Mon, 1 Feb 2021 08:24:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 926F164E33 for ; Mon, 1 Feb 2021 08:24:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 926F164E33 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B40766B006E; Mon, 1 Feb 2021 03:24:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AF0526B0070; Mon, 1 Feb 2021 03:24:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A063D6B0071; Mon, 1 Feb 2021 03:24:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id 8B8E06B006E for ; Mon, 1 Feb 2021 03:24:11 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 429F6181AEF1A for ; Mon, 1 Feb 2021 08:24:11 +0000 (UTC) X-FDA: 77769011502.07.swing22_0800d91275c0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 265BB1803FF02 for ; Mon, 1 Feb 2021 08:24:11 +0000 (UTC) X-HE-Tag: swing22_0800d91275c0 X-Filterd-Recvd-Size: 1989 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Mon, 1 Feb 2021 08:24:10 +0000 (UTC) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DTgtH4B55z162Vx; Mon, 1 Feb 2021 16:22:47 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Mon, 1 Feb 2021 16:23:55 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH] hugetlbfs: rework calculation code of Hugepage size in hugetlbfs_show_options() Date: Mon, 1 Feb 2021 03:23:25 -0500 Message-ID: <20210201082325.33875-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected 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: Rework calculation code of the Hugepage size to make it more readable and straightforward. Signed-off-by: Miaohe Lin --- fs/hugetlbfs/inode.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 3a08fbae3b53..1be18de4b537 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1014,11 +1014,12 @@ static int hugetlbfs_show_options(struct seq_file *m, struct dentry *root) if (sbinfo->max_inodes != -1) seq_printf(m, ",nr_inodes=%lu", sbinfo->max_inodes); - hpage_size /= 1024; - mod = 'K'; - if (hpage_size >= 1024) { - hpage_size /= 1024; + if (hpage_size >= SZ_1M) { + hpage_size /= SZ_1M; mod = 'M'; + } else { + hpage_size /= SZ_1K; + mod = 'K'; } seq_printf(m, ",pagesize=%lu%c", hpage_size, mod); if (spool) {