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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 F0F80C433F5 for ; Thu, 23 Sep 2021 01:22:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7770861130 for ; Thu, 23 Sep 2021 01:22:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7770861130 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 1E10F940007; Wed, 22 Sep 2021 21:22:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1913E6B0071; Wed, 22 Sep 2021 21:22:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A867940007; Wed, 22 Sep 2021 21:22:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id ECB046B006C for ; Wed, 22 Sep 2021 21:22:49 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A9EEA8249980 for ; Thu, 23 Sep 2021 01:22:49 +0000 (UTC) X-FDA: 78617088858.25.DA224C2 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by imf09.hostedemail.com (Postfix) with ESMTP id 7215F3000104 for ; Thu, 23 Sep 2021 01:22:49 +0000 (UTC) Received: by mail-qk1-f173.google.com with SMTP id 73so16632572qki.4 for ; Wed, 22 Sep 2021 18:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=vegAYHHwWq1ucbb5wAql7Fq5zi2BQ/ySb7VWAZVFi2E=; b=TFjcvXxSWkkR0Nh9wFz2aZ4K4yNk6JJBI+NS97vRGxt/BD1h97F0GYiRDUv/fLZOv9 ciHK2yFJUc/BBGKHwy5+torH60ukEx24FtkrrltDf9kwJJ8qtnqonF7V1Eds5E6swvRc B+4oPl31Heh8O5BENZGK2EJA2MFrUOJvhUoBW7NUGnD5ARaIY3pusJjjeTBiPgoyWlzG TZ+d57lBeUiVBc++9mAo8VuTR+qC/WTtA9cdQYon5nhZ0cks/ZHzu5oeZBG561xy2HXB E9K5yIimQIIl4HhO9/aMRjKFwWJep6tiGiOqaDfMkaO2mmsaf3cXZmnqdD085ityfZ14 Pj0w== 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:in-reply-to:message-id :references:mime-version; bh=vegAYHHwWq1ucbb5wAql7Fq5zi2BQ/ySb7VWAZVFi2E=; b=UlbGYrWgOgd5ih7Kmftbwlr6XHf3Ah29fHTy/NLHKvZDGcTzjcINIRAfqZJ0SVZknm tG1vX+gNZ38MNxtx5QML1BIg13cmlLkcaJNrnOhHgbua7x/3gQHFLm+cbI8F88ciKC0P 4Ythh+/Q62y3y5yTNBUQJJcdrsFosXkhUDmuOjk1Q4c1D8eGjzy0YX6uikTHxduEc7Il uVJtdpQuTiWhEXzrPHSSU2JrzbemJRE3JaohZpYZ4zvUV/RHe79TToTfOvMoiAnGEfzU YeZlMTk2gRyaHNy63WooMudKDVoLXT1RdfJL2Ua50lZPkcATlTh8UPkHyfF/aOXIWJmV 0H2Q== X-Gm-Message-State: AOAM533PDsqepU3rhoYStnjxzSPvBJI9kkWYsz5UwiD+Vxvkv/vuuROe g7FRmo+w6JNX5XU4z4ZwPXWyIQ== X-Google-Smtp-Source: ABdhPJwgFEA68LwNG5vPFKwN4yJ0g4++HtDEwv+1VFUIGTzQK3c19FfBU6Yg2yrcULMP1GZBEFuK/A== X-Received: by 2002:a37:6350:: with SMTP id x77mr2463135qkb.356.1632360168544; Wed, 22 Sep 2021 18:22:48 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id g5sm3021545qkl.48.2021.09.22.18.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 18:22:47 -0700 (PDT) Date: Wed, 22 Sep 2021 18:22:45 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Peter Xu cc: Hugh Dickins , Axel Rasmussen , LKML , Linux MM , Andrew Morton , Andrea Arcangeli , Nadav Amit Subject: Re: [PATCH] mm/khugepaged: Detecting uffd-wp vma more efficiently In-Reply-To: Message-ID: <472a3497-ba70-ac6b-5828-bc5c4c93e9ab@google.com> References: <20210922175156.130228-1-peterx@redhat.com> <24224366-293a-879-95db-f69abcb0cb70@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=TFjcvXxS; spf=pass (imf09.hostedemail.com: domain of hughd@google.com designates 209.85.222.173 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7215F3000104 X-Stat-Signature: pq96j3szykg98rwf3pbio7pcrsaktewc X-HE-Tag: 1632360169-752497 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, 22 Sep 2021, Peter Xu wrote: > 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? No, I think I misunderstood you before: thanks for re-explaining. (And Axel's !userfaultfd_minor() check before calling do_fault_around() plays an important part in making sure that it does reach shmem_fault().) Hugh