Skip to content

Commit

Permalink
hugetlb_cgroup: hugetlbfs: use helper macro SZ_1{K,M,G}
Browse files Browse the repository at this point in the history
Use helper macro SZ_1K, SZ_1M and SZ_1G to do the size conversion. Minor
readability improvement.

Link: https://lkml.kernel.org/r/20220729080106.12752-3-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Mina Almasry <almasrymina@google.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Miaohe Lin authored and Andrew Morton committed Sep 12, 2022
1 parent 862f7f6 commit abfb09e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mm/hugetlb_cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,12 +675,12 @@ static ssize_t hugetlb_cgroup_reset(struct kernfs_open_file *of,

static char *mem_fmt(char *buf, int size, unsigned long hsize)
{
if (hsize >= (1UL << 30))
snprintf(buf, size, "%luGB", hsize >> 30);
else if (hsize >= (1UL << 20))
snprintf(buf, size, "%luMB", hsize >> 20);
if (hsize >= SZ_1G)
snprintf(buf, size, "%luGB", hsize / SZ_1G);
else if (hsize >= SZ_1M)
snprintf(buf, size, "%luMB", hsize / SZ_1M);
else
snprintf(buf, size, "%luKB", hsize >> 10);
snprintf(buf, size, "%luKB", hsize / SZ_1K);
return buf;
}

Expand Down

0 comments on commit abfb09e

Please sign in to comment.