From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE1B23FDC1A for ; Thu, 18 Jun 2026 15:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781796489; cv=none; b=F0Ibgn3LU4r1IgUahZUT+Dum2cv1/YoIOFRegEd5UJyojKZT/klK/QauIZDsA3UxdZH14i+SjoqW6ItJwiuPxFo/VNoruc2K/m0L3mn3bSdqhiEd0VxYnm4FfJPCpLEHJk13+KiAkrh1TpZtpreFjYNUP7xUCxBr7svtxlYw4/E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781796489; c=relaxed/simple; bh=0QMdV0N5NpX2KPdHDqUOENxi6RazWZG2GolVOS2HIg8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uwQEdhOScfgpMw8vkwdyk0pv7A/V6+QF80ROJsIxRNmGLEI6RX1yQjkfXvFvxeLKzljqOdEzg8RB6lTGRMMvSgRt+kVUcSy+s/98z272qXuoqvsFVlhaaVtZlRqRxgoBKI1uCFz30qKLUzB0sLPk23I1VQFZi+4YcsejC/coO2c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=NBInqi+J; arc=none smtp.client-ip=209.85.219.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="NBInqi+J" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-8ce9df31840so7620266d6.1 for ; Thu, 18 Jun 2026 08:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1781796487; x=1782401287; 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=P63dWZztD1Zc0WqIHW+0U1XALCCx2pgBRGQ79zLsHtM=; b=NBInqi+JAujNXzMKGiwXcFTOVU8oJrCpUjPbk5ORGfwNsOAvPsQhQH2FrE9nmGqc7k 1Cx7dAg/6z5zMmkqMOgVqPagM3lLX+df4tuCPrwVisb6t5vW7jczxhDrXi/5oLK46FgI +7v1k7VEChXkFP+oZ3p6NacM/u3iRShayPeqeQQXJbher9yX2eifqFdoafDEYRRPanB9 GJAk/8VaWjHGTktOSlHcgVqUkjQ2BtRluhWL3Zi2WvY+1OtPgtBSF5sRDDjuXOyZxw81 MaWYz8M0Fy6a+zK6rNnfI8+zzSGIk76uX3lXg0Gz+B8/pC3tphQ6+8GGWWZBteY6QSnM CtNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781796487; x=1782401287; 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=P63dWZztD1Zc0WqIHW+0U1XALCCx2pgBRGQ79zLsHtM=; b=PSJMGUSOsAUUz4irqitZFEO9mZiVbPLAQKx5neNkDVJQu21Zp/gsggovltTef8sLEo +UiocA+NyAo+nhfqUmC2vKobC0y1NgiTeXdkNejQbDW0K0FsS6NIWMgf9XjERyh1xxYZ LT4yUyYViQJBHVARqepT60PpUPiWjML1LzJWM/6SR0Fg8CvWQ4YjlqNS11ruPpL/U7OC Hmg1CIvX0FTbMXBaWXDMCCPPnj0s35EFsTBa6MuJJG0OcWNzhHsGTd8DkrcUGj0mDnod DzgyqFPYpwpUKjtbt7Lx7axDLD7KHKnBww0BaHtyajsM64hjflqWayxxLAPbTemPWgu/ yWMA== X-Forwarded-Encrypted: i=1; AFNElJ+Nnb3k8RCskYr/5Fzx29WiQ1xV4E9ZW5AlHxdbJDad5JFXVFFIiIvCERrSu660iJRqL+Dt/LSPgG1Ya6Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yx29B49FX94o4quRoBYs9U04XCA+UZsLgc1p84eLaRAKM4MC7CP yNhAoeTpsILZQ9KMIkSXsFu5xFfOOsr0bWrwE3xVaTkhM2XWaIZW0mLuvtKcd6INOHs= X-Gm-Gg: AfdE7clgl6AZdNaEAmlruKIyTtqaCObmfC/uJd5DrhHQ2ItgBe5H7aZZWSTOClYNN9O /r2LUa2TRC5CH3MSrV44cHWUOoTC3vmBbLjZ444b+Chsd3zwnvVk7T3qeQM6+YvTcU+XLMBnsgn XLPmzB8SAa2pY3hLBL7aApD9ahsw+Nd5qSJfMlayWP1YOIUNpowmHldDxA2doIRZv7AD+0fYjDy BLfhnXaRj3BGSCYy1i65GsLoN+rKCcFjvtTrEdfhX7XEmEGt4lsQWIzCxcG6t7/u4X88zfOnISo P40DYEgh3g1aKIO1E4kpdx+nOmXQhDYBsRuI02R/Jal+gVPmXunlekmP+aoqC/7TlDzSFkkiOvW Lf41eRLYNW/CIWW7KMFwaBUjdxqwdkFmTEYSHQiXPWdygU+2hxUKYvHQrLs9b+Vc8kM5vbXfH4X NdmFNl/bmHj/G3j/rEH2orFOc8c92mH0dx1f9rugUpWW21AElWVkNpR5JZgY77DGcbdB4= X-Received: by 2002:ac8:58c9:0:b0:517:6fa5:94ef with SMTP id d75a77b69052e-519a90253edmr135623381cf.50.1781796486476; Thu, 18 Jun 2026 08:28:06 -0700 (PDT) Received: from ziepe.ca (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net. [47.54.130.67]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-517fb84188asm213419051cf.29.2026.06.18.08.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 08:28:06 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1waEez-00000002sf4-1fkX; Thu, 18 Jun 2026 12:28:05 -0300 Date: Thu, 18 Jun 2026 12:28:05 -0300 From: Jason Gunthorpe To: Lorenzo Stoakes Cc: Matthew Wilcox , Peter Xu , Alex Williamson , Anthony Pighin , linux-kernel@vger.kernel.org, Kefeng Wang , kvm@vger.kernel.org, linux-mm@kvack.org, "Liam R. Howlett" , Ryan Roberts Subject: Re: [PATCH] vfio: Request THP-aligned mmap for device fds Message-ID: <20260618152805.GF231643@ziepe.ca> References: <20260616180129.160016-1-anthony.pighin@nokia.com> <20260616163054.77fdb61a@shazbot.org> <20260617192928.GB231643@ziepe.ca> 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: On Thu, Jun 18, 2026 at 03:55:58PM +0100, Lorenzo Stoakes wrote: > > A pfn driver often has a single already known physical range that it > > will use for the VMA and that range should drive the alignment > > decision of the VMA. > > > > vfio in particular has common use cases where you want to mmap from > > weird offsets, but we still want to achieve a VMA starting point that > > has pa % PUD_SIZE == va % PUD_SIZE. It is impossible to do this if the > > thing building info does not know pa. > > > > I do think it makes sense that no file provider should be computing > > the VA area itself, I think I made that case when Peter was last > > working on this. Now that we have Lorenzo's mmap changes maybe we > > should be talking about supporting VFIO by having a callback to obtain > > the starting pfn for the VMA. Usable only by drivers like VFIO that > > are working with the pfn functions. > > Can't we figure this out from what the driver tells us when it invokes an > mmap_prepare action? VFIO installs the pages via fault handler so there is not a naturally existing way to pass in the pfn? > Can't we figure it out from the PFN the driver tells mmap_prepare about? Maybe it can pass the pfn anyhow and not have the mmap logic map anything? > > Maybe other users would prefer a 'max order' callback and then the mm > > would assume the VMA will be popoulated with pgoff aligned folios up > > to that highest order? > > Not in favour of that, fear it'll be seen as a new go-faster stripe. Ask > somebody how many free pints they want and they may veer rather towards the > upper bound :) I think you need something, otherwise we will be aligning VMAs that never have anything larger than a 2M THP to 1GB boundaries, doesn't seem good. Jason