From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (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 1EF4323ED5B for ; Thu, 18 Jun 2026 15:31:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781796662; cv=none; b=oGVw0IbuZNR9LHCVfNRxpkHeh7BE0Up1YNDkuDlK5af4AI898QRSU6b7h9Xqkh2czxo+gYGFfjEvhh1AHzLzPEjcbqRz8MYHx9U0AvpfasRoq856KJcMFiFd2xZuccf3hKWVXF0Nqz2Cx9SwtYKvQwiMoA+anqFW3gkWN+eHyw4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781796662; c=relaxed/simple; bh=eGQggG7i7VbSA0hSDcFTISaARbLDieURyHfGv233He0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S+/RdAiO1CuJGOvz90NK0KQGiiufk0H9NxsyEU66ePLCPyqoziGlKNIJDRXg7LA4jq5iqrUxW0UZrnm8b5wZJr21LKrCWSaYCCp2SbPER9D4cBQdtFYm6Lijw0NqeSYSyzsSg5YElAMhAEY0hZtYmtMtTaYQSY8wlJGS5jo/1NY= 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=VBPM4wxV; arc=none smtp.client-ip=209.85.160.179 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="VBPM4wxV" Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-5177b9a02bdso14564291cf.1 for ; Thu, 18 Jun 2026 08:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1781796660; x=1782401460; 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=l2YbFlGbsb/BC3pB5tDgDJVPXhu01tr5a7yfMtRUunQ=; b=VBPM4wxVgTdmBOrYm86eoEMcJdaSFNX+4RJHxUNmzLWdVh3tSkp5XHf/bbDGMJ4wx+ xsN5tpvznynT3ThgzqrPt7K+cIbWv9bhUTMGkgdB1wjjOFiKDG253d2w9aZTFE/hM73f gMWqbow0Ud75VJmZ1Q+BCxEqdFx456HQli9VzYGr1zEAH1IipV9ZnQSeHrbemtLJxNVS hsUJm3FhSB9uV0L3nkthcBBCdr3qwHJb9/lOFPxVpAjuNjHIT2WxFmiKXHTrNN6DC3au Nd8iOUrBujfvdR+Gig8O+3IefR7x6/Wth46jTB+/RDSumyTMb1gqcEC6zRvzmBgpd92w KMAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781796660; x=1782401460; 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=l2YbFlGbsb/BC3pB5tDgDJVPXhu01tr5a7yfMtRUunQ=; b=ULcx4c9yl8kKHPyi/s1zVhW862pcO47EqjVUS8/+i+L4y/1miu5CqOJL/1D8PkffEp v5k4T2LsPo0MjkbRVumqgTennycUCYpJIqlAhuQTRA6Ms4TUSUASAwNfEpPBYaG7Bn9h CrZXG3we334PnfbVhoStYBYFPOBevrei+M8GjtidqSOKMBcWqPjgD6z0kBtyhpr29V8/ 5oESJMS5aiLVOaAaZYSSlftMxBb1/sMYX1m+sUfJg889GuE8SdruXMVocPuZ1X3EuZzU /OxGz4ZfCvhBK370fsv5WcZFn5pfsM1DkM0d5+qOLHad89JNJ4vkW4ut6oevt007wb2A vHEQ== X-Forwarded-Encrypted: i=1; AFNElJ9XsQWJ0SL0xCWQngiVLg3tyzTgfxJk9nLbq16Jy2sy6oFYSCTQWPs9fh2nfpnjUd5/RYVtN1rmyDlQgcU=@vger.kernel.org X-Gm-Message-State: AOJu0YyBs90agGSVjCouqVoUpwoSGtRKBK5hIdSMRQO0pae8+Iyx/Va/ FTfGE8donFxcvHiqs7vKBmU6mr2Kh+4qB5eXk7LZBTWNoGAyCk4tYbYuKDgd5r//ewI= X-Gm-Gg: AfdE7cnt6YT0z0M1QGQMsPMwoCljbap/UXws+jyjzhCye7WeZYsP2d3YuWU278Dc5Ah 651wMmSFKqh3n7S+2zdZ62799zF/WA/R+n8LRCABPpOuMg/69TMX4Ot1nPkDlDNwm+GJDruxx4D /r+Ekti7LL7Z75pY1uPVTLoMbbvS1LdJ9UL/RtqnwYcc8kah4taSgY6eRz2IgBhIaNqlMJPVZXv X3Wf3s0sgpGptCuNRk87aNU1DdxsoO/B/eMbilAakmVIc2MmyGNhN/MKSobScWjO+XgFW8Filhz IYhoAvDhTaEIbUPXbG7aY9LMt7hB124mVGACmiL/R8RAQVGi1viZRmi4+vaM0zEGnKwea0ZrEt5 S1wt+h+cgwGjWkndVTmyjL890WXvHTVAPMBoOREG8wJebDZzxB8vPwfDGvLDjXHBF2JqZmRCi6A dNva+vSTewIMz8OBCFYxSJMIPWEj6X/94zOC+Gy71r8VmQ43x17TCm6iBgFoIVJ/iD/pb4axwOS 1NelQ== X-Received: by 2002:a05:622a:514:b0:517:875a:d634 with SMTP id d75a77b69052e-519c6d110b0mr56448271cf.2.1781796650715; Thu, 18 Jun 2026 08:30:50 -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-517fb7e8900sm221236521cf.23.2026.06.18.08.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 08:30:50 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1waEhd-00000002syZ-1gad; Thu, 18 Jun 2026 12:30:49 -0300 Date: Thu, 18 Jun 2026 12:30:49 -0300 From: Jason Gunthorpe To: Matthew Wilcox Cc: Lorenzo Stoakes , 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: <20260618153049.GG231643@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 04:04:06PM +0100, Matthew Wilcox wrote: > On Thu, Jun 18, 2026 at 03:55:58PM +0100, Lorenzo Stoakes wrote: > > On Wed, Jun 17, 2026 at 04:29:28PM -0300, Jason Gunthorpe wrote: > > > On Wed, Jun 17, 2026 at 07:34:06PM +0100, Matthew Wilcox wrote: > > > > > > > I don't see this as being something that drivers should be involved with > > > > at all. The MM should be able to get this right without any hints from > > > > the file-provider. Yes, that means I also want to get rid of the setting > > > > of get_unmapped_area in ext4/xfs/other filesystems. > > > > > > > > Looking at generic_get_unmapped_area_topdown(), I think we can do this by > > > > making an additional call to vm_unmapped_area() before the existing two, > > > > setting info.align_mask and info.align_offset appropriately. > > > > > > > > Now, what's "appropriately"? I think it's based on length (>= PMD_SIZE, > > > > then >= PUD_SIZE), but we should also take CONTPTE architectures into > > > > account. > > > > > > The info.align_mask and info.align_offset do need information from the > > > driver based on what it intends to map into the VMA that is being > > > created. > > What you're saying is that offset 0 of the opened file might correspond > to a PFN that is not aligned in any way? I had assumed that when trying > to do the mapping of (2MB+4KiB to 64MB), that the offset specified to > mmap was 2MB+4KiB. But you seem to be saying that the offset in that > case would be 0 and someone needs to know that it corresponds to a PFN > that is misaligned? I do expect that the pgoff space is usually aligned to the pfn space, most drivers do that or could be improved to do that. There will be some off cases, but maybe we don't care, and VFIO should be fine. That is certainly an easier place to start. Jason