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 BDA3D2F069D for ; Fri, 24 Apr 2026 15:55:44 +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=1777046146; cv=none; b=ghkSLsiIFprv0WE7jUM+fnJ7LwWwKdjq16xfi8nYL45LwXt/5YSWZP8hhJunQtF6UCDHUObr8xp0D1QE3sKqRdCgFxZzwuieIp7tKJ9nT3OB8me8Ddf1WGL43qp1s4Qs37VsUbQwVjCzC6sXzdbcAyQJBAZwdpRcTiCNBsbL8ss= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777046146; c=relaxed/simple; bh=LZ1g410fGp9cQzldzvNuJ90pocHt3VissIO7Xj+d5+I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=E1VTRFhqByAGDvugc6MhfbGNyTfn0CwPq2Dsjo6TYIOR5zLxHZH4aCxPsz2UcG7N+LnQ5SBwq5TISFWXEgeXvOyCGHY/BRGLL48Wi1DARWnbD4rHskM2u5S5Snl2Yjo8pC8tlmkM/DZ8a+dC1Nxb8HSH1hUT81z8a/O4U/RWjk8= 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=O3bS9i0B; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=EUBEQbAk; 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="O3bS9i0B"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="EUBEQbAk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777046143; 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=qLmU//rnAAA5yNF6Ee9JskKj79xD8INjyMeyu+N95bA=; b=O3bS9i0Bug9ZofHx2fd0fuHbDlAO33JkaEKeTtghMdV85FPNwMYCM0LsQP3jQWrsttYkdK 5nprh6FwtOJttSQC8oOVJwtPXnqmSQUBKTL5IaYhX7xdps0OYE4CsZxAl5J2Vyk2QmOV5j uqcwcRjWMD4mgPe22KwPDt1KTLwwIuE= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-OUaBCSfrNm2fP_wKFKq3Pw-1; Fri, 24 Apr 2026 11:55:42 -0400 X-MC-Unique: OUaBCSfrNm2fP_wKFKq3Pw-1 X-Mimecast-MFC-AGG-ID: OUaBCSfrNm2fP_wKFKq3Pw_1777046142 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-50ea1a7a5d0so131540871cf.3 for ; Fri, 24 Apr 2026 08:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1777046142; x=1777650942; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=qLmU//rnAAA5yNF6Ee9JskKj79xD8INjyMeyu+N95bA=; b=EUBEQbAkbuNfos+bk1ZVgR3yyz+3sYi2/npQVvto4J3EOkqB1553h1EZ45IOMkFADF syoO3jVLZO1ij7mS0IVGuI8KRsg/XIcSMpXCRYzQqM6m3OsfMuQown9Tzoxw4IKZHl4t /6uFTJQaS1/BuRURFHtbaKMgwkWdmncOJigOEM9Z1MDM88ZxzJxYaagpCRSQNCuVoISk Myeq/4wAmlLFF5Eg4US2OYW5azIHcjhEvxuQ6ZBTO5KqDffjorfx9QYyeFtiP+0sMqLA L3sTNLVw4gbgkzLRhoi44pNZ9DghKLfwMxDnEkOSOwqcGP8MkbSDVfqkic7RcoU8oPoo /xNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777046142; x=1777650942; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qLmU//rnAAA5yNF6Ee9JskKj79xD8INjyMeyu+N95bA=; b=OYWcOrYxmRbe5roQKLLZdIWFTBoe6vrY0MtDRDuHqtN6rP8k0Il2hHFYTtnUflcENH 34YtCx58BINDUKNFik7phvNYaeWVAZy2Ar2vYnuL5//0+QFKXicvarscgo3iOrooMr+J weFoQxbdeF5FN++9yzE+qFemdqAQVZZc0yBEJyA3biIwlq2I5iTpOig2a9sKSocpgUPE yiHrDMgMwKMJtiiOyklEMlOIP/uncHqmgtk1eOWI/Z+Sls0h/tShhIPB1W8+qWXAlnm+ mviryQo7elHTjst4433lzVE5tpWvmHB/suUbWztWn6C1hH+D8d7Qv+R0aMTrrKIgp9BW EFzw== X-Forwarded-Encrypted: i=1; AFNElJ9PRzXsLmhulS16ZdWEFIeoqdAg95bc/Wu5uZRlqrbdqd0LtFw5L6siWjaNW/cfLtVrD9Qk55sgU+2WAes=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9UtiRpuGwZjQJa3g9l6tv9n8FRRHJb55x4MMIsP8QzGSI69dk 0uvQIEd5mEQhoteJKk2p+M2veTnlEOpD5pnSOn+isiH/4ggubXRJRzZ123eXQRLPxt8GP6r1UAj jxyn/nMGJFVauSr947eWcRoY41ywurUc9ZYO5yzR36d78+S/BS1BG52NxToxrxNC0/w== X-Gm-Gg: AeBDies05p8FGDDlZvKH2Piy/tqTgU+lh1Ucs9Yb8Ia+d7cweiqKalswx1ChnrPXpXS SYWUBX19WNGhlS/OW3NSWFQjJbmB8Lh0xxNLrm1wn9AzhzzDa241c9+G9teHmHpIiqsArrp8KER sYZJagRpzlXGOvtoleuDXVCGR+WlgVjaN2XV4DImurqx6R0ajb+Vrgb4q0jyGR/A5N8Uvgn2071 1mite67FSPmxy3aKQ2wcWyDaT2pZWD8zGY6FMEXRz3ELr5LhkG1IL/iDOOJPjAIBUE9khjf4HAS 38R44G4LI1Hnmv6JQymlYHgYxtsMiDgBxEj+cL5D5CgasV/x6Wx7agh/2cV+vxwB9UO3qBQvSjN gijXs2gijGYAk75i7emnOA0iv0B+yqgGZbOUP+ojrQmRGJOsHZTLGLws/Qg== X-Received: by 2002:ac8:5892:0:b0:509:3cd:b22f with SMTP id d75a77b69052e-50e36b41242mr499700331cf.23.1777046141634; Fri, 24 Apr 2026 08:55:41 -0700 (PDT) X-Received: by 2002:ac8:5892:0:b0:509:3cd:b22f with SMTP id d75a77b69052e-50e36b41242mr499699791cf.23.1777046141002; Fri, 24 Apr 2026 08:55:41 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50fafe9674csm148150631cf.3.2026.04.24.08.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:55:40 -0700 (PDT) Date: Fri, 24 Apr 2026 11:55:39 -0400 From: Peter Xu To: Kiryl Shutsemau Cc: "David Hildenbrand (Arm)" , Andrew Morton , Lorenzo Stoakes , Mike Rapoport , Suren Baghdasaryan , Vlastimil Babka , "Liam R . Howlett" , Zi Yan , Jonathan Corbet , Shuah Khan , Sean Christopherson , Paolo Bonzini , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [RFC, PATCH 00/12] userfaultfd: working set tracking for VM guest memory Message-ID: References: <34f75083-29a3-4860-8a6e-94551d37ac6a@kernel.org> 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 Fri, Apr 24, 2026 at 02:49:58PM +0100, Kiryl Shutsemau wrote: > On Fri, Apr 24, 2026 at 07:51:44AM -0400, Peter Xu wrote: > > On Fri, Apr 24, 2026 at 11:34:48AM +0100, Kiryl Shutsemau wrote: > > > Both page_idle and the LRUs (legacy or MGLRU) track accesses on physical > > > memory. We need visibility in the virtual address space domain. > > > > Yes they are, but ACCESS bit isn't. > > A-bit is not a reliable signal for userspace working-set tracking > because the kernel itself is a concurrent consumer. It is exactly why > page_idle needs PG_young on top of the A-bit: PG_young is the "kernel I assume you meant PG_idle. I actually don't know whether PG_young is still actively used anywhere in the current code base. > ate the A-bit but the page was actually touched" escape hatch. And > bringing PG_young into the picture puts us right back into physical-side > tracking. > > > For migration, see e.g. remove_migration_pte() has: > > > > if (!softleaf_is_migration_young(entry)) > > pte = pte_mkold(pte); > > remove_migration_pte() only propagates young-at-unmap. It does not > cover the common case: A-bit cleared by reclaim before migration > started. The concurrent-consumer problem is what breaks the signal, > not the migration boundary. IMHO it's a separate problem, and AFAIU it was well solved at least with old LRUs with PG_idle. It's just slightly unfortunate it doesn't yet work with MGLRU. Also, when the extra bit is in folio->flags, it only works if both the consumers are reporting per-folio, not per-mm. I'm actually curious whether there're numbers or solid proof showing that in your case the per-folio perf is too bad already to justify a new per-mm API, like RWP. It's because currently this proposal is still so far very much about "let's implement a swap system". It really doesn't yet have a lot to prove on hotness tracking POV. Not asking for a time-consuming test immediately, but IMHO these should really be solid clues to first justify the overhead with current rmap in production. For us, we know the overhead in theory, but we never really measured how much. Even if so, I don't think it's unsolvable. I want to explore if there's something that can still be generic and work for per-mm tracking. I believe if we can have some bit in the ptes, then when mm reclaim code walks clearing ACCESS bit and sees some vma is being tracked, then instead of setting PG_idle, it can just move the access bit over to that special pte bit, and only to this vma this pte. IIUC that'll benefit from both worlds: fast HW-accelerated access bit, and no minor faults. Would something like that worth exploring? -- Peter Xu