Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1460207pxu; Thu, 17 Dec 2020 10:24:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9PrxQEm3Z/bD2i2tBvfUZN8BnUdIgVIVbYNoxxL569bV7sR2jFjFVo5J4CX/NsVGztPwe X-Received: by 2002:a17:906:3b5b:: with SMTP id h27mr289700ejf.450.1608229494555; Thu, 17 Dec 2020 10:24:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608229494; cv=none; d=google.com; s=arc-20160816; b=xlWG+mJsXcwi+jNPsJvZ7GN0cXbJPvKPnt//2kFciH54nwGCIDsKq4GZTtZ/TXW76e OPxzeEpeYTEhb9VgS3fBwleiSj/sdflJCegbnpJcCx78KnVpHfUtOvyvaQj+OQFtlksp 9qkTuhrqpmw266X2flLw6N+ryfizJENOKBsHIiP3M3Q4Pdw/7rk6vrXRt0isbmNbTbX2 e9Mbq34QMiFikggQc9wiC8Z1n5VV0hgBsd7ZyNGF1MhPACPoe+mKqmmr6FySVaCe5IsM e5bDqWewWtZz0Rgp+QA/LKVHx1asoltbX3rGhSeRmiie/w56AWWCOIBnYJ5hG7VHATJY H18Q== 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=NUD7gJA5lhMFnM/41VDmQs/Ea6kW133DDlTS4YuhSr8=; b=HKRA2TM1FQV4VfgoIiGlDhDz9nY64pknRw18Yqr9O2k11IbsuA0lX5qJH5sqG614Hs EIocIwdq04X673EsTwVbAbdn7rSI/LNH6LuN7jnfyquXGyLyizJm2IicMvs2zUOtEtiy 1OykCq8swh251N3HOi4E9pIbpU4/Vp7tJ07RLIIxWQ2/OQEJRhB5Bm0p8g6Ucgyo4AMV KrtVb3MijHdBTdXMfd51Hr2bGb37fUAiSznDbx+03uiUz/szkWVUmgXHixddLgAzvypo JGjCSgf3FU8930Af9w13XGkNl/45VLtsMKPtU6R22/dYDvK4BOwvLQazT9AP4pC/Pumn I9HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="duD8Q/Zh"; 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 qn10si3077326ejb.591.2020.12.17.10.24.30; Thu, 17 Dec 2020 10:24:54 -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=@linux-foundation.org header.s=google header.b="duD8Q/Zh"; 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 S1730220AbgLQSXf (ORCPT + 99 others); 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-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