From patchwork Tue Jun 28 13:28:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12898296 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 B45D3CCA479 for ; Tue, 28 Jun 2022 13:28:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 782828E000B; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 498058E000D; Tue, 28 Jun 2022 09:28:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24DCB8E0009; Tue, 28 Jun 2022 09:28:49 -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 E64CB8E000C for ; Tue, 28 Jun 2022 09:28:48 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B34F7896 for ; Tue, 28 Jun 2022 13:28:48 +0000 (UTC) X-FDA: 79627724736.13.8555245 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf21.hostedemail.com (Postfix) with ESMTP id 293991C0024 for ; Tue, 28 Jun 2022 13:28:48 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LXQQD4qlWz9skG; Tue, 28 Jun 2022 21:28:04 +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; Tue, 28 Jun 2022 21:28:43 +0800 From: Miaohe Lin To: CC: , , , , , , Subject: [PATCH v2 12/16] mm/huge_memory: minor cleanup for split_huge_pages_all Date: Tue, 28 Jun 2022 21:28:31 +0800 Message-ID: <20220628132835.8925-13-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220628132835.8925-1-linmiaohe@huawei.com> References: <20220628132835.8925-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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656422928; a=rsa-sha256; cv=none; b=bPQrCqvZChHJmZfnmuia8kcb5c/xyUG7c4SDRSciwbENK+xATz6PbqDp01b6Ayy/InV0I+ xDJLlixS4xh17TM0mOH0bu4ceNnJ4Jd9aV6yYvDkqjNWBkGmcOPkhXV5tHT+tscr/Hb20b 6Ll7YgTWy8aGyi9Td5plLrIZ0o/gFAQ= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656422928; 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=MnsL7pXT73vfl7zOZ3MxFqXXtKUWvwiDrKAN2i6LEIs=; b=d53bY+H/5hddBZMuWdlR/JkAsH8UPbz6aPqawKIN+X/I4SyCXb9a4lLCkcvVnVX6Utsd21 QHRk0y/6Pd1xM3Ae09QuNb1ABfl1GYQLu6EA444qOvLyTyW96XfsjRuq67obFgMRjktMGS M2fPda13QT/EX0XToOLZ68RPNFuiZRM= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 293991C0024 Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Stat-Signature: ms4zdiygqtppenytas5obgoyb9i451rm X-HE-Tag: 1656422928-975400 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 bded58ada414..5ea932beef22 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2956,9 +2956,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; @@ -2974,8 +2977,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);