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 C9622C433EF for ; Thu, 23 Sep 2021 16:48:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 59E05610D1 for ; Thu, 23 Sep 2021 16:48:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 59E05610D1 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 9FFB56B006C; Thu, 23 Sep 2021 12:48:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AF1C900003; Thu, 23 Sep 2021 12:48:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84F7B6B0072; Thu, 23 Sep 2021 12:48:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0143.hostedemail.com [216.40.44.143]) by kanga.kvack.org (Postfix) with ESMTP id 716EA6B006C for ; Thu, 23 Sep 2021 12:48:20 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 29543180A3231 for ; Thu, 23 Sep 2021 16:48:20 +0000 (UTC) X-FDA: 78619421160.12.0F3C3AA Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) by imf02.hostedemail.com (Postfix) with ESMTP id DEAF57001A0A for ; Thu, 23 Sep 2021 16:48:19 +0000 (UTC) Received: by mail-il1-f173.google.com with SMTP id b15so7290609ils.10 for ; Thu, 23 Sep 2021 09:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kxbhH0FBrH9RlY3GCWj3vHyXUDd29e30TtZJPUe9Ibk=; b=Jtq5H3GPyNn1265DoS44A3ihlFLvNyoVn26DSAjKcXA5NWsF0vQTPeiBtAZfRATOs5 jMymN/ac1DO84W/iNoDVqKiAMC/zRn2Q9pXKhqvnc6+gJKIOYF8Eba//Ff9BEsc5sRek AajE1ciWtVU6f2qfm7WHD6gOnMM140hHMC0MsK+iP/WudBEaWtXSlOKAWoye30bO0gWv SjQ6NjfKPtmCwF5Fpxrc3zQH5nYHbEI84ttOgBSmOAcYEcvxofxXTBjuUxpchm6a3JGp +wOIm3osaUk1Gb1wrt9BQpOZH6/aMFtYBqQUydlXMPJM1nhm1IVN9b6khmq5+GOkqCdw bC/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kxbhH0FBrH9RlY3GCWj3vHyXUDd29e30TtZJPUe9Ibk=; b=AWH1calkZs2+bJuvYorMEH0ET96Cc+2oQ3lKlfPtYrNN6zYbYp7h8uV8+kqhsr+Loa 1pjZlPMT97fwxgIEeJTs7iz4xhiyFhqZx/Scwd2Inf6eHFJXFibsMsi7Z2WtxPJnch2y /L5LQ9gVg/Likk32/EqxTtkkebWb+4y5AYe/ScMRIEnZspM6aJy6BLNpaPapymDPuClG oidraBP1NWPHwMyXBOKFoYkhWgPG8J+Gu2obMaALlPJveP+obCsfdLZwbNs+SG+I0wF7 0EdIU5D2p8mIOfHG0ViM8CKAnFpDwk6I3WMlZfT9ajiMzm5ctLSOgfvb4hNV1xxbCMKC T/GQ== X-Gm-Message-State: AOAM533O79IhdBsozADozfTaxwj+2kyQ2PC7ybWsIDmyd6oTqLing9U8 HYNb6kthbdx91jEhZDry7dk11E1C1aEuc87Hyr9VnA== X-Google-Smtp-Source: ABdhPJyNLcJWJ4cf4hRRACEbrYhFMbPyl9v2GI1tCWXExlcI87+rVJkMusdSUtoWRAIYRhGKEpZ/eZeyzBVkt5ln8IQ= X-Received: by 2002:a92:db0b:: with SMTP id b11mr4397642iln.275.1632415699032; Thu, 23 Sep 2021 09:48:19 -0700 (PDT) MIME-Version: 1.0 References: <20210922175156.130228-1-peterx@redhat.com> <24224366-293a-879-95db-f69abcb0cb70@google.com> <472a3497-ba70-ac6b-5828-bc5c4c93e9ab@google.com> In-Reply-To: From: Axel Rasmussen Date: Thu, 23 Sep 2021 09:47:42 -0700 Message-ID: Subject: Re: [PATCH] mm/khugepaged: Detecting uffd-wp vma more efficiently To: Peter Xu Cc: Hugh Dickins , LKML , Linux MM , Andrew Morton , Andrea Arcangeli , Nadav Amit Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: DEAF57001A0A X-Stat-Signature: qxora5tn8wpya5ks8khsfqjzbg7bxq5p Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Jtq5H3GP; spf=pass (imf02.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.166.173 as permitted sender) smtp.mailfrom=axelrasmussen@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1632415699-430034 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 7:18 PM Peter Xu wrote: > > On Wed, Sep 22, 2021 at 06:22:45PM -0700, Hugh Dickins wrote: > > 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().) > > Still thanks for confirming this, Hugh. > > Said that, Axel, I didn't mean I'm against doing something similar like > uffd-wp; it's just a heads-up that maybe you won't find a reproducer with real > issues with minor mode. > > Even if I think minor mode should be fine with current code, we could still > choose to disable khugepaged from removing the pmd for VM_UFFD_MINOR vmas, just > like what we'll do with VM_UFFD_WP. At least it can still reduce false > positives. > > So far in my local branch I queued the patch which I attached, that's required > for uffd-wp shmem afaict. If you think minor mode would like that too, I can > post it separately with minor mode added in. No worries, you can leave the minor fault case to me. My thinking there was a THP collapse bug was really just based on speculation, not a real reproducer, so it's very possible my speculation was wrong. It will take some more thinking and reading to convince myself one way or the other. :) Thanks to you and Hugh for all the details. I'd prefer not to add this fix "just in case", if it isn't a real problem, as it seems like it may confuse future readers of the code. I'll send out a patch for it if / when I manage to build a real reproducer. Or, in the meantime, some of my Google colleagues are testing this code via their live migration implementation, so if there is a bug here there's a good chance we'll find it that way too. > > Note that it's slightly different from what I pasted in reply to Yang Shi - I > made it slightly more complicated just to make sure there's no race. I > mentioned the possible race (I think) in the commit log. > > Let me know your preference. > > Thanks, > > -- > Peter Xu