From patchwork Tue Jul 7 07:44:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11647943 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 3304092A for ; Tue, 7 Jul 2020 07:45:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 005EF20702 for ; Tue, 7 Jul 2020 07:45:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vbad23Al" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 005EF20702 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 290986B0031; Tue, 7 Jul 2020 03:45:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2188C6B006E; Tue, 7 Jul 2020 03:45:16 -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 0E05D6B0070; Tue, 7 Jul 2020 03:45:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0231.hostedemail.com [216.40.44.231]) by kanga.kvack.org (Postfix) with ESMTP id E923E6B0031 for ; Tue, 7 Jul 2020 03:45:15 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id AEE9E181AC9CC for ; Tue, 7 Jul 2020 07:45:15 +0000 (UTC) X-FDA: 77010494190.02.mint16_450f65d26eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 78F1B20002CEE326 for ; Tue, 7 Jul 2020 07:45:15 +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.210.194:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yfqzxoynawwchgzwz7pp61smymtycs891i3hehemhem3wuz38somt7cnagqjq.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: mint16_450f65d26eb2 X-Filterd-Recvd-Size: 4057 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:45:14 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id z3so8786539pfn.12 for ; Tue, 07 Jul 2020 00:45:14 -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=Vbad23AlnQOk0GUC76j8CTK+/qKNN9hFL3i4/MhHD281K/tlIVzkVrKX4ZMncJqnqk 4XNfwEBuQgaHmn0Wl31LFSUeMY8sa0dLH3bKra/rBA0Qa1Qts+90pFXiFKK2ZLdsEDA7 k5+eacop/fCCryMmD+Qb8/3DA26WUItWVZVfjT8HKOoBwVuoYcb4YA+2TVsN2IrnZdkl P0I15QZfDAR1YhCB2DI4ZP1cwR1eXVgAJ4dX3cyIXs898jdTff6o0D8NGUQD2igFTqTR gpcn0NwM2KrjkJ8NrAhACysJ496YTc48AZgzHlAtVTePQXnO0TC4i3RifyjxCK4+GD9F O2Zw== 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=dLgQabuF0pf/pjUNNs15c08FWAEJfFW2TA6941+sLMa+v4CM0DE4ZZu+Rlpzfmnizf wsJKjIN4QM7Zk2v6Y9Fl5p1Q4ZELm6D1zX1Y8Wdc4UJlhncuTXPT6RAaSUdqXBVOI4nZ GFxTWGgxzJfiobNzQaKDjJK1fOKHl15Rnoi49hpKkgPFToTezGq1BW815troArt4Ko1D HwzIxr53indZBxtH6UK9TUWRI4gIK0qSK9h2jwnWo8yOrQn8QelyuO7iB4Kifv7trgE/ KU5+zi/opFd1zzp32hh7xhaJJ3XgSU27au19li8BlUB9p7quM6jAV0CilLxQQnzDiU2R /bvA== X-Gm-Message-State: AOAM530k8ICkqNpCZGG73txENjPITKDKldq4a5hgZT05kvNEJpv+cpkS yrYFgbpqLg5mff1fgxWz55A= X-Google-Smtp-Source: ABdhPJyBY9P14Z7TZVWcW0g/XRnUzMq8W6ZRVVwEUlQa4xk2icW0pqQPXYlWDGNgoBpOUqe6nGfOPg== X-Received: by 2002:a63:d40d:: with SMTP id a13mr43580473pgh.225.1594107914104; Tue, 07 Jul 2020 00:45:14 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 191sm21330151pfw.150.2020.07.07.00.45.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 00:45:13 -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 01/11] mm/page_isolation: prefer the node of the source page Date: Tue, 7 Jul 2020 16:44:39 +0900 Message-Id: <1594107889-32228-2-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> X-Rspamd-Queue-Id: 78F1B20002CEE326 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 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 Tue Jul 7 07:44:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11647945 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 6D8B013B6 for ; Tue, 7 Jul 2020 07:45:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 39DD9206E2 for ; Tue, 7 Jul 2020 07:45:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JpdQnD6k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 39DD9206E2 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 2196F6B0070; Tue, 7 Jul 2020 03:45:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1A6CF6B0071; Tue, 7 Jul 2020 03:45:19 -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 092ED6B0072; Tue, 7 Jul 2020 03:45:19 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id E2B926B0070 for ; Tue, 7 Jul 2020 03:45:18 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AB2141EE6 for ; Tue, 7 Jul 2020 07:45:18 +0000 (UTC) X-FDA: 77010494316.23.suit30_1a12e2526eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 76A3E37608 for ; Tue, 7 Jul 2020 07:45:18 +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.210.194:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04ygr4yzayf6wi75eomas6f8iysjeypi15i9tqf7j197c1m5qpknuapz9i9wjs7.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:26,LUA_SUMMARY:none X-HE-Tag: suit30_1a12e2526eb2 X-Filterd-Recvd-Size: 6866 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:45:17 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id s26so4442838pfm.4 for ; Tue, 07 Jul 2020 00:45:17 -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=JpdQnD6k+V6ba5PJn/GrzAKU8muopio2PJq0dEuINtMXUp48S0FwmS1wN3Sai0ljZw z71aGQQ4r6ZE1u8JElbTPLyNJKx8pf93ZwWNVTKDtctBKFF4BWtZyeGv0+GucY7G8rBO Mir/s2/7JliyHxd2sZRknrGQArJl4UPeAIrFclivu0xtDNgAKJVmFnwXT93lhBzBxPgN /cUslNQdthBxQ5zq9vpo8rzLsKLqjw2LjuMEsTRuV53CHAcTOBXdIilBWKY0ILAAdL4e 30LoJCBza9OC9SVBhLXtbQoURT2ThQN9mVyM7UGF/AfDf0cJyGChRiryVsPc4JnKZaQX EBBQ== 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=czGTL0QLO6JcK1rcfCrdlilClrj8Bwc490jEWscOubXf37A3+XjaouV+vUrVfdAmXY 5wQcDlVRP4c+18Fm3Oi5HQ1QGilCY/Qcs/49Q3OtxpppR0MOt0VQ8lLmPznI0h/TNInO Ld8Q2LUtSk3Ow9re71fCn4JUoHx2kRW1hXk+6QefXM/OZfZnYDepEBjWSiUlWPwyyNB+ XOijPjxDmQMyHbSGKNI8dNdHqOcrQz4PG43XTAvIfVaz1wSelHpzwkcRo2gmDKu+p2as YpP5R7H8ZwEDv6QKHn1SsqUMH9eaAJD0IKDErZ2xELIaqUSWIO/967i2kk4an89JGiIO Lx7g== X-Gm-Message-State: AOAM533bzOnWCzwsifSQQP3s/K4qsV+LLXVv7oPsoF3wnLp5/YBJk6tV LtLYt4JVdqCmqtqpIDmlb2o= X-Google-Smtp-Source: ABdhPJwTRoCvXaC3wp8nMbfqXJZdgd11trQAs5VSp1+5X4PUATzPS2jov1YpYikkz7vOR6F0MlfZOQ== X-Received: by 2002:aa7:9736:: with SMTP id k22mr46221449pfg.62.1594107917231; Tue, 07 Jul 2020 00:45:17 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 191sm21330151pfw.150.2020.07.07.00.45.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 00:45:16 -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 02/11] mm/migrate: move migration helper from .h to .c Date: Tue, 7 Jul 2020 16:44:40 +0900 Message-Id: <1594107889-32228-3-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> X-Rspamd-Queue-Id: 76A3E37608 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 Tue Jul 7 07:44:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11647947 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 F344F92A for ; Tue, 7 Jul 2020 07:45:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B28EE206E2 for ; Tue, 7 Jul 2020 07:45:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Eok4t1VS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B28EE206E2 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 835046B0072; Tue, 7 Jul 2020 03:45:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7BDF96B0073; Tue, 7 Jul 2020 03:45:22 -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 687786B0074; Tue, 7 Jul 2020 03:45:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id 4EAF56B0072 for ; Tue, 7 Jul 2020 03:45:22 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1259F180AD807 for ; Tue, 7 Jul 2020 07:45:22 +0000 (UTC) X-FDA: 77010494484.14.fog28_430527226eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id D5BD418229818 for ; Tue, 7 Jul 2020 07:45:21 +0000 (UTC) X-Spam-Summary: 1,0,0,ef4591f4c4ca7aed,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.216.68:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yg614sie6ws77es4drz7hh15wm4oc7fy8jxcbfi6pckjdunmx5irzbddycc47.a7e3339ot3qo57tqwmcyf7di6wezt4qgfwhntciqcnaztuhwz4rcka7r76pisyo.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:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: fog28_430527226eb2 X-Filterd-Recvd-Size: 9664 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:45:21 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id mn17so4612735pjb.4 for ; Tue, 07 Jul 2020 00:45:21 -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=7w5+1Hzjf18z/2o2/PilHVAz4Imm/6C4QWMh97XIOQc=; b=Eok4t1VStxGOWAzkWm8zcnnWYQ6dk6skFyuJ8nlZZnv7bK2671l1bF8AxXH6Z+E1nl +xIX7Z9ENHPCYzGuD3ecvpipA3JxVfK1AJRvwUYL1MuQJX2tbgscezorIGfdmAutjy9i oKl53WriyOznSdUXfkK84KUzCwL9g4vlhsCogXxwD6jtd2bA/Gi8mveKMF16P5CPg6sD F+p+ySX5Zxplp1t1T9j6t1JgBZn/jj4biHrZkYc0o70dZg0BaTVCao0qjWdb2W+4YTAT tPKXEdlSCjeKz3t3+fhbO5A8W8HxdFO//N+u+r1yMSmC2iyOy34xtjVyPNo54lzYI/Jm GSKA== 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=7w5+1Hzjf18z/2o2/PilHVAz4Imm/6C4QWMh97XIOQc=; b=klv+39r0wLIDsZ07YsqrbCmkj4Pd0xysd4+qOpjjVCGuUJTps/n1RgCoj1HXgV1jvX L2k+Bz+BZe5XqjIcEvmVOcO0AsWADqwCy32P7pf3rCNRMB4f4YYfD8QvwnX9S+XvsLAU bcFtJ3LYI8AYyekq+K5Xgrc8b161kT9sHsyqEq5FJ6jy1zeTNjS5qqfpmfYxRs1OBUUI OV7sAoIK7Q/sZnmDsu0/LzvUpQExDlSHQ1roZjtCKCo9lXPUcDargzsXQARZUFZElp9P DsME1UYGORecu7K3jev5vrMTlMw9Gw3ltf1DJKZ0Fp/ZIQG2uPLiTdjPZBgvf477FS3l jFoA== X-Gm-Message-State: AOAM532EmXDH1Jz8pX0idqMosHwvp30X8gG7fGqos2tCArvfUAV12Eho Du3MWfmz1fhqhSW4COqBgf0= X-Google-Smtp-Source: ABdhPJzKxbOEZngb7E5WhqmRHvRexoOxmzytcrzXDlvurQI7mrbOt9M/Sv99Iki3b6sJLDJ8CArhdg== X-Received: by 2002:a17:90a:de0c:: with SMTP id m12mr3109445pjv.228.1594107920405; Tue, 07 Jul 2020 00:45:20 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 191sm21330151pfw.150.2020.07.07.00.45.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 00:45:20 -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 03/11] mm/hugetlb: unify migration callbacks Date: Tue, 7 Jul 2020 16:44:41 +0900 Message-Id: <1594107889-32228-4-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> X-Rspamd-Queue-Id: D5BD418229818 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Signed-off-by: Joonsoo Kim Reviewed-by: Vlastimil Babka Acked-by: Michal Hocko --- 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 Tue Jul 7 07:44:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11647949 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 214D392A for ; Tue, 7 Jul 2020 07:45:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D46DC20739 for ; Tue, 7 Jul 2020 07:45:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jobv/5LY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D46DC20739 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 85BD66B0074; Tue, 7 Jul 2020 03:45:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7E5166B0075; Tue, 7 Jul 2020 03:45:25 -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 611B26B0078; Tue, 7 Jul 2020 03:45:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0185.hostedemail.com [216.40.44.185]) by kanga.kvack.org (Postfix) with ESMTP id 460736B0074 for ; Tue, 7 Jul 2020 03:45:25 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0B2048248068 for ; Tue, 7 Jul 2020 07:45:25 +0000 (UTC) X-FDA: 77010494610.28.yard93_420606426eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id DE60E6C26 for ; Tue, 7 Jul 2020 07:45:24 +0000 (UTC) X-Spam-Summary: 1,0,0,1a98b48edd56a786,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:1:2:41:69:355:379:541:800:960:966:973:988:989:1260:1345:1359:1431:1437:1605:1730:1747:1777:1792:2196:2199:2393:2559:2562:2693:2898:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3874:4050:4250:4321:4385:4605:5007:6119:6261:6653:7576:7903:8957:9010:9413:9592:10004:11026:11473:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12679:12683:12895:12986:14096:14394:21080:21212:21444:21451:21627:21666:21740:21990:30003:30054:30064:30070,0,RBL:209.85.215.193:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yr1exho1dk9bf6irza75j4rj7ncopmdsu6z97ppfy453dftfwg7a4apr9iwx1.3zce4jxs1qthkmggep5ath1zs8aimtadpphg1rruuzrqpnddwfhk9c1p6x5qmqe.c-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: yard93_420606426eb2 X-Filterd-Recvd-Size: 10956 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:45:24 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id d4so19616551pgk.4 for ; Tue, 07 Jul 2020 00:45:24 -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=qnoK4TvyfV1LRCnzNkO0sqYOjp7Armsh3/cW2lDsC+Q=; b=jobv/5LYElZozBTe1V8H6oXs2SS82tcccFNT1Fx/0CN/Dt4Ya/uzNhWhvnwrkUko5E 7NBqO3SiduMLv2ylTEsL1DGacWRs+1ilbZH8y2/kfLBfWZ3KWLxn/Vd+liaAp348aeAt ppuUi0tMVN9BljVTgUJLnqcsJR98W2Xy9u5fTiT1bh9xGrXLp3LQri9jXhPxKbBN0Fio ibqu0tge5U2LSf79tgdW3kA5kKXhYRvKGZBiCm8Mo5RyrF4LtL118zB/7Nywptx/Pm29 zMWHUDvkJiVyjgKwPNv5znXz33AejY8BF0dqtG7JTq5eaFDy4U6I0E2bmvCnrP2uADq5 wLiQ== 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=qnoK4TvyfV1LRCnzNkO0sqYOjp7Armsh3/cW2lDsC+Q=; b=XEI/RbM+pntgisAT15y8xdBWRO5IV/CGl42ExjAjuTfQ86iXn3kFH2vJWtaMoD7UAc WG/gHD119z8bWCyRZcRj/w0fAJ1eb0R7bmXlSmToLHF/ZJeI1Mx5fhq1g3AUIR7qZ0xW SA97IBQOpazuXfxoJb34usaAqdX8gSSoyY858zQUf1g9Rrana1pE+kTojTurSY1AjTtd e1wBhOiYSBVtbI9NRgs+Zz0m/gq+pHB+fxWPwdOAHZgBsgS9QgmsS11eX8C9NTzRbvVi lzQlcxLr5mrdvvac3L5MsMNnFwHNvfdMMnHXBZIXHOX9t27DWaiXubJRpzdIcbzhm+tL pAdQ== X-Gm-Message-State: AOAM533m97edc5cqn7IZdr3r//03z4Yyni7oUwIq0AyO2NcC6hoUyFeq wA9j4cvjbi8H33B5xsoPZzed5ZcS X-Google-Smtp-Source: ABdhPJzbD9rVzloBGi9muM3LkFH+P5PEtYezvEv6+d9lkLW2H2SyN8bq7RDgMXzPGTBGgQLAbzW8jw== X-Received: by 2002:a65:5c88:: with SMTP id a8mr9026434pgt.215.1594107923604; Tue, 07 Jul 2020 00:45:23 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 191sm21330151pfw.150.2020.07.07.00.45.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 00:45:23 -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 04/11] mm/hugetlb: make hugetlb migration callback CMA aware Date: Tue, 7 Jul 2020 16:44:42 +0900 Message-Id: <1594107889-32228-5-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> X-Rspamd-Queue-Id: DE60E6C26 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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_non_cma_page() in gup.c which try to allocate migration target page requires to allocate the new page that is not on the CMA area. new_non_cma_page() implements it by removing __GFP_MOVABLE flag. This way works well for THP page or normal page but not for hugetlb page. hugetlb page allocation process consists of two steps. First is dequeing from the pool. Second is, if there is no available page on the queue, allocating from the page allocator. new_non_cma_page() can control allocation from the page allocator by specifying correct gfp flag. However, dequeing cannot be controlled until now, so, new_non_cma_page() skips dequeing completely. It is a suboptimal since new_non_cma_page() cannot utilize hugetlb pages on the queue so this patch tries to fix this situation. This patch makes the deque function on hugetlb CMA aware and skip CMA pages if newly added skip_cma argument is passed as true. Acked-by: Mike Kravetz Signed-off-by: Joonsoo Kim Acked-by: Mike Kravetz Signed-off-by: Joonsoo Kim --- include/linux/hugetlb.h | 6 ++---- mm/gup.c | 3 ++- mm/hugetlb.c | 46 ++++++++++++++++++++++++++++++---------------- mm/mempolicy.c | 2 +- mm/migrate.c | 2 +- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index bb93e95..5a9ddf1 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -506,11 +506,9 @@ 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_nodemask(struct hstate *h, int preferred_nid, - nodemask_t *nmask, gfp_t gfp_mask); + nodemask_t *nmask, gfp_t gfp_mask, bool skip_cma); 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, - int nid, nodemask_t *nmask); int huge_add_to_page_cache(struct page *page, struct address_space *mapping, pgoff_t idx); @@ -770,7 +768,7 @@ static inline struct page *alloc_huge_page(struct vm_area_struct *vma, static inline struct page * alloc_huge_page_nodemask(struct hstate *h, int preferred_nid, - nodemask_t *nmask, gfp_t gfp_mask) + nodemask_t *nmask, gfp_t gfp_mask, bool skip_cma) { return NULL; } diff --git a/mm/gup.c b/mm/gup.c index 5daadae..2c3dab4 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1630,11 +1630,12 @@ static struct page *new_non_cma_page(struct page *page, unsigned long private) #ifdef CONFIG_HUGETLB_PAGE if (PageHuge(page)) { struct hstate *h = page_hstate(page); + /* * We don't want to dequeue from the pool because pool pages will * mostly be from the CMA region. */ - return alloc_migrate_huge_page(h, gfp_mask, nid, NULL); + return alloc_huge_page_nodemask(h, nid, NULL, gfp_mask, true); } #endif if (PageTransHuge(page)) { diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 3245aa0..bcf4abe 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -1033,13 +1034,18 @@ static void enqueue_huge_page(struct hstate *h, struct page *page) h->free_huge_pages_node[nid]++; } -static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid) +static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid, bool skip_cma) { struct page *page; - list_for_each_entry(page, &h->hugepage_freelists[nid], lru) + list_for_each_entry(page, &h->hugepage_freelists[nid], lru) { + if (skip_cma && is_migrate_cma_page(page)) + continue; + if (!PageHWPoison(page)) break; + } + /* * if 'non-isolated free hugepage' not found on the list, * the allocation fails. @@ -1054,7 +1060,7 @@ static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid) } static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask, int nid, - nodemask_t *nmask) + nodemask_t *nmask, bool skip_cma) { unsigned int cpuset_mems_cookie; struct zonelist *zonelist; @@ -1079,7 +1085,7 @@ static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask, continue; node = zone_to_nid(zone); - page = dequeue_huge_page_node_exact(h, node); + page = dequeue_huge_page_node_exact(h, node, skip_cma); if (page) return page; } @@ -1115,7 +1121,7 @@ static struct page *dequeue_huge_page_vma(struct hstate *h, gfp_mask = htlb_alloc_mask(h); nid = huge_node(vma, address, gfp_mask, &mpol, &nodemask); - page = dequeue_huge_page_nodemask(h, gfp_mask, nid, nodemask); + page = dequeue_huge_page_nodemask(h, gfp_mask, nid, nodemask, false); if (page && !avoid_reserve && vma_has_reserves(vma, chg)) { SetPagePrivate(page); h->resv_huge_pages--; @@ -1928,7 +1934,7 @@ static struct page *alloc_surplus_huge_page(struct hstate *h, gfp_t gfp_mask, return page; } -struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask, +static struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask, int nid, nodemask_t *nmask) { struct page *page; @@ -1971,21 +1977,29 @@ struct page *alloc_buddy_huge_page_with_mpol(struct hstate *h, /* page migration callback function */ struct page *alloc_huge_page_nodemask(struct hstate *h, int preferred_nid, - nodemask_t *nmask, gfp_t gfp_mask) + nodemask_t *nmask, gfp_t gfp_mask, bool skip_cma) { + unsigned int flags = 0; + struct page *page = NULL; + + if (skip_cma) + flags = memalloc_nocma_save(); + spin_lock(&hugetlb_lock); if (h->free_huge_pages - h->resv_huge_pages > 0) { - struct page *page; - - page = dequeue_huge_page_nodemask(h, gfp_mask, preferred_nid, nmask); - if (page) { - spin_unlock(&hugetlb_lock); - return page; - } + page = dequeue_huge_page_nodemask(h, gfp_mask, + preferred_nid, nmask, skip_cma); } spin_unlock(&hugetlb_lock); - return alloc_migrate_huge_page(h, gfp_mask, preferred_nid, nmask); + if (!page) + page = alloc_migrate_huge_page(h, gfp_mask, + preferred_nid, nmask); + + if (skip_cma) + memalloc_nocma_restore(flags); + + return page; } /* mempolicy aware migration callback */ @@ -2000,7 +2014,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, gfp_mask); + page = alloc_huge_page_nodemask(h, node, nodemask, gfp_mask, false); mpol_cond_put(mpol); return page; diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 9034a53..667b453 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1072,7 +1072,7 @@ struct page *alloc_new_node_page(struct page *page, unsigned long node) 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); + return alloc_huge_page_nodemask(h, node, NULL, gfp_mask, false); } else if (PageTransHuge(page)) { struct page *thp; diff --git a/mm/migrate.c b/mm/migrate.c index 3b3d918..02b31fe 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1543,7 +1543,7 @@ struct page *new_page_nodemask(struct page *page, gfp_mask = htlb_alloc_mask(h); return alloc_huge_page_nodemask(h, preferred_nid, - nodemask, gfp_mask); + nodemask, gfp_mask, false); } if (PageTransHuge(page)) { From patchwork Tue Jul 7 07:44:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11647951 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 2ED6313B6 for ; Tue, 7 Jul 2020 07:45:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E61E220738 for ; Tue, 7 Jul 2020 07:45:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bCudhXV2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E61E220738 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 AA71D6B0078; Tue, 7 Jul 2020 03:45:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A7BD26B007B; Tue, 7 Jul 2020 03:45:28 -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 9490E6B007D; Tue, 7 Jul 2020 03:45:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id 78F936B0078 for ; Tue, 7 Jul 2020 03:45:28 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 411028248068 for ; Tue, 7 Jul 2020 07:45:28 +0000 (UTC) X-FDA: 77010494736.03.tooth18_170e7a826eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 12AFE28A4E9 for ; Tue, 7 Jul 2020 07:45:28 +0000 (UTC) X-Spam-Summary: 1,0,0,1b79d547cf89f2ad,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:2731:2736:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:5007:6119:6120:6261:6653:7576:7901:7903:8957:9413:10004:11026:11473:11658:11914:12043:12296:12297:12517:12519:12555:12679:12895:12986:13069:13255:13311:13357:14181:14384:14394:14721:21080:21444:21451:21627:21666:30054,0,RBL:209.85.215.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yfzsm9i6whffa834oyauz4qiiqdopea8txkxqzi6m71mq9kogj68y6izkz9cn.7qwy1owbi1q19kcuje4cbt4e8rmgz91r9cnahe3gb8nhft7xigrh3krazrxmmqh.g-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: tooth18_170e7a826eb2 X-Filterd-Recvd-Size: 4648 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:45:27 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id t6so19639054pgq.1 for ; Tue, 07 Jul 2020 00:45:27 -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=ktEVs8Hqf991Zw2ArJoEaKXQpHVgkoYtcCgWjEGUnPA=; b=bCudhXV2TzMRpdKEib0op4Bt1pN4XyWefDsWoE0tYUAf4gkc81psR8GAUTwgJJRAJv thHfe6n8q2aCG+nNXI2nzD7uRDNnN/OA8SOvjSeQj+iL94vLPSZk4ONTQTFMzp+k1biU /t3G2ZqdZhhE3VAKwLBBGhv7YRqJMdDo7UOKJQVBDYUoCW4YvjpDsovPbpcAa8hFUuC3 /0Z6/m68F6DqhNf5tZuJ6GIuFeqg9lFHLMTnxVGqJl4dVRhoID6u34VcGT/ZzlB8fFsa Vpz9G0PMMSH7a7enbL0XdW14UF28HegZGy7SYA0A5hJS9VizcDYiNGvaM0gBHN+FMDZA aiBA== 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=ktEVs8Hqf991Zw2ArJoEaKXQpHVgkoYtcCgWjEGUnPA=; b=ZdnuGRWt0YXTW6ty/9Oj0k5DqY+2kJdWlffqMLUy4fdn4IFFktyYdjSqlYcMlsmqqX SNMSNQZ6OEk1msMve0SEP5GMKj37Pt/CNfRFo4I3FvAQie9RvDnrw6kPrcs7ibH2F+n7 1S6RAskqFwcZyrYBKAa79hYS93ZzpRkjK46rJSdSmmlx0vddNla5BmCumUqCYYX+/mcD 9YwLn0LrFw3mwvWQ9IwJlR7EXeodgl89d5BH+8UeO8mH1PAVrLJvCx0B1I0IvsUU7f4O Mxo4hIb4wIF/u9eOXeaZvpWmxIWsF/8OPZHNVaPaL5qe8M/kikIhVvQVJxvYMDSKqrRD 5QLw== X-Gm-Message-State: AOAM5326myZAy+ypt9Ccqns/G05yQedki8fJKhum3L76mkswR7DvQlh3 J/ZYK6OMaSkSCffyvQsZe9w= X-Google-Smtp-Source: ABdhPJyeoOTD1Nw+9ZWQrMNZq3+EUZHWgPrHfwthTufo+Dtl4PXEZE+ujykdKKimw15qkv8P1+4o3Q== X-Received: by 2002:a65:6150:: with SMTP id o16mr28727781pgv.237.1594107926731; Tue, 07 Jul 2020 00:45:26 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 191sm21330151pfw.150.2020.07.07.00.45.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 00:45:26 -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 05/11] mm/migrate: clear __GFP_RECLAIM for THP allocation for migration Date: Tue, 7 Jul 2020 16:44:43 +0900 Message-Id: <1594107889-32228-6-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> X-Rspamd-Queue-Id: 12AFE28A4E9 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 In mm/migrate.c, THP allocation for migration is called with the provided gfp_mask | GFP_TRANSHUGE. This gfp_mask contains __GFP_RECLAIM and it would be conflict with the intention of the GFP_TRANSHUGE. GFP_TRANSHUGE/GFP_TRANSHUGE_LIGHT is introduced to control the reclaim behaviour by well defined manner since overhead of THP allocation is quite large and the whole system could suffer from it. So, they deals with __GFP_RECLAIM mask deliberately. If gfp_mask contains __GFP_RECLAIM and uses gfp_mask | GFP_TRANSHUGE(_LIGHT) for THP allocation, it means that it breaks the purpose of the GFP_TRANSHUGE(_LIGHT). This patch fixes this situation by clearing __GFP_RECLAIM in provided gfp_mask. Note that there are some other THP allocations for migration and they just uses GFP_TRANSHUGE(_LIGHT) directly. This patch would make all THP allocation for migration consistent. 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 02b31fe..ecd7615 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 since GFP_TRANSHUGE is the gfp_mask + * that chooses the reclaim masks deliberately. + */ + gfp_mask &= ~__GFP_RECLAIM; gfp_mask |= GFP_TRANSHUGE; order = HPAGE_PMD_ORDER; } From patchwork Tue Jul 7 07:44:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11647953 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 8E67A13B6 for ; Tue, 7 Jul 2020 07:45:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4E38E20708 for ; Tue, 7 Jul 2020 07:45:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f283josl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E38E20708 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 E9EEE6B007D; Tue, 7 Jul 2020 03:45:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DFF5D6B007E; Tue, 7 Jul 2020 03:45:31 -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 C534A6B0080; Tue, 7 Jul 2020 03:45:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0246.hostedemail.com [216.40.44.246]) by kanga.kvack.org (Postfix) with ESMTP id ABD8C6B007D for ; Tue, 7 Jul 2020 03:45:31 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 69CB7180AD802 for ; Tue, 7 Jul 2020 07:45:31 +0000 (UTC) X-FDA: 77010494862.21.veil57_120b3b326eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 3D989180442C0 for ; Tue, 7 Jul 2020 07:45:31 +0000 (UTC) X-Spam-Summary: 1,0,0,5413a445ae92e830,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:1:2:41:69:355:379:421:541:800:960:966: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:4050: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:13161:13180:13229:13230:13255:14394:21080:21433:21444:21451:21627:21666:21795:21939:21990:30051:30054:30080,0,RBL:209.85.210.196:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yg3qbs45xquxkmh3wk7jtzye14gocn5tq5wsefkkrjcxzqw8tsxzxapoiqiur.ccsh88687w1dqub4t43oaf67ke7m4uk36ikj6b37egengnxrckhw1cci7dw3xb1.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: veil57_120b3b326eb2 X-Filterd-Recvd-Size: 10570 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:45:30 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id u5so18080118pfn.7 for ; Tue, 07 Jul 2020 00:45:30 -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=vQ5GSoRjpV3R4SO9Acoy8xbibvkjIyOIkvQQtOlm5pQ=; b=f283josljPq6DKf1JQSdsMSFFQredCoAwLG3Yvmiem7LiGKNwz3J7BUtwDqrzZv4SH 1SPNgz/774QEYHIPwHCfX/xQ8NjTsLxGDijd1TsdmRnHuu9U1HUhjo/Njc0jd85ivtbH S1QycfVPg4GGLLlxKRGJK5dRI2ZVbwoYz2NZSAQkO+RH8xd0kx9Nsq7XTbP8MoQ0A+5M gjMciWUXhzIQ78c81cPjrV41sEs0jEmtKekDudymRx6tzIFxpiC5ctdulsioavSJE0ue XLbbRoAw2n/37dZpgo4v/d3etiP7cGSzdQ4YaTP3Cl+bQ+rY4rNKxu+pFW+2iqZ+fU82 ZwFg== 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=vQ5GSoRjpV3R4SO9Acoy8xbibvkjIyOIkvQQtOlm5pQ=; b=K2caKHsf0h/m5JqWnQys7pww/kk6dhBfuq+nJ+UnerRgOV1OnPTnwm4Sd/7BdrKjZy FmzmbMItCMurcMLQ5uqTOv/VVIgIaDrYwZ0OnA0y6QHmP0rRKLovKj+siaSTEp5jZ0Zm UI4vLcOeKH46la9YFa5nZMIcXxluR1X38+yuza15NErwJPFAg0DvntmmBODaWCp1pGeC uzzt3RIjfK+QzOXMx7BtPhTX42XUms///DRy8xSYunNSAFmFmo0K357znEi8XcipME52 yXr+OW8tdm18DUMvRIUo8ne2tghY+Hl3nvh6fA7s+hPg8kafg3xbYNWO2g2f3r53ap77 bfkQ== X-Gm-Message-State: AOAM531V4KxjYWyDDFlVdg7xb+AwrfXJpAoqg8we1T3SGmYs6CjASro4 nA0FlGq0a068h5opLwCWiRw= X-Google-Smtp-Source: ABdhPJy9xbFX1kg3Yu/H+ipD+c5/vdn4TdKwlrP/IwLzgfvlvEHoXzzt3paVxtngRaqFAp6l1At4KQ== X-Received: by 2002:a63:7cf:: with SMTP id 198mr42664298pgh.309.1594107929940; Tue, 07 Jul 2020 00:45:29 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 191sm21330151pfw.150.2020.07.07.00.45.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 00:45:29 -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 06/11] mm/migrate: make a standard migration target allocation function Date: Tue, 7 Jul 2020 16:44:44 +0900 Message-Id: <1594107889-32228-7-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> X-Rspamd-Queue-Id: 3D989180442C0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 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 ORed since a user could provide a gfp_mask from now on. Third, if provided node id is NUMA_NO_NODE, node id is set up to the node where migration source lives. Note that PageHighmem() call in previous function is changed to open-code "is_highmem_idx()" since it provides more readability. Acked-by: Vlastimil Babka Signed-off-by: Joonsoo Kim Acked-by: Michal Hocko --- include/linux/migrate.h | 9 +++++---- mm/internal.h | 7 +++++++ mm/memory-failure.c | 7 +++++-- mm/memory_hotplug.c | 14 +++++++++----- mm/migrate.c | 27 +++++++++++++++++---------- mm/page_isolation.c | 7 +++++-- 6 files changed, 48 insertions(+), 23 deletions(-) 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..86bc2ad 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); - if (nodes_empty(nmask)) - node_set(nid, nmask); + node_clear(mtc.nid, *mtc.nmask); + if (nodes_empty(*mtc.nmask)) + node_set(mtc.nid, *mtc.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 ecd7615..00cd81c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1531,19 +1531,27 @@ 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, false); + gfp_mask |= htlb_alloc_mask(h); + return alloc_huge_page_nodemask(h, nid, mtc->nmask, + gfp_mask, false); } if (PageTransHuge(page)) { @@ -1555,12 +1563,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 Tue Jul 7 07:44:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11647955 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 0A02313B6 for ; Tue, 7 Jul 2020 07:45:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CBA1C20708 for ; Tue, 7 Jul 2020 07:45:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zg+77soX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CBA1C20708 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 2B69A6B0080; Tue, 7 Jul 2020 03:45:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 23FA36B0081; Tue, 7 Jul 2020 03:45:35 -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 12F0C6B0082; Tue, 7 Jul 2020 03:45:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id E85B06B0080 for ; Tue, 7 Jul 2020 03:45:34 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AB4591EF2 for ; Tue, 7 Jul 2020 07:45:34 +0000 (UTC) X-FDA: 77010494988.12.shoes32_520da9326eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 708261800EC30 for ; Tue, 7 Jul 2020 07:45:34 +0000 (UTC) X-Spam-Summary: 1,0,0,67ad061f93f47a67,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:968:973:988:989:1260:1345:1359:1437:1535:1544:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2693:2899:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3871:3872:3874:4118:4250:4321:4605:5007:6119:6261:6653:7576:7903:8531:8957:9413:9592:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12683:12895:13161:13229:14096:14181:14394:14721:21080:21212:21220:21444:21451:21627:21666:21990:30054:30080,0,RBL:209.85.216.67:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yg7g1ptfznuoqn4xdetnbn81hgqyp1f9gy4rsfqzg5bjin94zrb5rycrc3wz6.ycz9ys46fu4xjytw7tw3gsfmk1jd5j6ny3dnbjdrh5wzg8s4nkqt1r4ebtoc3os.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:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: shoes32_520da9326eb2 X-Filterd-Recvd-Size: 7749 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:45:33 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id cm21so8598399pjb.3 for ; Tue, 07 Jul 2020 00:45:33 -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=+ALly2iCWh0BQrkDtphHPvmMGWbm0eTErSKhy81hot0=; b=Zg+77soXJbGPc0NLsJ1kxiqjpVafBKmMrM7OrBM/xlmVUcDE60zBLnfNUgGGVdVK2s 0w8xvrmQ2Q0eJ+1i+W52IE020sATbBxP2fTnqWsjmH+UR82HhNYSeZaFZe/q3N3qyk6y n4mwItTqjvUKh7fE5iQQoRubyoBMRMOM0WUpaYxYeAR6GdVzsmBmJhfSvsCzvrUj+obn BKdPyYXDG2rNiso+K+HhOJh1dSGn92Yn29xep5Vfe+W9e0AsjcdosphSScN7ixuhtOUz zX0YQpzayUfiJ2AUgxgNL3yPUPW+yhfV26GKkKhdyLODcWkEqp5bgUDt1hWp2sa040i1 ndeQ== 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=+ALly2iCWh0BQrkDtphHPvmMGWbm0eTErSKhy81hot0=; b=SNFJNB1RpyUfoU4aFA9ceniS9WimjagqzKryt0ScLT+oNBmgMeC+/WE1mZ9pTBpMmP Kb20YjKN//cHg1+bgACX8yv0TLfRTbbRnPQdvxUAzp6Oj8qZCbO60aqslc43pI3vUExI 18Y3KL84sk1YzkHP0E1Vk208X1y6BbGmT0Umau76xCJjgioD/D+8jr7SWc4ZsctNP5+7 WrwABQ+uFM+nHDau/yNNPyiGv0ZFTQ8zZl9Hy+a9l1pUx7ma2tjK4wobuex8ZuBNL4LB cS9GTZ+HPEnahcPu+C/FmbNUdrtaRvHeJFYYNmxcWH8O/kFNvWMdmIuF66Nc5ZrKB536 OuBg== X-Gm-Message-State: AOAM5302MGgkYY1VFuklZPKOk/ji03Mqi18h+pmdnBz7l0OXePsVdToF b1/yq+VW/NJMEj+AarpRCaep7Q7J X-Google-Smtp-Source: ABdhPJwQlR9icSQ/ViMylCqjKeK8iBXZ5C6sPnSc8IPP0qMzT56rzVGFjpDNgYoarPioFStmVxlTbw== X-Received: by 2002:a17:902:161:: with SMTP id 88mr16321361plb.325.1594107933119; Tue, 07 Jul 2020 00:45:33 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 191sm21330151pfw.150.2020.07.07.00.45.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 00:45:32 -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 07/11] mm/gup: use a standard migration target allocation callback Date: Tue, 7 Jul 2020 16:44:45 +0900 Message-Id: <1594107889-32228-8-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> X-Rspamd-Queue-Id: 708261800EC30 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. It's mostly similar with new_non_cma_page() except considering CMA pages. This patch adds a CMA consideration to the standard migration target allocation callback and use it on gup.c. Acked-by: Vlastimil Babka Signed-off-by: Joonsoo Kim --- mm/gup.c | 61 +++++++---------------------------------------------------- mm/internal.h | 1 + mm/migrate.c | 9 ++++++++- 3 files changed, 16 insertions(+), 55 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 2c3dab4..6a74c30 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1608,58 +1608,6 @@ static bool check_dax_vmas(struct vm_area_struct **vmas, long nr_pages) } #ifdef CONFIG_CMA -static struct page *new_non_cma_page(struct page *page, unsigned long private) -{ - /* - * We want to make sure we allocate the new page from the same node - * as the source page. - */ - int nid = page_to_nid(page); - /* - * Trying to allocate a page for migration. Ignore allocation - * failure warnings. We don't force __GFP_THISNODE here because - * this node here is the node where we have CMA reservation and - * in some case these nodes will have really less non movable - * allocation memory. - */ - gfp_t gfp_mask = GFP_USER | __GFP_NOWARN; - - if (PageHighMem(page)) - gfp_mask |= __GFP_HIGHMEM; - -#ifdef CONFIG_HUGETLB_PAGE - if (PageHuge(page)) { - struct hstate *h = page_hstate(page); - - /* - * We don't want to dequeue from the pool because pool pages will - * mostly be from the CMA region. - */ - return alloc_huge_page_nodemask(h, nid, NULL, gfp_mask, true); - } -#endif - if (PageTransHuge(page)) { - struct page *thp; - /* - * ignore allocation failure warnings - */ - gfp_t thp_gfpmask = GFP_TRANSHUGE | __GFP_NOWARN; - - /* - * Remove the movable mask so that we don't allocate from - * CMA area again. - */ - thp_gfpmask &= ~__GFP_MOVABLE; - thp = __alloc_pages_node(nid, thp_gfpmask, HPAGE_PMD_ORDER); - if (!thp) - return NULL; - prep_transhuge_page(thp); - return thp; - } - - return __alloc_pages_node(nid, gfp_mask, 0); -} - static long check_and_migrate_cma_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, @@ -1674,6 +1622,11 @@ static long check_and_migrate_cma_pages(struct task_struct *tsk, bool migrate_allow = true; LIST_HEAD(cma_page_list); long ret = nr_pages; + struct migration_target_control mtc = { + .nid = NUMA_NO_NODE, + .gfp_mask = GFP_USER | __GFP_NOWARN, + .skip_cma = true, + }; check_again: for (i = 0; i < nr_pages;) { @@ -1719,8 +1672,8 @@ static long check_and_migrate_cma_pages(struct task_struct *tsk, for (i = 0; i < nr_pages; i++) put_page(pages[i]); - if (migrate_pages(&cma_page_list, new_non_cma_page, - NULL, 0, MIGRATE_SYNC, MR_CONTIG_RANGE)) { + if (migrate_pages(&cma_page_list, alloc_migration_target, NULL, + (unsigned long)&mtc, MIGRATE_SYNC, MR_CONTIG_RANGE)) { /* * some of the pages failed migration. Do get_user_pages * without migration. diff --git a/mm/internal.h b/mm/internal.h index 0beacf3..3236fef 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -619,6 +619,7 @@ struct migration_target_control { int nid; /* preferred node id */ nodemask_t *nmask; gfp_t gfp_mask; + bool skip_cma; }; #endif /* __MM_INTERNAL_H */ diff --git a/mm/migrate.c b/mm/migrate.c index 00cd81c..ab18b9c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1539,6 +1539,7 @@ struct page *alloc_migration_target(struct page *page, unsigned long private) struct page *new_page = NULL; int nid; int zidx; + unsigned int flags = 0; mtc = (struct migration_target_control *)private; gfp_mask = mtc->gfp_mask; @@ -1551,9 +1552,12 @@ struct page *alloc_migration_target(struct page *page, unsigned long private) gfp_mask |= htlb_alloc_mask(h); return alloc_huge_page_nodemask(h, nid, mtc->nmask, - gfp_mask, false); + gfp_mask, mtc->skip_cma); } + if (mtc->skip_cma) + flags = memalloc_nocma_save(); + if (PageTransHuge(page)) { /* * clear __GFP_RECALIM since GFP_TRANSHUGE is the gfp_mask @@ -1572,6 +1576,9 @@ struct page *alloc_migration_target(struct page *page, unsigned long private) if (new_page && PageTransHuge(new_page)) prep_transhuge_page(new_page); + if (mtc->skip_cma) + memalloc_nocma_restore(flags); + return new_page; } From patchwork Tue Jul 7 07:44:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11647957 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 3936913B6 for ; Tue, 7 Jul 2020 07:45:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F14732075B for ; Tue, 7 Jul 2020 07:45:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f4sx6BvZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F14732075B 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 4D9BB6B0081; Tue, 7 Jul 2020 03:45:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 464786B0082; Tue, 7 Jul 2020 03:45:38 -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 2B5356B0083; Tue, 7 Jul 2020 03:45:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id 16CC36B0081 for ; Tue, 7 Jul 2020 03:45:38 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C31728248047 for ; Tue, 7 Jul 2020 07:45:37 +0000 (UTC) X-FDA: 77010495114.07.smash90_0f0b5be26eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 8F29C1803FF14 for ; Tue, 7 Jul 2020 07:45:37 +0000 (UTC) X-Spam-Summary: 1,0,0,ff15f0a4010f3a4e,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: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-62.50.0.100 66.100.201.100;04yf3sdt4nxmzmt86mu8dpfzpq7s5yco66ckud369x9ctu44b3adsyswaoxae15.pm9cyu8mzzfri79p9tqnoqn14i1r5u6nourgr5qwtytiy89zqapx9uwomtn1dxh.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:25,LUA_SUMMARY:none X-HE-Tag: smash90_0f0b5be26eb2 X-Filterd-Recvd-Size: 6462 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:45:37 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id j19so12753063pgm.11 for ; Tue, 07 Jul 2020 00:45:36 -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=JREELX005WpRXb73w0JtV5PhDqNNv1F/EVctlbeQmTE=; b=f4sx6BvZ+581C+xa5MZ1bi5iz0cs2DtAB3sGsqj40LqP3WuYPyyfKMarja8129+yFA RvXbLlA3STRqCTIr/h5t8vcyYTtxIGYFubNpGFnwO6O+JEaYqRk37f9TED34q1DTZVth FbirWZdShwrEtSvPBqrwCu22UTiZbldD45kzIHT1oH8pHAGDV9T1QgXh9St+kL3FS1Bc hOp9qtt0KG8ksVOHKRuwmOumfYwhf58fc05v54WCE+esXszvICYs/Dp5/qk/9H7tqZUt ON6VnIcYoXMM9NXMNtc4OVHISJ/0K0f8ivLMlR0/PiZU0U5CAXhEW0JcN76aZZpSatm3 yN9g== 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=JREELX005WpRXb73w0JtV5PhDqNNv1F/EVctlbeQmTE=; b=d5Wtu8m6U6Jd0tig+0katL9rb3wh57yKllu/PvQt9URyfUrTRoNB4XQmYmmlRqtD4q kKRwDc2IkinagKOGGvSnC2VAg1/qf+22C/H5lnDeNm57jaknDH0Zk/TkMAcg99JjBKYY HJaQ56b+9j/buZ8W0wRum7Lw/LwA3hhGiKH6Afu2olvtyLPo17o8YfQiBvl+rFqh4zWW HfukEn4O3AdJdjyRU8XhZrm0MKlwi2NM5W56h4A2WVNvngYVtHPuHUQwWHHWBId/laob 2VjyBNBIOCvOIvoigY5CKdLoURBC62P5OT1sAvqobq3ywJf57xXzKv7USTjXyHgGIW12 IQHw== X-Gm-Message-State: AOAM533yWlV6AXIUPL61vIJjPpZnJnm5sCXKB3OT0kD4z9cHE12YvSm2 opz7kPx56LmVd3O5Yui7oh8= X-Google-Smtp-Source: ABdhPJyFBvzhDiXcrh5tQrtq9cTzCrIXfD0xjKrVR7jyJKrJMbNqWvZPkjntb3GJSlKTTv84tOn7CA== X-Received: by 2002:a65:6706:: with SMTP id u6mr43598298pgf.69.1594107936274; Tue, 07 Jul 2020 00:45:36 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 191sm21330151pfw.150.2020.07.07.00.45.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 00:45:35 -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 08/11] mm/mempolicy: use a standard migration target allocation callback Date: Tue, 7 Jul 2020 16:44:46 +0900 Message-Id: <1594107889-32228-9-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> X-Rspamd-Queue-Id: 8F29C1803FF14 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 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 3236fef..6205d8a 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 667b453..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, false); - } 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 ab18b9c..b7eac38 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1599,9 +1599,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 Tue Jul 7 07:44:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11647959 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 755A092A for ; Tue, 7 Jul 2020 07:45:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38FD920738 for ; Tue, 7 Jul 2020 07:45:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CpTVF/md" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38FD920738 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 A09A86B0082; Tue, 7 Jul 2020 03:45:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9B8BC6B0083; Tue, 7 Jul 2020 03:45:41 -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 8809A6B0085; Tue, 7 Jul 2020 03:45:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id 6F1536B0082 for ; Tue, 7 Jul 2020 03:45:41 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 360802C78 for ; Tue, 7 Jul 2020 07:45:41 +0000 (UTC) X-FDA: 77010495282.17.snail06_3c10e9d26eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 03A88180D0181 for ; Tue, 7 Jul 2020 07:45:40 +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.216.65:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yf894gfoi6okcr7b8bmmr5nrf9wycw6ojn3ftksnqhyptuh4kxcj8sr9i7dbs.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:24,LUA_SUMMARY:none X-HE-Tag: snail06_3c10e9d26eb2 X-Filterd-Recvd-Size: 5046 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:45:40 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id cm21so8598520pjb.3 for ; Tue, 07 Jul 2020 00:45: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=jW8zp7RHqtHeCyFdrmHu1jeTiXid01JuKsYb1RMidWg=; b=CpTVF/md2a3iCa8VR9iJwBK+G4iEO3L+T91WDz+Cwf9dU1AKAoDicsLjreeKyMuI6+ YwZ1SAPNLzOt2HW4z52+kblxmx9Giou4qhMRLwMT0gTMZI5ezBRqgROq30oOJoKjouRK 3J1uVk+GxIJlUFvnsrYkMvc55CDvOetiLuVba0Bp72G2bMdvpN+EkHNpQoOFwRfzpMS6 9zaldDwb7AKe/ABA84GNM5tGWm8q7roaWmtD2I0O8JkUe0PO9LoSpgUINDwMo/mPrQgF g+IWXRTXEEVZisw32wOull+Rocr/zu84Vk9HidbWayBOJwzb0zvF2a0QvBq7upT3lFZF lqLQ== 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=TFeNDoxwmWxbcKzmrSSRCfGEb+dl+4eFeH5pK4hYzAOSJO2s3cBoHVLXBCQG9Wi+Lb l4jeasDEs2Z1y76l2FiwgYyok187ERu5XorVQLD2qFYXHaUeJZnFz/eYMTcpOiSbOvWB /75lBkt/1b71mldpReNqWTdn7c96X1nVDXOJMvtHRfl+JE17HzBSDfgFwzoLALYHMpRn iyvFWHc3cCAb403qcy8kloS3ACOx0AP/ynsE/4Vm0d90wPMn+rz/ZltvmUYfx5OuDs9d CSQoUmXjqO10UUmlVZH3jXgLrPWxnweuYOwwvBNK+o8GfqlTZ6Mn7Ki/8pOlEEVqE7WV tb4A== X-Gm-Message-State: AOAM5338+h9E4UKem/nl7QKpC/8DCCtxrL8WANvBtiRof1g4ykoCpTio N4MB9hLGDHrOD0lNepMhTGA= X-Google-Smtp-Source: ABdhPJwAO+CEp4G8QkmcEaAo7/LkG4zHaUlREQ+Dc3Aaen6AxX9LJktCqAXuiD93ex8IH76Q/lo/RA== X-Received: by 2002:a17:90a:db87:: with SMTP id h7mr3221109pjv.159.1594107939801; Tue, 07 Jul 2020 00:45:39 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 191sm21330151pfw.150.2020.07.07.00.45.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 00:45: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 v4 09/11] mm/page_alloc: remove a wrapper for alloc_migration_target() Date: Tue, 7 Jul 2020 16:44:47 +0900 Message-Id: <1594107889-32228-10-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> X-Rspamd-Queue-Id: 03A88180D0181 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Tue Jul 7 07:44:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11647961 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 C42D292A for ; Tue, 7 Jul 2020 07:45:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9054420738 for ; Tue, 7 Jul 2020 07:45:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e6OMYuv6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9054420738 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 E4FCE6B0083; Tue, 7 Jul 2020 03:45:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DFF3C6B0085; Tue, 7 Jul 2020 03:45:44 -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 CED206B0087; Tue, 7 Jul 2020 03:45:44 -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 B48A36B0083 for ; Tue, 7 Jul 2020 03:45:44 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7C84A180AD802 for ; Tue, 7 Jul 2020 07:45:44 +0000 (UTC) X-FDA: 77010495408.18.shelf65_5e0f22b26eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 49648100EDBC0 for ; Tue, 7 Jul 2020 07:45:44 +0000 (UTC) X-Spam-Summary: 1,0,0,2d8ce11e7096d013,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:2199:2200: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:13255:13311:13357:14181:14384:14394:14721:21080:21220:21444:21451:21627:21666:21987:21990,0,RBL:209.85.210.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yf3ajkfh39f7p7b81encpszqzn4opqi7k4cwgu9ejgr4baip4p51uypeesb74.cnqutxow9azqd9npukgxib1dw3h54ig346hj6fqp6xomz315gyor1qwdq9a6ghe.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:23,LUA_SUMMARY:none X-HE-Tag: shelf65_5e0f22b26eb2 X-Filterd-Recvd-Size: 4873 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:45:43 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id a14so13500802pfi.2 for ; Tue, 07 Jul 2020 00:45:43 -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=n6Rbtl/txKKgUuy/PEsZA5yJ3o5QkIBUvNqo+dh4x9U=; b=e6OMYuv6Cvw8rOj3djW6dTQTmnVCROGwcC5f18pto4sRD2ohXbd8J2oHAO7OEJMjjo dEWQKsL9DBuiqYEOSoAkza3yycdMtE6wkMJSEbf7dh4owmMNOvJKUZ+8B6U5wGu1xHjz 6xkqCdO8l2H8jHQJYr09htT4bf5pIvamI22VNvk30BVA4oZEYJ2FjLBl2BroVX3+vLpG IRvuYZd/Lf0CxYfl2CKzbsyK2FWiNN/UlZJ4ide9GbUB4HIKewuWsCec9yh41m0tG6Vk UchpaM7bkesbK02c6sKL+q64Z+Vm6CGjMT9AyiAvuXKE/CUrRoCJ8HWZ/kHrE/0NA1yo ALiw== 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=n6Rbtl/txKKgUuy/PEsZA5yJ3o5QkIBUvNqo+dh4x9U=; b=l/o/y4ciP+u5ZK2Hh4vcURSICVEXM2CJBiTrt4RWm0BjXe+x5FIIWWGSHQ+4KxTRTa yrdn59ievRukKTUsEI6I1TEp0XXZ00/oDHV0OJxmuEBkGfDD1rPyiLh7fCkVnHvyizio xzOMbxutVqXMiAlKC8WFz56w+YKhWBcHmDRKO8SEp+wL16DxQGy5JO7HFoxb5+p+DTGw qixIUiqjPs+Yuqpwkp+x3/BL8+EOfr3cmGB9LBHQ+xl7Ry+TrtYzvTch5pz08wMYWFUA uKUUoutB6gY6Wq1dhbS4tSOowui0531/T5YYu/n356VTcUsM2K2dAwY2zMfnytSpGXUS oKJg== X-Gm-Message-State: AOAM531t9/PW0DVYm1Wd/HfOkz/x+JSwNkTBt1EgzW7lEpPwnfkph1Vr 1htqFydmXd/4VkdP7Ac44gc= X-Google-Smtp-Source: ABdhPJyw8VwJQhpVC5lwFEMc/qLi7+XCVCWj0fqhAIQ9/IxGxoDSgpKnUy27bITILGbIBXVOmhWGoA== X-Received: by 2002:a63:3fc2:: with SMTP id m185mr45078394pga.426.1594107943087; Tue, 07 Jul 2020 00:45:43 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 191sm21330151pfw.150.2020.07.07.00.45.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jul 2020 00:45: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 v4 10/11] mm/memory-failure: remove a wrapper for alloc_migration_target() Date: Tue, 7 Jul 2020 16:44:48 +0900 Message-Id: <1594107889-32228-11-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> X-Rspamd-Queue-Id: 49648100EDBC0 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 There is a well-defined standard migration target callback. Use it directly. Signed-off-by: Joonsoo Kim Acked-by: Vlastimil Babka --- 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 Tue Jul 7 07:44: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: 11647963 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 BCC6C13B6 for ; Tue, 7 Jul 2020 07:45:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7FD1F20720 for ; Tue, 7 Jul 2020 07:45:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hLhvTve8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FD1F20720 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 0E2AE6B0085; Tue, 7 Jul 2020 03:45:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 092C76B0087; Tue, 7 Jul 2020 03:45:47 -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 E50DA6B0088; Tue, 7 Jul 2020 03:45:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id C9EBD6B0085 for ; Tue, 7 Jul 2020 03:45:47 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7C9BF1EF1 for ; Tue, 7 Jul 2020 07:45:47 +0000 (UTC) X-FDA: 77010495534.26.glove70_611468c26eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 556821804B661 for ; Tue, 7 Jul 2020 07:45:47 +0000 (UTC) X-Spam-Summary: 1,0,0,625399ebe9b7114e,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1535:1542: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:5007:6119:6261:6653:7576:7903:9413:9592:10004:11026:11473:11658:11914:12043:12114:12291:12297:12438:12517:12519:12555:12679:12683:12895:13255:14096:14181:14394:14721:21080:21220:21444:21451:21627:21666:21990:30054:30070:30080,0,RBL:209.85.215.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04ygo4bhzd8ca46otk8geo31x1pjeyc7jhr683cpq4pkc1diqrd8oe871z6u148.c9n3gekywrz68twrpzedz1uu474n3msd7t7af3dfgzjercoj5zhcey1jwfeumn1.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: glove70_611468c26eb2 X-Filterd-Recvd-Size: 6092 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 07:45:46 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id w2so18816291pgg.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=ES1JVQ16sQs0P4v7doFMCUN430OUPy1W7qPWhyfdGSUS/RbGc0E0pV8uL/DPGDIZ0X BXpJ0f0TBENRw4gk3jp2MmsMoNtrb9xSrkw1x3g1+Xwqo6b5RKQIXR2r1W1Hg2vRfyQG fV27O7V03+va09nYEiZO5OmEJHjUqk4MjdbGpI/sfJTfcEfA5EACx11Fv17yU8BPrlua QFdp7sDqiUAtfhmQgsxkatHhwNMfjFvp16kWBo4b7rnAE/RwPlXt2SDPUtOaZNS8aelO KLdTmUrpYirtz6MTByAvKj6MEBQWMbsxE/dvLb7MjgdIp8EJ4aPwjdxuVc1gsLSj1ebQ aOxA== X-Gm-Message-State: AOAM531rW/ceq//S3lEzdBc3sXc8uk2/LQlSn3f+TLeGECdkgRw0d7R2 givgBEPcGKtqsYUJZ9uJXL8= X-Google-Smtp-Source: ABdhPJxlDO3WoaDglb+wcPrmU/2YdnCSFYtWgnyHAXUK3MmN5luVVbSC7GR0VJ76/+5DCFgxQUNvgg== 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> X-Rspamd-Queue-Id: 556821804B661 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. Signed-off-by: Joonsoo Kim Acked-by: Michal Hocko Acked-by: Vlastimil Babka --- 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 ",