From patchwork Wed Sep 8 22:18:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12481881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7254C433FE for ; Wed, 8 Sep 2021 22:18:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 845326113A for ; Wed, 8 Sep 2021 22:18:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 845326113A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 27AC86B0073; Wed, 8 Sep 2021 18:18:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 229FA6B0074; Wed, 8 Sep 2021 18:18:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F0E46B0075; Wed, 8 Sep 2021 18:18:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id F1DD86B0073 for ; Wed, 8 Sep 2021 18:18:02 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9009E8249980 for ; Wed, 8 Sep 2021 22:18:02 +0000 (UTC) X-FDA: 78565820004.24.8111444 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf16.hostedemail.com (Postfix) with ESMTP id 46B03F00008C for ; Wed, 8 Sep 2021 22:18:02 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 5B6E761166; Wed, 8 Sep 2021 22:18:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1631139481; bh=/86B/oJOImUzQJj8YYpw9OE2C2agTidEvnZ/CVTjXoA=; h=Date:From:To:Subject:In-Reply-To:From; b=JtMNhsgq3+ta7M5WzONOJJ6yhqYRMCTjimxRrOFILI3atqf0TzyBukg0FA7fD6PJ6 Z1/tjaFj06UuQStqkDEp5qfAM4HzY10NNEsA2bBiHGpVAGsPYN5nXztA0fEnYVrfq7 NM4LzasWYGqB5DmRT4ILPUFxS6BKF3F+VPWAjbv0= Date: Wed, 08 Sep 2021 15:18:01 -0700 From: Andrew Morton To: akpm@linux-foundation.org, apopple@nvidia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, shy828301@gmail.com, torvalds@linux-foundation.org, willy@infradead.org Subject: [patch 02/10] mm: migrate: introduce a local variable to get the number of pages Message-ID: <20210908221801.pXExhc7i6%akpm@linux-foundation.org> In-Reply-To: <20210908151729.c9a15a9508ba0aed22289c76@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 46B03F00008C Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=JtMNhsgq; dmarc=none; spf=pass (imf16.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Stat-Signature: 3fu7nucgcxfnpzgrmwj5kz8o64zy6i15 X-HE-Tag: 1631139482-110312 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: From: Baolin Wang Subject: mm: migrate: introduce a local variable to get the number of pages Use thp_nr_pages() instead of compound_nr() to get the number of pages for THP page, meanwhile introducing a local variable 'nr_pages' to avoid getting the number of pages repeatedly. Link: https://lkml.kernel.org/r/a8e331ac04392ee230c79186330fb05e86a2aa77.1629447552.git.baolin.wang@linux.alibaba.com Signed-off-by: Baolin Wang Reviewed-by: Yang Shi Cc: Alistair Popple Cc: Matthew Wilcox Signed-off-by: Andrew Morton --- mm/migrate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/mm/migrate.c~mm-migrate-introduce-a-local-variable-to-get-the-number-of-pages +++ a/mm/migrate.c @@ -2107,6 +2107,7 @@ out: static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) { int page_lru; + int nr_pages = thp_nr_pages(page); VM_BUG_ON_PAGE(compound_order(page) && !PageTransHuge(page), page); @@ -2115,7 +2116,7 @@ static int numamigrate_isolate_page(pg_d return 0; /* Avoid migrating to a node that is nearly full */ - if (!migrate_balanced_pgdat(pgdat, compound_nr(page))) + if (!migrate_balanced_pgdat(pgdat, nr_pages)) return 0; if (isolate_lru_page(page)) @@ -2123,7 +2124,7 @@ static int numamigrate_isolate_page(pg_d page_lru = page_is_file_lru(page); mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON + page_lru, - thp_nr_pages(page)); + nr_pages); /* * Isolating the page has taken another reference, so the