Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1003545pxu; Wed, 2 Dec 2020 08:40:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+YtBvVWkSwofP5wi282PrP9StEpArH2zZj93L4KJXWK9ThcBJpEwXdl40tCtdjH5aom7p X-Received: by 2002:a17:907:94c6:: with SMTP id dn6mr588890ejc.13.1606927224806; Wed, 02 Dec 2020 08:40:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606927224; cv=none; d=google.com; s=arc-20160816; b=zO0XtbtShWVcVIC/htuYCubzDF+cjd562sfczAUBgoQeWabNzniHb8/X6neNClBRvZ zNqRrcUyKSwwwLYNxMEy3Jqc9+nm4kVtIDaiLZ0aNWdYKBKbTxM+Tl/8iGtndBS8CWJC Gqmz3jBiNtukY2K2Jyxi9m729OHJ3IFDoVxqsEAzQVJ0SZaFntqI5qlOujMMpxCUzqqV l1nrnC2Op/iyv9WadpwaZIXTItHP/cfEofu3SNwTXb8UfzBsq/GE5NN7jS+vn0fJRfJb TtLG6bpdfZPgFsaYZ6c1owNIX+ZpJRhLBrv3WM5WprsOQ8f9HDu2WcApnQSNOabHFQ5i UM4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4hAyW+JiNSbp72nZBWsfmIBRqBtiOCYtYCN54NjZjGM=; b=UFouaGCMlVE3kpVwXwHG8eFRfgWbdfrVtQAiyElKa3Wv7RQsH/30Ad+OwVSQmH0MKo SEck5ddUFSD2x4f6xyE/35Vq0Di0i7JX8OW1VfJ8ObfHNnYmXlTRkELrJd5c+pDidbMn VEkz5yLgBsGfmdzA640YJETAG/4SNNDL0kdIAN/dyv+tc2OY6KCzLDknPNQ20VzZLTx1 XBJXuqHXoQLbSK/qNfCqxDI/XxaAP7xYwP2KyQdSNdb9NxiPog53p+zozuv9TqOg9mF1 8Eh7+iTPMzEp7B/P5YYP5fxUoCV9azhE22dMZYXQpDI0pI/V37ny3XXjcQjkLj8c7Kc0 QWTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=KAmCkI3X; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si304750edb.395.2020.12.02.08.40.01; Wed, 02 Dec 2020 08:40:24 -0800 (PST) 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=@ziepe.ca header.s=google header.b=KAmCkI3X; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389074AbgLBQge (ORCPT + 99 others); Wed, 2 Dec 2020 11:36:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728241AbgLBQgb (ORCPT ); Wed, 2 Dec 2020 11:36:31 -0500 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 753DCC061A4D for ; Wed, 2 Dec 2020 08:35:09 -0800 (PST) Received: by mail-qv1-xf42.google.com with SMTP id es6so973032qvb.7 for ; Wed, 02 Dec 2020 08:35:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4hAyW+JiNSbp72nZBWsfmIBRqBtiOCYtYCN54NjZjGM=; b=KAmCkI3XgKwS7JrjNjdZixSGStpnUIsz+GAuDutpC16uLJxjKM5vZ7OdkDQVk1sw9U NegzZCzRgbgGy+fH/inFmM2HbgGW4E584g3f2OkY1IqOSG75YqdDEA5gUViIJDu4izfZ nSZzp3MtaFdYC4zitfa8xX1DoGZR4H3VOaDFmg37NcXRtLrBPWx55G0abBTm/YgpsGPT Sv9IGEXeqNvJr61wSOPEsl99SYVYhbk8nPpjHMM0Mt0cSA5sveO7C2qBCJ1Ih1o4BULU 5LGBdQY29XB5mv30AiAAU+fTtU2DLFHTID6asouveENswHVa5sglFe1+dvr54oMNI/iS ZQmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4hAyW+JiNSbp72nZBWsfmIBRqBtiOCYtYCN54NjZjGM=; b=PvseEvHnEqcBpUKKz6ebdEL4xfqjzYPyAgEUeOl7H8mnOWzo7WFDNAGYbPLsfxGnA8 1LN6T1GRw+yuHIsTe68/fcBXVG16oa9HCEVB+MN/f2nqbZTfQVDyOR/pWfgUzdqHhqc0 kUcGr8114mYfSSmuKuJZuVkP/B1znoBDKnaMIHaKvQeo1OgSb8DHKcw6tl+K0yehmEVa AbE3cJy9Nh1BSuIh0WxlQFlUesYJOezhyJcqbJJt2/v59eO/UNWsCt2gAN1k3nGrwptI 6CzvABa7a6Owcnt6yYYSRnuwmu/aOJ7PpCFNjbswCSqu5MT8G09Z8ftwpFBWgf7uf3f9 1ppA== X-Gm-Message-State: AOAM531TaQ7+ZyM1P2Phx0uTAcZE11p1l/6R8Y+85e4JN7WEQZunqyOH zfZSGIFZ/cyDSPmvKRcX2bU3/g== X-Received: by 2002:a0c:b3d6:: with SMTP id b22mr3263441qvf.10.1606926908608; Wed, 02 Dec 2020 08:35:08 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id n21sm2246937qke.32.2020.12.02.08.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 08:35:08 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kkV5v-0056oY-G4; Wed, 02 Dec 2020 12:35:07 -0400 Date: Wed, 2 Dec 2020 12:35:07 -0400 From: Jason Gunthorpe To: Pavel Tatashin Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, vbabka@suse.cz, mhocko@suse.com, david@redhat.com, osalvador@suse.de, dan.j.williams@intel.com, sashal@kernel.org, tyhicks@linux.microsoft.com, iamjoonsoo.kim@lge.com, mike.kravetz@oracle.com, rostedt@goodmis.org, mingo@redhat.com, peterz@infradead.org, mgorman@suse.de, willy@infradead.org, rientjes@google.com, jhubbard@nvidia.com Subject: Re: [PATCH 6/6] mm/gup: migrate pinned pages out of movable zone Message-ID: <20201202163507.GL5487@ziepe.ca> References: <20201202052330.474592-1-pasha.tatashin@soleen.com> <20201202052330.474592-7-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201202052330.474592-7-pasha.tatashin@soleen.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 02, 2020 at 12:23:30AM -0500, Pavel Tatashin wrote: > /* > * First define the enums in the above macros to be exported to userspace > diff --git a/mm/gup.c b/mm/gup.c > index 724d8a65e1df..1d511f65f8a7 100644 > +++ b/mm/gup.c > @@ -1593,19 +1593,18 @@ static bool check_dax_vmas(struct vm_area_struct **vmas, long nr_pages) > } > #endif > > -#ifdef CONFIG_CMA > -static long check_and_migrate_cma_pages(struct mm_struct *mm, > - unsigned long start, > - unsigned long nr_pages, > - struct page **pages, > - struct vm_area_struct **vmas, > - unsigned int gup_flags) > +static long check_and_migrate_movable_pages(struct mm_struct *mm, > + unsigned long start, > + unsigned long nr_pages, > + struct page **pages, > + struct vm_area_struct **vmas, > + unsigned int gup_flags) > { > unsigned long i; > unsigned long step; > bool drain_allow = true; > bool migrate_allow = true; > - LIST_HEAD(cma_page_list); > + LIST_HEAD(page_list); > long ret = nr_pages; > struct migration_target_control mtc = { > .nid = NUMA_NO_NODE, > @@ -1623,13 +1622,12 @@ static long check_and_migrate_cma_pages(struct mm_struct *mm, > */ > step = compound_nr(head) - (pages[i] - head); > /* > - * If we get a page from the CMA zone, since we are going to > - * be pinning these entries, we might as well move them out > - * of the CMA zone if possible. > + * If we get a movable page, since we are going to be pinning > + * these entries, try to move them out if possible. > */ > - if (is_migrate_cma_page(head)) { > + if (is_migrate_movable(get_pageblock_migratetype(head))) { > if (PageHuge(head)) It is a good moment to say, I really dislike how this was implemented in the first place. Scanning the output of gup just to do the is_migrate_movable() test is kind of nonsense and slow. It would be better/faster to handle this directly while gup is scanning the page tables and adding pages to the list. Now that this becoming more general, can you take a moment to see if a better implementation could be possible? Also, something takes care of the gup fast path too? Jason