Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2133115pxu; Fri, 18 Dec 2020 06:22:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUhgcVfOkQpHJH46aWcONWraVxgOjjHr8T6npf6F5qETAKjHay+9dZiNiwjXifZzccxDSb X-Received: by 2002:a05:6402:352:: with SMTP id r18mr4519269edw.373.1608301321102; Fri, 18 Dec 2020 06:22:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608301321; cv=none; d=google.com; s=arc-20160816; b=cJmab8sLl4xFDhrPKr4RVFuPI63DQnapi+niHTp2809KXgTyHPIIvuRrsPsSoPw2mm NhaRkv/rU/8lyijPzK9fRt9vm+Dh4f2fxIzCNNPKY7dlDxcOXZbcShjUMQ33FaeSWDH5 2sfE4I9Lkg8AzbQOdNh/uFovOfw2yW7Hekv5K5QXQQPv+Qs4XR/0yMF7OLq4yktXMZTT LbikZzriOOHtI3JjgSSBRf+zmLvL6d2OcuOkNpGVKvF2XW/FElujT6V/v/piaYG6h91K MiwAJVcT+e/qy1/jRM+uMQL1yKFwUBzilXOxJ3HWFVBXbmigTpLnNzg8zr0Ut7hwUukg 1c4A== 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=WERPNLKxdgIzL5x4a7MSy0JBfPg8vRpdWpyRT6Y+Lx4=; b=iz1Jn0yvxgkQs6gedVT6hXc6lDgN15wsZ5ijEC1CHXI1FhpZ5oZkTHgdkQegmpfcGK 2DAeTSRhHeKWIJTAvHeGlnzI5MtdLyp2PqljGM2jzpan3yLzyTHluLoKPYW9/TBlw85O o8orR2QKegEdVcHJ8EmP+DN0bRIS7s8Zw2GCCwuSvH3nlBpGwNKYqYgTZqpwMmSyvi0m BZ76mcEil1AtIHhWIGKDRuCxjUs12S1JF1whJrVN972PRjyrzbmptGcfwuTgT5BSOcqG Ohsd9vM9sOarD31NnTp+plr84Yzq6pGpm9k7jw4SEDuiiziLtlDdpLsSm/MjvNB1ZLSQ yuCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=JWVockya; 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 gs31si4309632ejc.337.2020.12.18.06.21.37; Fri, 18 Dec 2020 06:22:01 -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=JWVockya; 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 S1726616AbgLROUL (ORCPT + 99 others); Fri, 18 Dec 2020 09:20:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbgLROUL (ORCPT ); Fri, 18 Dec 2020 09:20:11 -0500 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5C5AC0617B0 for ; Fri, 18 Dec 2020 06:19:30 -0800 (PST) Received: by mail-qv1-xf35.google.com with SMTP id 4so934525qvh.1 for ; Fri, 18 Dec 2020 06:19:30 -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=WERPNLKxdgIzL5x4a7MSy0JBfPg8vRpdWpyRT6Y+Lx4=; b=JWVockyamEBA1QzjNns4oKAV8HOKMsYdVPooYbIOFtw278D5Gt2qniBWvLXweuFSj1 tzoYgabP31sX8hAUUWwt4d0+LhYZklSF/9Z3Fjkyzcx403vDihglcZmVY9UWldsSa209 8KGP9Eedu9P7hKrxzgJg7+VYF77W8RFgrnq9eZz6CHtBH3d7cRyxqUGaefNQ/BPmrNEx 9oi1tjrsWCdOQocEJGzhvaO1K25b4dVre+HK05WlgxLdhuRdrs5lGz4do084bbGZMjD9 igN58y1WTKT0to1tcAZQOxq+tGgZe7hUtUrwUcHq0n/sMfcq1W3S32vgfSrF4OeLu0iI CNLw== 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=WERPNLKxdgIzL5x4a7MSy0JBfPg8vRpdWpyRT6Y+Lx4=; b=VbOuc7uGZtwiD6zRXwx3/9AaX+0KflvypIdOIvGJ6FglfNlXiqcHvdBIRYXm/MdSI6 msQDbR1oXARTXLzFNLyBVaum5K4gsnkneLEJN239Bm1RcTx0A4vkx/J6XlxLaiEhZVkl I75OIVItWkOw4fA0BBvgEf0YETrNHqPAWH0bNgRPEOPTX3KlaVBxCtr5cBLCHxgEtRVS F9SnPahzcLu2m3hV0O7KMQbUcUDx5jgbs3sRK60EXWbwFhJRtNjb0mmsPB/1kq3JATEd NyfyIy+fMho6SAlbyIHanIkqpeyiJRjXQHnrMZvyp137s4XtdN0mDnbXPpPj2EbOi1jo zHBQ== X-Gm-Message-State: AOAM533b7ldVCAeX0tkCAxugjfETn7BIzGeQQb6zLT8dhJezX0Tku2yG +yS6snGTr8/dFGyAXGfwPjVQiQ== X-Received: by 2002:a05:6214:768:: with SMTP id f8mr4637876qvz.1.1608301168974; Fri, 18 Dec 2020 06:19:28 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-115-133.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.115.133]) by smtp.gmail.com with ESMTPSA id s130sm5426876qka.91.2020.12.18.06.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 06:19:28 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kqGbP-00CgM0-FO; Fri, 18 Dec 2020 10:19:27 -0400 Date: Fri, 18 Dec 2020 10:19:27 -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 , Linux Doc Mailing List , Ira Weiny , linux-kselftest@vger.kernel.org Subject: Re: [PATCH v4 08/10] mm/gup: limit number of gup migration failures, honor failures Message-ID: <20201218141927.GM5487@ziepe.ca> References: <20201217185243.3288048-1-pasha.tatashin@soleen.com> <20201217185243.3288048-9-pasha.tatashin@soleen.com> <20201217205048.GL5487@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 Thu, Dec 17, 2020 at 05:02:03PM -0500, Pavel Tatashin wrote: > Hi Jason, > > Thank you for your comments. My replies below. > > On Thu, Dec 17, 2020 at 3:50 PM Jason Gunthorpe wrote: > > > > On Thu, Dec 17, 2020 at 01:52:41PM -0500, Pavel Tatashin wrote: > > > +/* > > > + * Verify that there are no unpinnable (movable) pages, if so return true. > > > + * Otherwise an unpinnable pages is found return false, and unpin all pages. > > > + */ > > > +static bool check_and_unpin_pages(unsigned long nr_pages, struct page **pages, > > > + unsigned int gup_flags) > > > +{ > > > + unsigned long i, step; > > > + > > > + for (i = 0; i < nr_pages; i += step) { > > > + struct page *head = compound_head(pages[i]); > > > + > > > + step = compound_nr(head) - (pages[i] - head); > > > > You can't assume that all of a compound head is in the pages array, > > this assumption would only work inside the page walkers if the page > > was found in a PMD or something. > > I am not sure I understand your comment. The compound head is not > taken from the pages array, and not assumed to be in it. It is exactly > the same logic as that we currently have: > https://soleen.com/source/xref/linux/mm/gup.c?r=a00cda3f#1565 Oh, that existing logic is wrong too :( Another bug. You can't skip pages in the pages[] array under the assumption they are contiguous. ie the i+=step is wrong. > > > > > + if (gup_flags & FOLL_PIN) { > > > + unpin_user_pages(pages, nr_pages); > > > > So we throw everything away? Why? That isn't how the old algorithm worked > > It is exactly like the old algorithm worked: if there are pages to be > migrated (not pinnable pages) we unpinned everything. > See here: > https://soleen.com/source/xref/linux/mm/gup.c?r=a00cda3f#1603 Hmm, OK, but I'm not sure that is great either > cleaner, and handle errors. We must unpin everything because if we > fail, no pages should stay pinned, and also if we migrated some pages, > the pages array must be updated, so we need to call > __get_user_pages_locked() pin and repopulated pages array. However the page can't be unpinned until it is put on the LRU (and I'm hoping that the LRU is enough of a 'lock' to make that safe, no idea) > > I don't like this at all. It shouldn't be so flakey > > > > Can you do migration without the LRU? > > I do not think it is possible, we must isolate pages before migration. I don't like this at all :( Lots of stuff relies on GUP, introducing a random flakiness like this not good. Jason