Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp434643imn; Thu, 28 Jul 2022 05:25:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sPez2yP0O1KYE5r8g6NSD2YKkjZy00imtv88gdyi+8g/G4RNVH6EZ6gNwVWZfyJ0eUSU5Q X-Received: by 2002:a17:907:2c61:b0:72b:3a12:5121 with SMTP id ib1-20020a1709072c6100b0072b3a125121mr20979093ejc.52.1659011118121; Thu, 28 Jul 2022 05:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659011118; cv=none; d=google.com; s=arc-20160816; b=S5DX8nR1VBsJdYWCwqBEsheRa4tjS+44iuaa0vUI7SLuVWgNsm7/iXpFJI7eN7jDEA Gk1D5OEpAqZKQdiYMBIk4qAhEwNeqK+TyvPXZFuDUknDZkfSrwZxrhx2IZ8Q6quwTLBx uzt59unvLUsmpPRK9MWbrlnh01mFqUJdkxluIM8GnWeRd5YDgaEePTIyaJI5P92NI64c 03xllb70ZliqLlXIrX5EMqGpSQ8aOUcV2fcOSqDdvufe7dxNwrXenWOT64/UtN/1IT+V oPjsiO6m/gIGXnjoKTaszb3hFBwQ36oxdqOVXfiZkH+4MJ0ghbuYOl0numWvd43tjaWZ EKtQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=u4sN/8UBmm7w+I2ql581CCBYcVR895+bMloZ1ZVgdb4=; b=YJ7gj43Op3iULbIPWD4FRcuPYUNJVakpeITiQqkFzDMtlom9xZIRsUnM1woOWzxZrn anoyS916KC6jkpK85hbZeyKzq4SRTaEY1pHkfzOc6H1Eoz4eUYe5tiWl/eJHGIPd3jYs 92DTxpGZ6MMU5lUQTlXjSnoi2pH3YusgqQMxIIWCN+DoxMwNrphWwnark2UfJv4thic2 /FXwt3T8P0WaWxNkm/HdjEhR3VrNznG5M/DjdMYp9/m9vQ+zJFSMqtvb2awO1KFI1PF1 Ux7q0fBDGI90eL41VlKQwsEq6a4VMu82DtyTtRMA8ZWvDqDphsi5GV6gWmb3wr8xIXVq YJIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a50cd0f000000b0043c3c9a0836si665205edi.558.2022.07.28.05.24.53; Thu, 28 Jul 2022 05:25:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236927AbiG1MUT (ORCPT + 99 others); Thu, 28 Jul 2022 08:20:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235647AbiG1MUJ (ORCPT ); Thu, 28 Jul 2022 08:20:09 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A9CBDEC for ; Thu, 28 Jul 2022 05:20:08 -0700 (PDT) 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use helper macro SZ_1K, SZ_1M and SZ_1G to do the size conversion. Minor readability improvement. Signed-off-by: Miaohe Lin --- 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; } -- 2.23.0