From patchwork Wed Jun 22 17:06:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891180 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 A7E55C433EF for ; Wed, 22 Jun 2022 17:07:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C75958E00D5; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 996D38E00D6; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 677F38E00D1; Wed, 22 Jun 2022 13:06:54 -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 443378E00D3 for ; Wed, 22 Jun 2022 13:06:54 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 228848118C for ; Wed, 22 Jun 2022 17:06:54 +0000 (UTC) X-FDA: 79606501548.06.5E728B3 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf18.hostedemail.com (Postfix) with ESMTP id 7E11A1C0016 for ; Wed, 22 Jun 2022 17:06:49 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LSqT85tK4zShBY; Thu, 23 Jun 2022 01:03:08 +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, 23 Jun 2022 01:06:32 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 12/16] mm/huge_memory: minor cleanup for split_huge_pages_all Date: Thu, 23 Jun 2022 01:06:23 +0800 Message-ID: <20220622170627.19786-13-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917609; a=rsa-sha256; cv=none; b=aOR1k2WChoYMxrTCfoB7mpqEpH/kx8oFkoBZk4Y0FemiA31FYuBMz7BIxhxiGvLlAVXeSj hEitStlG6Er8FdJu5LjpzexbOJlox4ZZzkGC9MI9v5Fqu5Jury/iTLEpQKMPUZXpHiDm8D 35QkSvr9sV2E8y0XsdPIR3MR48qEeDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655917609; 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=RIOt7QIGP4ypomvGQ3TBO5jZwJNbtWFYEHxfhbxcgeo=; b=8YGHiKAiSTegpztz9wOoHZwjutZWcq6SGc/U4Kzp+ANiaM1q16oL71RUpjU7ySSGqgVPAz 3ZATZKdWgOcdiOjJqasSk+Mwr15cSnOwvXB4h/Mza0SdQmVPcmC2jKY67UEmuwJsGWzM2J eaQq6iT4flLE/RBJc/IOD0gv/NQn7ho= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Rspamd-Queue-Id: 7E11A1C0016 Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: iyinbbe1j45668zh9pi8hehowkke5eya X-Rspamd-Server: rspam09 X-HE-Tag: 1655917609-83647 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: There is nothing to do if a zone doesn't have any pages managed by the buddy allocator. So we should check managed_zone instead. Also if a thp is found, there's no need to traverse the subpages again. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 506e7a682780..0030b4f67cd9 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2858,9 +2858,12 @@ static void split_huge_pages_all(void) unsigned long total = 0, split = 0; pr_debug("Split all THPs\n"); - for_each_populated_zone(zone) { + for_each_zone(zone) { + if (!managed_zone(zone)) + continue; max_zone_pfn = zone_end_pfn(zone); for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) { + int nr_pages; if (!pfn_valid(pfn)) continue; @@ -2876,8 +2879,10 @@ static void split_huge_pages_all(void) total++; lock_page(page); + nr_pages = thp_nr_pages(page); if (!split_huge_page(page)) split++; + pfn += nr_pages - 1; unlock_page(page); next: put_page(page);