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); From patchwork Thu Jul 28 12:19:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12931196 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 1FC47C19F21 for ; Thu, 28 Jul 2022 12:20:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1BC506B0074; Thu, 28 Jul 2022 08:20:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 144A66B0075; Thu, 28 Jul 2022 08:20:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00BF08E0001; Thu, 28 Jul 2022 08:20:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E2FA76B0074 for ; Thu, 28 Jul 2022 08:20:10 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B97C01A0FA6 for ; Thu, 28 Jul 2022 12:20:10 +0000 (UTC) X-FDA: 79736415780.12.B3965FD Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf13.hostedemail.com (Postfix) with ESMTP id 1E83B200B5 for ; Thu, 28 Jul 2022 12:20:09 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LtqQZ3krgzjXNm; Thu, 28 Jul 2022 20:17:10 +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 2/6] hugetlb_cgroup: remove unneeded header file Date: Thu, 28 Jul 2022 20:19:45 +0800 Message-ID: <20220728121949.20985-3-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; imf13.hostedemail.com; dkim=none; spf=pass (imf13.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=1659010810; a=rsa-sha256; cv=none; b=d3ACfgkT1CAf24YhbX8x447TQzQ/Q8mrpPtm66mWyZvc50asXlQhDI1cZB51Mc5XKULdmI lET5wytMPQEhJEIrn2oeVcSa+rXWbYrrw9A5xqjIFZRc6ghTlYv54ylTPOwTO6BRhJaOOo fOYJ4Z4d0D1gWB3ABtihatvSfbNxVEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659010810; 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=+v6j4nhpZMz2JVzWdVJNu63/KR7x7RwrMAHX8hmQ2i4=; b=mfXw+BdgBsbUa2XKcTryiRDkns1Enj6614hYzVwrj+owXn9yQtKTgm8BuBG0oKSnGYaz+i IC5QVBRhSFBu/tftJqU6lGtcnbcDp/O0ZPStN5leszFv3BrrvtYiQwDcAZFyCsYPsIiL3/ IeulUweTjOm5TGPQgvf4muarJB7A4oc= Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.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-Rspamd-Server: rspam04 X-Rspam-User: X-Stat-Signature: gw3rb1w5knogr6mw3cio47hoqbjeati6 X-Rspamd-Queue-Id: 1E83B200B5 X-HE-Tag: 1659010809-109638 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: The header file slab.h is unneeded now. Remove it. Signed-off-by: Miaohe Lin Acked-by: Mina Almasry --- mm/hugetlb_cgroup.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index d16eb00c947d..99e9a367e1e5 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -19,7 +19,6 @@ #include #include -#include #include #include 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; } From patchwork Thu Jul 28 12:19:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12931198 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 92F61C19F21 for ; Thu, 28 Jul 2022 12:20:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 713D56B0078; Thu, 28 Jul 2022 08:20:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C2FE6B007B; Thu, 28 Jul 2022 08:20:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53FA78E0001; Thu, 28 Jul 2022 08:20:12 -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 45EAC6B0078 for ; Thu, 28 Jul 2022 08:20:12 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 20175140F4E for ; Thu, 28 Jul 2022 12:20:12 +0000 (UTC) X-FDA: 79736415864.08.1465FA0 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf27.hostedemail.com (Postfix) with ESMTP id 83638400CD for ; Thu, 28 Jul 2022 12:20:10 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LtqSZ6Bncz9sv0; Thu, 28 Jul 2022 20:18:54 +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 4/6] hugetlb_cgroup: remove unneeded return value Date: Thu, 28 Jul 2022 20:19:47 +0800 Message-ID: <20220728121949.20985-5-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=1659010810; a=rsa-sha256; cv=none; b=cuZpmRRxEvi3j6UuQBDnYejD2dp2S93qd7rV5OpiTh8I+zfdph9iHgJHgHesRWZ4YepUB3 gFAbzI+v9HtgNUKwjOOmQapH7fVnCCphucf31wseAhK4i2hrsBMCxko7dKogx5OK6GIiIh DZe35yvAiGDzxCHDCntvmJpQBouzcFs= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 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=1659010810; 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=yWMae9ZvoZYWv6IzsggsR9Xo2U1sf4XjkBQerFzS1bE=; b=YNNlSrFD4uAErCJ+mXUS0hmLtfG51eqWViVnDjrcbmTiKcMuURO1uPeojixogPZAp7aRuc HP5ZDBk1b8BCSl1IwPTfecxLpZxEDTSKibvWDV1cXsBWjr5g2Itd6e40VWe3OlZYBPUrlR gZyghq8C7bXEnTmwlpKxRXgE9DUc75M= X-Rspamd-Queue-Id: 83638400CD X-Rspam-User: X-Stat-Signature: te1ouoaar3hon1684je1whuy8jh4ymdg Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam08 X-HE-Tag: 1659010810-778137 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: The return value of set_hugetlb_cgroup and set_hugetlb_cgroup_rsvd are always ignored. Remove them to clean up the code. Signed-off-by: Miaohe Lin Reviewed-by: Mike Kravetz --- include/linux/hugetlb_cgroup.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h index 379344828e78..630cd255d0cf 100644 --- a/include/linux/hugetlb_cgroup.h +++ b/include/linux/hugetlb_cgroup.h @@ -90,32 +90,31 @@ hugetlb_cgroup_from_page_rsvd(struct page *page) return __hugetlb_cgroup_from_page(page, true); } -static inline int __set_hugetlb_cgroup(struct page *page, +static inline void __set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg, bool rsvd) { VM_BUG_ON_PAGE(!PageHuge(page), page); if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER) - return -1; + return; if (rsvd) set_page_private(page + SUBPAGE_INDEX_CGROUP_RSVD, (unsigned long)h_cg); else set_page_private(page + SUBPAGE_INDEX_CGROUP, (unsigned long)h_cg); - return 0; } -static inline int set_hugetlb_cgroup(struct page *page, +static inline void set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg) { - return __set_hugetlb_cgroup(page, h_cg, false); + __set_hugetlb_cgroup(page, h_cg, false); } -static inline int set_hugetlb_cgroup_rsvd(struct page *page, +static inline void set_hugetlb_cgroup_rsvd(struct page *page, struct hugetlb_cgroup *h_cg) { - return __set_hugetlb_cgroup(page, h_cg, true); + __set_hugetlb_cgroup(page, h_cg, true); } static inline bool hugetlb_cgroup_disabled(void) @@ -199,16 +198,14 @@ hugetlb_cgroup_from_page_rsvd(struct page *page) return NULL; } -static inline int set_hugetlb_cgroup(struct page *page, +static inline void set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg) { - return 0; } -static inline int set_hugetlb_cgroup_rsvd(struct page *page, +static inline void set_hugetlb_cgroup_rsvd(struct page *page, struct hugetlb_cgroup *h_cg) { - return 0; } static inline bool hugetlb_cgroup_disabled(void) From patchwork Thu Jul 28 12:19:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12931197 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 CD148C04A68 for ; Thu, 28 Jul 2022 12:20:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE6DA6B0075; Thu, 28 Jul 2022 08:20:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F8256B0078; Thu, 28 Jul 2022 08:20:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BE138E0001; Thu, 28 Jul 2022 08:20:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7D4206B0075 for ; Thu, 28 Jul 2022 08:20:11 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5237C80F63 for ; Thu, 28 Jul 2022 12:20:11 +0000 (UTC) X-FDA: 79736415822.31.967FD3A Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf10.hostedemail.com (Postfix) with ESMTP id B4659C00AA for ; Thu, 28 Jul 2022 12:20:10 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LtqSb2DTSz9svq; Thu, 28 Jul 2022 20:18:55 +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:06 +0800 From: Miaohe Lin To: CC: , , , , Subject: [PATCH 5/6] hugetlb_cgroup: use helper macro NUMA_NO_NODE Date: Thu, 28 Jul 2022 20:19:48 +0800 Message-ID: <20220728121949.20985-6-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=1659010811; a=rsa-sha256; cv=none; b=c7colyTiiZx/xfxwqJj7hubUvN8w3pOt8TkC2VW1i5eGxPmxjoZIuWh+0QV09B05xP6IpS PUdpyIjAJgg8unRCoqHZvHktrUPRem+fLWSDCPG5JPUCVKbWYVTzoSGEIUNcpGcb+GFZWJ WcRS1BKGPMp5IRhqS7K8KYDZG3lyb+U= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 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=1659010811; 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=MgyhmvMq7xlcwCXjOdf9or2ojdpUHLN3+s74D0iDNX0=; b=LoPYTclkmkE4n9/XzKTb8cvO+P73oBedr6Cg6QSlkmVwDHh8VY/pRmZi2ixF53U7pCkzn1 MMZUjf4YHZUpBsYv6csJ6O3ZIxG+FpgLTp1k8tokFsRnXDb2dCUUdgRZNX0+6Ve/abw9vF B4ymA3BVG8bSXbo84GUsUtIfxbxES7s= X-Rspamd-Queue-Id: B4659C00AA X-Rspam-User: X-Stat-Signature: aka5uhq8ppinqegf1se4eu94mmjr5kx4 Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam08 X-HE-Tag: 1659010810-442466 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: It's better to use NUMA_NO_NODE instead of magic number -1. Minor readability improvement. Signed-off-by: Miaohe Lin Reviewed-by: Mina Almasry --- mm/hugetlb_cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 7e0bca52c40f..13ec091385af 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -153,9 +153,9 @@ hugetlb_cgroup_css_alloc(struct cgroup_subsys_state *parent_css) * function. */ for_each_node(node) { - /* Set node_to_alloc to -1 for offline nodes. */ + /* Set node_to_alloc to NUMA_NO_NODE for offline nodes. */ int node_to_alloc = - node_state(node, N_NORMAL_MEMORY) ? node : -1; + node_state(node, N_NORMAL_MEMORY) ? node : NUMA_NO_NODE; h_cgroup->nodeinfo[node] = kzalloc_node(sizeof(struct hugetlb_cgroup_per_node), GFP_KERNEL, node_to_alloc); From patchwork Thu Jul 28 12:19:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12931195 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 51503C04A68 for ; Thu, 28 Jul 2022 12:20:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA8E26B0073; Thu, 28 Jul 2022 08:20:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B56676B0074; 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 A1DC96B0075; Thu, 28 Jul 2022 08:20:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8716A6B0073 for ; Thu, 28 Jul 2022 08:20:10 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5BDD0A12E2 for ; Thu, 28 Jul 2022 12:20:10 +0000 (UTC) X-FDA: 79736415780.02.3B54FC8 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf24.hostedemail.com (Postfix) with ESMTP id BBB961800CC 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 4LtqRr3V2DzmVML; Thu, 28 Jul 2022 20:18:16 +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:06 +0800 From: Miaohe Lin To: CC: , , , , Subject: [PATCH 6/6] hugetlb_cgroup: use helper for_each_hstate and hstate_index Date: Thu, 28 Jul 2022 20:19:49 +0800 Message-ID: <20220728121949.20985-7-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=1659010810; a=rsa-sha256; cv=none; b=KzPFAJYTVx/fl9co+M6qeeRBdJ3A1J3uBv6xawkKo4h7mWeU5byvjQjM99TqsdoydXU/UI fkKy3aklSx1wORISVtv70oTeMB4jvzB8EqWITWuaiCqyh1hq2XHdVwLTMWAi0Ic5LbWt0g EdUWdMobrFHo6R00XIZPhqEb2YvK2zM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 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=1659010810; 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=ZpOzjgnlMlGSD2f0h+2bWNmv1PniCvgWU0Us6t7IIO8=; b=t+KdR3c4s6x7ssvwTA7PLBDI5X9WeLfT5EAPwByl2nZ05G/pT3YFZj4fneUPp8JsiBmd7N +mcR8tKyxrnhf/si+WZ2jKl6hye9bLuZ4xrmVfwhf5TngZ2P9jSu1k4FLiXxeP2FDMThP0 gb9zoxbKp1BMVb8534PzEAisEM5K+Sg= X-Stat-Signature: axg7m56wd1k7a68jghwmd7urfdt8j6iw X-Rspamd-Queue-Id: BBB961800CC Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1659010809-963283 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 for_each_hstate and hstate_index to iterate the hstate and get the hstate index. Minor readability improvement. Signed-off-by: Miaohe Lin Reviewed-by: Mina Almasry --- mm/hugetlb_cgroup.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 13ec091385af..8f20082df4c8 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -74,11 +74,11 @@ parent_hugetlb_cgroup(struct hugetlb_cgroup *h_cg) static inline bool hugetlb_cgroup_have_usage(struct hugetlb_cgroup *h_cg) { - int idx; + struct hstate *h; - for (idx = 0; idx < hugetlb_max_hstate; idx++) { + for_each_hstate(h) { if (page_counter_read( - hugetlb_cgroup_counter_from_cgroup(h_cg, idx))) + hugetlb_cgroup_counter_from_cgroup(h_cg, hstate_index(h)))) return true; } return false; @@ -224,17 +224,14 @@ static void hugetlb_cgroup_css_offline(struct cgroup_subsys_state *css) struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_css(css); struct hstate *h; struct page *page; - int idx; do { - idx = 0; for_each_hstate(h) { spin_lock_irq(&hugetlb_lock); list_for_each_entry(page, &h->hugepage_activelist, lru) - hugetlb_cgroup_move_parent(idx, h_cg, page); + hugetlb_cgroup_move_parent(hstate_index(h), h_cg, page); spin_unlock_irq(&hugetlb_lock); - idx++; } cond_resched(); } while (hugetlb_cgroup_have_usage(h_cg));