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 320FCC02190 for ; Fri, 31 Jan 2025 17:01:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B71926B007B; Fri, 31 Jan 2025 12:01:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B200F6B0082; Fri, 31 Jan 2025 12:01:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99A936B0088; Fri, 31 Jan 2025 12:01:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7C0106B007B for ; Fri, 31 Jan 2025 12:01:03 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 56A36160F78 for ; Fri, 31 Jan 2025 17:00:57 +0000 (UTC) X-FDA: 83068361754.19.BBDFC9A Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by imf28.hostedemail.com (Postfix) with ESMTP id E2D9BC0027 for ; Fri, 31 Jan 2025 17:00:53 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=ffwll.ch header.s=google header.b=TihoT6+y; spf=none (imf28.hostedemail.com: domain of simona.vetter@ffwll.ch has no SPF policy when checking 209.85.221.43) smtp.mailfrom=simona.vetter@ffwll.ch; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738342854; 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=aNin4moK4eUBxK3vPAgTMhDUk/P6pM+fAX5RqvxKF3I=; b=ue7MTFivOyNMb3+C0FbgeQTkXcLCTXihNjrvbYS2m5aoS4V//vVeEhFA0bZZG9oXC4JGZ6 vlXUdBWKHbHuXjbcDmgMF+Y2YYKEPoQPIxUWB3aMORbWQBVI8y4QFRoSlQPYNRUTp2TSgd z72NjMoIVpO0QjnZEFDcXrQDq/xVZA8= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=ffwll.ch header.s=google header.b=TihoT6+y; spf=none (imf28.hostedemail.com: domain of simona.vetter@ffwll.ch has no SPF policy when checking 209.85.221.43) smtp.mailfrom=simona.vetter@ffwll.ch; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738342854; a=rsa-sha256; cv=none; b=0c4Tp3jj5WwHZJYf4k6jm88C2KWaDyOWyS8ZtnvpqoJU+wVx+AtIrZguNOTWDuISyoMJrH Cvyp5JFajyvINb8fpH6mSidZ0Xuy5gD30Uu6LbrNdiPHOseBIjLYXAMV8WUFfmGOJB2uLn /yUNEZBMCDw5k0xFQbzocMOR/eLJxkA= Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-385ef8b64b3so2060331f8f.0 for ; Fri, 31 Jan 2025 09:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1738342852; x=1738947652; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=aNin4moK4eUBxK3vPAgTMhDUk/P6pM+fAX5RqvxKF3I=; b=TihoT6+yd4QSWwWsHK0OtAPfNEIu4Vlrb4mpAbkdtylag5bQ1ypjcyPJmR9aJpmSpS AgBZ6YKfqkYMiRz/4XrLcrva5ifS4nUuDGd9KXImEInUky2eAdSVwbAn+QjDSNyDfctT wqqPm+ax+3LKqZgPo6pZAFNIg8TTKfW77rQXQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738342852; x=1738947652; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aNin4moK4eUBxK3vPAgTMhDUk/P6pM+fAX5RqvxKF3I=; b=lHbhq85lzxWEn2loqpBTPQogw+fM795Qlw7c2MRFms9Hdww5VeadS0J1Ju3tx8cP38 5WhBC8mGJ7yFcVVIKuG0BRtA+G57ISQVfBnRfuQW2qNM1HkFwRKoN3Z9E1tn5NqLWwyd RZdo/e4cFm/svsA3eVrIJnQLHhudNEnQ5wFI9jIFFNWed3zYyPCS/dh/t4uYYG/ZRTtA pHgjQBSACL0pRNsMaNuY1fBQKoMobDlvkj26q6JnnyLqd/PaBt12NzghYAfNxR2yKv2P rs+guxy8De2Y+Xf0IszWOYzDOg9FGdGoDLeU1HIQ/QX75dGiUpmUhuLG1hSEuIufKdE9 7hJA== X-Forwarded-Encrypted: i=1; AJvYcCWy1qQNAZz7y2+dMa6tZRJRSjp7bBXn6VsHE61godZ7fdFn8gLAqtq8XWgLtM1x9aBRF5Bu/N7TDg==@kvack.org X-Gm-Message-State: AOJu0YzDOJUYICHJXrJM6czT4qotL199Ot+Nyu9zVQnGcNedMortEibL TbYrQ06Jx+GsLjarZNwTTf5lW/qHGp8nB/iosFhwgH1laeLuqF1LYu4eSNPZiWI= X-Gm-Gg: ASbGncs9EQF7i/v5MLndG54D+FDjIUHzHjGlNuycAJVVd+Zo0b716FFaSdQePh6xr/S PdUzisnH/NxO1P7gwjJcppHxJaRllDotdOH66esKErrAMLiKy1lFD45Zr77FeQFdrHSMM+F06Sa wk72y5sMb6CV0fwNl+D9sjQothREn/IzBE6TsWV1D9Jv5c2wiuqra2puFjfTJBDXbvjp1j4XTo9 /2PLpA7gyfbVYttxYWZRLGEzopz3HsIBuQk/WOJgjeOtyPAaCx10YN0khD9sxbknhhEPdKZXdg/ VbxFFBdfoRjT2Ryw4dgIvf+VYx8= X-Google-Smtp-Source: AGHT+IG+wK8v3ltoU+dMOZ5Egg+X1fduaSB/k0+6guPHhIiHiZusmikjMEVA/Y4fTi33o54vzPLBkg== X-Received: by 2002:a05:6000:400b:b0:386:42a6:21f2 with SMTP id ffacd0b85a97d-38c5192f4afmr10830620f8f.10.1738342851857; Fri, 31 Jan 2025 09:00:51 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:5485:d4b2:c087:b497]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c5c0eca02sm5194639f8f.12.2025.01.31.09.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2025 09:00:51 -0800 (PST) Date: Fri, 31 Jan 2025 18:00:49 +0100 From: Simona Vetter To: David Hildenbrand Cc: Alistair Popple , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, nouveau@lists.freedesktop.org, Andrew Morton , =?iso-8859-1?B?Suly9G1l?= Glisse , Jonathan Corbet , Alex Shi , Yanteng Si , Karol Herbst , Lyude Paul , Danilo Krummrich , David Airlie , Simona Vetter , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pasha Tatashin , Peter Xu , Jason Gunthorpe Subject: Re: [PATCH v1 04/12] mm/rmap: implement make_device_exclusive() using folio_walk instead of rmap walk Message-ID: Mail-Followup-To: David Hildenbrand , Alistair Popple , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, nouveau@lists.freedesktop.org, Andrew Morton , =?iso-8859-1?B?Suly9G1l?= Glisse , Jonathan Corbet , Alex Shi , Yanteng Si , Karol Herbst , Lyude Paul , Danilo Krummrich , David Airlie , Simona Vetter , "Liam R. Howlett" , Lorenzo Stoakes , Vlastimil Babka , Jann Horn , Pasha Tatashin , Peter Xu , Jason Gunthorpe References: <20250129115411.2077152-1-david@redhat.com> <20250129115411.2077152-5-david@redhat.com> <7tzcpx23vufmp5cxutnzhjgdj7kwqrw5drwochpv5ern7zknhj@h2s6y2qjbr3f> <54a55ff7-38c8-42c2-886f-d6d1985072a9@redhat.com> <9f59b475-232f-41d4-bd6f-7f84111062ac@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9f59b475-232f-41d4-bd6f-7f84111062ac@redhat.com> X-Operating-System: Linux phenom 6.12.11-amd64 X-Rspamd-Queue-Id: E2D9BC0027 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: i6ca4bnxfpqazrd7k6fzx6w4eh66sqa1 X-HE-Tag: 1738342853-298147 X-HE-Meta: U2FsdGVkX18pdup2/22svVsnXXeEkXqNWQ9Gl2YEDqJpbn93xoXXioEM7PQcbKTncJCbWEFQvuyFWSTQFsTiy1oQyrWLamuiohGjR5QjuXQBZiIF6mYTVLi2I2ggv7NiSUEiY57bYhHdd1/vj7YrxsdMu0LjsqHYzkDHYoyzQD1U4Vn6EaICwiw7XHifxYgT2f0HmCZ2lf/woxVhgwdpYZ47xUTAQzC2gKjQu/2ep3VxwZDT1kztC9SxfxFBUAd1AFIbui8kZckVyHaq0UF8QONFPv9Ph6+4MWw1zvmkAu7gXf/HuYl8ur3FxzfHUFtjWCELxLaB1dOq/8yU3DUkv+eCoMit3ml+1lLpNIyz/+yV2iJrsj99uS2SY3nc30GyXG3NtfeJpYZ9Wcnbv4mJa6L0YTLU6Gf2Rl5ag1aR4abF8zlSMaWhRVxsEIzNgo2Kj2tmVt9kEO6QxsiNSKO5D9jOMO/+MTl2kN5BFXITuDbpZc6kQ4Elf0RQZZEzfYGl5h6InvlAemXhyPpfR10Hw6jknl22E9HbOJvM9AY8P7nvNUMVFn2q5TdekJE3wfVfc5DD/EOwMH9i/9qt9xf0snGo4MzCQ21ZQK9sx8gI6W8mPGPS+V3CvfAJjivt/XBeRSDG00uiYAQNh73A0SHslH4yc0KhCIjgBHdkSr6FQPkDvqzBCy7Wuuwf2UxSU9fn+OzGERfFNwGNc6gTnuMX+KFb6ZixxCPvxHrnzd5PMmN5BOmxRoWW0OLYVoQWAvHd7hglM+YiDnC0XtHvloTR7v++IGWBcQ5pR7PE5tWOjWgAE1USb8GVn49xu4wCQnKjicreXUIAtruFnKKXisdOnIl2asAOmyK/dF/3VJs6iLaQX/CYc0GJz124tCCx4yywssdWFk0Fwm0x/WivattFvcjtDIbyhUttwrD3Mqf0pdxbVGHVdut4cvN4CAu2Le9IO+aiMHolQP45SgQ+dbT 6qhyPgAy 8ZPmi9BB91TKHEDriixhUMSZrN5/eyZvlZUrxCJDMwYDEVXd8LprB8bNQoNbAgKmpb9xQIJo+6R7NLrCM1u353ErhJ+lsZhdqO9EIW/P9hkcvFMp8X3jUPy+AsCYQNCztuEvrnYfS0fX1fQ6iej7AmY9Dyw3vILwWx67szNkyylva7Ed9L8/c6wgsoD7VeQ4HCyDT0PpI+Hczp80F6uGtyKS3R7w3de1rF4qrJpL82/rsqjAgeW0FGpCFjYr6/tO1Q9m3i9FuIzIR4nFHLvTxlfTrYp3EddN1SejjAkNWduGGn3mts9UmmbmbFx4sibjLPhqaxlElBGcq8leXZ8vAEtxAUg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000423, 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 Thu, Jan 30, 2025 at 04:59:16PM +0100, David Hildenbrand wrote: > > > > > > Note that the PTE is > > > > > > always writable, and we can always create a writable-device-exclusive > > > > > > entry. > > > > > > > > > > > > With this change, device-exclusive is fully compatible with THPs / > > > > > > large folios. We still require PMD-sized THPs to get PTE-mapped, and > > > > > > supporting PMD-mapped THP (without the PTE-remapping) is a different > > > > > > endeavour that might not be worth it at this point. > > > > > > > > I'm not sure we actually want hugepages for device exclusive, since it has > > > > an impact on what's allowed and what not. If we only ever do 4k entries > > > > then userspace can assume that as long atomics are separated by a 4k page > > > > there's no issue when both the gpu and cpu hammer on them. If we try to > > > > keep thp entries then suddenly a workload that worked before will result > > > > in endless ping-pong between gpu and cpu because the separate atomic > > > > counters (or whatever) now all sit in the same 2m page. > > > > > > Agreed. And the conversion + mapping into the device gets trickier. > > > > > > > > > > > So going with thp might result in userspace having to spread out atomics > > > > even more, which is just wasting memory and not saving any tlb entries > > > > since often you don't need that many. > > > > > > > > tldr; I think not supporting thp entries for device exclusive is a > > > > feature, not a bug. > > > > > > So, you agree with my "different endeavour that might not be worth it" > > > statement? > > > > Yes. > > > > Well I think we should go further and clearly document that we > > intentionally return split pages. Because it's part of the uapi contract > > with users of all this. > > Yes, see my reply to patch #3/ Ack. > > And if someone needs pmd entries for performance or whatever, we need two > > things: > > > > a) userspace must mmap that memory as hugepage memory, to clearly signal > > the promise that atomics are split up on hugepage sizes and not just page > > size > > > > b) we need to extend make_device_exclusive and drivers to handle the > > hugetlb folio case > > > > I think thp is simply not going to work here, it's impossible (without > > potentially causing fault storms) to figure out what userspace might want. > > Right, I added a link to this discussion in the patch. Thanks, Sima -- Simona Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch