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.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 ACEDF330301 for ; Tue, 9 Jun 2026 19:54:09 +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=1781034851; cv=none; b=Wvnm7XykiYtjoqb6MacDBkhmAwM5VC1XH6WWRjMwug2EvNH/QwGW7wBWZN9/1+PzJ+nzsKgCWgi8ym1MCf01f2u55y6TuymPe5D1lkaJ9ASV+6wYbRxq6Z3Oedk6K0pnnHJSPyZXSl0hStVGwg9EtasQM4dLb3dnz+jbGOjjRQg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781034851; c=relaxed/simple; bh=TkaWFvSM6RyZrxUqK+02jv3D7cQIKgZRTwhbtgg1dkg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LdTz/YuMu+OZxi5Opq3/tyHJ1S+QKO2dpbF8zSA/D9JerwMuv9nQS9NXwyUUyOdx7y8m9IcUuExWN8+vcm0IfQe5sWpAgoBMDG+pzrdpGH8Qdbd9wEyY+i+olBpSXV5Z7AL77lH46SwvAfzHemAf4mhBLCT+/M2aXZF0Fqe522c= 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=WgPQDGFw; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=mygTeC2u; arc=none smtp.client-ip=170.10.129.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="WgPQDGFw"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="mygTeC2u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781034848; 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=JJYRstItJSN50oqy/Ac1ulkKACubDQSvXFZtdF0CG6M=; b=WgPQDGFw08EnEOh7+Z53W7Ne6OVaQXadC1wUVRt2kAs9bpYslwt0q3T0HqhXR8HuYlg4KB RIq1+6MsO1MTRtMcMw1e5OYK/1dse8QSoZpBbPp/HNLnMe/6usdlcDPVnPKmFNz5QQgHCS xjqZViRF3bqrbd+KuFgKWbFrMAGJQXI= 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-7-7A87CZJ5N16-0K4rTnfeLg-1; Tue, 09 Jun 2026 15:54:07 -0400 X-MC-Unique: 7A87CZJ5N16-0K4rTnfeLg-1 X-Mimecast-MFC-AGG-ID: 7A87CZJ5N16-0K4rTnfeLg_1781034846 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-490ae0167ceso27491635e9.1 for ; Tue, 09 Jun 2026 12:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781034846; x=1781639646; 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=JJYRstItJSN50oqy/Ac1ulkKACubDQSvXFZtdF0CG6M=; b=mygTeC2u5j8LZWYScebgCwO/NH4RzZ6PN7eqj++qs6EmIiDux0MtYalgKNEhNzzIa6 bXObRAVzagZ0PXOTV5iQDA3cH2leJghZhkumz8uW9zO0Tu+tAdKfwABjxkJKQEn5c6TD YOnD/eGBZ1j+KRUd7H9GgmVzxa3Ft9SEYHNhHkNpwTQVJ5bRnNLcxB5eLBCNqt8xiSzg T1vAi7PCdiGZ2UM/H4BxAzjQQ2Lufp0eywpW+UZB6n1lYfMrgqW8SrBn1qE63zDvA/4d 1lZNuZQkEEvRH380SZDNWZz6k/swK8ENr8X+GANVugNHV3LhH/ORh/bAlrGp2KxuPGXD 2CCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781034846; x=1781639646; 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=JJYRstItJSN50oqy/Ac1ulkKACubDQSvXFZtdF0CG6M=; b=AAUIPOFWD1g0XxXcppgJu1tm9N/b7zcnOZNM/On7rFIA6y945ypbFpnDr3VhSq6llD 6ahdfc3XXw414OVPWPUDNmzirtyaXw4h2I6lsLYzblYikHDKWBZmSD0ULXjpsJMIYCiV GadRLrhqbt1tCmcazWnwjdNTvuYrqywWySRNBb6CmTBXOOO0q6xlz5y5TbeFtNYYrqYi DzvZ7fGE/WEHkLxqH2tyXEC19Q1U8jOzeDI1urUQ/GkEQutfLJp53FPY8DNRZWWT53yG L+SB5ti2tjzyi/AILpCrHqrUKj2K+tlkIxENJ8GEqat8BEe4kcUtJnnG2uj+kGPBrGch +ZsA== X-Gm-Message-State: AOJu0YymK5s8SvuYi109EbDPmzHC8ipVBFF0Js1wWSu+bAo02XVjrNE5 KJmU1tBt3zpzGfsQ/6wJU3EEiAX8S/oHTzt14Zs1xDExsC4pYSPA5B11i9qWfaKxBZPkPrZUq9t DBEfQupX0L/zUY3Vaq/RUiAYPN4LVSavd/RCozT8s/8wlD9OCPyuR48mSmGfnRBMpTg== X-Gm-Gg: Acq92OFSe69JaMUqx8zJI+IiZGCL1w3R0FoknVfGKw20h8KUN4jQd3l4dE2l3D8x9nF njnNxNNqmtBZWeu7aV3emizG5MTHLgjiiOZrcNoY3HOr1ogKsLaEn+R5FrvYmRrwf+UyS0ttBU2 fGYsHSXK4rXrAR1n9v6yxX+a6I/9YzXiDNKbUN0TDh/AtmbXkFFNkatjMdwpTfkjZxx0KGE2y3d 3aoSdehde7ct5BoVCq8dVyLCKMO3SKIPKsjI8n6xup0K73gc71B4ZXbZCpCe3/KCYrohqLftvN4 r4bi4OS40Tjq+BmPJaCN/DtY7eQTbvqBH1lT/a68yiP2GiDkBCZwJDPMllcgp83D+rGTnPa8Tsk A4PdVDa3YUDbjyt5YCrCwTjKHNy2FuyaybrIaLzkrTQ6/jJl2Tbk7BA== X-Received: by 2002:a05:600c:8b6a:b0:490:bb19:b110 with SMTP id 5b1f17b1804b1-490c26216ddmr332896535e9.27.1781034845705; Tue, 09 Jun 2026 12:54:05 -0700 (PDT) X-Received: by 2002:a05:600c:8b6a:b0:490:bb19:b110 with SMTP id 5b1f17b1804b1-490c26216ddmr332896135e9.27.1781034845160; Tue, 09 Jun 2026 12:54:05 -0700 (PDT) Received: from redhat.com (IGLD-80-230-85-71.inter.net.il. [80.230.85.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc3c183asm511355045e9.6.2026.06.09.12.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 12:54:04 -0700 (PDT) Date: Tue, 9 Jun 2026 15:54:02 -0400 From: "Michael S. Tsirkin" To: Sean Christopherson Cc: linux-kernel@vger.kernel.org, Paolo Bonzini , David Hildenbrand , Vlastimil Babka , Shivank Garg , kvm@vger.kernel.org Subject: Re: [PATCH] KVM: guest_memfd: fix NUMA interleave index double-counting Message-ID: <20260609154046-mutt-send-email-mst@kernel.org> References: <0eff0a90667b900bee837d06b5db5025e1f304b5.1780501924.git.mst@redhat.com> <178102235481.2735841.1203781071933134475.b4-ty@google.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=us-ascii Content-Disposition: inline In-Reply-To: <178102235481.2735841.1203781071933134475.b4-ty@google.com> On Tue, Jun 09, 2026 at 09:31:29AM -0700, Sean Christopherson wrote: > On Wed, 03 Jun 2026 11:57:33 -0400, Michael S. Tsirkin wrote: > > kvm_gmem_get_policy() sets *ilx to the full page offset > > (vm_pgoff + vma offset). But get_vma_policy() adds the page > > offset on top of *ilx, so the offset is counted twice. This > > causes NUMA interleaving to skip nodes: for order-0 pages the > > effective index jumps by 2 for each consecutive page. > > > > The get_policy vm_op should return only a per-file bias in *ilx > > (like shmem_get_policy does with inode->i_ino), letting > > get_vma_policy() add the page-offset component. > > > > [...] > > Applied to kvm-x86 gmem, with a heavily massaged changelog to explicitly spell > out that ilx == interleave index, and to try and explain the role of the index > (it wasn't at all obvious to me why using the inode number was "correct"). > > Thanks! > > [1/1] KVM: guest_memfd: fix NUMA interleave index double-counting > https://github.com/kvm-x86/linux/commit/48dbe4732198 Thanks! Sean, what is your take on interleaving for guest_memfd? To the best of my understanding: Right now IIUC kvm calls __filemap_get_folio_mpol which in turn does not pass the index to filemap_alloc_folio. That uses NO_INTERLEAVE_INDEX, so MPOL_INTERLEAVE uses the task's global counter - effectively unpredictable placement. This looks like an oversight (the index was available but never threaded down), but it's been shipping since 6.19. Should we fix it to use the file offset instead? Or GPA? And if so, should that be the default or does userspace need a way to opt out of NO_INTERLEAVE_INDEX? Thanks, MST