Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp588412ybm; Wed, 27 May 2020 03:07:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLz6/vSHONOP3364etl022HyXn9ysSQTFxds5N1CMK7dThKwbR7ApNEEUOgRkiPpT2MpWn X-Received: by 2002:a17:906:81c6:: with SMTP id e6mr5069781ejx.241.1590574065667; Wed, 27 May 2020 03:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590574065; cv=none; d=google.com; s=arc-20160816; b=e9GNWkTiZuJI5PVUy5M+3itRE9vOlxD0sLvTugTvfT2jpIlsCZJ+2KTOHXaIFj3Nc3 2r4gj5RVEztBnCKvNmuB5bLcLuS8zdlL/bG/sJRauGDKTF76P1Nm3HR4dxEVx9WpPSdy If4FL6yy9a4T0zOrnlGHhTVoyVo9jpfk08ZtULjqLvdFvjaOtl/8auUog6LGexfnw7My 53U8fj/YzUtfviaxYRYeEdnhgpDi7PrTdeycL9JLgli9Zuxx48e5OkKn5VBlJhjZRAdv bGWI33SZgYYu4ddL75y3hW3tGaf/Yem3v91scIMFoSCGrtXUUh75WP0coL49zLF6h3x9 2VPQ== 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=oCWTo8ae5wYqiJISS3BTEu3KhdtRS7foiClTJOTmPqk=; b=JysahxwrUM/FrEIJJrdtKON5p2HmUwlSzChr5h19h4fg2cZF3RiZzKM8buNTXaUYPg plL5q8pGhqb2pVJhqmsffUym2iPkpeiTI+BtRu2FSmyXXCaHSnzMbtp/tOMYM+ZNq1al 6OaAohmLjYNgoXHALGUeGxOEglfTotdVx/e5mprkxxPSNZO1uQOEvZp8BbMDhHuFuS+k J65lNemOEfxGaqlIq9fQvb8Eo7VaNeDxFRo02/Ld2o4vCPFiWIglPry16obuVwfQt6Tl ty4d0Yzl9HR/r4IRbyoENb3c7FiyvjbpRH8JfaPGtLOKO0yQEkY0KqfPredyxVLHUMw6 sHFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KsSlU8K3; 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 r16si1506483edp.57.2020.05.27.03.07.21; Wed, 27 May 2020 03:07:45 -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=KsSlU8K3; 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 S1728990AbgE0GqR (ORCPT + 99 others); Wed, 27 May 2020 02:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728922AbgE0GqQ (ORCPT ); Wed, 27 May 2020 02:46:16 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B93DC061A0F for ; Tue, 26 May 2020 23:46:16 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id s69so1126884pjb.4 for ; Tue, 26 May 2020 23:46:16 -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=oCWTo8ae5wYqiJISS3BTEu3KhdtRS7foiClTJOTmPqk=; b=KsSlU8K3mDcBiOUAUkKkIwvhCMS4g9bfdCw4o4WsKIf22rLAtmHAXQsoHGN7UZz444 R21H+Aulwtj2jNq0ihq4BvK1LveOWhyzf5yjzsHd0Zo3bDYryfRveYuTCk2EJq5WNmRg mQ1cCYr8mHA7FF7m7VDFgIwAa0GE4Egot9Vz0z25QFbeJQmxxRv8q18hYl3ie8Gia34l KAdgPWYYY/2frIOy3xexSVkyubLJYzSiWeRYQIfTG5FZ8EeKJbJp179ulCV6l8ukxiQV CB3WG8E2dZ+3XPJnoVKZSF6aob4zhGkX8MXaNpJa9NCVg6MrjwULuYdRNlyb/bHq5PB1 ZFdw== 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=oCWTo8ae5wYqiJISS3BTEu3KhdtRS7foiClTJOTmPqk=; b=JDziRNMKPZqcC29kozxcMUJDg6DG/4/fmIsUecFaMguHEt+K6Z3vEh08BW27P3JzIF tIIQ4CL3o7hU7e2le6xwjjd4x3iw6JgGrwWvJlZzGwT3jfmtiZkVBcoFNsip/u5eXQwb h+0eZoE7qkFEA2sd5uRKUDoXJVk5csVjWIR2sI8JBiphax8P3+5UR8qystJQYJGi3Wgc 7YPy6GA4a8R0zT8BbuMvVQVl68a7iqzEj7EcH9oNTjOjRL94FcnQK79Oxd1zxAuYL0pu Z4KGblmoQuybqAlk51LhjlIVRT6eRD7LDEZV7I7VW6PoCNjLzgHVW6gM0my+mb5f9RNn vV+g== X-Gm-Message-State: AOAM530M4/tpWzWQ1uw2lvAJemcurCjAM0TyB7FQGCM6jzin6p64WDNz eSTlEFscvtkEE/nCwiIj7aU= X-Received: by 2002:a17:90a:2325:: with SMTP id f34mr3212211pje.91.1590561975534; Tue, 26 May 2020 23:46:15 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id r13sm443883pgv.50.2020.05.26.23.46.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 May 2020 23:46:15 -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 v2 10/12] mm/gup: use standard migration target allocation function Date: Wed, 27 May 2020 15:45:01 +0900 Message-Id: <1590561903-13186-11-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590561903-13186-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1590561903-13186-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 a49d7ea..0e4214d 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1593,58 +1593,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, @@ -1706,8 +1664,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