From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 0F1EFC433E0 for ; Mon, 1 Feb 2021 01:22:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0BF8664E22 for ; Mon, 1 Feb 2021 01:22:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BF8664E22 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 72E676B006E; Sun, 31 Jan 2021 20:22:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B76D6B0070; Sun, 31 Jan 2021 20:22:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57EC36B0071; Sun, 31 Jan 2021 20:22:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id 3F3FC6B006E for ; Sun, 31 Jan 2021 20:22:41 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id F26133631 for ; Mon, 1 Feb 2021 01:22:40 +0000 (UTC) X-FDA: 77767949322.18.fly49_320938f275be Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id D403A100ED0FE for ; Mon, 1 Feb 2021 01:22:40 +0000 (UTC) X-HE-Tag: fly49_320938f275be X-Filterd-Recvd-Size: 2740 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Mon, 1 Feb 2021 01:22:39 +0000 (UTC) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DTVWQ38TDzlDTM; Mon, 1 Feb 2021 09:20:50 +0800 (CST) Received: from [10.174.179.241] (10.174.179.241) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Mon, 1 Feb 2021 09:22:21 +0800 Subject: Re: [PATCH] hugetlbfs: show pagesize in unit of GB if possible To: David Rientjes CC: , , , References: <20210130090339.4378-1-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: <24ab70d6-1d23-d118-f1e7-473f01615dcc@huawei.com> Date: Mon, 1 Feb 2021 09:22:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.241] 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: Hi: On 2021/1/31 6:07, David Rientjes wrote: > On Sat, 30 Jan 2021, Miaohe Lin wrote: > >> Hugepage size in unit of GB is supported. We could show pagesize in unit of >> GB to make it more friendly to read. Also rework the calculation code of >> page size unit to make it more readable. >> >> Signed-off-by: Miaohe Lin >> --- >> fs/hugetlbfs/inode.c | 12 ++++++++---- >> 1 file changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c >> index 3a08fbae3b53..40a9795f250a 100644 >> --- a/fs/hugetlbfs/inode.c >> +++ b/fs/hugetlbfs/inode.c >> @@ -1014,11 +1014,15 @@ 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_1G) { >> + hpage_size /= SZ_1G; >> + mod = 'G'; >> + } else 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) { > > NACK, this can break existing userspace parsing. > . > I see. I should take care of this. Many thanks.