From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 D5E60C433F8 for ; Mon, 13 Jul 2020 06:42:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9A34420720 for ; Mon, 13 Jul 2020 06:42:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AZB4uQqX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A34420720 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 408958D000E; Mon, 13 Jul 2020 02:42:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B9B38D0002; Mon, 13 Jul 2020 02:42:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25A308D000E; Mon, 13 Jul 2020 02:42:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0045.hostedemail.com [216.40.44.45]) by kanga.kvack.org (Postfix) with ESMTP id 11BB58D0002 for ; Mon, 13 Jul 2020 02:42:45 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C9FF81EFD for ; Mon, 13 Jul 2020 06:42:44 +0000 (UTC) X-FDA: 77032109448.16.hat71_4016ae826ee6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 92592100E690B for ; Mon, 13 Jul 2020 06:42:44 +0000 (UTC) X-HE-Tag: hat71_4016ae826ee6 X-Filterd-Recvd-Size: 6147 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jul 2020 06:42:44 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id ls15so5747606pjb.1 for ; Sun, 12 Jul 2020 23:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RMAOJW0/CmwPwEQhOEGIEPyh16r3aJTNjCuNXO3OJWw=; b=AZB4uQqXY6c9kubbJEswrTO/ZtxFCRCcCXxcRIeAq76C8iM4CZt2RAS4FUMZGDxans +fKptV+TKZx0eeYmhpKtTa25EkoObRsvtEbOZwGEEurWsvxUVK4dK4M7ghncW4DrSNy1 H4u7kcW2CvTkCDPTcAb/JJw/H8xv+IIJJJieJ8u9GECfgsodCAVM2uoVbYAyAtj5AJJV KHRSaGRSjBnzMEKyed3AQnwNyKQH3spdbaNOWkPza41TTK6YEXMT6WYtN1BKCmG56Qa8 B6kdgEN8x7WrjMubEjFt70/UrkVTEL66RJWtuaWALjDbVySBjeYQ0PSZipwgdi2WgmOJ lBxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RMAOJW0/CmwPwEQhOEGIEPyh16r3aJTNjCuNXO3OJWw=; b=lvFmDL10p+pM1W8lFoeTF9r+qnLtaIocw9HmCawthbft4Nymy0z005aS5dUpCrPLrC vawYcXevmQQ0kjtnBCD/GZVYeYmc4amRR4Rv4y28hk+zA82RK/MXCT/+O1Eu5XPJrOZE lElaMEMvNjEO/Fw/32NAldkAUMCGXOQWTnWLE4nGwGNSO9unu6fe5H8yF8QHPfEsMi54 SnHlYEg+IjwKDflpp4bujZ81CCf6LBXR3WDtQnZg5LisdbvTMiBzRYAI6pz1p0+SC2Yy VAySQPVUlcRNgS7PPMcB2EAy3XKN+rts1yh9jrnG+HC3+fHpoGd85evsNF4P0RuV4bOM GOXA== X-Gm-Message-State: AOAM532+OO6+Krdb5mdlx/ZkO/of+lPyZmM2IGkYXML2IHobqIBhM2cQ MthnGiHhLimp+eocpi37kfY= X-Google-Smtp-Source: ABdhPJxmeB8MEEIDLVv5USvjyzYJ9LQmHfHKPMcFOR38oMOIYgi4ke1nsR2D9huc7P4TGo3RkIv4sg== X-Received: by 2002:a17:90a:bf89:: with SMTP id d9mr18915464pjs.89.1594622563228; Sun, 12 Jul 2020 23:42:43 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id l134sm12448695pga.50.2020.07.12.23.42.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jul 2020 23:42:42 -0700 (PDT) From: js1304@gmail.com X-Google-Original-From: iamjoonsoo.kim@lge.com To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Vlastimil Babka , Christoph Hellwig , Roman Gushchin , Mike Kravetz , Naoya Horiguchi , Michal Hocko , Joonsoo Kim Subject: [PATCH v5 9/9] mm/memory_hotplug: remove a wrapper for alloc_migration_target() Date: Mon, 13 Jul 2020 15:41:57 +0900 Message-Id: <1594622517-20681-10-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594622517-20681-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1594622517-20681-1-git-send-email-iamjoonsoo.kim@lge.com> X-Rspamd-Queue-Id: 92592100E690B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: Joonsoo Kim To calculate the correct node to migrate the page for hotplug, we need to check node id of the page. Wrapper for alloc_migration_target() exists for this purpose. However, Vlastimil informs that all migration source pages come from a single node. In this case, we don't need to check the node id for each page and we don't need to re-set the target nodemask for each page by using the wrapper. Set up the migration_target_control once and use it for all pages. Acked-by: Vlastimil Babka Acked-by: Michal Hocko Signed-off-by: Joonsoo Kim --- mm/memory_hotplug.c | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 431b470f..7c216d6 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1265,27 +1265,6 @@ static int scan_movable_pages(unsigned long start, unsigned long end, return 0; } -static struct page *new_node_page(struct page *page, unsigned long private) -{ - nodemask_t nmask = node_states[N_MEMORY]; - struct migration_target_control mtc = { - .nid = page_to_nid(page), - .nmask = &nmask, - .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, - }; - - /* - * try to allocate from a different node but reuse this node if there - * are no other online nodes to be used (e.g. we are offlining a part - * of the only existing node) - */ - node_clear(mtc.nid, nmask); - if (nodes_empty(nmask)) - node_set(mtc.nid, nmask); - - return alloc_migration_target(page, (unsigned long)&mtc); -} - static int do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) { @@ -1345,9 +1324,28 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) put_page(page); } if (!list_empty(&source)) { - /* Allocate a new page from the nearest neighbor node */ - ret = migrate_pages(&source, new_node_page, NULL, 0, - MIGRATE_SYNC, MR_MEMORY_HOTPLUG); + nodemask_t nmask = node_states[N_MEMORY]; + struct migration_target_control mtc = { + .nmask = &nmask, + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + }; + + /* + * We have checked that migration range is on a single zone so + * we can use the nid of the first page to all the others. + */ + mtc.nid = page_to_nid(list_first_entry(&source, struct page, lru)); + + /* + * try to allocate from a different node but reuse this node + * if there are no other online nodes to be used (e.g. we are + * offlining a part of the only existing node) + */ + node_clear(mtc.nid, nmask); + if (nodes_empty(nmask)) + node_set(mtc.nid, nmask); + ret = migrate_pages(&source, alloc_migration_target, NULL, + (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_HOTPLUG); if (ret) { list_for_each_entry(page, &source, lru) { pr_warn("migrating pfn %lx failed ret:%d ", -- 2.7.4