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 8F4C2C433E0 for ; Mon, 1 Feb 2021 11:19:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B7F8364D7F for ; Mon, 1 Feb 2021 11:19:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7F8364D7F 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 21E516B0075; Mon, 1 Feb 2021 06:19:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A77A6B0078; Mon, 1 Feb 2021 06:19:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 070676B007B; Mon, 1 Feb 2021 06:19:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id E55DD6B0075 for ; Mon, 1 Feb 2021 06:19:44 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B6C2F8249980 for ; Mon, 1 Feb 2021 11:19:44 +0000 (UTC) X-FDA: 77769453888.09.ball23_5417c7a275c1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 8CA6A180AD804 for ; Mon, 1 Feb 2021 11:19:44 +0000 (UTC) X-HE-Tag: ball23_5417c7a275c1 X-Filterd-Recvd-Size: 2856 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Mon, 1 Feb 2021 11:19:43 +0000 (UTC) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DTlmv1FpLzjHQ8; Mon, 1 Feb 2021 19:18:23 +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 19:19:39 +0800 Subject: Re: [PATCH] hugetlbfs: rework calculation code of Hugepage size in hugetlbfs_show_options() To: David Hildenbrand CC: , , , References: <20210201082325.33875-1-linmiaohe@huawei.com> <2bb70cac-b8ef-cdbe-fa4e-db6229587e98@redhat.com> From: Miaohe Lin Message-ID: Date: Mon, 1 Feb 2021 19:19:38 +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: <2bb70cac-b8ef-cdbe-fa4e-db6229587e98@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US X-Originating-IP: [10.174.179.241] X-CFilter-Loop: Reflected Content-Transfer-Encoding: quoted-printable 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/1 18:56, David Hildenbrand wrote: > On 01.02.21 09:23, Miaohe Lin wrote: >> Rework calculation code of the Hugepage size to make it more readable = and >> straightforward. >> >> Signed-off-by: Miaohe Lin >> --- >> =C2=A0 fs/hugetlbfs/inode.c | 9 +++++---- >> =C2=A0 1 file changed, 5 insertions(+), 4 deletions(-) >> >> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c >> index 3a08fbae3b53..1be18de4b537 100644 >> --- a/fs/hugetlbfs/inode.c >> +++ b/fs/hugetlbfs/inode.c >> @@ -1014,11 +1014,12 @@ static int hugetlbfs_show_options(struct seq_f= ile *m, struct dentry *root) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (sbinfo->max_inodes !=3D -1) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 seq_printf(m, "= ,nr_inodes=3D%lu", sbinfo->max_inodes); >> =C2=A0 -=C2=A0=C2=A0=C2=A0 hpage_size /=3D 1024; >> -=C2=A0=C2=A0=C2=A0 mod =3D 'K'; >> -=C2=A0=C2=A0=C2=A0 if (hpage_size >=3D 1024) { >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hpage_size /=3D 1024; >> +=C2=A0=C2=A0=C2=A0 if (hpage_size >=3D SZ_1M) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hpage_size /=3D SZ_1M; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mod =3D 'M'; >> +=C2=A0=C2=A0=C2=A0 } else { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hpage_size /=3D SZ_1K; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mod =3D 'K'; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 seq_printf(m, ",pagesize=3D%lu%c", hpag= e_size, mod); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (spool) { >> >=20 > Looks correct but I am not convinced the old code was that complicated = to understand. >=20 The old code is not complicated but I think it may be better to use macro= instead of well-known "magic number". Many thanks for review.:)