Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4258585pxb; Mon, 1 Feb 2021 17:28:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6fTcOKoRjnevP/k9X/0snC7B+N3z21XnrIzgtAbJfG/j+lpAYWFOuihXQXRBXy35tap14 X-Received: by 2002:a17:907:2058:: with SMTP id pg24mr11773096ejb.441.1612229296525; Mon, 01 Feb 2021 17:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612229296; cv=none; d=google.com; s=arc-20160816; b=nz5I7m3yejf/JMYx//NemohlU2SY/5Rh1LHD5ULBmnGLBCXBSxiuZtD/v+e1C67HtE sTujYoisCXZ3MrOzT5CV05vhhoQF/9JrxzsiyjRjz22zmLkd3qNC2rNYYsSpBZt6PHK1 ZYzJOf2wBDmB1jKZUlQS1T+QxZyHpliCXEeOuOPyMZ89n1x535LKwqfy885hkAOl45OQ KfKYKr4EdC0ZEL2YBDMVeG/hrF25NsFVkqUvPRmq+CCxIKAbcSSST8egiSNBBgHlsgtw 3Ec0FuPvwOcHkfWPjbXzPEtxhdYfOrl4Or6DZth6LZdLGR8q/R4q43iZnwwSvkZvtFvT u9+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=h0yHB9WRn0nZiFC0XBqAy8q2zYEVW2OAB35ZixN85Ow=; b=1BCOPbKPaZAI5GzpyOOyaEtPE0I3vcmundSq5DshDZdZeqaoHHUhmkzE5ZK6SUAP/E BbhTF/Q4AV0NcW9N5AyTIubQxOCz9uPYrIqj0UeaIED9S4paBn/o/IFkll5E95FPrVtV REHW8tsK36ovYQ8GirNDAm6e+NzG6364XQMGPSvlTShtatmMzRC+vf7Y3DNY7bEuvLsc Oka8kMglpUsFSGwRYaBic1HliALxCZ4jSlwqMzkQDTBi3NtEMzR6UWYHDg+mIYwFRCgK awM2IVWwoUXbEbdQxkuEdGIUEZwf61n/zXRH9Da+I0o48B/YeJJosQqKw50+J1JgzlNH ZGlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si1474420ejw.171.2021.02.01.17.27.52; Mon, 01 Feb 2021 17:28:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbhBBB0v (ORCPT + 99 others); Mon, 1 Feb 2021 20:26:51 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:11998 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbhBBB0u (ORCPT ); Mon, 1 Feb 2021 20:26:50 -0500 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.