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 2A7EBC71157 for ; Tue, 17 Jun 2025 23:26:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BAF346B007B; Tue, 17 Jun 2025 19:26:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B60156B0088; Tue, 17 Jun 2025 19:26:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4F276B0089; Tue, 17 Jun 2025 19:26:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 91FE66B007B for ; Tue, 17 Jun 2025 19:26:35 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 418471A12DD for ; Tue, 17 Jun 2025 23:26:35 +0000 (UTC) X-FDA: 83566479150.15.757567A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id D3E024000E for ; Tue, 17 Jun 2025 23:26:32 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Cr9zbx/z"; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750202793; a=rsa-sha256; cv=none; b=emLS3AZVEaK7cb1n5t2i6PhQpaiKMFCZnToPY7bqNZCER8gadH4u165iIYZaqeWQVAAZIA mvLjC/UdE/0LmyoLVIt7rJFS0ycqiPtujv1JNGipW64cjvlUtYCu9I1CffN6CnSsUfSV9m yfOUqQszP1MdVYWcAfVBZiUHCnZScWs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Cr9zbx/z"; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750202793; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bEsBD5Y/shPQUCHjJaNwvlMTpenqDbmzETQpk04GETY=; b=J8Q7epOUL6LlwfxAKoedJ6tEsD3GqJBhVrBWVJjrUR0fL0GgDDkRXZ636Ru3i7LHI41whb m8xMlzvEeGucExu0uk5vDDFVOrhoU9GV3BXo5SVYFZB9qWbvfFEEB766RWW/UOqpnbzbCo bXiAfWGVxsq29/1ajCOSZGkvCh2Pjfk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750202792; 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=bEsBD5Y/shPQUCHjJaNwvlMTpenqDbmzETQpk04GETY=; b=Cr9zbx/zmeorc/VOroDyW4bybh9Q2gnTA6ORRfqFVDvzwemqcC9E9Fw8waGRJ3lGf2i0WZ oaV3b/+CtN1jClUunjmvFct/Pj/l/mH0X4OMmBhtEM/pSp0KQbfwKfT8gJ99rt8KBCGh/r pWkJUp9LbNIjI/mFGhGokT+Rsi67Rq0= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-s404MqNSNdSKqi6HoXKXqg-1; Tue, 17 Jun 2025 19:26:28 -0400 X-MC-Unique: s404MqNSNdSKqi6HoXKXqg-1 X-Mimecast-MFC-AGG-ID: s404MqNSNdSKqi6HoXKXqg_1750202788 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7d0aa9cdecdso524400685a.3 for ; Tue, 17 Jun 2025 16:26:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750202788; x=1750807588; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bEsBD5Y/shPQUCHjJaNwvlMTpenqDbmzETQpk04GETY=; b=Y5/SR22SBSHFyNIPE+X5Dqgn9PUt8K9sWjf6RgwNa6sazFawlmoxEtAcETnkyY42Eh Sjly8LMwP5dRCOh0nhnPzzoCmyLWTH1iYlLHImcKFtAqMsL/0PWdTKqhjJd6YYkGwY1L SO/PxmEpZbOzmNVZxWOwBtNsWOiLJUSWhh0fVu3nIZHLfRhTB7+6EdAfYseGIMhqkbMP CJcmrmqCvDoRoNl+LHE4gpomf4ZJgwnac91NrQDwCcwc4WC4Jej/7xuwBQodimeVOBd6 2wz/Tun9qyVhp6eNHIW5obIJ6LRXF0LHeU6BLkqTDt8YseJ/Hk+KVPos7/iGqE/0uiXa vFJA== X-Forwarded-Encrypted: i=1; AJvYcCXpB9OsFxVsk1xAiibZYIwvPn9A7EaJtJh+sNg12DztswXxGYdiQxKJpRKtPaypoGtsFFn1X+sqKw==@kvack.org X-Gm-Message-State: AOJu0YwxKKC7TScH+6cGYUg6Edcmx33kk3EWQPNanNn7pubo0p2xoFCl DxjWnz9tgfQ566rMZMXM1R4pZt6ASRqbqS6IghpENaKwzzNT8aZQj8Xwaxl+Kj9cJzaDuUIcGbq juTBiDVFdXUvyfsa58lBzWTVjO9zcddyQ2AxfunAMadijjQpKc4RY X-Gm-Gg: ASbGncuK2/3XQPKqUMz0FAdDI7qvVsBOpmLjcRI0ssh1Ds4TVrngsCWaScKA0/qnTIF uqXTFeQa0buPbbv2yF5n1kk64J3xKhYDi9XpU7VLFPM12/WO+wz9Wls1jbkeY1W9DbsQ/Xsz1uw /8sn5guDCdh4xDMiqFET0GXiFn5GXa+HgjNSvf1DwCkX6t8mBfe+mG0S+YfogLHUQZDyEh+8AtJ zDHOyuPSmtgiTmzODFTj+Dx+a8OLhgN6S+fpYMv6bP/P5fG86nj2Y+U/VL4NBB3Fo7GfzyVyywv kciBurWR2fqPGQ== X-Received: by 2002:a05:620a:454e:b0:7d3:c4cb:1b76 with SMTP id af79cd13be357-7d3c6cf0880mr2064453585a.41.1750202788273; Tue, 17 Jun 2025 16:26:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGi3MMf4tNBUwb4DWR6Icb7TRcNxnrJ4m6pAGFQDw3d9WUhT0y7JRmDmGn7yEga4dgomvUXJw== X-Received: by 2002:a05:620a:454e:b0:7d3:c4cb:1b76 with SMTP id af79cd13be357-7d3c6cf0880mr2064451585a.41.1750202787919; Tue, 17 Jun 2025 16:26:27 -0700 (PDT) Received: from x1.local ([85.131.185.92]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7d3b8dce685sm703341185a.10.2025.06.17.16.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jun 2025 16:26:27 -0700 (PDT) Date: Tue, 17 Jun 2025 19:26:24 -0400 From: Peter Xu To: Jason Gunthorpe Cc: kernel test robot , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, oe-kbuild-all@lists.linux.dev, Andrew Morton , Alex Williamson , Zi Yan , Alex Mastro , David Hildenbrand , Nico Pache Subject: Re: [PATCH 4/5] vfio: Introduce vfio_device_ops.get_unmapped_area hook Message-ID: References: <20250613134111.469884-5-peterx@redhat.com> <202506142215.koMEU2rT-lkp@intel.com> <20250617154157.GY1174925@nvidia.com> <20250617194621.GA1575786@nvidia.com> <20250617230030.GB1575786@nvidia.com> MIME-Version: 1.0 In-Reply-To: <20250617230030.GB1575786@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ppTebWgA1_8L_gOn1sWA0BdTXLl08vlVB4wjWotkLL0_1750202788 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Stat-Signature: i5o7u6qkrbcqgmmhy59xxr86mtzooa8c X-Rspamd-Queue-Id: D3E024000E X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1750202792-850151 X-HE-Meta: U2FsdGVkX19fJWVZzm0Yj4ekvfePqZj4cx+UxCsOIBm0fIiwmaTOgBV6TGoA54ik/jtSFoLXGKCjtf7fh4ja4Mh1jfJXpvqJiGKEzZ618rqdWIA3hOnIZKRWTQtfIYY1bb4ER6QPG2kF+cfIO/DN8ZadLcpPCpBUnXFQTtfajfpHgt1SlBpaDhE6l9COcVmQ2mOJrWreDlJJuPm952XXbMWvzuiY0JfXhodXZr6FNsJyt7IieMmpXqGFFJy8GCqiWcctJss6vDoLjUpkPXjG2oVaNk/L62jF/vLlI9n6pxjLEzoSnPVsO5JunI5yzM8BrPpPHMDlMxyN9r0pYHaPtgN29zi8oB3LeoEjIBjxiMfRVegOiOkNVp5UUsvNBkSl8Qd+E6huuoDb3NG+C0hm58a9wpfpPbcYtQJxOmlN4wD/H3vphjVahUCqixmQwwQnwceQut0icz+YLi2FOIpt/qzgrDWxndVqnWPGhT4igC5iZTqll18wqNCouhZLPKWYy9d1arLEokoGcEDIRofQ5I9AAqpjmso6fIzcr+lfr2Iv49V188pSvH8Cxy30TChxMKRNdb3p02zCqZ08JT0oq7Rz84/sKfArvVXgsSdE3WR6OgXUw9/gZUcAmPp9HxSXlf0VdkPI71yQY1XIvlAT/9AzZ26/sf2nK7dzZa+TdJ8DzEzXkx/KxZq1f8MxGxB3n++yDUBVC8/dKuNZOhRVnFYhASJnHjH4aCijqjYgapKg0bn2LwwgNIKgB1znjxxHSBVsud0Juq1XmUtiCN84CDDGyDaXD0X2DAkug1v+dHOrTxpXiOZcrx02+82n7QaySn+HzHqVOZKmekV8AdQI0ggj5YSLCNlaV1PNJUbLQ6TOJGmZyNMBwEC0O8B9YblLQZ2CCNW77RIsXsUM2J9SXC+nIweidtoT8PGpN3Z0P0DgiQFCWwU1RWNocyjSJfYig6alGkn4wGw6XAzVaNA Ujy3DFwp xtoKNrlbhjKBl7OiB3Wh/mahdR11mpDAfSpat1JnIhZDxoZub2iqLjiMF9oysf8vLgmQj8qhArM/JetCq+d/ezM2JNjWJ7+CStKDYhDMkQrQjnee4JVTfaBxKde1ad90AIP7v8TsklU6V8II3TO2oMaBAVJbMELQNDwZGyb71eLBORJjY455tLFNHA+oTK0MRL/x3g8J3d4UY8dir6ImWWTKB/xSYrPqU/NZWklwScv/II0MVkwjZ8fphnJfENPJltgLCVuAfBfWhybk+TXOzj8F9TG/F7x8cr8uAizOdfWppAUOsQzjviHCNo46CsiHwlYO+UyUaPHqv4DE4O1ivdRTkIf69NSxAMK9/6prMBhAq9ThNOGhYrjBrDaXutDnJRd+FXhsZFfRvUSY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Jun 17, 2025 at 08:00:30PM -0300, Jason Gunthorpe wrote: > On Tue, Jun 17, 2025 at 04:01:11PM -0400, Peter Xu wrote: > > > > So what is VFIO doing that requires CONFIG_ARCH_SUPPORTS_HUGE_PFNMAP? > > > > It's the fallback part for vfio device, not vfio_pci device. vfio_pci > > device doesn't need this special treatment after moving to the new helper > > because that hides everything. vfio_device still needs it. > > > > So, we have two ops that need to be touched to support this: > > > > vfio_device_fops > > vfio_pci_ops > > > > For the 1st one's vfio_device_fops.get_unmapped_area(), it'll need its own > > fallback which must be mm_get_unmapped_area() to keep the old behavior, and > > that was defined only if CONFIG_MMU. > > OK, CONFIG_MMU makes a little bit of sense > > > IOW, if one day file_operations.get_unmapped_area() would allow some other > > retval to be able to fallback to the default (mm_get_unmapped_area()), then > > we don't need this special ifdef. But now it's not ready for that.. > > That can't be fixed with a config, the logic in vfio_device_fops has > to be > > if (!device->ops->get_unmapped_area() > return .. do_default thing.. > > return device->ops->get_unmapped() > > Has nothing to do with CONFIG_ARCH_SUPPORTS_HUGE_PFNMAP, there are > more device->ops that just PCI. IMHO CONFIG_ARCH_SUPPORTS_HUGE_PFNMAP doesn't imply anything PCI specific either, it only says an arch supports PFNMAP in larger than PAGE_SIZE. IIUC it doesn't necessarily need to be PCI. So here in this case, get_unmapped_area() will only be customized if the kernel is compiled with any possible huge mapping on pfnmaps. Otherwise the customized hook isn't needed. > > If you do the API with an align/order argument then the default > behavior should happen when passing PAGE_SIZE. This should indeed also work. I'll wait for comments in the other threads. So far I didn't yet add the "order" parameter or anything like it. If we would like to have the parameter, I can use it here to avoid the ifdef with PAGE_SIZE / PAGE_SHIFT / .... when repost. Said that, I don't think I understand at all the use of get_unmapped_area() for !MMU use case. Thanks, -- Peter Xu