Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp179780pxb; Fri, 15 Jan 2021 10:13:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzO4ceq7csAGGoPppmsqvAT5oNmCLs3c6dLgDWXv4rDDyn/OK7q3aiTW4yoCHdDPNZiecZK X-Received: by 2002:a05:6402:5112:: with SMTP id m18mr10935723edd.129.1610734429679; Fri, 15 Jan 2021 10:13:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610734429; cv=none; d=google.com; s=arc-20160816; b=JOQvIQyXO9L41pTrmxOOOXBowgmN3Y3v+h3ILLPQ6ygMI/T4WxWNTsi/uDeE9hdhJM CJ/xHw9mjYCak+6vwGkksFAtsTC72OpOg6EGpWcyKORxT64vKdWqy2BnIXf7q+EGYCx+ lJdjmIZV2C/Kwi93jDZYzbdY97yFwUWLfor0aDzY5krQpZrDXAIACw5Iys6afDHGSjxh 7nU71h37THf+oEpaOKvml5XZ7Ze/tJr1YPIQjEJosN/+bzy8+xIQgIQEa26kePABY3Vj yAPQU2ysayPgjZi00EReOA0tp5ZdIOAay+SZkSzT677Ctz/BNXYVurz7yUqYcMpg4afJ 1Xdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8SVfCmLEiWAiL0R631NmKWHiEv5/3BnE+DWgN7tCTHc=; b=x5v4VAaCVh6Akrd09hixbbMixllUe2am6aP5ns/98YEHjJSkMrvZDmPQbMrr08CGXF VSeoyKPVZItI4kAzvbnjT0Y8PylbHy/UtXQ0So6LsrYzCNG4CxEhpUBhrlII/vZOy91r 7vEKWxQUtecwNRZeJAvODKIx3bjrs6i6PWKztehJJDesprqbXrOWfUL7CIBJyeUBePWa xyAj6xTsPyNwdrRaVHmYSyO5R5DRHzfWLqL26WqyH+4Z1+8hZUlk+/LJYlCpMzmV1JJ8 jvQZWK09WOeq0S2o6o8AgbvetuZ9SNWWmNBmcpnjzBpVhxvKaze73jxpkhsxUhPgomRX 8lrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=LT7meLxf; 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 r26si4436292edi.245.2021.01.15.10.13.25; Fri, 15 Jan 2021 10:13:49 -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=@soleen.com header.s=google header.b=LT7meLxf; 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 S1727203AbhAOSLp (ORCPT + 99 others); Fri, 15 Jan 2021 13:11:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbhAOSLo (ORCPT ); Fri, 15 Jan 2021 13:11:44 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70788C0613D3 for ; Fri, 15 Jan 2021 10:11:04 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id p22so10519584edu.11 for ; Fri, 15 Jan 2021 10:11:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8SVfCmLEiWAiL0R631NmKWHiEv5/3BnE+DWgN7tCTHc=; b=LT7meLxfsN9ZJj1NVem9T3FdAJp7+fYnVVLGwj0ymfrrDwmC+Cp8fY2m76Y9p9ZOUY DrG9gQkiUneL7meMDl40kir9wD+lupIwVSgT2zkgrec2qM8QF5wKiFCI0BYssd/bujN9 7e9y5wg/6fUxw5exORuFv1NOXcQFRNhRudlb01jPO/RYYfgfBwicm3NBR1mKkmC6ntNv z/v07mXjdkt/D3ipAVODDI918IZEOqRT/nREaddodPRN7hV3O2l5iLCwEZy4fZx+txr4 cJXdRlrTKCp+YAQeB4+j3QawjuhXB/UMPof/CfB1SrHkgf8zxD8gBjDC+QBEcFFkE46k leqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8SVfCmLEiWAiL0R631NmKWHiEv5/3BnE+DWgN7tCTHc=; b=a8INncNc8Cr/txrf3tpAsFV+zPa0pJ6JPcMoK2Q/HI7GmezC6P2MMLNwRBa/NTnmbW 3zVbt9+k65k4pI+h/u6A1no7UjtQJJ5jTK2aVSsDaOdN4hRbrv2n45Drn8iUXWBJUX2a 4sJPXQrqnUfUzu9X2jo0hYjLJm2zhpNwFbT69IqttClKNbEADk9Hu+LhxgJEXGE3snSs 0muH6n0cHbZVuN5ReMrEXklpYfIr6psYzLExo2L9txAILL6VqYSnWZt5BdhNbouARpN3 EIED2PYzYOsn0xWEWoOr4+zdbBM1Dya5DeDPwwNZnMZdJ1dV/v7DEzs2LIGnVsarNu9c svEw== X-Gm-Message-State: AOAM5329blMGEQrk2Ci9hgZkJr3Z1Zb4V3YOq8JYmqS1e3/iTM7xxOx2 E7gkxhcY/BedinX2QFOslrKOStOrzsJxSQpjoLMBiA== X-Received: by 2002:a05:6402:17:: with SMTP id d23mr10770454edu.341.1610734263068; Fri, 15 Jan 2021 10:11:03 -0800 (PST) MIME-Version: 1.0 References: <20201217185243.3288048-1-pasha.tatashin@soleen.com> <20201217185243.3288048-9-pasha.tatashin@soleen.com> <20201217205048.GL5487@ziepe.ca> <20201218141927.GM5487@ziepe.ca> <20210113195528.GD4605@ziepe.ca> In-Reply-To: From: Pavel Tatashin Date: Fri, 15 Jan 2021 13:10:27 -0500 Message-ID: Subject: Re: [PATCH v4 08/10] mm/gup: limit number of gup migration failures, honor failures To: Jason Gunthorpe 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 13, 2021 at 3:05 PM Pavel Tatashin wrote: > > > > > Oh, that existing logic is wrong too :( Another bug. > > > > > > I do not think there is a bug. > > > > > > > You can't skip pages in the pages[] array under the assumption they > > > > are contiguous. ie the i+=step is wrong. > > > > > > If pages[i] is part of a compound page, the other parts of this page > > > must be sequential in this array for this compound page > > > > That is true only if the PMD points to the page. If the PTE points to > > a tail page then there is no requirement that other PTEs are > > contiguous with the compount page. > > > > At this point we have no idea if the GUP logic got this compound page > > as a head page in a PMD or as a tail page from a PTE, so we can't > > assume a contiguous run of addresses. > > I see, I will fix this bug in an upstream as a separate patch in my > series, and keep the fix when my fixes are applied. > > > > > Look at split_huge_pmd() - it doesn't break up the compound page it > > just converts the PMD to a PTE array and scatters the tail pages to > > the PTE. Hi Jason, I've been thinking about this some more. Again, I am not sure this is a bug. I understand split_huge_pmd() may split the PMD size page into PTEs and leave the compound page intact. However, in order for pages[] to have non sequential addresses in compound page, those PTEs must also be migrated after split_huge_pmd(), however when we migrate them we will either migrate the whole compound page or do split_huge_page_to_list() which will in turn do ClearPageCompound(). Please let me know if I am missing something. Thank you, Pasha > > Got it, unfortunately the fix will deoptimize the code by having to > check every page if it is part of a previous compound page or not. > > > > > I understand Matt is pushing on this idea more by having compound > > pages in the page cache, but still mapping tail pages when required. > > > > > This is actually standard migration procedure, elsewhere in the kernel > > > we migrate pages in exactly the same fashion: isolate and later > > > migrate. The isolation works for LRU only pages. > > > > But do other places cause a userspace visible random failure when LRU > > isolation fails? > > Makes sense, I will remove maximum retries for isolation, and retry > indefinitely, the same as it is done during memory hot-remove. So, we > will fail only when migration fails. > > > > > I don't like it at all, what is the user supposed to do? > > > > Jason