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 F0EA1C433DB for ; Fri, 15 Jan 2021 18:11:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 83A3B23A58 for ; Fri, 15 Jan 2021 18:11:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83A3B23A58 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DEF788D01C9; Fri, 15 Jan 2021 13:11:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC5428D01B2; Fri, 15 Jan 2021 13:11:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDC7E8D01C9; Fri, 15 Jan 2021 13:11:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0118.hostedemail.com [216.40.44.118]) by kanga.kvack.org (Postfix) with ESMTP id B4BA48D01B2 for ; Fri, 15 Jan 2021 13:11:05 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 71929181DF77D for ; Fri, 15 Jan 2021 18:11:05 +0000 (UTC) X-FDA: 77708800890.06.rest66_53003c627531 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 2D2CE100503BC for ; Fri, 15 Jan 2021 18:11:05 +0000 (UTC) X-HE-Tag: rest66_53003c627531 X-Filterd-Recvd-Size: 6344 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Jan 2021 18:11:04 +0000 (UTC) Received: by mail-ed1-f43.google.com with SMTP id dk8so10565542edb.1 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=Bo5E+qJHnrSrEy4uDWo89Npp3NgBZWvv0m8LtFMglv0dLohlTdg1FDjQNGKlJK+LdY U6Um38M18zXAVfd5mbUS0f91Z9AD2RAmJYpm5lif4pKr1OPWMXq2vED/p1FQYfIzldg9 VSUCWScmMYNN+dvxhnhIOTnMaTNZjkN+Z/aryTDovfe3u6ASINimVzto8T7eRPtcbj6Q XOCeaiXrI1f2PVGuLVeAwbQ0C7mzLenBlDTZjOu7I6BoR7YssX+h2byP7wwoXKClG5Ks oTpIxKcYFD7j4alhFhQAhivcVir65t+WjzgpiPL7y+f06hAyigeBUEFyypqlvfL7OhS3 fEoQ== X-Gm-Message-State: AOAM533OmPbPF/nsbrKjREijXDHkbMWC8gf5aJT9djSV3Z/YfGMCP6kO DaZLidlrJhf1N2TcW8EeTC5BaBC4Da5vnjRRkf+iiw== X-Google-Smtp-Source: ABdhPJxcm9uW7ZpupMY4AzchVg5VAJOLsBRme8D47yXaQiHft3XUpIVHGE9veIXESaC3fSpI9Az8dNQaliYFA4XPzxA= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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