Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3469879pxb; Sun, 31 Jan 2021 17:26:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHpXzNOEOB9fs3NkQXDwAEyA74Qvj1mM5AV/HvnAmsATeApqYEdA4p1M6anregbfI2EorJ X-Received: by 2002:a50:da8b:: with SMTP id q11mr16774646edj.352.1612142769745; Sun, 31 Jan 2021 17:26:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612142769; cv=none; d=google.com; s=arc-20160816; b=Wc/+vfVUcHXfI3XoljT8y/QlAtpAzGCmPBXglSMW3J4DFOCslHOwhcU/v3Be5yYCma WKuegINidwE3+9EH1S6z6/9iGUQ87gpjBv8FlK3Cjl6P2xz9PbxSwZQVfBFi/ZkaXyz3 649Q31MexeMwDBIzAjYeMbxujV3bNItQKkamccJYFxgo5/5GFM4K6HKaCngYExEegdRT 8+8IwPw91Je+8C9jZ+OXo+HXWeamjPO//OkvhBuEx3hZTAig3nt+4IR6GF5Cl7uIXiQn P2pAjJWdk/Xi0f0d/Xx0+m4gnAQr+PzqWRwJQbJz3tNsYekAjETExuu6OLyUrGPqEGAp bWjA== 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=TW4yaw2XkPbarQuP/8d9/wbLYiZBi7WABHSG0pxXTgY=; b=hW/F9OrWj5szb8L+nQ61qWpjTCtCdZL5t/TzkewMqfJvHmgqPvIIkFbFv7BJB99FBA Goo3JLMz37CNY+qNhLHC0I9NgCzR+UEhuMmKx4DeekH1RpGLCuyp4A8Sz9agrE65ptpy hPRHLCYwv/DRrpe+sfZBDaScLrcMFomhpi4Z+Iyss19UAja9ygmESdyNOSedduWkgaaW ndfQp4Af+pWHFW4gV94udvP4zEv1iSyZy5K6mMQptZ7sP1OqVmwVpknWaiMJX8gOvDRI 7AW7YOCaU0odFnMosirisSC1QGqGj+F6Ikjgxyr4nI2Gok7DzG9ckcEbIxoqQpdwzh3K 0+nQ== 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 dd20si10183329edb.489.2021.01.31.17.25.45; Sun, 31 Jan 2021 17:26:09 -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 S230526AbhBABX7 (ORCPT + 99 others); Sun, 31 Jan 2021 20:23:59 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:11221 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231153AbhBABXK (ORCPT ); Sun, 31 Jan 2021 20:23:10 -0500 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.