Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2407471pxb; Sat, 30 Jan 2021 01:28:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJx08LnLYSTr52fNSk2nG2pyCg9plk+8VcI4EEw3HhSLS/rE7HO30oa/vRuQcqFDYjNo7zc2 X-Received: by 2002:a17:906:7cd8:: with SMTP id h24mr8113150ejp.511.1611998925612; Sat, 30 Jan 2021 01:28:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611998925; cv=none; d=google.com; s=arc-20160816; b=Bgx9kpo51EcwD+4rN03NxCWm247PTBWaTAviP4jTzldLE8LFNjZzPvKQRYStcW/YhZ ig417BS5zmkPcLoD5nKmZC3BQp22XM/mzct8V3C1IjbRLmCRo3HJ6o/nQ/D6g/+QiLyq EVuNxVG7ZfjhecfRaliqJMl4VaoKh6z7ad1jzDNmJa64IimcNW2R1tqdRcuiEbehUp8r MhzCbFizkS4uKTnv+e67wZr7mw1QteCptI8hJQFQ3Gzz7MpJUDXvBqejJlnFqEvqEndu CEHazJ7Y0cedP/awyYEWKfy1HfM43lNB+7M+vhGichwHvwGxMED3LyQ+5w8yNPllKfaF bdGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=NFzNcmMYP8s+JvBw3RKeRtBr38bDahkBEvE8LdgLWT4=; b=duMBTgIhbSkDy325/SAQRYq1SEAMOenPTGb+dfqVr6j636Qv8kCj6VjgBRbf9Ed6Gv wwDtTqOzTUqp+9hBepDtf9n4V9v4NU/q77ENg9nERvj2jjzG4F+ThF1s1WteZQd9aVow 6PcciPrK+K4oKWre3Gg26sAhyNwycAbIuKA9mnQCelZx0VWqWAcG+VZ5QB9DjwOHId5v n+wO/VuJ0kH2f+oouK/8uWrYgIIISMaohLvv03bazM5mis3XA1W86Nn0TYNwqJJ9YHgX yczJnB0hDxUMf/DCs4WoU0ghpJSuL267m6R64YoIXUQdZNt/P8SefStl6lyUj/4ck6hR hqOQ== 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 u1si6346403ejy.721.2021.01.30.01.28.21; Sat, 30 Jan 2021 01:28:45 -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 S231861AbhA3J1k (ORCPT + 99 others); Sat, 30 Jan 2021 04:27:40 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:12368 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231490AbhA3JYO (ORCPT ); Sat, 30 Jan 2021 04:24:14 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DSSsf6G7Rz7d9g; Sat, 30 Jan 2021 17:03:02 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Sat, 30 Jan 2021 17:03:48 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH] hugetlbfs: show pagesize in unit of GB if possible Date: Sat, 30 Jan 2021 04:03:39 -0500 Message-ID: <20210130090339.4378-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) { -- 2.19.1