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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D3F8C83F03 for ; Fri, 4 Jul 2025 15:00:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A805E6B8057; Fri, 4 Jul 2025 11:00:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A57C86B803F; Fri, 4 Jul 2025 11:00:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96D9F6B8057; Fri, 4 Jul 2025 11:00:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8561F6B803F for ; Fri, 4 Jul 2025 11:00:06 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 13D415641D for ; Fri, 4 Jul 2025 15:00:06 +0000 (UTC) X-FDA: 83626892412.30.3EAC888 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id A3F8540009 for ; Fri, 4 Jul 2025 15:00:03 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TavfJOVC; spf=pass (imf27.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751641203; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=C/Cwj9oRPW2MMTaqz9C0MJPxO4pJHPnVvDIUyE/4QRA=; b=k/RJC2/vxzUcgqhUXO0p+v0621ueZ2XNLcGXGhT69xSg8t+BGhso2vdn/KgblJHKMJghHu vjwRpiSs0WuoBoS/6vw+I1gkVcqWppi9qU/b9YToDv7jRxJqDAB21mrjQUFrto9c9/CYru PufOrnrvJqvyUMTmrUj3XMzAEQD39AQ= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TavfJOVC; spf=pass (imf27.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751641203; a=rsa-sha256; cv=none; b=h2UsKRgCYSiIHcqEn5T4D1xcJD65Ke4OKmZ1BiVszmmGr+3Dp89u+mt5LtX/dnI58h/rgW nuwjEdBP0eBjQCTBcO0QzT+p9oxEosY8v7l5qZG2hrgEhQA7qBj77yf5TdyqGeeVbR5M+O vNabU3n0ujUjyyodtTFJOwv6tz0sLHY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751641203; 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=C/Cwj9oRPW2MMTaqz9C0MJPxO4pJHPnVvDIUyE/4QRA=; b=TavfJOVC4TCommpPuIaQHmwTmowzMrOALUpXjoBYylY58QjCsKUFZv5CvneG4xJtpt4igQ bojlQecKXWsdThHH0k74ZHeHhjzeTZ0I6mk6m3ut4lr8ESFWrULK2FxuSCi1gBReczCzO1 90qd8blXbp1bpK5YAlZYGiQzdhyc1F0= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-235-y4mzmlttNTiS1GbHgvTZlA-1; Fri, 04 Jul 2025 11:00:01 -0400 X-MC-Unique: y4mzmlttNTiS1GbHgvTZlA-1 X-Mimecast-MFC-AGG-ID: y4mzmlttNTiS1GbHgvTZlA_1751641201 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6fb4eed1914so19927716d6.0 for ; Fri, 04 Jul 2025 08:00:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751641201; x=1752246001; 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=C/Cwj9oRPW2MMTaqz9C0MJPxO4pJHPnVvDIUyE/4QRA=; b=M/7ZDzElp7lhqUsp7Jpzd5s4oFi24sNolZrFfkoLyqe16AgiVRm5FB2vnLyjjWpzID cDuBVnLqnT3OF+/ROcExSvNRTeQ+ZyUixrWsj8f7YotOLkGBBDku/h1l+W/HxTAs72KI BEpFwsJmIAwQs5fjlF08ee1LJmUH1udT8tJ/292HB8qmqsb2Jz5tyRekmG8630Z56Yxn Vj4PpC1yOQAxoAabj6O+DDlGdT9tMGnttV0hEgP4mJCzoQe3Og43wBFmY7FhNCFCbI0Y ynKhYuzTnzXh13v8HYGBoWWRng4H9oKpIBpsdlzVrBhv40rBTaURbTQ5FLsQ9SJwudMa 9Ezg== X-Forwarded-Encrypted: i=1; AJvYcCUKqWYA4wNKZ2/LP25Elb17k0cmwWARZDxjWZPEPiigFADQO9mTTRhIeUzwAvn2C8VEPPd1JPdx+Q==@kvack.org X-Gm-Message-State: AOJu0YzJJhu/XgjEPtAsrS+Siy7JLMmIwgw5nqbJkG8WtEWc1yfwKTZx Cr6UJsmLsg0HwpAWKB2+5THLUa+x/D2JWhoo+4yFRtGBprLE3RYMW0LiB54TjXkJ1YUGJHZBKwH 62aoJCJwWeQIkef3HAwsuapwDkE480KocAn/1LP/egJykNULrjRQf X-Gm-Gg: ASbGncvbxLWMO9NW8B5WCHak8BWJYohcKkaUJKt5oLrnT0JBGqdG5S17XVqs5vrS3xh Vfw9a6iTn66OvfGRO5Tt+IwMj3ywB7rvwrxQzMiCZhdU6lXQ2RdMW4nCD2QQZ8bWbyQwoHdwumh cem6Zi6MliZnpvBiIcQjHhNLL9oJHR+0uViwwcoKGfM76sbg98D0nWMWmj60mrZtrTQBYsL8Fb8 wQGwCrSBCbU4gjiCiRGvJ+jCUat89GZVE6Le1r0BDF6FH0GOs5UzjWdVR/vm8u03NCoPZlAqnw1 DMMeVRYNOOFsWg== X-Received: by 2002:ad4:5f0a:0:b0:6fb:59de:f8ab with SMTP id 6a1803df08f44-702c8b72059mr36080896d6.10.1751641199637; Fri, 04 Jul 2025 07:59:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhPr2MJbmotTsNytY9PPizY5rZHNJJDa1rC3WhIDApCHnYhg45xf20jKrYIUTpS+SAQb2S+g== X-Received: by 2002:ad4:5f0a:0:b0:6fb:59de:f8ab with SMTP id 6a1803df08f44-702c8b72059mr36078116d6.10.1751641196742; Fri, 04 Jul 2025 07:59:56 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-702c4cd4128sm13562166d6.52.2025.07.04.07.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jul 2025 07:59:56 -0700 (PDT) Date: Fri, 4 Jul 2025 10:59:52 -0400 From: Peter Xu To: David Hildenbrand Cc: Mike Rapoport , Nikita Kalyazin , Lorenzo Stoakes , Suren Baghdasaryan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vlastimil Babka , Muchun Song , Hugh Dickins , Andrew Morton , James Houghton , "Liam R . Howlett" , Michal Hocko , Andrea Arcangeli , Oscar Salvador , Axel Rasmussen , Ujwal Kundur Subject: Re: [PATCH v2 1/4] mm: Introduce vm_uffd_ops API Message-ID: References: <20250627154655.2085903-1-peterx@redhat.com> <20250627154655.2085903-2-peterx@redhat.com> <982f4f94-f0bf-45dd-9003-081b76e57027@lucifer.local> <289eede1-d47d-49a2-b9b6-ff8050d84893@redhat.com> MIME-Version: 1.0 In-Reply-To: <289eede1-d47d-49a2-b9b6-ff8050d84893@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: hKz3sE-_Mo0knvPoBUQkYDSX2e2uWa0qlIBNrGOBA8I_1751641201 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Stat-Signature: c7pwezj1ncpqbot5p61y1irhrbg41cjt X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A3F8540009 X-HE-Tag: 1751641203-434872 X-HE-Meta: U2FsdGVkX19dPRoG4fSFBmqb/pBn7WWu5D7sgSg2qrdgPn42IyrbTqVJOlcj0M8pwGLTL78UwW4pmsQ1jFAXqntV3MVISgGbAYy2hzd9VyOtVSK3OeneNypNhrFBoGcUhfaIyrX1ksS7RylqdEGtS6/x54DwchSQ1b5opVXCO/U4PUXixWvIKKPZBAT6yL2VXAmP5mFatTZTc3M5QcDRcZX3uKSc1ITxmvczP7Yi3TndkqMXgbSLJT+qh0rbEM+HxpNo8KMCuH7WYGyl7k+LpJyyuH3/AprpZa8pGt1lTzgoAqyQPaUrotQX3KIEiMzocQ2HvgID7VAJwdF9vZlltS0osuWlGKMVH4HPdQ+/VjqmEC2dlup3MlabpKxg4DcPT4mURoskLIRzNPRRl6Bk4BjgGxFi+DTlJ78CN2erVB2TW7IWmkjOnzu3atxWIlQ9oOPrHTTwP6I/7wM+BicA1t4uDCwSGsytYEFjbLRsGnC6xVa4qCIqZzjaHVkpOKAWRz/Qb0uKPgg5tzlPxJwMDafqZRIW5II2UZGkxbmAHwoOLRDu4bgrq9myo5tIDuglpVtlQ/2Rg4k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bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Jul 04, 2025 at 11:34:15AM +0200, David Hildenbrand wrote: > On 03.07.25 19:48, Mike Rapoport wrote: > > On Wed, Jul 02, 2025 at 03:46:57PM -0400, Peter Xu wrote: > > > On Wed, Jul 02, 2025 at 08:39:32PM +0300, Mike Rapoport wrote: > > > > > > [...] > > > > > > > > The main target of this change is the implementation of UFFD for > > > > > KVM/guest_memfd (examples: [1], [2]) to avoid bringing KVM-specific code > > > > > into the mm codebase. We usually mean KVM by the "drivers" in this context, > > > > > and it is already somewhat "knowledgeable" of the mm. I don't think there > > > > > are existing use cases for other drivers to implement this at the moment. > > > > > > > > > > Although I can't see new exports in this series, there is now a way to limit > > > > > exports to particular modules [3]. Would it help if we only do it for KVM > > > > > initially (if/when actually needed)? > > > > > > > > There were talks about pulling out guest_memfd core into mm, but I don't > > > > remember patches about it. If parts of guest_memfd were already in mm/ that > > > > would make easier to export uffd ops to it. > > > > > > Do we have a link to such discussion? I'm also curious whether that idea > > > was acknowledged by KVM maintainers. > > > > AFAIR it was discussed at one of David's guest_memfd calls > > While it was discussed in the call a couple of times in different context > (guest_memfd as a library / guest_memfd shim), I think we already discussed > it back at LPC last year. > > One of the main reasons for doing that is supporting guest_memfd in other > hypervisors -- the gunyah hypervisor in the kernel wants to make use of it > as well. I see, thanks for the info. I found the series, it's here: https://lore.kernel.org/all/20241113-guestmem-library-v3-0-71fdee85676b@quicinc.com/ Here, the question is whether do we still want to keep explicit calls to shmem, hugetlbfs and in the future, guest-memfd. The library-ize of guest-memfd doesn't change a huge lot on answering this question, IIUC. It definitely reduces the use of mfill_atomic_install_pte() so that we don't need to export it. However if we want to generalize userfaultfd capability for a type of memory, we will still need something like the vm_uffd_ops hook to report such information. It means drivers can still overwrite these, with/without an exported mfill_atomic_install_pte() functions. I'm not sure whether that eases the concern. So to me, generalizing the mem type looks helpful with/without moving guest-memfd under mm/. We do have the option to keep hard-code guest-memfd like shmem or hugetlbfs. This is still "doable", but this likely means guest-memfd support for userfaultfd needs to be done after that work. I did quickly check the status of gunyah hypervisor [1,2,3], I found that all of the efforts are not yet continued in 2025. The hypervisor last update was Jan 2024 with a batch push [1]. I still prefer generalizing uffd capabilities using the ops. That makes guest-memfd support on MINOR not be blocked and it should be able to be done concurrently v.s. guest-memfd library. If guest-memfd library idea didn't move on, it's non-issue either. I've considered dropping uffd_copy() and MISSING support for vm_uffd_ops if I'm going to repost - that looks like the only thing that people are against with, even though that is not my preference, as that'll make the API half-broken on its own. Said that, I still prefer this against hard-code and/or use CONFIG_GUESTMEM in userfaultfd code. I'll wait for a few more days to see whether there's comment on above plan to drop uffd_copy(). Thanks, [1] https://github.com/quic/gunyah-hypervisor/tree/develop/hyp [2] https://lore.kernel.org/all/20240516143356.1739402-1-quic_svaddagi@quicinc.com/ [3] https://lore.kernel.org/lkml/20240222-gunyah-v17-0-1e9da6763d38@quicinc.com -- Peter Xu