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 51FE8C02198 for ; Fri, 14 Feb 2025 17:17:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF555280008; Fri, 14 Feb 2025 12:17:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA4FE280007; Fri, 14 Feb 2025 12:17:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A45E4280008; Fri, 14 Feb 2025 12:17:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 86B06280007 for ; Fri, 14 Feb 2025 12:17:44 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CE0761A06E0 for ; Fri, 14 Feb 2025 17:17:43 +0000 (UTC) X-FDA: 83119207206.14.0628363 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 5A89714000D for ; Fri, 14 Feb 2025 17:17:41 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dsJq+BYM; spf=pass (imf26.hostedemail.com: domain of alex.williamson@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=alex.williamson@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739553461; a=rsa-sha256; cv=none; b=UwR1jrmGEyrV4Dug5f0fMIuuL/4jwt0XdvqFEnxGBLzOQ4jFBbLQGwZuamZj/ixoiwa6Ka hUb88sHBztVhNNFk0dmTnPY5f/g/yRudRPSZ+30JwaoUn+EKof59rs87fOgLwJCDA6cZYu A5154kYlCzWDjcNjyw5k9xEiTkQVNw4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dsJq+BYM; spf=pass (imf26.hostedemail.com: domain of alex.williamson@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=alex.williamson@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1739553461; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vPfsF1K7YUp9R9mQX+7RKyz57Btz7H8JUY3WuYwgCK4=; b=8X3p2mMyCg8kq6waLy/s+8Omf4HRhT1fo0P/t678zLheF2/bAzE3HrBgUyICuSdh48aVwe QnQfWy4AItgxNslDM17fCbm9uO+b2oIPiVT/Gvq4iEeJ0FM4w/t9ed+GDgduh88g2UmpU5 eqsmywp773uQYJ0USFKneGmbjlK++qI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739553460; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vPfsF1K7YUp9R9mQX+7RKyz57Btz7H8JUY3WuYwgCK4=; b=dsJq+BYM1op0k9I5u8G9noHCO6/bwTSyLtEUAFVzhV6ZjCOuzWj1a8yzT9LK13KNHW5nDs HfdIJHDUe5GgajbhCz0a83D+ezzBdRCEkRYcKYgAKLR5Qfhl/1n1XUILMRFdcRLxqQ/ioY CObZwuDgcWAVFpPvHSh27POAU3Zbm1E= Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-325-f5R3iIYkMP238hp16Q_VGA-1; Fri, 14 Feb 2025 12:17:39 -0500 X-MC-Unique: f5R3iIYkMP238hp16Q_VGA-1 X-Mimecast-MFC-AGG-ID: f5R3iIYkMP238hp16Q_VGA_1739553458 Received: by mail-io1-f69.google.com with SMTP id ca18e2360f4ac-85564b0facbso3075739f.2 for ; Fri, 14 Feb 2025 09:17:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739553458; x=1740158258; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vPfsF1K7YUp9R9mQX+7RKyz57Btz7H8JUY3WuYwgCK4=; b=D0Gw0LIkPCzv8nbq9SKiecnxXn34T/a69Rk4a2is5aHm3t2AX5Lr7KPgRB0jmOppGy VwjH41GCnS6n0W1riS9DV1aePyswKcUTIjvntk95jt2vmNulMje9JNkkEqAWI+AX8vxn mBXwRE5jpdIo91AZwfVElhhly29VbT5lbEJUAFAvuCeNnGWCQDY9zDrBFfdGywgbUnmf 96RvNONqmSXxkzOo1kZD/IBnt9axxBdk34uEnf251A10e+DyPi1t9/0qAycxCRv+p/DU Ua/91VagiUHjgxGXSbGIlMIYNHaUYgTftOqu1gNdmckxX+1IPNl8IxvtLYlvuwgNmRYH yrKA== X-Forwarded-Encrypted: i=1; AJvYcCVlFV6yIsXp9tL4/93Ep5TZjDMy+Cu/9tp9ROxuKCS+8T4Icx0BKMteSlbnmCw3M9GS3KXawkxPsw==@kvack.org X-Gm-Message-State: AOJu0YwKv5PZKxJiJEBerueDz2al9a3drhpEzObzG2owAXrSX6xGH4qS FhU45J7HElD16nYuJt7jKojFTpB5n2wosYCZ3o2yEl5xNmV1Zc5ZFDlKjGi83CyC55yU3+aipGo 778zW4o01lg0oVn686N9s5PhsKxlFng9ffsPDiDoS0vsPjVoH X-Gm-Gg: ASbGncsqm0ztVUCxgp82Nljud8Qy9qrQhzmRGuJilSs+pCz0GNegU5vuCJThJxASmOB 1GNhvGMK20584U87Wk8mXFjTOq6OcKfpqH1vOckr8z8cmRU3r7EsGs/CGn5e++XmsPHeInfS+/G XrMzlIcnrx1P5uMrL4S71niAgKE5A7isxzAW3YdMGcQLU+7nZ6N9sONhyxYyVPvXypaZMMYXASR oeUKR5Y15n4JNmYs/ZSPxUx0BHTp6I5UqP84ImMOLvo2nOYcSmgmx5CLIP39zaSQWvNx1AcTrJA xYQcc/yT X-Received: by 2002:a05:6e02:1d13:b0:3d1:8bf1:46f9 with SMTP id e9e14a558f8ab-3d280987dcdmr318315ab.7.1739553458422; Fri, 14 Feb 2025 09:17:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0Qz9VO3Ey/mEXhAHSN+HIg08dAc+H18Eqqwc7ITCwAustrikXMJraW28xXpxtim+2NFB8yg== X-Received: by 2002:a05:6e02:1d13:b0:3d1:8bf1:46f9 with SMTP id e9e14a558f8ab-3d280987dcdmr318125ab.7.1739553458021; Fri, 14 Feb 2025 09:17:38 -0800 (PST) Received: from redhat.com ([38.15.36.11]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4ed282d7b4bsm902182173.115.2025.02.14.09.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2025 09:17:37 -0800 (PST) Date: Fri, 14 Feb 2025 10:17:35 -0700 From: Alex Williamson To: alex.williamson@redhat.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, peterx@redhat.com, mitchell.augustin@canonical.com, clg@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org, David Hildenbrand Subject: Re: [PATCH 4/5] mm: Provide page mask in struct follow_pfnmap_args Message-ID: <20250214101735.4b180123.alex.williamson@redhat.com> In-Reply-To: <20250205231728.2527186-5-alex.williamson@redhat.com> References: <20250205231728.2527186-1-alex.williamson@redhat.com> <20250205231728.2527186-5-alex.williamson@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: -szfjRf5fEIoAzIVw3AMQMWCxTIFYdrtLTyBu4Ydb30_1739553458 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: w74exwi5y9emnknkfk1ur7jxg1k8ks4o X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5A89714000D X-Rspam-User: X-HE-Tag: 1739553461-513921 X-HE-Meta: U2FsdGVkX19H2OUhuDCoO3JQBEtxBOaPD9flQ0hc2CkhRnrSNefoh8n7+NncuD/qxnH1CgzHMJIxkpyDpIH3kV+/30YByKfdG686T4ldt63ImgQ6ibVAPgf7Q3mOzb+oFaSP6wwnNUpIVcrnaxBt2sOiLEDA2Ew5Id1MEja9ctubcVe/vhMqA+pBCGdGYsTo3BL6oVTDUXqezzQoFOcTz/wy7ILRuMvO8XrSRrbE9GXqOPW0K2++giQRLPVyn67717z4xGJEj35X34d0LRjJXgl7SItMgj9n13oYL8cfQps6P1WVV6N8xvcDdD0EdxhBlYx6WW59++99A2Z/y2Voo/4fACKhsNIMplo6o74eGAInty7192kcfWv6HvMIsLXsRoJ/xXsVMngVw2jBj4eOx0iqXiz+WKIUGPW9rfBgQ7akiqbIewnJFXQg96KJp9W5CNlGOdgoZEPAyr6OWr91Iwi8mx+bAjBCCMLdBRprUjMt2KcogHMziXesqnLNZgsiYFWs4ITFq2Z/t7musxFqyU5Jm68HU5mfbynAOdJRgf7ufegv0liq6srPpPZVcTMaOZ4U68CFf+VCPiweijS3tyohGARZjCwf+u86Kh2o6S2P//U+eX+pSv2iAoXyiEHwYFjJZWaKAYPSkA3Vm9bscupf4Alg3lnaQQVkvZDzT6ojbrfCtMllVEZDQVPnt0ieo0d5BPeuc0oGt13Ke3bZZl6nVxyjgdI0uyARfi5nDqU1cISM+wW4jgGm7RisjwjP4QHL7/flisYF7mPqJ3AO8hefHyi88ZL7UQmmKF3QubSTtZ0uK6jDRLTd7MBLyBusb30W3LmwWAnQ1Sr79fn5O4mmoFwUr1yaGkn4XgI07h9dbxuDHfEeZRqEmtMvQkiA4WYeG6ieXyoK+LnI3kN5ruloxkTBK851ppxABuSHMdOFShupMDT+mGqHnlHemLh3CsaI/iun4Cho+NdfraB dmkAzuAc /Mx3FIYDfgxgpPk2HbVt8EDKoPpc1m6S3BimqMI5/lWERIQBtI8YTf7Iz2wuMFVta+ourtYfVMrOcgnxNj6XNFcKg1LDa8diqka/YWUlgEpR04Vevl6KY9avIZCJfiVZliQ3gbtYGDa83c3UlkTyW3V2OjfZwXSI95dfC6gZcEKcI5AO83uV4tdSOHn/aDFhaBG0Br89M/jFcYAFsg9HHfE+JvBoN6uHZ28ncJkUYNkfsZOB0mAh8jYgxFdk/ZX8Pld6zt4hP+k4TXGj6E3qWJ0NZMaU+Rcybq801TDqZvePdzvIy4H1FBxQyc7nwcH5miu7XwTGg8Fumk5yFmJtqCCX2E3IzDUpshl5kPvhI0bzyVnaKVxhw7/zHTckaF0iffOyeVUlHezpHzQmEYgByOCrH0kkNtONYXg/wWLPHGwK8gmGgK3j7nwT5UTNn7TbiDYwi9nD6xIiXB+rb2KYWQyTkMqd5nL2gge4oPY+eJaG5R4X8OZBHOY5s7QD6VkTqNxf/dZJlVfIxVE3zLNw+ez8F+IEnaXtOwJW4/txQmFNsmutgwNlS1eAffxsu9coN4fbMsyxOAcQgIre5N+VeqvlH2cerCCGrqMp3fEq3E7xh/OY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000865, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Nudge. Peter Xu provided an R-b for the series. Would any other mm folks like to chime in here to provide objection or approval for this change and merging it through the vfio tree? Series[1]. Thanks! Alex [1]https://lore.kernel.org/all/20250205231728.2527186-1-alex.williamson@redhat.com/ On Wed, 5 Feb 2025 16:17:20 -0700 Alex Williamson wrote: > follow_pfnmap_start() walks the page table for a given address and > fills out the struct follow_pfnmap_args in pfnmap_args_setup(). > The page mask of the page table level is already provided to this > latter function for calculating the pfn. This page mask can also be > useful for the caller to determine the extent of the contiguous > mapping. > > For example, vfio-pci now supports huge_fault for pfnmaps and is able > to insert pud and pmd mappings. When we DMA map these pfnmaps, ex. > PCI MMIO BARs, we iterate follow_pfnmap_start() to get each pfn to test > for a contiguous pfn range. Providing the mapping page mask allows us > to skip the extent of the mapping level. Assuming a 1GB pud level and > 4KB page size, iterations are reduced by a factor of 256K. In wall > clock time, mapping a 32GB PCI BAR is reduced from ~1s to <1ms. > > Cc: Andrew Morton > Cc: linux-mm@kvack.org > Signed-off-by: Alex Williamson > --- > include/linux/mm.h | 2 ++ > mm/memory.c | 1 + > 2 files changed, 3 insertions(+) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index b1c3db9cf355..0ef7e7a0b4eb 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2416,11 +2416,13 @@ struct follow_pfnmap_args { > * Outputs: > * > * @pfn: the PFN of the address > + * @pgmask: page mask covering pfn > * @pgprot: the pgprot_t of the mapping > * @writable: whether the mapping is writable > * @special: whether the mapping is a special mapping (real PFN maps) > */ > unsigned long pfn; > + unsigned long pgmask; > pgprot_t pgprot; > bool writable; > bool special; > diff --git a/mm/memory.c b/mm/memory.c > index 398c031be9ba..97ccd43761b2 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -6388,6 +6388,7 @@ static inline void pfnmap_args_setup(struct follow_pfnmap_args *args, > args->lock = lock; > args->ptep = ptep; > args->pfn = pfn_base + ((args->address & ~addr_mask) >> PAGE_SHIFT); > + args->pgmask = addr_mask; > args->pgprot = pgprot; > args->writable = writable; > args->special = special;