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=-7.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 26B28C433FE for ; Wed, 22 Sep 2021 23:44:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D10CB611C4 for ; Wed, 22 Sep 2021 23:44:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D10CB611C4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 1F0866B0071; Wed, 22 Sep 2021 19:44:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1783D900003; Wed, 22 Sep 2021 19:44:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 017B16B0073; Wed, 22 Sep 2021 19:44:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0166.hostedemail.com [216.40.44.166]) by kanga.kvack.org (Postfix) with ESMTP id DD3CB6B0071 for ; Wed, 22 Sep 2021 19:44:47 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8626E2BFCC for ; Wed, 22 Sep 2021 23:44:47 +0000 (UTC) X-FDA: 78616841814.31.BF44DA7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf13.hostedemail.com (Postfix) with ESMTP id E29CF10125F2 for ; Wed, 22 Sep 2021 23:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632354286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ne0ywWngZHBSJ8dAIWoxHtO3qWVXQfT+1+GXEa8/WYk=; b=GY3+DngfEsjpFkqeqB8qwx+IbIpp5DoVVaoB59mK4Dkni22xd8GUeTGeZ8h8Um8HAS1pVh joFed9W8aDt6VfjzmfpUL2GZuESNI3bIQR5BYlnJNRl0z1onZ95cM0Fxu5x41CKjqV/8gD xAn3NxnyNxNneHIbc1Qku8XxTIOCr8k= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-391-inK42kh3PZC4EWNPBy8f9Q-1; Wed, 22 Sep 2021 19:44:45 -0400 X-MC-Unique: inK42kh3PZC4EWNPBy8f9Q-1 Received: by mail-qt1-f200.google.com with SMTP id 7-20020ac85907000000b002a5391eff67so13223652qty.1 for ; Wed, 22 Sep 2021 16:44:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ne0ywWngZHBSJ8dAIWoxHtO3qWVXQfT+1+GXEa8/WYk=; b=UJ/QCZ0F4BHXmjTumhGrG6hA6aVxvRrL/6Hxg6Ko6k1db2DAeGZV+CCXwFLGbgiCeA y/mgd66FHdptmCu+NOstPmmCy4D1Hh8pRKtaR7hv0ltZNXZgaEbaTy0fyY8xDFhS5z7j 90p1+CxeGgu66KMU8BVxp5wr9/BcE+eJvISpgL79DE6jCDSOECQFPx95dl4vUoB8wcF4 IYVi4NPCI/v0p0Mt3odb2QWYO03vPn9jA9kkOnZbmbzEpyufpKxGijUDObi0POTgn5fS 0IVR45NoAifemzYx/k24seoMTcKO8vuc62aW2L6IiOsWy48E3Q3JcK1IR4nEhNCrZ8yI mpTA== X-Gm-Message-State: AOAM532WPm3hppAp8zjln45TVN6wlSh5dXiWgZSof9cF5jA7wAmlk6rl ivGEdJxninIX6Akh2dHlHerMpjxx9jwJ9CensBhwnKJW0UT+cXuLEm4yrsPrEFtcrdRAyz9kXBa igk4IIHFtPOo= X-Received: by 2002:ac8:6112:: with SMTP id a18mr2095035qtm.120.1632354284959; Wed, 22 Sep 2021 16:44:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrpGgdy4IzBHebYvi/26Kw8sVv+UUWE4AJ4iQwt2K6Ve0g5KvZwqr66BpyRZ+rUhLREAurbA== X-Received: by 2002:ac8:6112:: with SMTP id a18mr2095024qtm.120.1632354284739; Wed, 22 Sep 2021 16:44:44 -0700 (PDT) Received: from t490s ([2607:fea8:56a2:9100::d3ec]) by smtp.gmail.com with ESMTPSA id d17sm2475932qte.0.2021.09.22.16.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 16:44:44 -0700 (PDT) Date: Wed, 22 Sep 2021 19:44:42 -0400 From: Peter Xu To: Hugh Dickins Cc: Axel Rasmussen , LKML , Linux MM , Andrew Morton , Andrea Arcangeli , Nadav Amit Subject: Re: [PATCH] mm/khugepaged: Detecting uffd-wp vma more efficiently Message-ID: References: <20210922175156.130228-1-peterx@redhat.com> <24224366-293a-879-95db-f69abcb0cb70@google.com> MIME-Version: 1.0 In-Reply-To: <24224366-293a-879-95db-f69abcb0cb70@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GY3+Dngf; spf=none (imf13.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: yex6jta5f3m4r6ngazbzbqbzzi4dmtdm X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E29CF10125F2 X-HE-Tag: 1632354286-326737 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, Sep 22, 2021 at 04:18:09PM -0700, Hugh Dickins wrote: > On Wed, 22 Sep 2021, Peter Xu wrote: > > > > Not installing pmd means uffd-minor can still trap any further faults just like > > before, afaiu. > > > > There's a very trivial detail that the pmd missing case will have a very slight > > code path change when the next page fault happens: in __handle_mm_fault() we'll > > first try to go into create_huge_pmd() once, however since shmem didn't provide > > huge_fault(), we'll go the VM_FAULT_FALLBACK path, and things will go like > > before when faulting on a small pte. The next UFFDIO_CONTINUE will allocate > > that missing pmd again, however it'll install a 4K page only. > > I think you're mistaken there. > > I can't tell you much about ->huge_fault(), something introduced for > DAX I believe; but shmem has managed pmd mappings without it, since > before ->huge_fault() was ever added. Right, I wanted to express we didn't go into there, hence no way to allocate pmd there. > > Look for the call to do_set_pmd() in finish_fault(): I think you'll > find that is the way shmem's huge pmds get in. > > Earlier in the thread you suggested "shmem_getpage() only returns > small pages": but it can very well return PageTransCompound pages, > head or tail, which arrive at this do_set_pmd(). But note that uffd-minor will trap the shmem fault() even if pmd_none: page = pagecache_get_page(mapping, index, FGP_ENTRY | FGP_HEAD | FGP_LOCK, 0); if (page && vma && userfaultfd_minor(vma)) { if (!xa_is_value(page)) { unlock_page(page); put_page(page); } *fault_type = handle_userfault(vmf, VM_UFFD_MINOR); return 0; } That's why I think it'll be fine, because it should only be UFFDIO_CONTINUE that installs the pte (alongside with allocating the pmd). Or did I miss something? Thanks, -- Peter Xu