From patchwork Thu Jul 28 12:19:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12931194 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 70663C19F21 for ; Thu, 28 Jul 2022 12:20:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 70FC36B0071; Thu, 28 Jul 2022 08:20:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4511F8E0001; Thu, 28 Jul 2022 08:20:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 234D56B0074; Thu, 28 Jul 2022 08:20:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0348A8E0001 for ; Thu, 28 Jul 2022 08:20:10 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CCB42AB39D for ; Thu, 28 Jul 2022 12:20:09 +0000 (UTC) X-FDA: 79736415738.10.C367B98 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf03.hostedemail.com (Postfix) with ESMTP id 2D5352009D for ; Thu, 28 Jul 2022 12:20:09 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LtqRq12vlzmVDm; Thu, 28 Jul 2022 20:18:15 +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; Thu, 28 Jul 2022 20:20:05 +0800 From: Miaohe Lin To: CC: , , , , Subject: [PATCH 3/6] hugetlb_cgroup: hugetlbfs: use helper macro SZ_1{K,M,G} Date: Thu, 28 Jul 2022 20:19:46 +0800 Message-ID: <20220728121949.20985-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220728121949.20985-1-linmiaohe@huawei.com> References: <20220728121949.20985-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659010809; a=rsa-sha256; cv=none; b=nO6ERHrPL8DFfQ8p1PWRWaiVBqc1UYo00pltNhkaUUrlIFo+kvAWi36+YaBoyCmXvnfitp TRcGs5jehMiKyAIgpH1ArzI2uwETBLGi04Zrazf8+g+VJon2x9nLLphnueTV32lmDGlbAZ A+Njh/rYrR+9NXgliC3FzE2AE5GMWyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659010809; 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=u4sN/8UBmm7w+I2ql581CCBYcVR895+bMloZ1ZVgdb4=; b=566w/P0GV9LPqI6TvtQWCyhf6KqDLhDM1FleIZaXpGeFetTnKhFLicNoRMT8zB1hW209Q3 535qXuZYlPWbik5Dm1UgiEAsBu0aWz/e5dB5pdurhzQ3rfm1NIB34iG4hURZb4tMM9jEHL MeLGC3abuUR7WeE7F8UkTgSn++9f788= X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 2D5352009D Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: rg7nm3xc6tdoi5ne1q1ybs35fjn8sh1o X-Rspam-User: X-HE-Tag: 1659010809-508450 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 99e9a367e1e5..7e0bca52c40f 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -674,12 +674,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; }