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=-9.6 required=3.0 tests=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=ham 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 C1EB8C433E6 for ; Mon, 18 May 2020 01:22:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8115B207F9 for ; Mon, 18 May 2020 01:22:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TuGN6hvO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8115B207F9 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 681A180010; Sun, 17 May 2020 21:22:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60CBD8000B; Sun, 17 May 2020 21:22:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43A0B80010; Sun, 17 May 2020 21:22:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0114.hostedemail.com [216.40.44.114]) by kanga.kvack.org (Postfix) with ESMTP id 21E5C8000B for ; Sun, 17 May 2020 21:22:10 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CB6A38248047 for ; Mon, 18 May 2020 01:22:09 +0000 (UTC) X-FDA: 76828088778.22.thing89_8744c184e1810 X-HE-Tag: thing89_8744c184e1810 X-Filterd-Recvd-Size: 5896 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Mon, 18 May 2020 01:22:09 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id f23so4074835pgj.4 for ; Sun, 17 May 2020 18:22:09 -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=hSmTRtwjBP1ZZownFG4HBeG6KLnsrTJB9GY/Fcznxzc=; b=TuGN6hvOEpkfqCs4Mvgl/vl8r+hMnu+bB+x9wBx+9bEp99DAdm6X8DZvpyWGMysK6v /a2//CE3tJV7QOfl68+JpvvSaiWYsBK5QKtenLwI9T3PfkxzRFAsmDi9A2LwYliCz6NQ FBlBWw78UvlD6iM4YTL+ZUBw2dJVxXSRp8Zk5MceYVwwqD/yvQ0V09whKPIbKyF7As5R udmPfK3hOaR+GxQVHDwnypOFO6AwuNFMUjFJQURv/38bBvLvFQBhCSz2159A/v7pp90R oyWkR3CXI0eWEdOb7Zsp7GlTYy7PWNwLc4mK6SCXDL2uWiYMB3hhK8Gu117NzaON1ftT iNQw== 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=hSmTRtwjBP1ZZownFG4HBeG6KLnsrTJB9GY/Fcznxzc=; b=MxXq3BvEeAN4KvVcZvJ42jcgdHIPF2JW/ZI1FS/yWnEx39bRWZOSdogJXnGMQyCzCV om2g6gVXFrh1i1UcWKeLmRXtbt2GhUa5gJ9zjBm+RRRhmRZX4Wg15KI96ccnrKdqpKsu BtyuhMX9ujxyWa0YWS5rp2m+1Wz+kFkTuFqo9u9mCz/K0uxRHmWs0JKXSXS8hrC4ZqeR P/dZDhoZleWO+4D2qtUKLIARbxBTOnl+wZC55Worhl5R6tuhHkxLMWvLawx8NMO1U+no 4Z8Y7JE+b4W51HUl1MZwzS5K261HJSpLjZlDAy41FJkn476SllbiqOSqVdzoo/tgDCPv UNKA== X-Gm-Message-State: AOAM531wyqj7aVDSj05Cd21t+iI+necfeXWpZXloqmDSV3/Ws1qH1CBE 67wEyOeyZmcZoF+5VbToXVQ= X-Google-Smtp-Source: ABdhPJwdffOTCzgAHEOzll3Uppf9LzYDzLMemDkCIRp0Bxicgs2qNDjNkDk572iKIGCGbwWZuGngjQ== X-Received: by 2002:a63:5209:: with SMTP id g9mr12546532pgb.162.1589764928658; Sun, 17 May 2020 18:22:08 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id fw4sm1544376pjb.31.2020.05.17.18.22.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2020 18:22:08 -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 09/11] mm/gup: use standard migration target allocation function Date: Mon, 18 May 2020 10:20:55 +0900 Message-Id: <1589764857-6800-10-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589764857-6800-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1589764857-6800-1-git-send-email-iamjoonsoo.kim@lge.com> 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 reason to implement it's own function for migration target allocation. Use standard one. Signed-off-by: Joonsoo Kim --- mm/gup.c | 61 ++++++++++--------------------------------------------------- 1 file changed, 10 insertions(+), 51 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index be9cb79..d88a965 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1594,58 +1594,16 @@ 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, +static struct page *alloc_migration_target_non_cma(struct page *page, struct alloc_control *ac) { - /* - * 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; - - if (PageHuge(page)) { - struct hstate *h = page_hstate(page); - struct alloc_control ac = { - .nid = nid, - .nmask = NULL, - .gfp_mask = __GFP_NOWARN, - .skip_cma = true, - }; - - return alloc_huge_page_nodemask(h, &ac); - } - - 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; - } + struct alloc_control __ac = { + .nid = page_to_nid(page), + .gfp_mask = GFP_USER | __GFP_NOWARN, + .skip_cma = true, + }; - return __alloc_pages_node(nid, gfp_mask, 0); + return alloc_migration_target(page, &__ac); } static long check_and_migrate_cma_pages(struct task_struct *tsk, @@ -1707,8 +1665,9 @@ 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, NULL, MIGRATE_SYNC, MR_CONTIG_RANGE)) { + if (migrate_pages(&cma_page_list, + alloc_migration_target_non_cma, NULL, NULL, + MIGRATE_SYNC, MR_CONTIG_RANGE)) { /* * some of the pages failed migration. Do get_user_pages * without migration. -- 2.7.4