From patchwork Fri Jul 29 08:01:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12932114 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 3F6D4C19F2C for ; Fri, 29 Jul 2022 08:01:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3EE4B6B0073; Fri, 29 Jul 2022 04:01:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 34B186B0072; Fri, 29 Jul 2022 04:01:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0E446B0073; Fri, 29 Jul 2022 04:01:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B673994000A for ; Fri, 29 Jul 2022 04:01:28 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 72F911A11A4 for ; Fri, 29 Jul 2022 08:01:26 +0000 (UTC) X-FDA: 79739392572.15.AAF316F Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf02.hostedemail.com (Postfix) with ESMTP id 924B7800A0 for ; Fri, 29 Jul 2022 08:01:25 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LvKdZ05Rjz19VdF; Fri, 29 Jul 2022 15:58:26 +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 1/5] hugetlb_cgroup: remove unneeded nr_pages > 0 check Date: Fri, 29 Jul 2022 16:01:02 +0800 Message-ID: <20220729080106.12752-2-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-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 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=1659081685; a=rsa-sha256; cv=none; b=qFmf+tWNDH0MhXXU+ilJ8cEB0/jNBfIeGQpVLNDby0AY42n9gBzmu841aA8PhyuqEItLFh +vYakVH4R8FllmZ1rihU+DrPj7+wBSBScHGGv6D69nmLQU8dfPA7NzQhan6WSuHxC44/Mk HugTcxH7p8eNU80SAD9EebZQS/Ddil0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659081685; 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=/AGRNrl5cXhKu7JRlCKA2uuL1YG6tIafvSEuZWoxVHQ=; b=v3Qr/Ver2pyaEb0rLFlcXhVyN1Q4mFOrmlXh97gTMNrVkDQmdTnYPtTELnRVhZqLp7IaLo xMtoWzEKfkRDC0TY3Yl1ZZSfoml/8vbQGduedAf097DHSfQnvwFWDmZFq+hFon+4tq6m0A KGGv3guZjiBzlpq1cV2wxdF4zR8dqg4= Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam04 X-Rspam-User: X-Stat-Signature: y5izwoj9aiugcdjjrr69kit1ihbtez4w X-Rspamd-Queue-Id: 924B7800A0 X-HE-Tag: 1659081685-827132 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: When code reaches here, nr_pages must be > 0. Remove unneeded nr_pages > 0 check to simplify the code. Signed-off-by: Miaohe Lin Reviewed-by: Mina Almasry --- mm/hugetlb_cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index c86691c431fd..d16eb00c947d 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -442,7 +442,7 @@ void hugetlb_cgroup_uncharge_file_region(struct resv_map *resv, if (hugetlb_cgroup_disabled() || !resv || !rg || !nr_pages) return; - if (rg->reservation_counter && resv->pages_per_hpage && nr_pages > 0 && + if (rg->reservation_counter && resv->pages_per_hpage && !resv->reservation_counter) { page_counter_uncharge(rg->reservation_counter, nr_pages * resv->pages_per_hpage);