Received: by 2002:ab2:5c0e:0:b0:1ef:a325:1205 with SMTP id i14csp31597lqk; Wed, 13 Mar 2024 15:26:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAYMAj3LybupoWkWQOXWukXOcBdW50q7jDnT7VPNBaTF/dRDDF7XdmVEFFwrOxzGPv7LJLBQcKzqRYMuCCaa626glarLqo+kAyQbTINA== X-Google-Smtp-Source: AGHT+IEPR+QBKKE/ODg3BZmhPKUhehTk8vQ/HEGAPFvB8P6Z/F1Te4i/lONgiG+5VX/0dMLc5M0U X-Received: by 2002:a05:6a20:1608:b0:1a1:6b04:9f2e with SMTP id l8-20020a056a20160800b001a16b049f2emr301764pzj.9.1710368806815; Wed, 13 Mar 2024 15:26:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710368806; cv=pass; d=google.com; s=arc-20160816; b=az/0kPLjwLirtirKe7KNxjoI+tygEKRdD/UCNT+2p0e9pgMj6G6cqhnLi4td5oyoaE Rla5lfB8Ao25fDDzD/8FdNh4c0PBsrbjDaZ81yzBuCZeSkq2fvN87PphR+hWKjuWJt8z IC3m7MU1CyQYtEFHz4+ZyR/uhBo/g4DMPV5UlUIv8WL47YtXSisK/xyzvdFJF/CKrNHy tMqfHxximgltGyTXltzTC5sYW7reAJDOvgdo45vJjsCtcb2R/SQCvmeVfPGAd+3mVGJq NnQtnbTTTqh34kij14Z3VjmN5j1zOmpML9ccKV4fyfJ8Fpm4b/uXKjc+x4WKKT+PvxO6 wQsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VmtTd9EKYIV2ElEzvy2se9UCmMxZ4RexG7SoSlWBNsI=; fh=LhIQIeaXno2rX2L8nUB+a0PSJ9EWaSl2sp7dRBbF3j8=; b=LotC/tuw1zSuZoIudhBsdmLJLhHPT3dJhgB78ZokY++RZQzt1KTtFhcRS8HqIh8Jtd 1ewn+vAzTp1JQIFr5a6Q9LT/g4Dt6gsIUsza3PtOeJi9YGqr/k2JQjYp/lt1/CsGtSuI iwqJV3BYttE0nKwnjKcFXbpS6ksRo8PZ6PoPiZYbXm1/yHIYQzIF24ZDD6QJcF/0m/kg rViBpQdD8v7o9P8CKf+fgOaC9QJgIvTQnm3NQZV3BDktdzBX7abBNlKzfAqb8QWBL1Ue NyK+rIGai/S17Ya6DCjAjjFKKKza1UbkDzK/0XWdzme80IgLCFknpLCyFw6TwcNKbe5H 7OZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NCo3Zjb3; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-102590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102590-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o11-20020a056a00214b00b006e6cc8f8ccfsi15157pfk.362.2024.03.13.15.26.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 15:26:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NCo3Zjb3; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-102590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102590-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7ED7E286BCF for ; Wed, 13 Mar 2024 22:26:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CE0259B71; Wed, 13 Mar 2024 22:26:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NCo3Zjb3" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51DDA273DC for ; Wed, 13 Mar 2024 22:26:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710368797; cv=none; b=Rcv3eJanti+9r5rdEB6TmSooeWqAUMt8oJfWcQwaUFu5jz01HvsPhG2HojvWJFC11ykqbCrZ9yosWIHESMwgd+ariNEMkjgck/1grgf8tr1LQRxCFqstiSLF4xi87syJxoheFydFRm+VQILWMgZmmMGcjRK9/2ssRe6K/9P8y7U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710368797; c=relaxed/simple; bh=7t2g8GHVH47753LDXxWWeDsYtFpmH386oBAW9FhlzDI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=egjBC/UpIQFLtTIlNVW+OCaeU58RK2R1GrF8btujwazHRQQVkOcPlrs89BAaoZQTMFgw9nBLto5d8JzyTUnQ90qwUu3VdYP9CPmc+nVGUKPFt3/KNj+TUuXfG3HT9sAkHagJ+Gz7c54AuRm4EPA8NtPMxbHP8ZW5SWFVkzevFIA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NCo3Zjb3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710368794; 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=VmtTd9EKYIV2ElEzvy2se9UCmMxZ4RexG7SoSlWBNsI=; b=NCo3Zjb3hV133F0wI1pNWimuKG/tFjBJEWPFzOvblp1lo0oUmsXoqGMXqVdaD1DOzzdBdZ K9E7dJD6i6kxpyknw1hGj5vSzWHMf1RCh42eX280j7BVMgh2gFuLTPdk6PPyCXeAUbuWll V2TdG0c47aHWVVugZM0oEEGv9VAwh8U= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-43-xLRpWRAdNTCihpW3C6Kpqw-1; Wed, 13 Mar 2024 18:26:31 -0400 X-MC-Unique: xLRpWRAdNTCihpW3C6Kpqw-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7830635331bso7130785a.1 for ; Wed, 13 Mar 2024 15:26:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710368791; x=1710973591; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=VmtTd9EKYIV2ElEzvy2se9UCmMxZ4RexG7SoSlWBNsI=; b=Ec73KC0YkExORmSO5L8vnqBN/2ji35xwuDHauwc8ctOAIU9Yy69KULzmzhySY3CWyw icz+jeXxoSeGDxHpYwILc9ugralg4sQHzlR23DOSNJuqfaOrXv9MBlfO8XBzLdw9S78J GZGjqhrvnqWblymxz3Gx+WAzVZj+a7Sk/OuG+0XfQfd0Lgbo96bVJQJ/v+Ecx80tESXo Sc3sSTxbBvdCaEaxYUm8u9XSBns+BfVur+ptusredWrIQA4ACxRFqO+VWOONfn8f4gUd IeyxeCUXpubARoXMkxVaULCPuJ/954pmZzBrqdu3KV2teJDsrdaFYIDW63dq6vwkgVGc 1Fvw== X-Forwarded-Encrypted: i=1; AJvYcCVSrsa/FjT76xsdxZS9KG7Bp5KhNOjURxmtXsmErkv//LXyxag5h3NVWCDWUyxxNY+hWo7vrpILg0xBT2Sh1CyGBS2CQU0WGpFnW3ti X-Gm-Message-State: AOJu0YyquEUVJlNGlvnySoWT9Fejd/+BsKHoEK8Cbgp7CoR1VEarOK0j IWwRqBt8Uflpbtgw+3eMHR1yuVOmXAqHLL4yRGp7xPEARZfVt52YDm9UJzEszCIyn8knmD8Jot6 UJYlUd/HNaQvJI709UNqa09vfPMuUFb9nO0XUhmX44LfEVQIfPCSdh5tkKk3HsQ== X-Received: by 2002:a05:620a:2408:b0:788:46ef:67ca with SMTP id d8-20020a05620a240800b0078846ef67camr122022qkn.2.1710368791360; Wed, 13 Mar 2024 15:26:31 -0700 (PDT) X-Received: by 2002:a05:620a:2408:b0:788:46ef:67ca with SMTP id d8-20020a05620a240800b0078846ef67camr122004qkn.2.1710368790947; Wed, 13 Mar 2024 15:26:30 -0700 (PDT) Received: from x1n ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id p7-20020a05620a22a700b007883f2f48absm77221qkh.108.2024.03.13.15.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 15:26:30 -0700 (PDT) Date: Wed, 13 Mar 2024 18:26:28 -0400 From: Peter Xu To: David Hildenbrand Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Muhammad Usama Anjum Subject: Re: [PATCH] mm/memory: Fix missing pte marker for !page on pte zaps Message-ID: References: <20240313213107.235067-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Wed, Mar 13, 2024 at 11:03:04PM +0100, David Hildenbrand wrote: > On 13.03.24 22:31, peterx@redhat.com wrote: > > From: Peter Xu > > > > Commit 0cf18e839f64 of large folio zap work broke uffd-wp. Now mm's uffd > > unit test "wp-unpopulated" will trigger this WARN_ON_ONCE(). > > Good that I added the WARN_ON_ONCE() :) To be explict, VM_WARN_ON_ONCE. :) And that's my guess that you didn't hit it when you posted the series and did the tests, as I know latest distros like Fedora dropped DEBUG_VM, so maybe you had your base config out of there (but I normally have it irrelevant of that). > > > > > The WARN_ON_ONCE() asserts that an VMA cannot be registered with > > userfaultfd-wp if it contains a !normal page, but it's actually possible. > > One example is an anonymous vma, register with uffd-wp, read anything will > > install a zero page. Then when zap on it, this should trigger. > > Are you sure? zap_install_uffd_wp_if_needed() contains right at the start: > > /* Zap on anonymous always means dropping everything */ > if (vma_is_anonymous(vma)) > return; My example is not exactly how the test failed, but should be a simpler version of it. To trigger this warning I don't think it requires the zero page to be wr-protected at all or have any pte marker involved. UFFDIO_REGISTER should suffice, afaiu (feel free to read the example above again; there's no mention of ioctl(UFFDIO_WRITEPROTECT)). > > So if that's the case the unit test triggers, I'm confused. > > > > > What's more, removing that WARN_ON_ONCE may not be enough either, because > > we should also not rely on "whether it's a normal page" to decide whether > > pte marker is needed. For example, one can register wr-protect over some > > DAX regions to track writes when UFFD_FEATURE_WP_ASYNC enabled, in which > > case it can have page==NULL for a devmap but we may want to keep the marker > > around. > > I thought uffd-wp was limited to specific backends only. But looks like that > changed with UFFD_FEATURE_WP_ASYNC, I guess? Correct. That was also what the new PAGEMAP ioctl relies on. > > > Change itself looks, good. Not sure about the anon_vma example above. > > Thanks! > > Acked-by: David Hildenbrand Thanks, -- Peter Xu