From patchwork Fri Jul 29 08:01:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12932110 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 024D4C00144 for ; Fri, 29 Jul 2022 08:01:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 111328E0001; Fri, 29 Jul 2022 04:01:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 065C26B0073; Fri, 29 Jul 2022 04:01:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E22198E0001; Fri, 29 Jul 2022 04:01:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CDCA36B0071 for ; Fri, 29 Jul 2022 04:01:26 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9571B141154 for ; Fri, 29 Jul 2022 08:01:26 +0000 (UTC) X-FDA: 79739392572.18.CE8F1E7 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf11.hostedemail.com (Postfix) with ESMTP id D23D84003A for ; Fri, 29 Jul 2022 08:01:25 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LvKdy2p8gzlWZj; Fri, 29 Jul 2022 15:58:46 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 29 Jul 2022 16:01:21 +0800 From: Miaohe Lin To: CC: , , , , Subject: [PATCH v2 2/5] hugetlb_cgroup: hugetlbfs: use helper macro SZ_1{K,M,G} Date: Fri, 29 Jul 2022 16:01:03 +0800 Message-ID: <20220729080106.12752-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220729080106.12752-1-linmiaohe@huawei.com> References: <20220729080106.12752-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659081686; a=rsa-sha256; cv=none; b=ZVtOtQR0GKgRXvs14WZnXE2lJsG29ud/UwxyltPG7DvMEi1Y1nGDpGUJrEU07g++JhWI9n H6TFSkDLhPrDb5I0b3sk5yZf5uCODMu1lT0RUjr1JklDxW59tRp+C3husugIQyJltPDHj6 sZFzH5LUOnHm5Ds8wn2KxP0k7Y5Z6HM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659081686; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RtNnTHtSHumuZen66UpnR7aXtpR0PYLSAq5475uMWFg=; b=uw9bdEywdSG0BfEkQOfILGk3MnjlFLOi5UXNJ7pHnlP1pUupNl6a7MsAyz0/nw70XCrNX4 HexcDB1Oi8juxu+Cmv79eeP+oYUv2Ev1I6t25BYfcxU7bQ9Zky5VvDiqLmizTWXiHd3bET clbkaV+exuHUhEZ3GtjkojcY4wR1InY= X-Rspamd-Queue-Id: D23D84003A X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam09 X-Stat-Signature: kzqqpqdtoh75bo3j6frmz84f7zco3tn4 X-HE-Tag: 1659081685-897426 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: Use helper macro SZ_1K, SZ_1M and SZ_1G to do the size conversion. Minor readability improvement. Signed-off-by: Miaohe Lin Reviewed-by: Mina Almasry --- mm/hugetlb_cgroup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index d16eb00c947d..01a709468937 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -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; }