From patchwork Mon Jul 13 06:41:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11658867 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F0EF6C1 for ; Mon, 13 Jul 2020 06:42:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5240620720 for ; Mon, 13 Jul 2020 06:42:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fJ2wAWd8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5240620720 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 569738D0006; Mon, 13 Jul 2020 02:42:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 51BF28D0002; Mon, 13 Jul 2020 02:42:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E3408D0006; Mon, 13 Jul 2020 02:42:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id 288C28D0002 for ; Mon, 13 Jul 2020 02:42:21 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E082E8248068 for ; Mon, 13 Jul 2020 06:42:20 +0000 (UTC) X-FDA: 77032108440.27.class01_600a94926ee6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id A8D753D669 for ; Mon, 13 Jul 2020 06:42:20 +0000 (UTC) X-Spam-Summary: 1,0,0,0b420d9e5d7b35b2,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1540:1711:1714:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3351:3865:3866:3867:3872:4321:5007:6261:6653:7576:9413:10004:11026:11658:11914:12297:12438:12517:12519:12555:12679:12895:13069:13161:13229:13311:13357:14181:14384:14394:14721:21080:21444:21451:21627:21666:21990:30054:30064,0,RBL:209.85.216.68:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yfwug98gf5ag33xrq3xpcxzq57yocs891i3hehemhem3wuz38somt7cnagqjq.fekramho7kxtc4dm1bikac3p3mreubmfosbh4bt4yf939khwjpzhtawyo1ptwz1.1-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: class01_600a94926ee6 X-Filterd-Recvd-Size: 4053 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jul 2020 06:42:20 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id k71so5747718pje.0 for ; Sun, 12 Jul 2020 23:42:20 -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=noldTA6TKGUO86OIVB7oA9T0/eymsgYb8B93ohzbuus=; b=fJ2wAWd8sVBowfNQlIYjTQgKE97koI1YqDvDAfd6uHrehSwNDh+QUIAWbXchLGE53T FO7SDKQBdY7BFhSnrxslfGgCGXHhSNRO0N6yZZ2HmUj1F5m/19tehni4HYoQY3gcT/8z Ds0wQ2ds0+bpJlNXyTCEj1dUR5G/rrimdM7a2VkzBXedNUK42Au4AeBre8ww++9pcMcQ vGOoXH6aGvhfQ75S4tnMBS2sH7e/NAhaysv1I2AMuqrflUr7w8HAMzzLGABi/jGfRU6j lLXyRu70tyicI0MyGZpyK6umgi4AQMlbIqZMWyRF7Ab5kyxDzagzK4LUm8DLiaoiQnbo q91w== 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=noldTA6TKGUO86OIVB7oA9T0/eymsgYb8B93ohzbuus=; b=scloqA5pgpo9F4sYv8gW2zgAAgOyLHLtzB7qLSMP0WgjzP8WiA3xuq6YCco+M1orS3 3ouTMB+TPO9EEXEmRUGMcimJd+ub7vVZwpfyHLgf5OwPNKGbaqKHhcPhpQtNRW7QXKH1 diawpqlbxqmoHvPK3+eIPUkVZJ2BBHLvHcvTUp9jssRXQ9iIbcRcpOsAeQrJwuoMzCTq sVTkvbE1AnzuXhWfOX/OM8lcdX9u/NfErzTef6CTVBkLs4i+nu9yi/W8N/j2F2el/6kd xz8XgeSJftA3MXeYNIFZvHqOqtH2/ZZyiOUJJ5uHPnjprMxZ5wTYeGtba+delTraKWGK 1g6w== X-Gm-Message-State: AOAM532rluZHKo+ztTSZWYPenOBBiufbbLixWtlsgteYC2c1zFeYxsdI vxwLQ8H8FoTQs5tRr18mQ+I= X-Google-Smtp-Source: ABdhPJwn+AcUDIjoxlY5QSg2l4apojuP3f6MX5U97ovJuEBrhG6ucQ8EykH/oSODENjgFRQvokIW6A== X-Received: by 2002:a17:90b:488:: with SMTP id bh8mr19357095pjb.49.1594622539325; Sun, 12 Jul 2020 23:42:19 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id l134sm12448695pga.50.2020.07.12.23.42.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jul 2020 23:42:18 -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 1/9] mm/page_isolation: prefer the node of the source page Date: Mon, 13 Jul 2020 15:41:49 +0900 Message-Id: <1594622517-20681-2-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: A8D753D669 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Joonsoo Kim For locality, it's better to migrate the page to the same node rather than the node of the current caller's cpu. Acked-by: Roman Gushchin Acked-by: Michal Hocko Reviewed-by: Vlastimil Babka Signed-off-by: Joonsoo Kim --- mm/page_isolation.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/page_isolation.c b/mm/page_isolation.c index f6d07c5..aec26d9 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -309,5 +309,7 @@ int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn, struct page *alloc_migrate_target(struct page *page, unsigned long private) { - return new_page_nodemask(page, numa_node_id(), &node_states[N_MEMORY]); + int nid = page_to_nid(page); + + return new_page_nodemask(page, nid, &node_states[N_MEMORY]); } From patchwork Mon Jul 13 06:41:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11658869 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF48014DD for ; Mon, 13 Jul 2020 06:42:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 725AC20720 for ; Mon, 13 Jul 2020 06:42:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fvB99VW/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 725AC20720 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 73E328D0007; Mon, 13 Jul 2020 02:42:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6EE988D0002; Mon, 13 Jul 2020 02:42:24 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DD248D0007; Mon, 13 Jul 2020 02:42:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0104.hostedemail.com [216.40.44.104]) by kanga.kvack.org (Postfix) with ESMTP id 474618D0002 for ; Mon, 13 Jul 2020 02:42:24 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 05BFB8248068 for ; Mon, 13 Jul 2020 06:42:24 +0000 (UTC) X-FDA: 77032108608.10.goat68_431301526ee6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id D187C16A4A1 for ; Mon, 13 Jul 2020 06:42:23 +0000 (UTC) X-Spam-Summary: 1,0,0,07b04249c8dc7c82,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1535:1543:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2731:3138:3139:3140:3141:3142:3355:3867:3870:3871:3872:4117:4321:4385:4605:5007:6117:6261:6653:7576:7903:8957:9413:9592:10004:11026:11473:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12679:12683:12895:13149:13230:14096:14110:14181:14394:14721:21080:21444:21451:21627:21666:21990:30046:30051:30054:30064:30070,0,RBL:209.85.214.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yfms33dufr1zpb3hbo7rr1zmcwdopi15i9tqf7j197c1m5qpknuapz9i9wjs7.dgztr7jxsx1pdhz44jpeiykcf3cyyhciqotd6ors9i89drqu64yro7uc4ix8ime.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: goat68_431301526ee6 X-Filterd-Recvd-Size: 6868 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jul 2020 06:42:23 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id p1so5092284pls.4 for ; Sun, 12 Jul 2020 23:42:23 -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=8WCuo1hnAUaO0+Z2p2Fsc+u9rGTZbpOKXHgrmd/p494=; b=fvB99VW/LWQ5I3IASm0gYYQ6DoiaRRGaNC9niBODuOfHie6auT8YHer0bkt4y7nkQ2 gVVGcwUlCLQHebNSvPSM/PKKZsNFfEXvDraKyFhVbqhJJ4EcHreYdByivy578CS1anXK IAI+A7tQdGIDe0oPAyqkEpmrca0Wy8tLKhceRPywiKuNCCAVxA25leIDZbGDZBsFALSI +NMV0k2mhVMSfvlBA7XEdsK1PB1JvyKjly5TVLLSfPCSEh3EEtd/23wgg958ul6eU0ap DzOQ4+2u3IQ9WMr9YcTwMoAkOratsaU7eInmC3B6HXioHd4bR/X/ICJhVRpO7VLqAWZI 2f1A== 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=8WCuo1hnAUaO0+Z2p2Fsc+u9rGTZbpOKXHgrmd/p494=; b=YMtGGmt4h/XFQ/qW+tDUGcF9Awxkiqdr1OYcD7hkgfnpbuHezdt4KLAu1xbT9Adh4M 0eqGhAYZbNd7K2V5X+KjKuEXRci3bB/JzidxcEHjKl4f7pXxSd9W9orWYlh2jwjPIKz9 ZdLW6vNDPggdSuGxIYR5ovGnWIEO2i5EelAGlDcDrrcIRcA6qnPsrrEf+BCc3qiZ4j1k Br95UYIa2o2kQ/ETN7Cxk8mNSlF4VLUzPpczGwcnOPFWfBZsPtEBuMwkPje1SAJEbIr3 ywByg/AygQzQOO2K7UTy7fAqkoUDGOOSHchZn9DHM+AzLE0KnZR3I5uwVYGgLeEQ+i9Y njCA== X-Gm-Message-State: AOAM5330opnV14oUqKyM7VfV3GnzWrrhD9f44YrgM7YjpS9ma6l28mQN 0+NbfmsD8yn/tmwhtWy08BU= X-Google-Smtp-Source: ABdhPJzNPX2G4NvuWUMTHo2kR7+iy2ba5GxYclH4gWjIX99gFAuDxqS0Jf54uf9Lmgo1ME25ffWddA== X-Received: by 2002:a17:90a:d912:: with SMTP id c18mr18273943pjv.184.1594622542591; Sun, 12 Jul 2020 23:42:22 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id l134sm12448695pga.50.2020.07.12.23.42.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jul 2020 23:42:21 -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 2/9] mm/migrate: move migration helper from .h to .c Date: Mon, 13 Jul 2020 15:41:50 +0900 Message-Id: <1594622517-20681-3-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: D187C16A4A1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 It's not performance sensitive function. Move it to .c. This is a preparation step for future change. Acked-by: Mike Kravetz Acked-by: Michal Hocko Reviewed-by: Vlastimil Babka Signed-off-by: Joonsoo Kim --- include/linux/migrate.h | 33 +++++---------------------------- mm/migrate.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 3e546cb..1d70b4a 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -31,34 +31,6 @@ enum migrate_reason { /* In mm/debug.c; also keep sync with include/trace/events/migrate.h */ extern const char *migrate_reason_names[MR_TYPES]; -static inline struct page *new_page_nodemask(struct page *page, - int preferred_nid, nodemask_t *nodemask) -{ - gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL; - unsigned int order = 0; - struct page *new_page = NULL; - - if (PageHuge(page)) - return alloc_huge_page_nodemask(page_hstate(compound_head(page)), - preferred_nid, nodemask); - - if (PageTransHuge(page)) { - gfp_mask |= GFP_TRANSHUGE; - order = HPAGE_PMD_ORDER; - } - - if (PageHighMem(page) || (zone_idx(page_zone(page)) == ZONE_MOVABLE)) - gfp_mask |= __GFP_HIGHMEM; - - new_page = __alloc_pages_nodemask(gfp_mask, order, - preferred_nid, nodemask); - - if (new_page && PageTransHuge(new_page)) - prep_transhuge_page(new_page); - - return new_page; -} - #ifdef CONFIG_MIGRATION extern void putback_movable_pages(struct list_head *l); @@ -67,6 +39,8 @@ extern int migrate_page(struct address_space *mapping, enum migrate_mode mode); extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free, unsigned long private, enum migrate_mode mode, int reason); +extern struct page *new_page_nodemask(struct page *page, + int preferred_nid, nodemask_t *nodemask); extern int isolate_movable_page(struct page *page, isolate_mode_t mode); extern void putback_movable_page(struct page *page); @@ -85,6 +59,9 @@ static inline int migrate_pages(struct list_head *l, new_page_t new, free_page_t free, unsigned long private, enum migrate_mode mode, int reason) { return -ENOSYS; } +static inline struct page *new_page_nodemask(struct page *page, + int preferred_nid, nodemask_t *nodemask) + { return NULL; } static inline int isolate_movable_page(struct page *page, isolate_mode_t mode) { return -EBUSY; } diff --git a/mm/migrate.c b/mm/migrate.c index d105b67..7370a66 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1531,6 +1531,35 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, return rc; } +struct page *new_page_nodemask(struct page *page, + int preferred_nid, nodemask_t *nodemask) +{ + gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL; + unsigned int order = 0; + struct page *new_page = NULL; + + if (PageHuge(page)) + return alloc_huge_page_nodemask( + page_hstate(compound_head(page)), + preferred_nid, nodemask); + + if (PageTransHuge(page)) { + gfp_mask |= GFP_TRANSHUGE; + order = HPAGE_PMD_ORDER; + } + + if (PageHighMem(page) || (zone_idx(page_zone(page)) == ZONE_MOVABLE)) + gfp_mask |= __GFP_HIGHMEM; + + new_page = __alloc_pages_nodemask(gfp_mask, order, + preferred_nid, nodemask); + + if (new_page && PageTransHuge(new_page)) + prep_transhuge_page(new_page); + + return new_page; +} + #ifdef CONFIG_NUMA static int store_status(int __user *status, int start, int value, int nr) From patchwork Mon Jul 13 06:41:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11658871 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC88414DD for ; Mon, 13 Jul 2020 06:42:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9C3892075D for ; Mon, 13 Jul 2020 06:42:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="atCKzJ3Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C3892075D 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 8A3498D0008; Mon, 13 Jul 2020 02:42:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 78A738D0002; Mon, 13 Jul 2020 02:42:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6528D8D0008; Mon, 13 Jul 2020 02:42:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0070.hostedemail.com [216.40.44.70]) by kanga.kvack.org (Postfix) with ESMTP id 516408D0002 for ; Mon, 13 Jul 2020 02:42:27 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0CFBF180AD801 for ; Mon, 13 Jul 2020 06:42:27 +0000 (UTC) X-FDA: 77032108734.01.earth86_290f9ef26ee6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id E22E420003523BD1 for ; Mon, 13 Jul 2020 06:42:26 +0000 (UTC) X-Spam-Summary: 1,0,0,2db9adfb81beaae3,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:2:41:69:355:379:541:800:960:966:968:973:988:989:1260:1345:1359:1437:1535:1605:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2731:3138:3139:3140:3141:3142:3866:3867:3868:3870:3871:3872:3874:4049:4120:4250:4321:4385:4419:4605:5007:6119:6261:6653:7576:7903:8957:9010:9413:9592:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12683:12895:12986:13161:13180:13229:14096:14394:21080:21212:21444:21451:21627:21666:21740:21990:30003:30054:30064:30070:30080,0,RBL:209.85.210.193:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yrz8u6su8exzc8qaye1oy19ch3eyc7fy8jxcbfi6pckjdunmx5irzbddycc47.a7e3339ot3qo57tqwmcyf7di6wezt4qgfwhntciqcnazukthbgiezcpr76pisyo.n-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: earth86_290f9ef26ee6 X-Filterd-Recvd-Size: 9751 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jul 2020 06:42:26 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id a14so5594648pfi.2 for ; Sun, 12 Jul 2020 23:42:26 -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=V+4QG5y5MI2sik505z3aqneUrvc8k4tfYjh515Z4aV0=; b=atCKzJ3Z55CGiaI3Z2TRL5UAnjeKAfjbepbKFRFonYWggBpBy0Z+YsTdkqbuGZKzpA c0YtHwCNLjCreSjtN2VH/irIVY7ldvKCFxzyATrexj247qfMBvGZ/oof8D3jEsG1LuRB B8c2pm3D0oSTclxUMjV1YsiTiypn2XxAR4xR75BrS20++ERc6hWdJhpdDlPIb8Xu7sOK vyC5Ha3+RFhf78yWzP5dO3WkPcl9mzWb8VhJ74wMpkaB2PXpz2vPpZXD06ZcgGrttXZ2 lf/Nv9JrxDbuNea9SSyAl7C1ANvCW2QV1xroQeFl0HbRYNiQnyS1SyUlpXlHqeQs62rh al+A== 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=V+4QG5y5MI2sik505z3aqneUrvc8k4tfYjh515Z4aV0=; b=MlxHeddSVsijj2kiRlB6K/t9/BzPubxuYIdBlKi4bHqOda86sCHYoEAPjQ/47Q09ZK O9czxdsvG2TYYrgCwam9kePJHP5XRaN5Lq61AqnhlCZ5kNluAaS4aWYwRuz6XsVXOfpj OBVmjXj7LZGlMeTdDZMUSbXVGzE+0qua6FBC9CNYeTERJSdh43/9wznBcssvfpNf6URs A+eEjzWix4/ClMZXchr8gheZ80cRAmrf+Ym4z+r1p4HdCuo5Jc61FnNfGjBgdWQYTzxx qhdX5kNgcGywRg/+wgZZ1PP8vNucMs1zcAtxnHT8IgE9mZNPpmXIy56pluRBtuM8ZyBr TQOg== X-Gm-Message-State: AOAM533ASY5Jk3yTsPfiNT35dDITIkDPXWHb2ycSGNG+uLZNEknTTuDv kEubCdQpJQ2Td0gIGTgT+PY= X-Google-Smtp-Source: ABdhPJwA0sKwDRvosYFZ+kOvmOyKqwmn3y6398Dv7Stu2LCp+MD46s0LNu6EeVFLVLN0J1AHq3CO8g== X-Received: by 2002:a63:ca11:: with SMTP id n17mr67131603pgi.439.1594622545556; Sun, 12 Jul 2020 23:42:25 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id l134sm12448695pga.50.2020.07.12.23.42.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jul 2020 23:42:25 -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 3/9] mm/hugetlb: unify migration callbacks Date: Mon, 13 Jul 2020 15:41:51 +0900 Message-Id: <1594622517-20681-4-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: E22E420003523BD1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 There is no difference between two migration callback functions, alloc_huge_page_node() and alloc_huge_page_nodemask(), except __GFP_THISNODE handling. It's redundant to have two almost similar functions in order to handle this flag. So, this patch tries to remove one by introducing a new argument, gfp_mask, to alloc_huge_page_nodemask(). After introducing gfp_mask argument, it's caller's job to provide correct gfp_mask. So, every callsites for alloc_huge_page_nodemask() are changed to provide gfp_mask. Note that it's safe to remove a node id check in alloc_huge_page_node() since there is no caller passing NUMA_NO_NODE as a node id. Reviewed-by: Mike Kravetz Acked-by: Michal Hocko Reviewed-by: Vlastimil Babka Signed-off-by: Joonsoo Kim --- include/linux/hugetlb.h | 26 ++++++++++++++++++-------- mm/hugetlb.c | 35 ++--------------------------------- mm/mempolicy.c | 10 ++++++---- mm/migrate.c | 11 +++++++---- 4 files changed, 33 insertions(+), 49 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 50650d0..bb93e95 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -10,6 +10,7 @@ #include #include #include +#include struct ctl_table; struct user_struct; @@ -504,9 +505,8 @@ struct huge_bootmem_page { struct page *alloc_huge_page(struct vm_area_struct *vma, unsigned long addr, int avoid_reserve); -struct page *alloc_huge_page_node(struct hstate *h, int nid); struct page *alloc_huge_page_nodemask(struct hstate *h, int preferred_nid, - nodemask_t *nmask); + nodemask_t *nmask, gfp_t gfp_mask); struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma, unsigned long address); struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask, @@ -692,6 +692,15 @@ static inline bool hugepage_movable_supported(struct hstate *h) return true; } +/* Movability of hugepages depends on migration support. */ +static inline gfp_t htlb_alloc_mask(struct hstate *h) +{ + if (hugepage_movable_supported(h)) + return GFP_HIGHUSER_MOVABLE; + else + return GFP_HIGHUSER; +} + static inline spinlock_t *huge_pte_lockptr(struct hstate *h, struct mm_struct *mm, pte_t *pte) { @@ -759,13 +768,9 @@ static inline struct page *alloc_huge_page(struct vm_area_struct *vma, return NULL; } -static inline struct page *alloc_huge_page_node(struct hstate *h, int nid) -{ - return NULL; -} - static inline struct page * -alloc_huge_page_nodemask(struct hstate *h, int preferred_nid, nodemask_t *nmask) +alloc_huge_page_nodemask(struct hstate *h, int preferred_nid, + nodemask_t *nmask, gfp_t gfp_mask) { return NULL; } @@ -878,6 +883,11 @@ static inline bool hugepage_movable_supported(struct hstate *h) return false; } +static inline gfp_t htlb_alloc_mask(struct hstate *h) +{ + return 0; +} + static inline spinlock_t *huge_pte_lockptr(struct hstate *h, struct mm_struct *mm, pte_t *pte) { diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 7e5ba5c0..3245aa0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1089,15 +1089,6 @@ static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask, return NULL; } -/* Movability of hugepages depends on migration support. */ -static inline gfp_t htlb_alloc_mask(struct hstate *h) -{ - if (hugepage_movable_supported(h)) - return GFP_HIGHUSER_MOVABLE; - else - return GFP_HIGHUSER; -} - static struct page *dequeue_huge_page_vma(struct hstate *h, struct vm_area_struct *vma, unsigned long address, int avoid_reserve, @@ -1979,31 +1970,9 @@ struct page *alloc_buddy_huge_page_with_mpol(struct hstate *h, } /* page migration callback function */ -struct page *alloc_huge_page_node(struct hstate *h, int nid) -{ - gfp_t gfp_mask = htlb_alloc_mask(h); - struct page *page = NULL; - - if (nid != NUMA_NO_NODE) - gfp_mask |= __GFP_THISNODE; - - spin_lock(&hugetlb_lock); - if (h->free_huge_pages - h->resv_huge_pages > 0) - page = dequeue_huge_page_nodemask(h, gfp_mask, nid, NULL); - spin_unlock(&hugetlb_lock); - - if (!page) - page = alloc_migrate_huge_page(h, gfp_mask, nid, NULL); - - return page; -} - -/* page migration callback function */ struct page *alloc_huge_page_nodemask(struct hstate *h, int preferred_nid, - nodemask_t *nmask) + nodemask_t *nmask, gfp_t gfp_mask) { - gfp_t gfp_mask = htlb_alloc_mask(h); - spin_lock(&hugetlb_lock); if (h->free_huge_pages - h->resv_huge_pages > 0) { struct page *page; @@ -2031,7 +2000,7 @@ struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma, gfp_mask = htlb_alloc_mask(h); node = huge_node(vma, address, gfp_mask, &mpol, &nodemask); - page = alloc_huge_page_nodemask(h, node, nodemask); + page = alloc_huge_page_nodemask(h, node, nodemask, gfp_mask); mpol_cond_put(mpol); return page; diff --git a/mm/mempolicy.c b/mm/mempolicy.c index dabcee8..9034a53 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1068,10 +1068,12 @@ static int migrate_page_add(struct page *page, struct list_head *pagelist, /* page allocation callback for NUMA node migration */ struct page *alloc_new_node_page(struct page *page, unsigned long node) { - if (PageHuge(page)) - return alloc_huge_page_node(page_hstate(compound_head(page)), - node); - else if (PageTransHuge(page)) { + 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, diff --git a/mm/migrate.c b/mm/migrate.c index 7370a66..3b3d918 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1538,10 +1538,13 @@ struct page *new_page_nodemask(struct page *page, unsigned int order = 0; struct page *new_page = NULL; - if (PageHuge(page)) - return alloc_huge_page_nodemask( - page_hstate(compound_head(page)), - preferred_nid, nodemask); + if (PageHuge(page)) { + struct hstate *h = page_hstate(compound_head(page)); + + gfp_mask = htlb_alloc_mask(h); + return alloc_huge_page_nodemask(h, preferred_nid, + nodemask, gfp_mask); + } if (PageTransHuge(page)) { gfp_mask |= GFP_TRANSHUGE; From patchwork Mon Jul 13 06:41:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11658873 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9851C6C1 for ; Mon, 13 Jul 2020 06:42:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6578320720 for ; Mon, 13 Jul 2020 06:42:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CgBe3t8n" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6578320720 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 1990B8D0009; Mon, 13 Jul 2020 02:42:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 14B5B8D0002; Mon, 13 Jul 2020 02:42:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0857B8D0009; Mon, 13 Jul 2020 02:42:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id E7F918D0002 for ; Mon, 13 Jul 2020 02:42:29 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B252C180AD801 for ; Mon, 13 Jul 2020 06:42:29 +0000 (UTC) X-FDA: 77032108818.17.cent47_521363d26ee6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 8DB6F180D0185 for ; Mon, 13 Jul 2020 06:42:29 +0000 (UTC) X-Spam-Summary: 1,0,0,d08ca091f9713883,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2693:2731:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3871:3872:3874:4250:4321:5007:6119:6120:6261:6653:7576:7901:7903:8957:9413:10004:11026:11473:11658:11914:12296:12297:12438:12517:12519:12555:12679:12895:12986:13069:13161:13229:13255:13311:13357:14181:14384:14394:14721:21080:21212:21444:21451:21627:21666:30054,0,RBL:209.85.214.193:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04y8t5xinripiui149h8djpest1r6op4yuy1pf36krqrfeuwtpctzx37qhqdzoz.year3npbg9qwqswgyck5zapk5qxpeij8idj5dmyrxqkmpsphrkewur7xwkkwy7a.q-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: cent47_521363d26ee6 X-Filterd-Recvd-Size: 4546 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jul 2020 06:42:29 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id b9so5091179plx.6 for ; Sun, 12 Jul 2020 23:42:29 -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=DYvbIUGr1klvf1KuM5X3vtjsbtYe5Ed8VKuo0vY8aNs=; b=CgBe3t8n7VNso1NPJiLgJXeLW3cIBJizUgkVaI8dO5owHBrbFC4uG+U4un4Kgm6Hyv LiiwhzvpRqGbzWmLMdTelDCH+srgcqedru314ibXq61m3uTaO5hXbPSTxRpO1i1kmntP ExKG+iPC+sYXYNhqFeXc0cPb9Ls/83S7YUmSg+0htTsneBykEZOBiAu5Livcf5m7qsQV HOOdS0qo2GOdbKZxzBBq/8DuKxts+c9dAc/r8lAnO0Iq1pzjRh1CulVrFtb/n7EMo69m vzeRmYEJgpczLoBjmaatUyoy2CrcZoupto848VUZPY2y3Y41X5LrQ7s1GEHVR1WLh/Ju Rkqw== 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=DYvbIUGr1klvf1KuM5X3vtjsbtYe5Ed8VKuo0vY8aNs=; b=e+hZsmnhLBW0uAvKLKKj4wX/28QeDyqdvn7+9PrtRE5L0id4uQh96/aGcXKtBTXDEs e9owujUZZe7gTn2F9mreTxG7j3h/QvtqGXZHlfmhhH9B+IM0TSAXeQ2bngghIFadiTg+ 6JZbGBpo2m/7orU9BFV3Y4N9tA6rgvKANliQfxono2CT3+/0weDiV1FlhZWMHWT6AplY c65zT6mgWtA48DSCJGKFWFAMKMqQlkfi8ciU2+94NaMPBE9QuKOLh7ZV2DrihmS8Fw67 B6NYzI++0OdTpLaziJhY6AhDxr5afX5fNdfJ449WcrnoSMP8OAUOTo73ERlTCSUIGoSH spkA== X-Gm-Message-State: AOAM533XVGI+nMkhUDRoMXdrfdC66c9YDPLTQ2bzCZKvlNHaOTvMWY4m 4tGgPl71dZiov5ijb7N5mmc= X-Google-Smtp-Source: ABdhPJzL56WSCGGGVz7bKQJxux8fS+oGRvXZYz6+Ns6WcAgpVYHewqzoEMpn8OExmd8A6ffq4maGiQ== X-Received: by 2002:a17:90a:de8d:: with SMTP id n13mr17681375pjv.95.1594622548490; Sun, 12 Jul 2020 23:42:28 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id l134sm12448695pga.50.2020.07.12.23.42.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jul 2020 23:42:28 -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 4/9] mm/migrate: clear __GFP_RECLAIM to make the migration callback consistent with regular THP allocations Date: Mon, 13 Jul 2020 15:41:52 +0900 Message-Id: <1594622517-20681-5-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: 8DB6F180D0185 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 new_page_nodemask is a migration callback and it tries to use a common gfp flags for the target page allocation whether it is a base page or a THP. The later only adds GFP_TRANSHUGE to the given mask. This results in the allocation being slightly more aggressive than necessary because the resulting gfp mask will contain also __GFP_RECLAIM_KSWAPD. THP allocations usually exclude this flag to reduce over eager background reclaim during a high THP allocation load which has been seen during large mmaps initialization. There is no indication that this is a problem for migration as well but theoretically the same might happen when migrating large mappings to a different node. Make the migration callback consistent with regular THP allocations. Signed-off-by: Joonsoo Kim Acked-by: Michal Hocko Acked-by: Vlastimil Babka Acked-by: Michal Hocko Acked-by: Vlastimil Babka Signed-off-by: Joonsoo Kim --- mm/migrate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/migrate.c b/mm/migrate.c index 3b3d918..1cfc965 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1547,6 +1547,11 @@ struct page *new_page_nodemask(struct page *page, } if (PageTransHuge(page)) { + /* + * clear __GFP_RECALIM to make the migration callback + * consistent with regular THP allocations. + */ + gfp_mask &= ~__GFP_RECLAIM; gfp_mask |= GFP_TRANSHUGE; order = HPAGE_PMD_ORDER; } From patchwork Mon Jul 13 06:41:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11658875 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BBA8214DD for ; Mon, 13 Jul 2020 06:42:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7BF0D20720 for ; Mon, 13 Jul 2020 06:42:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l4eDalfJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7BF0D20720 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 480458D000A; Mon, 13 Jul 2020 02:42:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4091B8D0002; Mon, 13 Jul 2020 02:42:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31FC68D000A; Mon, 13 Jul 2020 02:42:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0085.hostedemail.com [216.40.44.85]) by kanga.kvack.org (Postfix) with ESMTP id 1D3058D0002 for ; Mon, 13 Jul 2020 02:42:33 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D9A072C88 for ; Mon, 13 Jul 2020 06:42:32 +0000 (UTC) X-FDA: 77032108944.21.juice15_26030b426ee6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id AD902180442C0 for ; Mon, 13 Jul 2020 06:42:32 +0000 (UTC) X-Spam-Summary: 1,0,0,93ac2aa9ae864b17,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:1:2:41:69:355:379:421:541:800:960:966:968:973:988:989:1260:1345:1359:1437:1605:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2693:2731:2741:2899:3138:3139:3140:3141:3142:3865:3866:3867:3870:3871:3872:3874:4051:4250:4321:4385:4605:5007:6119:6261:6653:7576:7875:7903:8660:8957:9413:9592:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:13148:13149:13161:13180:13229:13230:14394:21080:21433:21444:21451:21627:21666:21795:21939:21990:30051:30054:30080,0,RBL:209.85.214.193:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04ygk71c1gjnrbo6sitea78j7bsrpop9ymjycirw1w3oftfj4ontd56thcqejsb.dtnsdx9w6umeyeajih5iia37x7p94ig8jdo5p9qe7rimknxrckhw1cci7dw3xb1.w-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: juice15_26030b426ee6 X-Filterd-Recvd-Size: 11772 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jul 2020 06:42:32 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id k5so5075119plk.13 for ; Sun, 12 Jul 2020 23:42:32 -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=GObApkfHEsPhLdQKUnzBpTACGgx9w+bZB8XLLvNmjJA=; b=l4eDalfJUj0pllGV80lDRU9AC0Jd9nzXPlKUt4SD0cI7JCpw7bySj/g6l6YwHjfp50 PSjBJsTIeu0xWym2YNMFetiQiFe3BQzSfqM0o+ekQdZQpl6UbepefyKfU/yUpq39rTMI vR1C39xzRImRgilD8LWvoEULWFMMFP2dl48HW83cvOLdGbx2ZxPuF9U7c3LsP8QOWNF8 2iFPxZT3muYf7lfnRjaomP8G3TPaU7p9nlLgejIfaHpbXUT/CVtyeZixrR4CN/7u4rBi /URW0rcjsNH4wVDjW6ApB/yIbme21KQqERJ7wY3fAfNYekdSqwpzriI4jbiqe/eiyQqv h/Yg== 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=GObApkfHEsPhLdQKUnzBpTACGgx9w+bZB8XLLvNmjJA=; b=jXdf5flebgOYSWW1BN9g028V/qI48tN9fQ0qQwceANwtLyCgJL32J+EFDnYXPUMYHb 4ju2b16yt7LHiBQEqvYb42LO+7W8TsdQh/z62j7fliqnpFziMoTmp6HsQ1/IkjeHqQSN 2HWsuzw/o0HYDbwAZkIBCwf8lKfRj49r8GQVWRvgPgn6xggMXZOgBMVa7yap0Z0GTz/T XoTQuxOD+9Yjgibrj34CpqLddnFurTgfp7oEUbbBy+qqwHv+abJ263XsS6RlImYWBZ7/ xjxGmHSWaqMtYiow+7SlPvYhL3HZw85xV+C/Pyd+8ig6dlRS+YCpD9h4ahrz07+C8mWs FBZg== X-Gm-Message-State: AOAM530Yh2CP++o3nYvYsjlqjApbvTnXR3CZFVmqYmztW2wgcD5TwbWO YuXt2sAdB/5Z1ZVs+QxHRMo= X-Google-Smtp-Source: ABdhPJxeuyOUkseS2VfZrAReKh+dvlWO5mIalOv1VpiMegCsiIyQFWZOXM4Q1B9fhYxcM+nXAANkZA== X-Received: by 2002:a17:90a:a50d:: with SMTP id a13mr17692395pjq.95.1594622551376; Sun, 12 Jul 2020 23:42:31 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id l134sm12448695pga.50.2020.07.12.23.42.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jul 2020 23:42:31 -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 5/9] mm/migrate: make a standard migration target allocation function Date: Mon, 13 Jul 2020 15:41:53 +0900 Message-Id: <1594622517-20681-6-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: AD902180442C0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 There are some similar functions for migration target allocation. Since there is no fundamental difference, it's better to keep just one rather than keeping all variants. This patch implements base migration target allocation function. In the following patches, variants will be converted to use this function. Changes should be mechanical, but, unfortunately, there are some differences. First, some callers' nodemask is assgined to NULL since NULL nodemask will be considered as all available nodes, that is, &node_states[N_MEMORY]. Second, for hugetlb page allocation, gfp_mask is redefined as regular hugetlb allocation gfp_mask plus __GFP_THISNODE if user provided gfp_mask has it. This is because future caller of this function requires to set this node constaint. Lastly, if provided nodeid is NUMA_NO_NODE, nodeid is set up to the node where migration source lives. It helps to remove simple wrappers for setting up the nodeid. Note that PageHighmem() call in previous function is changed to open-code "is_highmem_idx()" since it provides more readability. Acked-by: Vlastimil Babka Acked-by: Michal Hocko Signed-off-by: Joonsoo Kim Acked-by: Vlastimil Babka Acked-by: Michal Hocko Signed-off-by: Joonsoo Kim --- include/linux/hugetlb.h | 15 +++++++++++++++ include/linux/migrate.h | 9 +++++---- mm/internal.h | 7 +++++++ mm/memory-failure.c | 7 +++++-- mm/memory_hotplug.c | 12 ++++++++---- mm/migrate.c | 26 ++++++++++++++++---------- mm/page_isolation.c | 7 +++++-- 7 files changed, 61 insertions(+), 22 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index bb93e95..6b9508d 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -701,6 +701,16 @@ static inline gfp_t htlb_alloc_mask(struct hstate *h) return GFP_HIGHUSER; } +static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask) +{ + gfp_t modified_mask = htlb_alloc_mask(h); + + /* Some callers might want to enfoce node */ + modified_mask |= (gfp_mask & __GFP_THISNODE); + + return modified_mask; +} + static inline spinlock_t *huge_pte_lockptr(struct hstate *h, struct mm_struct *mm, pte_t *pte) { @@ -888,6 +898,11 @@ static inline gfp_t htlb_alloc_mask(struct hstate *h) return 0; } +static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask) +{ + return 0; +} + static inline spinlock_t *huge_pte_lockptr(struct hstate *h, struct mm_struct *mm, pte_t *pte) { diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 1d70b4a..cc56f0d 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -10,6 +10,8 @@ typedef struct page *new_page_t(struct page *page, unsigned long private); typedef void free_page_t(struct page *page, unsigned long private); +struct migration_target_control; + /* * Return values from addresss_space_operations.migratepage(): * - negative errno on page migration failure; @@ -39,8 +41,7 @@ extern int migrate_page(struct address_space *mapping, enum migrate_mode mode); extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free, unsigned long private, enum migrate_mode mode, int reason); -extern struct page *new_page_nodemask(struct page *page, - int preferred_nid, nodemask_t *nodemask); +extern struct page *alloc_migration_target(struct page *page, unsigned long private); extern int isolate_movable_page(struct page *page, isolate_mode_t mode); extern void putback_movable_page(struct page *page); @@ -59,8 +60,8 @@ static inline int migrate_pages(struct list_head *l, new_page_t new, free_page_t free, unsigned long private, enum migrate_mode mode, int reason) { return -ENOSYS; } -static inline struct page *new_page_nodemask(struct page *page, - int preferred_nid, nodemask_t *nodemask) +static inline struct page *alloc_migration_target(struct page *page, + unsigned long private) { return NULL; } static inline int isolate_movable_page(struct page *page, isolate_mode_t mode) { return -EBUSY; } diff --git a/mm/internal.h b/mm/internal.h index dd14c53..0beacf3 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -614,4 +614,11 @@ 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 */ + nodemask_t *nmask; + gfp_t gfp_mask; +}; + #endif /* __MM_INTERNAL_H */ diff --git a/mm/memory-failure.c b/mm/memory-failure.c index c5e4cee..609d42b6 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1679,9 +1679,12 @@ EXPORT_SYMBOL(unpoison_memory); static struct page *new_page(struct page *p, unsigned long private) { - int nid = page_to_nid(p); + struct migration_target_control mtc = { + .nid = page_to_nid(p), + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + }; - return new_page_nodemask(p, nid, &node_states[N_MEMORY]); + return alloc_migration_target(p, (unsigned long)&mtc); } /* diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index cafe65eb..431b470f 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1267,19 +1267,23 @@ static int scan_movable_pages(unsigned long start, unsigned long end, static struct page *new_node_page(struct page *page, unsigned long private) { - int nid = page_to_nid(page); 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(nid, nmask); + node_clear(mtc.nid, nmask); if (nodes_empty(nmask)) - node_set(nid, nmask); + node_set(mtc.nid, nmask); - return new_page_nodemask(page, nid, &nmask); + return alloc_migration_target(page, (unsigned long)&mtc); } static int diff --git a/mm/migrate.c b/mm/migrate.c index 1cfc965..c35ba2a 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1531,19 +1531,26 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, return rc; } -struct page *new_page_nodemask(struct page *page, - int preferred_nid, nodemask_t *nodemask) +struct page *alloc_migration_target(struct page *page, unsigned long private) { - gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL; + struct migration_target_control *mtc; + gfp_t gfp_mask; unsigned int order = 0; struct page *new_page = NULL; + int nid; + int zidx; + + mtc = (struct migration_target_control *)private; + gfp_mask = mtc->gfp_mask; + nid = mtc->nid; + if (nid == NUMA_NO_NODE) + nid = page_to_nid(page); if (PageHuge(page)) { struct hstate *h = page_hstate(compound_head(page)); - gfp_mask = htlb_alloc_mask(h); - return alloc_huge_page_nodemask(h, preferred_nid, - nodemask, gfp_mask); + gfp_mask = htlb_modify_alloc_mask(h, gfp_mask); + return alloc_huge_page_nodemask(h, nid, mtc->nmask, gfp_mask); } if (PageTransHuge(page)) { @@ -1555,12 +1562,11 @@ struct page *new_page_nodemask(struct page *page, gfp_mask |= GFP_TRANSHUGE; order = HPAGE_PMD_ORDER; } - - if (PageHighMem(page) || (zone_idx(page_zone(page)) == ZONE_MOVABLE)) + zidx = zone_idx(page_zone(page)); + if (is_highmem_idx(zidx) || zidx == ZONE_MOVABLE) gfp_mask |= __GFP_HIGHMEM; - new_page = __alloc_pages_nodemask(gfp_mask, order, - preferred_nid, nodemask); + new_page = __alloc_pages_nodemask(gfp_mask, order, nid, mtc->nmask); if (new_page && PageTransHuge(new_page)) prep_transhuge_page(new_page); diff --git a/mm/page_isolation.c b/mm/page_isolation.c index aec26d9..f25c66e 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -309,7 +309,10 @@ int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn, struct page *alloc_migrate_target(struct page *page, unsigned long private) { - int nid = page_to_nid(page); + struct migration_target_control mtc = { + .nid = page_to_nid(page), + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + }; - return new_page_nodemask(page, nid, &node_states[N_MEMORY]); + return alloc_migration_target(page, (unsigned long)&mtc); } From patchwork Mon Jul 13 06:41:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11658877 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AEF6114DD for ; Mon, 13 Jul 2020 06:42:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7C2D020720 for ; Mon, 13 Jul 2020 06:42:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="shEu22P2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C2D020720 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 4A6A18D000B; Mon, 13 Jul 2020 02:42:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 457B48D0002; Mon, 13 Jul 2020 02:42:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31E568D000B; Mon, 13 Jul 2020 02:42:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0176.hostedemail.com [216.40.44.176]) by kanga.kvack.org (Postfix) with ESMTP id 19C968D0002 for ; Mon, 13 Jul 2020 02:42:36 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CBD8D8248068 for ; Mon, 13 Jul 2020 06:42:35 +0000 (UTC) X-FDA: 77032109070.10.dogs94_3e0aabb26ee6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 9EC8D16A4B0 for ; Mon, 13 Jul 2020 06:42:35 +0000 (UTC) X-Spam-Summary: 1,0,0,93a7954d1bcdbe74,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1535:1543:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3354:3865:3866:3867:3871:3872:4117:4250:4321:5007:6119:6261:6653:7576:7903:8957:9413:9592:10004:11026:11232:11233:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12683:12895:12986:13161:13229:13255:14096:14110:14181:14394:14721:21080:21212:21220:21444:21451:21627:21666:21990:30034:30054:30080,0,RBL:209.85.215.193:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yg1y4sio67ydaeiihyerne4x7rdoco66ckud369x9ctu44b3adsyswaox5wnc.894fxb8mzzfri79p9tqnoqn14i1r5u6nourgr5qwtytiy89zqapx9uwomtn1dxh.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: dogs94_3e0aabb26ee6 X-Filterd-Recvd-Size: 6451 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jul 2020 06:42:35 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id w2so5602794pgg.10 for ; Sun, 12 Jul 2020 23:42:35 -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=e4UkZBzMSO+alu0tQHdIO8kGXLVkKaFgiCxJPtUpywzu3918zDzDfSNKGlFPe1AYjx AvNW6KqTSrClLtqRdd5KA9wqTodcEOmaJtw56Z+mscnCPo8x3IldCZwSSqABjE77RfMS hymnm9y/yQ/02zc0VUgYPqwEdg3/w9y+J5V1vQmi/6ok+pWq8wa5KpgO7B8V+mkOhoUr R9mtPMk0cAOSiRmwVibrBQsQXnD9KHopbl037U1QYAHLq2KQT+xQ5GjotLMoDOIQKBXT MaSQP45IIOTZm9+bdSiPOgOqChMDdz1EYKmb908RDaa1WRykdSw9UfCZocYulBdxF2qJ Mvbg== X-Gm-Message-State: AOAM531F2WIzoCbYS8SbPvW77n/t0XbTnq/65Y+jb9+r8le+PG3sIV64 wBV1DwKja5CNwIK+vBWrh5o= X-Google-Smtp-Source: ABdhPJwPpmFYrn1YsAQ6i67c53VPDIBX+BbW5s3FvEk2clA/rAsyvjpKb5hQQV4RXblLbW3xVq35QQ== 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> X-Rspamd-Queue-Id: 9EC8D16A4B0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 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; From patchwork Mon Jul 13 06:41:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11658879 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BB716C1 for ; Mon, 13 Jul 2020 06:42:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5F79320720 for ; Mon, 13 Jul 2020 06:42:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sDuNBNnO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F79320720 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 348998D000C; Mon, 13 Jul 2020 02:42:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2F6958D0002; Mon, 13 Jul 2020 02:42:39 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20D548D000C; Mon, 13 Jul 2020 02:42:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0131.hostedemail.com [216.40.44.131]) by kanga.kvack.org (Postfix) with ESMTP id 0BA778D0002 for ; Mon, 13 Jul 2020 02:42:39 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C1F822C88 for ; Mon, 13 Jul 2020 06:42:38 +0000 (UTC) X-FDA: 77032109196.15.anger66_0006a8326ee6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 8A22E1814B0C1 for ; Mon, 13 Jul 2020 06:42:38 +0000 (UTC) X-Spam-Summary: 1,0,0,c260d82b9e796e65,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1535:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3353:3871:3872:3876:4321:5007:6119:6261:6653:7576:7903:9413:9592:10004:11026:11473:11658:11914:12043:12114:12296:12297:12438:12517:12519:12555:12679:12895:12986:13069:13161:13229:13311:13357:14096:14181:14384:14394:14721:21080:21444:21451:21627:21666:21990:30054,0,RBL:209.85.215.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04ygpbrzsru75a8z55gwncs1j6fkuocw6ojn3ftksnqhyptuh4kxcj8sr9i7dbs.wbdw1ajg3yk7unfin8nib65ip8ctwamy3wckxynb5ubwa6cfcyhms1uy71tyoc5.w-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: anger66_0006a8326ee6 X-Filterd-Recvd-Size: 5042 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jul 2020 06:42:38 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id p3so5624692pgh.3 for ; Sun, 12 Jul 2020 23:42:37 -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=jW8zp7RHqtHeCyFdrmHu1jeTiXid01JuKsYb1RMidWg=; b=sDuNBNnOadqLFjEboOTN+KZ8ju+GgWtvG1go57WqkF61YVPNazQlaE46OSWopM8oFZ lGrlnqSLnlJEgCDa8NbqDo83oHtueBqc3u1SeeYXj1x2pW8CfhZiW1hT34jpnIlpKQq/ gxLbBKW+H0KK1PcAN+u1pLISm2FIP1SxRFyZdUwsYFcJBTo96Cb/q1aAppvV7CtB9Z+S PjCEPG/gMe4F8bD21AVn0NheipHo0/Hd6CzGpQFJxcTGYdcGcYwh6KYbOxe/k6ukiCmP eM5kzhMnchgu7kJV04iWSI+96y2Iw5a4aIIh4QsEaDzyByhLwimrGX8VCfxDrqh2wF6T oI5A== 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=jW8zp7RHqtHeCyFdrmHu1jeTiXid01JuKsYb1RMidWg=; b=nJRiy6bf32Nz5Rdhq+NPDG66IUf7yRr5KPacEu7+g/EiL1vV8kJj49G9e8PEXschWQ ZLEmsP8NufqvxRykTgQDw+BsnZw4UN3km+iK9bmc/X/i6k9cb+UuN7Zk35fA6YsAUTDO NXTotSQ3DWiqo9j68GC1GFpOoDV+1ikgT7qKORKAQWg+DwKRaL/bBwYXpKLsPp/0/3jz W0OmIAtLpAcFx7FriKpxd0z1YSRqg5MwJiwDlRCvTfYnt44ZfxSpQME74QPN9G4RuQd6 sEfqOCTBzqprmOhlz2sQqduW3Ua8jwKLmi30xw8viDQJC7szKCq+nx1fzSkb8GypmctV FW9w== X-Gm-Message-State: AOAM530iJb2XuV41bGDAOaGleXoo8tNffjvVDzR1DffaAVwVqxbbZdQV JO1gUevglI7rVCHh1li/ml4= X-Google-Smtp-Source: ABdhPJy5rFqXfwpnbs8a3UZi85qVhXCA9wmNrP9KpOBu9eRv/VWMwN3oVOjQ51d9bfLEXvlH7Sa6LA== X-Received: by 2002:a63:de4b:: with SMTP id y11mr43982722pgi.26.1594622557329; Sun, 12 Jul 2020 23:42:37 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id l134sm12448695pga.50.2020.07.12.23.42.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jul 2020 23:42:36 -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 7/9] mm/page_alloc: remove a wrapper for alloc_migration_target() Date: Mon, 13 Jul 2020 15:41:55 +0900 Message-Id: <1594622517-20681-8-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: 8A22E1814B0C1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 There is a well-defined standard migration target callback. Use it directly. Acked-by: Michal Hocko Acked-by: Vlastimil Babka Signed-off-by: Joonsoo Kim --- mm/page_alloc.c | 8 ++++++-- mm/page_isolation.c | 10 ---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index f3b70ee..6416d08 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8354,6 +8354,10 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, unsigned long pfn = start; unsigned int tries = 0; int ret = 0; + struct migration_target_control mtc = { + .nid = zone_to_nid(cc->zone), + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + }; migrate_prep(); @@ -8380,8 +8384,8 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, &cc->migratepages); cc->nr_migratepages -= nr_reclaimed; - ret = migrate_pages(&cc->migratepages, alloc_migrate_target, - NULL, 0, cc->mode, MR_CONTIG_RANGE); + ret = migrate_pages(&cc->migratepages, alloc_migration_target, + NULL, (unsigned long)&mtc, cc->mode, MR_CONTIG_RANGE); } if (ret < 0) { putback_movable_pages(&cc->migratepages); diff --git a/mm/page_isolation.c b/mm/page_isolation.c index f25c66e..242c031 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -306,13 +306,3 @@ int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn, return pfn < end_pfn ? -EBUSY : 0; } - -struct page *alloc_migrate_target(struct page *page, unsigned long private) -{ - struct migration_target_control mtc = { - .nid = page_to_nid(page), - .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, - }; - - return alloc_migration_target(page, (unsigned long)&mtc); -} From patchwork Mon Jul 13 06:41:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11658881 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D23614DD for ; Mon, 13 Jul 2020 06:42:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 29F6A20720 for ; Mon, 13 Jul 2020 06:42:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z2I7IHnR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29F6A20720 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 1E6E88D000D; Mon, 13 Jul 2020 02:42:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1BDE28D0002; Mon, 13 Jul 2020 02:42:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AED98D000D; Mon, 13 Jul 2020 02:42:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0110.hostedemail.com [216.40.44.110]) by kanga.kvack.org (Postfix) with ESMTP id EAD638D0002 for ; Mon, 13 Jul 2020 02:42:41 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A84B31E00 for ; Mon, 13 Jul 2020 06:42:41 +0000 (UTC) X-FDA: 77032109322.17.seat70_5a07caf26ee6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 7A56C180D0185 for ; Mon, 13 Jul 2020 06:42:41 +0000 (UTC) X-Spam-Summary: 1,0,0,b9fe1c900869ab45,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2899:3138:3139:3140:3141:3142:3353:3866:3871:3872:4321:4385:5007:6119:6121:6261:6653:7576:7903:8957:9413:9592:10004:11026:11473:11658:11914:12043:12114:12297:12438:12517:12519:12555:12679:12895:12986:13069:13161:13229:13311:13357:14181:14384:14394:14721:21080:21220:21444:21451:21627:21666:21987:21990:30054:30070,0,RBL:209.85.216.66:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yggo4w79dmxej6x8bbcz1ximi4jypqi7k4cwgu9ejgr4baipwp8yrrptk6b74.cnqutxow9azqd9npgxti444ixjh54ig346hnni5u3p7s8315gyor1qwdq9a6ghe.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: seat70_5a07caf26ee6 X-Filterd-Recvd-Size: 4913 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jul 2020 06:42:40 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id cm21so5740598pjb.3 for ; Sun, 12 Jul 2020 23:42:40 -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=U/VWaVj++GlMblCwFxNC0BZkTiy01OBPAbi2yw768aI=; b=Z2I7IHnRW+ZYg5Nqfw07NGatjjCO1bAgkzqvtLhoYSfW6FAOpO1im6WU8yjHJ53lxq EWFuNOu+TFNnYRx5Xk5sTYJwroMRtC/1LUPsAjhmzZj3CBTtCCBzCYYgyxhPKn9yqBxM tDe6qn1pGF3aZ6jYDL9z2u2wo60h1osPbUdYcUmz/gaZnubPl9lgA/GFYMsHWcLfbykh dQ0QDMZx0dT15wG4MRB+R9x+LkLAw5Gef71VthPDqVLmNgGyZOs13FgSmyFpXKWH2fZg OlgNFbzWlCM0d1FgCj8DXoVutaqKNQygYu+cTj8YzQ+VxD4T4peIXL+3mBUT9qaW5LbL qovg== 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=U/VWaVj++GlMblCwFxNC0BZkTiy01OBPAbi2yw768aI=; b=CMf7ih6SfB2005aOJbmy2p/t+MKFzrpREfibnSsGTk4X1ck7zd0MzuiTvbDa/p31GU SC8243rLdD2rQVD39NwbslBAZYXz68KRfF0MTDEgei9J2KI2ohkYekSycjGwDPGlb7HN zHGCwllyjBUXa4cjWYm93PXAXC8++7/6dFZpW+UqfRddy+R+CmiEqQe63HKHdoLpx0pQ faD0UdebAAzkMv0ZYoLuPXr38xdwIXRnbVOG22LpsQTpx/1NwIMgwhJMBTn/cnEM981u R2PIq4Nkf7DE2B18LrQ7mDb6AbJt6MdocBqrZnysAmnrlyCID4qXHsC0XiP+AToCjxRn OS5w== X-Gm-Message-State: AOAM531utVPWNdgimWrcE3DOCmlB0lwf/cc2u6X8xJilRCIdh3t+DJEh ajVV3MjmtUqhAI6jUPYssTE= X-Google-Smtp-Source: ABdhPJxHz84Y2guRTiEMqec1Vum4rDt1oofAjeSRK64Je2VNieMcvFdodBtEjaCCjiTI7beclxBSug== X-Received: by 2002:a17:902:d211:: with SMTP id t17mr36230695ply.323.1594622560225; Sun, 12 Jul 2020 23:42:40 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id l134sm12448695pga.50.2020.07.12.23.42.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Jul 2020 23:42:39 -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 8/9] mm/memory-failure: remove a wrapper for alloc_migration_target() Date: Mon, 13 Jul 2020 15:41:56 +0900 Message-Id: <1594622517-20681-9-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: 7A56C180D0185 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 There is a well-defined standard migration target callback. Use it directly. Acked-by: Vlastimil Babka Signed-off-by: Joonsoo Kim --- mm/memory-failure.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 609d42b6..3b89804 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1677,16 +1677,6 @@ int unpoison_memory(unsigned long pfn) } EXPORT_SYMBOL(unpoison_memory); -static struct page *new_page(struct page *p, unsigned long private) -{ - struct migration_target_control mtc = { - .nid = page_to_nid(p), - .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, - }; - - return alloc_migration_target(p, (unsigned long)&mtc); -} - /* * Safely get reference count of an arbitrary page. * Returns 0 for a free page, -EIO for a zero refcount page @@ -1793,6 +1783,10 @@ static int __soft_offline_page(struct page *page) const char *msg_page[] = {"page", "hugepage"}; bool huge = PageHuge(page); LIST_HEAD(pagelist); + struct migration_target_control mtc = { + .nid = NUMA_NO_NODE, + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + }; /* * Check PageHWPoison again inside page lock because PageHWPoison @@ -1829,8 +1823,8 @@ static int __soft_offline_page(struct page *page) } if (isolate_page(hpage, &pagelist)) { - ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, - MIGRATE_SYNC, MR_MEMORY_FAILURE); + ret = migrate_pages(&pagelist, alloc_migration_target, NULL, + (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_FAILURE); if (!ret) { bool release = !huge; From patchwork Mon Jul 13 06:41:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11658883 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BC1514DD for ; Mon, 13 Jul 2020 06:42:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 68B7020720 for ; Mon, 13 Jul 2020 06:42:46 +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 68B7020720 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3B9B38D0002; Mon, 13 Jul 2020 02:42:45 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 1,0,0,2efb14c94982e8b5,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1535:1543:1711:1730:1747:1777:1792:2194:2198:2199:2200:2393:2559:2562:2741:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3871:3872:3874:4117:4321:5007:6119:6261:6653:7576:7903:9413:9592:10004:11026:11473:11658:11914:12043:12114:12291:12297:12438:12517:12519:12555:12679:12683:12895:14096:14181:14394:14721:21080:21220:21444:21451:21627:21666:21990:30054:30070:30080,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04ygie8cyxjafqxgw4mxhcwj1om4uycg7w5is6xzodjogzei7rw74itdddynpng.g1krmp4ywrz68twrpzedz1uu4hionxmym4oaf3dfgzjercoj5zhcey1jwfeumn1.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none 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 ",