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 2C9E0C4361B for ; Thu, 17 Dec 2020 18:23:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F005222510 for ; Thu, 17 Dec 2020 18:23:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730287AbgLQSXf (ORCPT ); Thu, 17 Dec 2020 13:23:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730167AbgLQSXe (ORCPT ); Thu, 17 Dec 2020 13:23:34 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40528C0617A7 for ; Thu, 17 Dec 2020 10:22:54 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id o13so36764538lfr.3 for ; Thu, 17 Dec 2020 10:22:54 -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=Q5Tis5gGXr/ztrjstz612qs2lCf0YkCJ6C0RwReZ0WKymCKs0dAY/gnt0kpZnP5tJo 26AhlGbtagcpW2EBfmOW3TpdZrF7gA/t4mSNenayrqhsA0MmtV5ujqm2hKKxrseNxCOl 2p1E1uw3UTDYSq4xvTZ10Z6bPBRnjuvoMm/7Xg+ERbMgOMhOn63EI9nnFyrueZzvjZ1h 1YZVl3Vt+ld9V9gJC8HMB6e5Di9nWBNR7gqOS/j4o6H9P41T5i5jcU5t99zTqmWPzWWu lZhoiVP+9E7wBMt84y8yhi1nei8cmCfXIXuw/4U4YHjD4Rx0gYONnMsSLynWp76VfMJ7 U2Pw== X-Gm-Message-State: AOAM530S66YnJsxWBd84S8UISqDYmuRNAB1dUe82VsU+u2MUoK3/RF0p QykRe9DVuyiYL0cY7IkNU6VECGypyVuEXw== X-Google-Smtp-Source: ABdhPJznIUn1uB7EixM2WIkQ9kEtnee3ddT1x3vViJe6HX1abFa/ca7V+3XqjSihpsQVP9E/0yRqmw== X-Received: by 2002:ac2:46f4:: with SMTP id q20mr17036lfo.316.1608229372026; Thu, 17 Dec 2020 10:22:52 -0800 (PST) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com. [209.85.167.42]) by smtp.gmail.com with ESMTPSA id a15sm664146lfr.68.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-f42.google.com with SMTP id o13so36764128lfr.3 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 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=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 CB689C4361B for ; Thu, 17 Dec 2020 18:24:37 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8AC6B2388E for ; Thu, 17 Dec 2020 18:24:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AC6B2388E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9Qegodk1ZK1mPzvN1flaWKNpe/8vDSmjR3m+zqlHYVE=; b=Kndahi8SEIbWW71i1ygxJH9pA h1ne8Ot0+ooPmsDuF3HrLALKcUIm9yCaAKWdjnTCdYFmxzSo3Qhi55jgvIXMNaf1yOpmKlORxj2Iq a/rxh0z3x4vM1VZ2lz73hLFtQUeZBFIV8PwHl7o53jZjjLhjhLQjMgGGqIadhqwR/MXE3hz8DZO/P gYSJkKOGaNZAMYXDr6nIVuzB2A6Zy1zeGE4bOQqU4VFUlSF8stZwaSSIBL5wBUK1Hj5LsHVokUIHw YcOT+RV6kOETdqs/RY1fjaPzoQQ9o98Tszlzobf04rlMW5C/bBD88tzUvLQMe4YpMqbDUJa7U7gmx u7ih/oYJA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpxvg-0006DW-Tf; Thu, 17 Dec 2020 18:23:08 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kpxvd-0006Ap-Bt for linux-arm-kernel@lists.infradead.org; Thu, 17 Dec 2020 18:23:06 +0000 Received: by mail-lf1-x133.google.com with SMTP id x20so40417807lfe.12 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=Ovp7QN3AsVqocHNbUKOhqMFnU5nfHRqW4IR2Rt8Cd0Y+lwVzRVpaqCxDZbgLNNYDPS p5S+ndFbCCCSE1JSa1eiQIZtRCAzjv6i1e4C625hCmZMwv6Iq/CS4ndJ4IkAeNcaB4Ju Hv9d239KeQzqxtmiTQPnbguOidq0o0VPqPrIUckpH/Nm6mqmhwlPmWLnQ318aULeb946 boyNjvQMWixqKQumkSJa7KRy3rz9mg5d+sJtzd0dOKQeshhc3N26WsFz7izAKdH/XTnU zkbbWvhFZQZpUxGoZ96mLzjgX4WBO5Qesqd+npEpPTSW98d2B7xvwjRbBLx07/JICvQq 9tGQ== X-Gm-Message-State: AOAM530Wd8l8d7H+AVft+z4hxq4liABSMM/111vtWsW9j7yzsO/J0pLD zjaVken9R/2ev6UwcVZr2aJ67Y9hZ5i8gQ== X-Google-Smtp-Source: ABdhPJwCD7G/NquHVMvjbAABIyTD2NWMllyHTpYLLIg6G23ZJ85MT4PBpNNosGdDFYp1GtZPiTobXg== X-Received: by 2002:a2e:b80c:: with SMTP id u12mr238885ljo.490.1608229371739; Thu, 17 Dec 2020 10:22:51 -0800 (PST) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com. [209.85.167.48]) by smtp.gmail.com with ESMTPSA id x138sm661541lfa.66.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-f48.google.com with SMTP id a12so59966446lfl.6 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" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201217_132305_423428_763CCE7F X-CRM114-Status: GOOD ( 16.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Android Kernel Team , Jan Kara , Minchan Kim , Catalin Marinas , Linux Kernel Mailing List , Matthew Wilcox , Linux-MM , Vinayak Menon , "Kirill A. Shutemov" , Andrew Morton , Will Deacon , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel