Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp751571pxb; Thu, 23 Sep 2021 09:51:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFUrWu2HvHh1i/JusqkFly1qwD2hzDMXEsU85mqOTJQifRR+c6AjSCtYqr8441DOiBDZ6q X-Received: by 2002:a05:6e02:f13:: with SMTP id x19mr4640302ilj.216.1632415885002; Thu, 23 Sep 2021 09:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632415884; cv=none; d=google.com; s=arc-20160816; b=V7E0LaCKKqv6cgo/xaB352fkU/u3n3fuXU+iDcrlytTCVymjg9bGky+mOaO9Opcdg9 BJbNoShGZUryDtpMlXwffU7aJ8j+6V2+2qJE7+8TcXI2BMDvF/6yLsaxGhDC7NXOFiWL H7T0NgnJYCmR8OKyQUGCKvmTUx03Qr57Y0g6b6c2SALEi7S7UkMnqMACTiMfvMGWBrhU LYatemuGryrSbCwRVWePKLq1BkUcAWy2xqkuD+/JwR4i1JFfrsvD0nAAYo8PEef0k7Ws ioTuRq+m20k3OOc7WTIBo5BmsRaXV7V58wZ6b24FH+2JKIfjYjv5mSc2YiOXmbexOQFh B0oA== 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=kxbhH0FBrH9RlY3GCWj3vHyXUDd29e30TtZJPUe9Ibk=; b=hVOOSo04eJZAA6ekGOZHQq1aCRsu0V9p/XICy3KXMFV2etqXjSiwTVmD7pLFkEQ3Pj L1Dxf1alKUNPRA0LsTcg0TFzo18/RArPPLVi1yiq6kdH447kKC6G2HD+BqF+rPNHeJ27 qwkB9KAEm0xeTNaJGrLlhS3FH2wrRDOSdgM36+QsXIlqkjct1mxQ7wZLSJthfVO0lnLi 6RGyxjxwiJAPlm7G9QbDzpgfdXEaisy0DXQ4eEsl7M+YA+IUDFM/4Ur8Xf5pPS5T5Taz qyQJdtnoXB2woMlPinZeufvpq1h6o8wUNhBhAjEpoeF+uV8Hzr0lIJr28vXSjt3Ze4Je mvkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Jtq5H3GP; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k64si6919901iof.8.2021.09.23.09.51.13; Thu, 23 Sep 2021 09:51:24 -0700 (PDT) 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=@google.com header.s=20210112 header.b=Jtq5H3GP; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242440AbhIWQtz (ORCPT + 99 others); Thu, 23 Sep 2021 12:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242378AbhIWQtv (ORCPT ); Thu, 23 Sep 2021 12:49:51 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C803EC061574 for ; Thu, 23 Sep 2021 09:48:19 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id m4so7292363ilj.9 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=PRea8JjJC1JcxqSJYFpWDgIf1k6ghITf+f2m7IBb2s0KsEfeT73tWNEblK8O8kue8t 3vYsI1utiG3IJE0Lvg+6f4SYC/XXZgwez+kE4L3Jb8sGgN05KyqoceNNBFfD7nGnwZJ/ agkf02M/66zgKqxz1A+NJXUPqLtjYZsPT7JnBB1a7P1L9NIKyFmJmQT7kBfTz2aCUjG9 YIcqtJIZYD4Fd7IyyKjkvrEH6M8nG+UV5Y2G22q0ckDmBmpweHJT9WkTaPbAnEt2wTKc 8eRaxw7FnFY2Y8se7ivX/QFp+Ez4oU35uCJvnP2YFb6TldMhGQulHB2RKK+/usyPvSBr 8vHw== X-Gm-Message-State: AOAM532L8ZaipU5v9BxK/qsu2ZrXK5lnJtlLSVVRX32Vu81Jx5wYSrwI wBBpTbvnHVsjX3IWfEnF3y1PXoeSMVoyfhGfDUaeJA== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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