From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 6B5AC2FCBF5 for ; Wed, 1 Oct 2025 13:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759327103; cv=none; b=X0nmnJGSulRqWwXNPxwPQ/Ipnx9VJ3KXN5srTnSssew1guxpcgyqV41uXIRN8Sw+iUDo7xkShaX9+sHH4DrPI62hRuQ8rBZqJKOWgUGd10zjmGTUe6yFnq6BA/B6iedcBp2hbhgc6Y2jmlmDTDhZqoQOBUz/B93q71TAj6aD7gE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759327103; c=relaxed/simple; bh=GuwkYch3rT/c6VYaWFGNV64dyHepYE4WDA8+9On7HEg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iUUzjacDN7AL3ZStkTQy4Vf1+1zfPObQHSthz+9nWkjFEUVd6pttDCAp1/oj+fmWwYc5/m9dwQ556W84xK34v1jAkV2+EK0GebdA/HBKyIYQM199/MIi28XS9E3EfxuGdZkuix6ROI7WvDZkSfJKmHeEvDezubV3F6WDQwY3+i8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=CopufbLl; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CopufbLl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759327100; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=EzrKUl+2NkMxRoxmdVM9hHYfWN12ztBQRe+rscPZIc8=; b=CopufbLlmjr1lmxm1Wjh1nLd1meUQAnEJ4kqAXwjSz4tnVUFQJ03a9rLgmePd1/I+Yo8Cq WFt1Oki3lTUTtMvv1izHJhiKzbnxrbaIVt3h84DtRmE4hbgHZi4O0BD3y4g6st19OVUIik K8TiQ1Xq8ffEalJAHRVvxovLeWTvSPg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-yoPUcr3DOKazdrdAQfiwKg-1; Wed, 01 Oct 2025 09:58:19 -0400 X-MC-Unique: yoPUcr3DOKazdrdAQfiwKg-1 X-Mimecast-MFC-AGG-ID: yoPUcr3DOKazdrdAQfiwKg_1759327098 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e4d34ff05so20572705e9.2 for ; Wed, 01 Oct 2025 06:58:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759327098; x=1759931898; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EzrKUl+2NkMxRoxmdVM9hHYfWN12ztBQRe+rscPZIc8=; b=JWp9jIRB1GEh2dkQYJLOSb9bjRvCRrqvpsOhAMM2bqfv9LuU2P4z9xd7HHgqhePu2k N1C7naUGG4aZJ4sbOm/argAjLeJzOMKjGnu4q6lM4BDpZ3SQUw5TrLUgMWG+neqHVZWA m83i0vZvZmlYRpXUonCVA30jjZPUo5uDkMZiepitTwV9BHBBKR8lK9+vSW4yby/JPpLq q0HfhDORvzV0BPH8C8ewPlzSUMFoqRwNH/eFKj9/WcVYKPdQQZiyP2dy1Va3JU6HCqol Ac3eBwr3X1MzC8T76PqwlpUe4MBttcg34GA9YtP8h31Rc1GmilL9nWUHYahg000lZFcO pb9w== X-Forwarded-Encrypted: i=1; AJvYcCUBcy6FnehHSLXqKAqUPbNPg2wFi2+bzv1TiFWLS5FKvziN4uz6QL/Z9wAEGVUO8JoUEnK/7etoVglik0g=@vger.kernel.org X-Gm-Message-State: AOJu0YxdIRZ8MpDmbOHJYIpp6kFfALTOYhDdr9HlZpfE4oAHgHuL9L6w ejEFAmy8a56N3Y+lQLCC2GwznRKDQk0WoUTut/pAAbP9qbGvEFzofOM8C/jwBOXgxvuP0WA4HRp wQKCKC7axuhfOYjYR5a/X6QvQGUBiznM47OQ/f4iSuz9cNGlH+m6tqwgGfX0ZobC2Dw== X-Gm-Gg: ASbGnct22eamlTGlMSHxJBPQ0ehQS5pT7yZoHa+mZNVl3ahghlgqLQX8r0VM+DRo2Ab IIrX7Lvpt5O49Sg8SUC5g7kVycvZwmCi0Rq769bCL0sjaRzsiC4Kj0mpUTBXbNi4GxI/IQus65T rgWamGqlLsAiDdw/ZnF/XyOIoz4tNx/Boxuj4cBXOOtzt5etTRuhwTQ7ParMsLRGp3wvSTRLnLs Q1bBGkDKdt/EWgaDIK0pDpIOY5eAiWOqCCgUD2Zz1b5GOkEw4vbFshnfASRFZsRay6MPm91sYC3 T1v/hlrSugWBfeN6+kZ9L0cF1wMopfIHfVVwWvlHxaMcX3YS5L3SLfAPHAKkdI+3wKT98YoDgHj yJp++cygc X-Received: by 2002:a05:600c:1f8d:b0:46e:3d17:b614 with SMTP id 5b1f17b1804b1-46e676c7450mr10824505e9.6.1759327097801; Wed, 01 Oct 2025 06:58:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbmlLetAaGNeCKOH3qjvN1GbXYlFkysa1ZIB56tW7zS7mcnqFyRmh57QFuiH942kvyNYzrGA== X-Received: by 2002:a05:600c:1f8d:b0:46e:3d17:b614 with SMTP id 5b1f17b1804b1-46e676c7450mr10824145e9.6.1759327097338; Wed, 01 Oct 2025 06:58:17 -0700 (PDT) Received: from [192.168.3.141] (tmo-080-144.customers.d1-online.com. [80.187.80.144]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e619b8507sm41126065e9.3.2025.10.01.06.58.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Oct 2025 06:58:16 -0700 (PDT) Message-ID: <43d78ba7-8829-4a19-bdf3-d192a62cdac4@redhat.com> Date: Wed, 1 Oct 2025 15:58:14 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/4] mm: Introduce vm_uffd_ops API To: Peter Xu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Axel Rasmussen , Vlastimil Babka , James Houghton , Nikita Kalyazin , Lorenzo Stoakes , Ujwal Kundur , Mike Rapoport , Andrew Morton , Andrea Arcangeli , "Liam R . Howlett" , Michal Hocko , Muchun Song , Oscar Salvador , Hugh Dickins , Suren Baghdasaryan References: <20250926211650.525109-1-peterx@redhat.com> <20250926211650.525109-2-peterx@redhat.com> From: David Hildenbrand Content-Language: en-US Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9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EPcA/4NaBQJonNqrBQkmWAihAAoJEE3eEPcA/4NaKtMQALAJ8PzprBEXbXcEXwDKQu+P/vts IfUb1UNMfMV76BicGa5NCZnJNQASDP/+bFg6O3gx5NbhHHPeaWz/VxlOmYHokHodOvtL0WCC 8A5PEP8tOk6029Z+J+xUcMrJClNVFpzVvOpb1lCbhjwAV465Hy+NUSbbUiRxdzNQtLtgZzOV Zw7jxUCs4UUZLQTCuBpFgb15bBxYZ/BL9MbzxPxvfUQIPbnzQMcqtpUs21CMK2PdfCh5c4gS sDci6D5/ZIBw94UQWmGpM/O1ilGXde2ZzzGYl64glmccD8e87OnEgKnH3FbnJnT4iJchtSvx yJNi1+t0+qDti4m88+/9IuPqCKb6Stl+s2dnLtJNrjXBGJtsQG/sRpqsJz5x1/2nPJSRMsx9 5YfqbdrJSOFXDzZ8/r82HgQEtUvlSXNaXCa95ez0UkOG7+bDm2b3s0XahBQeLVCH0mw3RAQg r7xDAYKIrAwfHHmMTnBQDPJwVqxJjVNr7yBic4yfzVWGCGNE4DnOW0vcIeoyhy9vnIa3w1uZ 3iyY2Nsd7JxfKu1PRhCGwXzRw5TlfEsoRI7V9A8isUCoqE2Dzh3FvYHVeX4Us+bRL/oqareJ CIFqgYMyvHj7Q06kTKmauOe4Nf0l0qEkIuIzfoLJ3qr5UyXc2hLtWyT9Ir+lYlX9efqh7mOY qIws/H2t In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit >>>> I briefly wondered whether we could use actual UFFD_FEATURE_* here, but they >>>> are rather unsuited for this case here (e.g., different feature flags for >>>> hugetlb support/shmem support etc). >>>> >>>> But reading "uffd_ioctls" below, can't we derive the suitable vma flags from >>>> the supported ioctls? >>>> >>>> _UFFDIO_COPY | _UFDIO_ZEROPAGE -> VM_UFFD_MISSING >>>> _UFFDIO_WRITEPROTECT -> VM_UFFD_WP >>>> _UFFDIO_CONTINUE -> VM_UFFD_MINOR >>> >>> Yes we can deduce that, but it'll be unclear then when one stares at a >>> bunch of ioctls and cannot easily digest the modes the memory type >>> supports. Here, the modes should be the most straightforward way to >>> describe the capability of a memory type. >> >> I rather dislike the current split approach between vm-flags and ioctls. >> >> I briefly thought about abstracting it for internal purposes further and >> just have some internal backend ("memory type") flags. >> >> UFFD_BACKEND_FEAT_MISSING -> _UFFDIO_COPY and VM_UFFD_MISSING >> UFFD_BACKEND_FEAT_ZEROPAGE -> _UFDIO_ZEROPAGE >> UFFD_BACKEND_FEAT_WP -> _UFFDIO_WRITEPROTECT and VM_UFFD_WP >> UFFD_BACKEND_FEAT_MINOR -> _UFFDIO_CONTINUE and VM_UFFD_MINOR >> UFFD_BACKEND_FEAT_POISON -> _UFFDIO_POISON > > This layer of mapping can be helpful to some, but maybe confusing to > others.. who is familiar with existing userfaultfd definitions. > Just wondering, is this confusing to you, and if so, which part? To me it makes perfect sense and cleans up this API and not have to sets of flags that are somehow interlinked. >>> >>> If hugetlbfs supported ZEROPAGE, then we can deduce the ioctls the other >>> way round, and we can drop the uffd_ioctls. However we need the ioctls now >>> for hugetlbfs to make everything generic. >> >> POISON is not a VM_ flag, so that wouldn't work completely, right? > > Logically speaking, POISON should be meaningful if MISSING|MINOR is > supported. However, in reality, POISON should always be supported across > all types.. Do you know what the plans are with guest_memfd? > >> >> As a side note, hugetlbfs support for ZEROPAGE should be fairly easy: >> similar to shmem support, simply allocate a zeroed hugetlb folio. > > IMHO it'll be good if we do not introduce ZEROPAGE only because we want to > remove some flags.. We could be introducing dead codes that nobody uses. > > I think it'll be good if we put that as a separate discussion, and define > the vm_uffd_ops based on the current situation. Right. I'd vote for an abstraction in the lines of what I proposed above. Doesn't have to be the terminology I used above, but some simple single set of flag that we can map to the underlying details. But again, hoping to hear other opinions on this topic. -- Cheers David / dhildenb