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.7 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 8ED45C4361B for ; Thu, 17 Dec 2020 18:22:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 101472388E for ; Thu, 17 Dec 2020 18:22:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 101472388E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 490D46B0036; Thu, 17 Dec 2020 13:22:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 442446B005D; Thu, 17 Dec 2020 13:22:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32FED6B0068; Thu, 17 Dec 2020 13:22:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id 1D82F6B0036 for ; Thu, 17 Dec 2020 13:22:55 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CC505180AD83E for ; Thu, 17 Dec 2020 18:22:54 +0000 (UTC) X-FDA: 77603595468.06.body83_320f48127436 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id A07DD1003CA61 for ; Thu, 17 Dec 2020 18:22:54 +0000 (UTC) X-HE-Tag: body83_320f48127436 X-Filterd-Recvd-Size: 5876 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Dec 2020 18:22:54 +0000 (UTC) Received: by mail-lf1-f42.google.com with SMTP id a9so59932058lfh.2 for ; Thu, 17 Dec 2020 10:22:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NUD7gJA5lhMFnM/41VDmQs/Ea6kW133DDlTS4YuhSr8=; b=duD8Q/ZhTOv/pTgvO2qH536A7bKcX3BMXIjJ4srwYUsZSpZ4bqcbcbv/pghu/tC6JF hS0A4KbA1VabvHN6uhoxqA2JLFAQ/9KX8ZtEgLxxTP4lPd9ThjRBFuu5jfFgbJyP7oiW U17LTowLNvNoL2glQph+EwCFBlZLhqkjc5dVc= 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=NUD7gJA5lhMFnM/41VDmQs/Ea6kW133DDlTS4YuhSr8=; b=RYEK1vEfkCSpYwwVWMIYOQQM1dt+mnfiyYlG37RMvWQRROdw+BTew5GZxA0YVYsu6D kWSTQc8aAMEpHwmpuADAi3SsDFm1gkiKGo849ZHDBOqRcy5Mi9I4fCfb9EGBCEaTTjjU LRSfeQGRRPtxprrvTXn1vnKbjAlSsa89U5iMwAc1a6lLkl3S3aWp3cUbKdWqzzxP3xz7 JMvKNe6RGDkdJFJqIfsgdAsmA01VothC5lOzh+ivxdmvnF137f/n9CsCqurwppjDTvr/ faL0CHu6ZfcTIEEIZME6bLCEaR1P5cDAWArLlVuwodmOglAWkbIw178D+zIpS3muRZwt bwhA== X-Gm-Message-State: AOAM532cNtreJvVwhOxysvzVMZCpHHZy0xzutZMY6QJu8rBnrAt6vjx/ N/Lcwm+1kNG26U99IkLp0YIRzNbbZ4rCyg== X-Google-Smtp-Source: ABdhPJw1B+2MO25ZGc17Q6Y0cD3barFIHIb4fCN9L2g1k7r6rCNBo4lYIpxkaobJGiQb5OLGls9JQQ== X-Received: by 2002:a05:6512:1112:: with SMTP id l18mr11932lfg.538.1608229371877; Thu, 17 Dec 2020 10:22:51 -0800 (PST) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com. [209.85.167.46]) by smtp.gmail.com with ESMTPSA id b4sm658726lfa.261.2020.12.17.10.22.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Dec 2020 10:22:50 -0800 (PST) Received: by mail-lf1-f46.google.com with SMTP id o19so34339323lfo.1 for ; Thu, 17 Dec 2020 10:22:50 -0800 (PST) X-Received: by 2002:a05:6512:338f:: with SMTP id h15mr21990lfg.40.1608229369683; Thu, 17 Dec 2020 10:22:49 -0800 (PST) MIME-Version: 1.0 References: <20201209163950.8494-2-will@kernel.org> <20201209184049.GA8778@willie-the-truck> <20201210150828.4b7pg5lx666r7l2u@black.fi.intel.com> <20201214160724.ewhjqoi32chheone@box> <20201216170703.o5lpsnjfmoj7f3ml@box> <20201217105409.2gacwgg7rco2ft3m@box> In-Reply-To: <20201217105409.2gacwgg7rco2ft3m@box> From: Linus Torvalds Date: Thu, 17 Dec 2020 10:22:33 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] mm: Allow architectures to request 'old' entries when prefaulting To: "Kirill A. Shutemov" Cc: Matthew Wilcox , "Kirill A. Shutemov" , Will Deacon , Linux Kernel Mailing List , Linux-MM , Linux ARM , Catalin Marinas , Jan Kara , Minchan Kim , Andrew Morton , Vinayak Menon , Android Kernel Team 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 Thu, Dec 17, 2020 at 2:54 AM Kirill A. Shutemov wrote: > > Also if the range doesn't have a mappable page we would setup a page > table into the PMD entry. It means we cannot have huge page mapped there > later. It may be a bummer: getting the page table out of page table tree > requires mmap_write_lock(). > > We also take ptl for cold page cache. It may increase ptl contention, but > it should be negligible with split-ptl. Both good points. I doubt the second one is really noticeable, since if it isn't cached you're going to have all the costs of actually getting the page, but the first one sounds fairly fundamental., But I think both issues could be easily fixed by doing that "xas_is_value()" and checking for 'head' being non-NULL early. In fact, maybe that should be done as part of that early setup loop. So that early code that is now + head = xas_find(&xas, end_pgoff); + if (!head) { + rcu_read_unlock(); + return; + } + + while (xas_retry(&xas, head)) + head = xas_next_entry(&xas, end_pgoff); could/should perhaps be something more along the lines of + head = xas_find(&xas, end_pgoff); + for (; ; head = xas_next_entry(&xas, end_pgoff)) { + if (!head) { + rcu_read_unlock(); + return; + } + if (likely(!xas_retry(&xas, head)) + break; + } instead. So that if we don't find any cached entries, we won't do anything, rather than take locks and then not do anything. Then that second loop very naturally becomes a "do { } while ()" one. Hmm? Linus