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.2 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 D76EDC433E0 for ; Tue, 2 Feb 2021 01:26:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3CD6764DD4 for ; Tue, 2 Feb 2021 01:26:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CD6764DD4 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 97A056B0005; Mon, 1 Feb 2021 20:26:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 92A0B6B0006; Mon, 1 Feb 2021 20:26:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 840736B006E; Mon, 1 Feb 2021 20:26:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0026.hostedemail.com [216.40.44.26]) by kanga.kvack.org (Postfix) with ESMTP id 714AF6B0005 for ; Mon, 1 Feb 2021 20:26:13 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3D1AC3631 for ; Tue, 2 Feb 2021 01:26:13 +0000 (UTC) X-FDA: 77771587026.26.plate63_460e133275c6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 1D1631804B669 for ; Tue, 2 Feb 2021 01:26:13 +0000 (UTC) X-HE-Tag: plate63_460e133275c6 X-Filterd-Recvd-Size: 3450 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 01:26:12 +0000 (UTC) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DV6YZ0WLpzjGs6; Tue, 2 Feb 2021 09:24:50 +0800 (CST) Received: from [10.174.179.241] (10.174.179.241) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Tue, 2 Feb 2021 09:26:03 +0800 Subject: Re: [PATCH] hugetlbfs: show pagesize in unit of GB if possible To: David Rientjes CC: , , , References: <20210130090339.4378-1-linmiaohe@huawei.com> <24ab70d6-1d23-d118-f1e7-473f01615dcc@huawei.com> From: Miaohe Lin Message-ID: <0c9187f0-39c8-8f7d-79a7-9823cba43c5c@huawei.com> Date: Tue, 2 Feb 2021 09:26:03 +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/2/2 5:31, David Rientjes wrote: > On Mon, 1 Feb 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. >> > > Thanks. It's an important point to emphasize because it shows how > important user-facing interfaces are. Once the hugetlbfs mount options > are printed in the way they are, it becomes very difficult to change them > because there can be userspace in the wild that would break as a result. > This is why it's crucial to be very careful when specifying user-facing > interfaces the first time so they are extensible. > . > Many thanks for detailed explanation! I will keep this in mind! Thanks again.