From patchwork Tue Jul 26 13:11:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 12929273 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 03617C433EF for ; Tue, 26 Jul 2022 13:04:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 360118E0002; Tue, 26 Jul 2022 09:04:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 30FE98E0001; Tue, 26 Jul 2022 09:04:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D8768E0002; Tue, 26 Jul 2022 09:04:55 -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 0FBF98E0001 for ; Tue, 26 Jul 2022 09:04:55 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D6A3BC08AC for ; Tue, 26 Jul 2022 13:04:54 +0000 (UTC) X-FDA: 79729270908.11.DD0FCEA Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf07.hostedemail.com (Postfix) with ESMTP id 15F7E4009A for ; Tue, 26 Jul 2022 13:04:48 +0000 (UTC) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LscTr5tmpzWfVM; Tue, 26 Jul 2022 21:00:48 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 26 Jul 2022 21:04:42 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 26 Jul 2022 21:04:41 +0800 From: Kefeng Wang To: David Hildenbrand , Oscar Salvador , Andrew Morton , CC: Jason Wang , "Michael S. Tsirkin" , , Kefeng Wang Subject: [PATCH] mm: use is_zone_movable_page() helper Date: Tue, 26 Jul 2022 21:11:35 +0800 Message-ID: <20220726131135.146912-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658840689; 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: references; bh=jg290DhJWhnHz7r4TdH03/RkYHGgGEaKbd3Kc++y/iM=; b=KDDIcV5xlEaA+qlguld1JU5uvt/nKm1Utmk5bK1bBDWcpOjqXKWLjJeF0R9kSXm4E4Aa8R bh480PHKzVLefuRn0F1OFvAFMOFIftzhssfgD7jqyVatDiZfO9o4qh4Mp5aDEpJHHv7PK4 MRe0tTOysqpV2iPak0K/usnTfI+iAEQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658840689; a=rsa-sha256; cv=none; b=PXLAgZzaSe8N2M0DJD4gZDJy42fi3x+et8vkMB7ZrBoj1F1VDgBFIR8QYNcXpAghGMmCVe 6xF295orgft9Kk/5//39pK14QDwkrG4d66l8nm2ktqJqWgEWeJoy3QoCYBJVQexNmTR/nE TN48ICtQRULx3bEH9c8uAap4qjlH18Y= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com X-Stat-Signature: ux1dhkk3brcge17zaj7tc4h4hzekhbpq X-Rspamd-Queue-Id: 15F7E4009A X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1658840688-863668 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 is_zone_movable_page() helper to simplify code. Signed-off-by: Kefeng Wang Reviewed-by: David Hildenbrand Acked-by: Jason Wang Reviewed-by: Pankaj Gupta --- drivers/virtio/virtio_mem.c | 6 ++---- mm/memory_hotplug.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index e07486f01999..0c2892ec6817 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -862,8 +862,7 @@ static void virtio_mem_sbm_notify_online(struct virtio_mem *vm, unsigned long mb_id, unsigned long start_pfn) { - const bool is_movable = page_zonenum(pfn_to_page(start_pfn)) == - ZONE_MOVABLE; + const bool is_movable = is_zone_movable_page(pfn_to_page(start_pfn)); int new_state; switch (virtio_mem_sbm_get_mb_state(vm, mb_id)) { @@ -1158,8 +1157,7 @@ static void virtio_mem_fake_online(unsigned long pfn, unsigned long nr_pages) */ static int virtio_mem_fake_offline(unsigned long pfn, unsigned long nr_pages) { - const bool is_movable = page_zonenum(pfn_to_page(pfn)) == - ZONE_MOVABLE; + const bool is_movable = is_zone_movable_page(pfn_to_page(pfn)); int rc, retry_count; /* diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 1213d0c67a53..0f5914964a32 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -936,7 +936,7 @@ static struct zone *auto_movable_zone_for_pfn(int nid, if (!page) continue; /* If anything is !MOVABLE online the rest !MOVABLE. */ - if (page_zonenum(page) != ZONE_MOVABLE) + if (!is_zone_movable_page(page)) goto kernel_zone; online_pages += PAGES_PER_SECTION; }