From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6C5BC2BBD4 for ; Fri, 18 Dec 2020 14:20:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73EA023A00 for ; Fri, 18 Dec 2020 14:20:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727819AbgLROUM (ORCPT ); Fri, 18 Dec 2020 09:20:12 -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-Google-Smtp-Source: ABdhPJx8/DJ78GkxbcIU1memIsL2TB3DNuXc1GCmXG+0Kwa2zwOi49IxsU0awOMhpxtgwLhA0c9ALg== 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