Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp821229ybt; Tue, 7 Jul 2020 00:47:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8LZPO7u5TsvWOAkrcbg5oLTdYNikI+gL/4tV85GlUI3+XD62miLBHhfHsui0JhDqGG3fM X-Received: by 2002:a17:906:57da:: with SMTP id u26mr47799851ejr.157.1594108070162; Tue, 07 Jul 2020 00:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594108070; cv=none; d=google.com; s=arc-20160816; b=pImNONiTC8woevp0jpTp7NFE05MtUeCkNaflK5yzfbfu0Z6os7ISfwxxNiY/oIp0uR rGsSWLlvQ3xmMB8hAOBlZiaHWqFjVz/Y+HuskjJFxkwldXVCbSII7bjhhzdcy7mtUc93 jQUJrocOf3P1+N/1uoHcBQV4ScwhZA2yTJciBSu/u7jCrWTmWWYRCFUegBjlKgxlV0CR F0h4h67cuuHuoE0VviIsj5yRBr9prECVaQIQf3fiM70dcOLqMOMMFfyOAYvt2zZ88Qxs mL/m73+sIo5xhI5nKuoI9+RtcFBQI1SYrjQrdF07kCjW8EArMfYhzuSnI+d41fHNygub IQ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=KgSYgJifAABNAdCl31WAEwkkXwU/m9EAOT3Cz401Kt8=; b=dWR9irNCu2PRFoT9qcDSljxUmKJtpXm131jptHhl1Ymp83y7trw1y5+R6fpZ3Vtdbe AWAyUF4diLbTI6/tEHByjEDkgWZczBXg+bNb2+p+8GuyBswy8mDBPSPM1gbrRcwPA78R RTKtEt2FVDE7ME41wyuL8PbkMcahgwzITTFl1iWJUzjv9uw9KxN7kMfygR/jmc7HS4Ic MrJsDQ9G1byyBV9fdV+xBD5kqFcWF5BPeo0b7khIDt0T3KDwWyeUwpaYcFGxKjA2vmjy tnPK4WqLMO34X2UIOf3Y9/OZNhQxmGP1zZSS4jgyaZOGgw6794jEdwNgHFQmvfcAG/b5 3f3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hLhvTve8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v25si14137476ejx.496.2020.07.07.00.47.25; Tue, 07 Jul 2020 00:47:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hLhvTve8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728500AbgGGHps (ORCPT + 99 others); Tue, 7 Jul 2020 03:45:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728440AbgGGHpq (ORCPT ); Tue, 7 Jul 2020 03:45:46 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 911A8C061755 for ; Tue, 7 Jul 2020 00:45:46 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id u18so2770032pfk.10 for ; Tue, 07 Jul 2020 00:45:46 -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=KgSYgJifAABNAdCl31WAEwkkXwU/m9EAOT3Cz401Kt8=; b=hLhvTve8x5zI3uXWp0qoUJQ29QsztVfkJaD3Ks6ZD1fprMNLVmGC6HZZP4lfhXGhog AHJj7XueKuRo+AKpUnqm8ewpNXzKFaHEes5S7LF/3eQOUFGO6rxTLUhS7qbSNvJV4f+P phOZGS49CF3yCcbvwkFmdBdSm1T9OUClKDCCZ6Z/qBBKbAX2x2sTGFDnD5AC5eTLI9yR k1vdl+vTHP086FJgF0xZ/mFgZTlP27So2vTNLVaIuSb3ftZDzmDmnT0nHIaFnkwL8Skb oHuVk/M7PGu4KdAovMw3oIcOl3VpnESvfZnuyj2OpD2wcIYySGWZvc1fLMO0hec0N9Lp t10A== 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=KgSYgJifAABNAdCl31WAEwkkXwU/m9EAOT3Cz401Kt8=; b=Sww20ojh4+JPlJ1zyfUk4Y+RIn759FK9O8dLsMsB9zpB0sNTw0HkLs5G0K5vlh4XkM Dp8J3/H6j2RrBYCjJHUXdeAFU/xIH3G6/+1OSU4x7jnFpzXxcd8+Ypkm8IjhgBrTG8sd 5R+Zq+o1mRCwnfmSU+d7zhGJnQDZeJJP74XtdL8FNmG/dP0QklXIGvMCZde9xxSbCLME yG5nqF9iznvC4BF7M5uUR1I0LPMup4I0TGvf9Txw0QZT0cy88pQrjrq9oJEfKzEyGx++ tBVj6sWQek0diZBBeIrtHjiexfktzPVZWRTLOdEBRxwCxhqAZ34DvW6ykN5IvEnRr9in k7kQ== X-Gm-Message-State: AOAM533jKRk2yJGgv2mMGoe6HuknsCN62Nfg8j7yl8NJG5lY+UOWPNyP pb07EKBCJeW7MfnEZuhvcvc= X-Received: by 2002:a65:5502:: with SMTP id f2mr8232183pgr.375.1594107946170; Tue, 07 Jul 2020 00:45:46 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 191sm21330151pfw.150.2020.07.07.00.45.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 00:45:45 -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 v4 11/11] mm/memory_hotplug: remove a wrapper for alloc_migration_target() Date: Tue, 7 Jul 2020 16:44:49 +0900 Message-Id: <1594107889-32228-12-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594107889-32228-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1594107889-32228-1-git-send-email-iamjoonsoo.kim@lge.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 86bc2ad..269e8ca 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, *mtc.nmask); - if (nodes_empty(*mtc.nmask)) - node_set(mtc.nid, *mtc.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, *mtc.nmask); + if (nodes_empty(*mtc.nmask)) + node_set(mtc.nid, *mtc.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