From patchwork Thu Jul 28 12:19:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12931192 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 EA4DEC04A68 for ; Thu, 28 Jul 2022 12:20:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DBAB6B0072; Thu, 28 Jul 2022 08:20:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08EA88E0002; Thu, 28 Jul 2022 08:20:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E8BD46B0074; Thu, 28 Jul 2022 08:20:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D84066B0071 for ; Thu, 28 Jul 2022 08:20:09 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9CDB2AB755 for ; Thu, 28 Jul 2022 12:20:09 +0000 (UTC) X-FDA: 79736415738.14.EBF1758 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf01.hostedemail.com (Postfix) with ESMTP id CCA61400C5 for ; Thu, 28 Jul 2022 12:20:08 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LtqQy3lyWzlVsF; Thu, 28 Jul 2022 20:17:30 +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:04 +0800 From: Miaohe Lin To: CC: , , , , Subject: [PATCH 1/6] hugetlb_cgroup: remove unneeded nr_pages > 0 check Date: Thu, 28 Jul 2022 20:19:44 +0800 Message-ID: <20220728121949.20985-2-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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659010809; a=rsa-sha256; cv=none; b=O43JIUMpb5IlMCifdMvWRDq72bP8hIhiHDESwlZXu0+eNmP9HXjofjjbvU4K4e3CQRHw6E jbwQsmsu/dHgOJY62qoxkaZ/F2SxrGnUFd25sSCQSx/BX/XhzJG/9ztR4tpfo4nKpF+s8r FB0nYfG2B3R5Gp3hTUrzansg24h0Llg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.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=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=bk4cKHKgikA2vyM2dn1DknUbHeBKPZsSfduFmFPoKs0=; b=vSjNomCf6Kg0/YX/+/m74tSr5Yvqc+5DZeBhSXmz8SAIM3PTVT2JG7ZxCl9LMfGv/EFyrp Mf+vrifThPjKxvMYwKfxqUu0kispLWr+hwyIzTLPgiIV9VWVHX/3y8vyxoam+eos7RNbXy YiEkpFq64FZt4lCYmowuWOraMlAfO0g= X-Rspamd-Queue-Id: CCA61400C5 X-Rspam-User: X-Stat-Signature: a8ianyptepeu58z5aqnm9i7fc18n3iey Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam08 X-HE-Tag: 1659010808-165340 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);