Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp520664pxu; Thu, 3 Dec 2020 06:19:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcmZRxx0mjh2aCNZ8A7oRZlM8HSqlrcr+5q+KD46XzIQQs+ArhczmxjsDDhtsKA9hlZa2g X-Received: by 2002:a17:906:e093:: with SMTP id gh19mr2741247ejb.510.1607005199320; Thu, 03 Dec 2020 06:19:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607005199; cv=none; d=google.com; s=arc-20160816; b=Y8Sj5Cw0prHycsTebNNXmX2wgyTCkQwI1vNxu9Ox4xIsg3EQ0V5jKHxD1ppZ2Np7/G k+vQL7082w+39Cz1LtJ1znC6cGFw3MlWpQw41924bqApp74OsSeVgVXIekfCYUDCAVYz ZngtVQJ//S2JdptqFTsdvNeEcIWnbr71taD8/EiBq4E2YLBJDeldckZOfDN3grZezHJl FKnIRXz2IS7p6myTBD42x15AVzEdcBsu2ZyEl39YegwmWRxWDc+Msn5R9q4PYPANP40c rgWvTf0gDD76BnVIbyNFJe3aKeRjLDFBxFflE5/9YV4mdzc43DXZncA7zK7r6K3dNn9S ZyLA== 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=8OibpZHqlmZvNVYfBDxh1hs2pxMvlwSThz0lOwApQaI=; b=ghkC+zKftinbdikXJDz3o7E8+j4wFE60n0zZL/M5u/GSIMXheOud/dWI6OQbAskJlo smDIcx0VinJbzYrgK5aZLCob+rm3V0NIpgCmxuwzYfHibshLDkntTZv33lLXdDpijLNj TFDpdy+dgztzM106iUbeAGl8HPUwatofABoRWfP+97dNitWe8XSiDPVaERnDdAiiRaFe HauWEGYcIv1vnJI+y1XFHIFRDEHMk23OzPIvKQHSDS8KJyQNYwl0BTzNSMSVyyTyFkPe PWvRuuvsWYU18FwLjYjXKAPbwkdR5lJNM8r/hPYxV6r1WgBfcaMsEYcsBnoDXnKKAqda TJdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=dk5q4Lr+; 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 q23si1007660edt.531.2020.12.03.06.19.35; Thu, 03 Dec 2020 06:19:59 -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=dk5q4Lr+; 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 S1730692AbgLCOSN (ORCPT + 99 others); Thu, 3 Dec 2020 09:18:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbgLCOSM (ORCPT ); Thu, 3 Dec 2020 09:18:12 -0500 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D97D3C061A4E for ; Thu, 3 Dec 2020 06:17:31 -0800 (PST) Received: by mail-qk1-x729.google.com with SMTP id q5so2100742qkc.12 for ; Thu, 03 Dec 2020 06:17:31 -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=8OibpZHqlmZvNVYfBDxh1hs2pxMvlwSThz0lOwApQaI=; b=dk5q4Lr+q5IgxWjo0A+9TcXXXrq384wcGpfFnW+QthnBUzC+5B7hiePCXYDMPpV6jE sNhAIvlE1T5mx9PVfjK4oGcrSWpFcFeMzVu+qY+xubhZBvnXhJhAYP38b89l5ZZYibf9 ocSsdnRcueGyZCJvpT9QabpaDr/Oo55UVTpqQqm85hxK8UMQ3mqzE4IQkNLC9Wqo4cqT emcy7qR9d49DEeksCWwyjYGTuliI6iG0poQtlw8IIaDRn7kfinv8yVxM077suxO3eOa4 2KIKuaU0HTR6fp16fNrja+iOMPZgFPEyX6CGqQX4l857+vRgOlhbFMG5sIDG1rPhATEl L8Iw== 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=8OibpZHqlmZvNVYfBDxh1hs2pxMvlwSThz0lOwApQaI=; b=NmG7jL0gl05RI97HQWLU6z5+a9Y5MkMjGn+Vj4KGkoaB4BmHP8p1ujatA0nPJK4Jnx U7A0oDruYUz4oy8RRIGhLELH0/yb1tLBqjDWxNPEx+zo9oBQnbJpjSvuG29X2qBDJh4g rW2ZfRyeDqIEOpUShi/7ebNO9LzKE9Y1LXhNTd22hsWXOhXEU7/dmXYl8fYoKMGQ/7TV HYg7WI8hFtzheLAII/iUvlgbAx6gUejp5iQ4cbc6fpmt8cdCVUvw3U4+ddltMAQn9udq Xx+aThNHuguss6XoFYt4M64CJf/ByYFU+cSRPDobgwb5uudQ+o/M10TFw0l3ilmPV/X1 fYYA== X-Gm-Message-State: AOAM532t5rSXXksLigWNmEvPm/qTvnyID1wXCdOmoPw+HL6+rvPniMuO tLnjotBt+57OrVdbnCmFsQ0ILQ== X-Received: by 2002:a05:620a:1489:: with SMTP id w9mr3060597qkj.43.1607005051082; Thu, 03 Dec 2020 06:17:31 -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 k188sm1386697qkd.98.2020.12.03.06.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 06:17:29 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kkpQH-005V9B-25; Thu, 03 Dec 2020 10:17:29 -0400 Date: Thu, 3 Dec 2020 10:17:29 -0400 From: Jason Gunthorpe To: Pavel Tatashin Cc: LKML , linux-mm , Andrew Morton , Vlastimil Babka , Michal Hocko , David Hildenbrand , Oscar Salvador , Dan Williams , Sasha Levin , Tyler Hicks , Joonsoo Kim , mike.kravetz@oracle.com, Steven Rostedt , Ingo Molnar , Peter Zijlstra , Mel Gorman , Matthew Wilcox , David Rientjes , John Hubbard Subject: Re: [PATCH 6/6] mm/gup: migrate pinned pages out of movable zone Message-ID: <20201203141729.GS5487@ziepe.ca> References: <20201202052330.474592-1-pasha.tatashin@soleen.com> <20201202052330.474592-7-pasha.tatashin@soleen.com> <20201202163507.GL5487@ziepe.ca> <20201203010809.GQ5487@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 02, 2020 at 08:34:32PM -0500, Pavel Tatashin wrote: > > Either here or perhaps even lower down the call chain when the page is > > captured, similar to how GUP fast would detect it. (how is that done > > anyhow?) > > Ah, thank you for pointing this out. I think I need to address it here: > > https://soleen.com/source/xref/linux/mm/gup.c?r=96e1fac1#94 > > static __maybe_unused struct page *try_grab_compound_head() > if (unlikely(flags & FOLL_LONGTERM) && is_migrate_cma_page(page)) > return NULL; > > I need to change is_migrate_cma_page() to all migratable pages. Will > study, and send an update with this fix. Yes, missing the two flows is a common error :( Looking at this code some more.. How is it even correct? 1633 if (!isolate_lru_page(head)) { 1634 list_add_tail(&head->lru, &cma_page_list); Here we are only running under the read side of the mmap sem so multiple GUPs can be calling that sequence in parallel. I don't see any obvious exclusion that will prevent corruption of head->lru. The first GUP thread to do isolate_lru_page() will ClearPageLRU() and the second GUP thread will be a NOP for isolate_lru_page(). They will both race list_add_tail and other list ops. That is not OK. > What I meant is the users of the interface do it incrementally not in > large chunks. For example: > > vfio_pin_pages_remote > vaddr_get_pfn > ret = pin_user_pages_remote(mm, vaddr, 1, flags | > FOLL_LONGTERM, page, NULL, NULL); > 1 -> pin only one pages at a time I don't know why vfio does this, it is why it so ridiculously slow at least. Jason