Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2345852ybk; Sun, 17 May 2020 18:28:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwju7OMgFcxXKPMiTukcWYNDudR2fK6iK6kVFA09VzaeeNtKWLCsaOiAe7eQMOt0RgW1Iol X-Received: by 2002:a05:6402:d0a:: with SMTP id eb10mr11339095edb.60.1589765296248; Sun, 17 May 2020 18:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589765296; cv=none; d=google.com; s=arc-20160816; b=Pb3b8T4bLweBrZCAsC64KsB/1AZQWfKVbVlWuSm8w4Jnv/0FNj3G9GPiXE12SzMrXU Whk4Zi1JxLuMq8HRbnnq5hDKHLdn9PKlFHcUoSb2zAuZhztue6HNeKdkgotUncnnuwfF j6hruRc/0YTlOoiR3JbznXJY/pOBoSFHhyi5TQOsmxXQIZ/m6GkqNQsdonBQVDyH1on4 Hc2KGmqOb9fX94FuFm8+l+fPn/3GJE9kqtz5eRVJeAKJN/PSmn0/W+KLyWhceykQcFjD yC9VnM5xQX8j5R5gxKEGn3F+QKl2QbMlB5n1/OyxW/HJicM9ekpxc3dfdgPSdX+N9mxw TaFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=hSmTRtwjBP1ZZownFG4HBeG6KLnsrTJB9GY/Fcznxzc=; b=N2e5qePEvgknKt8b5gKJ8BLTfPABTzg9D9+SoJ61jhjP1DvrjUWxXZEND8qUaNrYgE QA9JUupcCZfXp1V7fmHr+TKnepVzPAKfWnfhWse/7NXiYs+y0GJZtLM91RqxNMNPsfFH tJpq55eM2sF8gpyLCYCZtKVJySh1B3K461Bg1izEvQXYYv8cy1kZDG8O6xDSyARBmIzE xKL+GFiln3X6Ophgak/2r/5W5AKmCbS+i46zl3BpP1cffkwWd9R66VFy0QeLjFIjjJ4q wd4cXD2OqSQZ/UkgUlN5fAR9Ls0oyZauKME2+u1EexkQvrnD7TKuLk/9nva70slRxkpv F/ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TuGN6hvO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k5si5465785eds.231.2020.05.17.18.27.53; Sun, 17 May 2020 18:28:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TuGN6hvO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726726AbgERBWT (ORCPT + 99 others); Sun, 17 May 2020 21:22:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727122AbgERBWJ (ORCPT ); Sun, 17 May 2020 21:22:09 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2392EC061A0C for ; Sun, 17 May 2020 18:22:09 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id c75so3065907pga.3 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=ekWRGowVCmssKI7GuFvCdOE5CJtJkDKlKolwKMV/Gen/LHsE7KISqUc30XNIxZFwtx pVvTruwWr/UYBXb1nB60sm8NfKs/IEVKv+gnEQEI8Qq2L/wCyW/Um0oqiEWi0sGNp9T6 5Tue2GNZS6YMqS392UgvZTPYzdVdRwQwK0Bj+c511CjV2GQtUrTwbrZnhB0SJJ75MSh0 mewMABkja7BQOAeNObYpbXqcE0EjjBItj1jDLUoWsJX89apx27uEy5iCteBSOpZ0JBUu wh5EPGjEJ8RaR+Uzq/oNdYHvQQ2qmSwWvpka8DHrT4BkNyPnRqb4bzo3jjfJya73SaXo PkBA== X-Gm-Message-State: AOAM532EGNAsS7RbYUsL0f4Qpleiy5r2kZttd6Z5CBHl4eW/FUr2d9hA R0odHbRv1kb51RESzF8MxFU= 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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