From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16425C433E1 for ; Fri, 31 Jul 2020 07:35:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C603D20829 for ; Fri, 31 Jul 2020 07:35:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p6cjWGM7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C603D20829 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 5F8F38D0015; Fri, 31 Jul 2020 03:35:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 57F488D000B; Fri, 31 Jul 2020 03:35:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4494F8D0015; Fri, 31 Jul 2020 03:35:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id 282BA8D000B for ; Fri, 31 Jul 2020 03:35:39 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DD2A18248047 for ; Fri, 31 Jul 2020 07:35:38 +0000 (UTC) X-FDA: 77097561156.30.shoes32_070157726f82 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id AC175180B3AA7 for ; Fri, 31 Jul 2020 07:35:38 +0000 (UTC) X-HE-Tag: shoes32_070157726f82 X-Filterd-Recvd-Size: 6056 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 07:35:38 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id b9so16619113plx.6 for ; Fri, 31 Jul 2020 00:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fz5EvzWcsoicVDmNg73Hue/6iS5qANYWrgBKFYsm2Zk=; b=p6cjWGM7sl0zlXQANnmmK2pluQpa12wDI/791cNq4b6MOShBvRCZEEQP5DIXgqJV0h iWDU5I3sKZxfLbmoY372/fADoK6qr8ExQ/vRQn0yY3Jd4sqp+wWissRwbrRH7pYk/zS+ dfTaKuQYwhLBINAUDVvGbB2uWnSKfpDpWKsNU4G5T7VrHHCB3/oR/ynoPeDn9DKENrlN 9xli6W4OdNu9V8Fpiu48wkcjFiiM8LZUMgxrsYMXkjvSuWjWYp0gYPEsQJz6Ivlnr2gf p4036Fpz9ulmfypc1Zq0KpvVy33oV1M0RWf5UhSrFPmwV5v1aGOXrQBwN47VSYZnhA0Y C3Vw== 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=fz5EvzWcsoicVDmNg73Hue/6iS5qANYWrgBKFYsm2Zk=; b=kJxUXU4933Sesx4UwCpM1nmLYQsKWK0O/8fGUTFugqvJx5dzzP3RkfD5ZjWwxWLUPF xocOpG9xTDCK/qMWLfWc07W+FewiYSDN9Gl1h5ZoHGV386XoYfqaG8qGK47WRhk9CTRE J9WQuGfyqZkQkUZ2hXdN6a6fKF5r75Hto2G7vCAQ7wMLc8OMtRl+zm4x1Rj2jKRG3YYh gb0OTmZnrfivQBpie82MkTfYLxKcuxW4oQQJD4eIHnu9KnI8duEaJYGBmTEgR50FD8Yj QnTBji+d2C2nP7mQ75SWOSpE5BLqxy830f8ZilakYphsVIFtflgZtBwcqiufue8+JPDe v3/A== X-Gm-Message-State: AOAM531N0BekTCYBdKAxTKwuwdOoIwkYxzWQnO+gXRnBzBkqT7fhB4zv h+g1AlgmQFZKCRjulELEXk0= X-Google-Smtp-Source: ABdhPJzpHCy21D2TSln0lf0yWFRkxFEHawCHi92eFry8Gc2RG7tB3k+D/dChftMGTjry5R/agH4Ufw== X-Received: by 2002:a17:90b:46c1:: with SMTP id jx1mr2972537pjb.125.1596180937167; Fri, 31 Jul 2020 00:35:37 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id 13sm8355522pfp.3.2020.07.31.00.35.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Jul 2020 00:35:36 -0700 (PDT) From: js1304@gmail.com X-Google-Original-From: iamjoonsoo.kim@lge.com To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Vlastimil Babka , Christoph Hellwig , Roman Gushchin , Mike Kravetz , Naoya Horiguchi , Michal Hocko , "Aneesh Kumar K . V" , Joonsoo Kim Subject: [PATCH v3 3/3] mm/gup: use a standard migration target allocation callback Date: Fri, 31 Jul 2020 16:35:06 +0900 Message-Id: <1596180906-8442-3-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596180906-8442-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1596180906-8442-1-git-send-email-iamjoonsoo.kim@lge.com> X-Rspamd-Queue-Id: AC175180B3AA7 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Joonsoo Kim There is a well-defined migration target allocation callback. Use it. Acked-by: Vlastimil Babka Acked-by: Michal Hocko Signed-off-by: Joonsoo Kim --- mm/gup.c | 54 ++++++------------------------------------------------ 1 file changed, 6 insertions(+), 48 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 7b63d72..ae096ea 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1590,52 +1590,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 CMA - * allocation memory. - * - * Note that CMA region is prohibited by allocation scope. - */ - gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_NOWARN; - - if (PageHighMem(page)) - gfp_mask |= __GFP_HIGHMEM; - -#ifdef CONFIG_HUGETLB_PAGE - if (PageHuge(page)) { - struct hstate *h = page_hstate(page); - - gfp_mask = htlb_modify_alloc_mask(h, gfp_mask); - return alloc_huge_page_nodemask(h, nid, NULL, gfp_mask); - } -#endif - if (PageTransHuge(page)) { - struct page *thp; - /* - * ignore allocation failure warnings - */ - gfp_t thp_gfpmask = GFP_TRANSHUGE | __GFP_NOWARN; - - 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 mm_struct *mm, unsigned long start, unsigned long nr_pages, @@ -1649,6 +1603,10 @@ static long check_and_migrate_cma_pages(struct mm_struct *mm, 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_MOVABLE | __GFP_NOWARN, + }; check_again: for (i = 0; i < nr_pages;) { @@ -1694,8 +1652,8 @@ static long check_and_migrate_cma_pages(struct mm_struct *mm, 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. -- 2.7.4