Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp759137ybh; Sun, 12 Jul 2020 23:44:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb66Vf9R5vAftCjNdDM2vX0tp/LWMrx0F0Q1sKsW24nHhYoX1cAGhmCaGESbZPYfGXkYAI X-Received: by 2002:a05:6402:202e:: with SMTP id ay14mr89635416edb.233.1594622642570; Sun, 12 Jul 2020 23:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594622642; cv=none; d=google.com; s=arc-20160816; b=jQFz9LCerKz1GXilkHfhTs1LzplN4+fI/R7WNx/mHXPjJlscPEyyQ4RK2k5ROmnz6R 63HKO14nafkPJ2tIvQJNw5sR+KTtngdSD3iNR7kGreMZGmbIvkO3teVBy/iEC4IZkwuA nrXSocmp/xHHL8tw7p7nZEcB0KALYIb5iHhsuv22AWKyqXFuAQkT5NyeCUxkO//tIiei CvMOetpA71Q7ZeyeBHN9Y/47z8ENa1EZ3wZiLcux4DNkZ/FyGeWEYQXwrfTR7CVy3pEG /NJlc4rU3xLyEEQyh3pXyLnVML+anUV6W9vbSaIQSQLBYABaqGiIn6HT6cymlPW+pQ6e j4LQ== 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=E3uBP2PMxjhLbF/Qn6q1UBEwi29LNMNdydYz1iguy44=; b=PCub0zYG2IlghEQlIbFX/Cb/J9J2/x+GWklbkw8YShynaGztJdcWuJSO7h3QKPMic8 0G2nlSH1KSBAtJ7oDStoH01SYyouXOrxQM4b1t00be+abx94G+8LtIMAjj0zsXmRrVFc 0/Evm6pSJ8cslSoXeLfTAO69BV65ZkhrNBTQegmeKfNEB3sNnMoaVCPnF1xd+DHAkDSK WbLBwcziaAocdc6uR1uuBaYhRmnqcdHrqvk7beYdwbFp7swF/YnBAalWAACf/2Tfns/R zYUSrsbl/r2sgQvMEvFehf0G+KzDG6ZK5W2Q9MN0Z6PVWIngJigdfa2fn3zqKDhq78W+ dzaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=shEu22P2; 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 mf17si8159606ejb.86.2020.07.12.23.43.40; Sun, 12 Jul 2020 23:44:02 -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=shEu22P2; 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 S1729548AbgGMGmi (ORCPT + 99 others); Mon, 13 Jul 2020 02:42:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729478AbgGMGme (ORCPT ); Mon, 13 Jul 2020 02:42:34 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3F54C061794 for ; Sun, 12 Jul 2020 23:42:34 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id m22so5608941pgv.9 for ; Sun, 12 Jul 2020 23:42:34 -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=E3uBP2PMxjhLbF/Qn6q1UBEwi29LNMNdydYz1iguy44=; b=shEu22P2JCmXlIIFbQ38vJWAUx4gInp3gxoVw4iwmwo1mZaIbkEONC/XBFxYprb/nU YtaTTgu8vwTKy44PKXsrTXTqMcJJ8F6x9UHSM7a5oqU4qGIUFCvWUTtrhsMqKoJs5k0G PdNYlGmwSduhF82avB4fixx/okO4YsXzQmP+1T3CxzOEn9Gj3fHkivQapqwaWwID2Mm4 YQD5wrmwhPC858Mk3YXSUPdMyjm6SUkFzJuqmp2vp4JMACxQnVujgzwHtYoRTl9OvH7j U05dK8Mdu6OAtGHz6HDsLnR0EmNjP9689BJrpmZEz7Tyny/s22VWYwyRVVWR/BESD9Sj 0INQ== 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=E3uBP2PMxjhLbF/Qn6q1UBEwi29LNMNdydYz1iguy44=; b=o1RKFv302HSw8r85I39GbLC+wMORs2WzhX3+q9RYWPowbWnwcM1rmDFNF5s1wHBvOf Jfnn8qQieACkUHRFLf4muYDrn7gCgevzy3AqQgHg4Nnok9K6XeB63mt58m4Lo7wGBF3o O8P9tc02ZIQNtWsAUNXKuIcKKVBYZIAU6jHCdJ9NtJp4vvCtpl19SJFHKUiajWSD7GZu vy6pk47KlFkhXj1pHpp0cxgZyxpy+iCNh8c567UiiPhxpKK/7nyr9JNze1XmU3tJiHpc GThOy5fAEAQRzWhKarTzsl5SZJAHj/8pCiWDZzfryJ1gPJbD7eFFzsbZdSiST1slCddv 2CeQ== X-Gm-Message-State: AOAM532xxVJJrNsm6hK1fOWua6JaLizHv0yFPlRClubbOfxLZe3sueU7 A0hmwvPXnRUajPwCGjEG1yg= X-Received: by 2002:a63:2223:: with SMTP id i35mr6735847pgi.64.1594622554361; Sun, 12 Jul 2020 23:42:34 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id l134sm12448695pga.50.2020.07.12.23.42.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jul 2020 23:42:33 -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 6/9] mm/mempolicy: use a standard migration target allocation callback Date: Mon, 13 Jul 2020 15:41:54 +0900 Message-Id: <1594622517-20681-7-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joonsoo Kim There is a well-defined migration target allocation callback. Use it. Acked-by: Michal Hocko Acked-by: Vlastimil Babka Signed-off-by: Joonsoo Kim --- mm/internal.h | 1 - mm/mempolicy.c | 31 ++++++------------------------- mm/migrate.c | 8 ++++++-- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 0beacf3..10c6776 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -613,7 +613,6 @@ static inline bool is_migrate_highatomic_page(struct page *page) } void setup_zone_pageset(struct zone *zone); -extern struct page *alloc_new_node_page(struct page *page, unsigned long node); struct migration_target_control { int nid; /* preferred node id */ diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 9034a53..93fcfc1 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1065,29 +1065,6 @@ static int migrate_page_add(struct page *page, struct list_head *pagelist, return 0; } -/* page allocation callback for NUMA node migration */ -struct page *alloc_new_node_page(struct page *page, unsigned long node) -{ - if (PageHuge(page)) { - struct hstate *h = page_hstate(compound_head(page)); - gfp_t gfp_mask = htlb_alloc_mask(h) | __GFP_THISNODE; - - return alloc_huge_page_nodemask(h, node, NULL, gfp_mask); - } else if (PageTransHuge(page)) { - struct page *thp; - - thp = alloc_pages_node(node, - (GFP_TRANSHUGE | __GFP_THISNODE), - HPAGE_PMD_ORDER); - if (!thp) - return NULL; - prep_transhuge_page(thp); - return thp; - } else - return __alloc_pages_node(node, GFP_HIGHUSER_MOVABLE | - __GFP_THISNODE, 0); -} - /* * Migrate pages from one node to a target node. * Returns error or the number of pages not migrated. @@ -1098,6 +1075,10 @@ static int migrate_to_node(struct mm_struct *mm, int source, int dest, nodemask_t nmask; LIST_HEAD(pagelist); int err = 0; + struct migration_target_control mtc = { + .nid = dest, + .gfp_mask = GFP_HIGHUSER_MOVABLE | __GFP_THISNODE, + }; nodes_clear(nmask); node_set(source, nmask); @@ -1112,8 +1093,8 @@ static int migrate_to_node(struct mm_struct *mm, int source, int dest, flags | MPOL_MF_DISCONTIG_OK, &pagelist); if (!list_empty(&pagelist)) { - err = migrate_pages(&pagelist, alloc_new_node_page, NULL, dest, - MIGRATE_SYNC, MR_SYSCALL); + err = migrate_pages(&pagelist, alloc_migration_target, NULL, + (unsigned long)&mtc, MIGRATE_SYNC, MR_SYSCALL); if (err) putback_movable_pages(&pagelist); } diff --git a/mm/migrate.c b/mm/migrate.c index c35ba2a..1a891c4 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1591,9 +1591,13 @@ static int do_move_pages_to_node(struct mm_struct *mm, struct list_head *pagelist, int node) { int err; + struct migration_target_control mtc = { + .nid = node, + .gfp_mask = GFP_HIGHUSER_MOVABLE | __GFP_THISNODE, + }; - err = migrate_pages(pagelist, alloc_new_node_page, NULL, node, - MIGRATE_SYNC, MR_SYSCALL); + err = migrate_pages(pagelist, alloc_migration_target, NULL, + (unsigned long)&mtc, MIGRATE_SYNC, MR_SYSCALL); if (err) putback_movable_pages(pagelist); return err; -- 2.7.4