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 79A62C7EE2E for ; Wed, 7 Jun 2023 19:03:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F8E36B0074; Wed, 7 Jun 2023 15:03:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A8416B0078; Wed, 7 Jun 2023 15:03:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6970B8E0001; Wed, 7 Jun 2023 15:03:18 -0400 (EDT) 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 5A5566B0074 for ; Wed, 7 Jun 2023 15:03:18 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1BA9C1C7A66 for ; Wed, 7 Jun 2023 19:03:18 +0000 (UTC) X-FDA: 80876874876.13.051FBDC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id 3FBEB40021 for ; Wed, 7 Jun 2023 19:03:14 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=Ssml13aG; spf=pass (imf04.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686164595; 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=yMg9D5d9coBx+p1yklEhjw4lXM468OIRpnbvgYsfWCo=; b=hej/Cw8LkjKiYk2uiYU3BmOmryECIe/zoA1TASbDlqpF3V/rceri8UrqpWZ4afTRpndl2h iSxgFRDUrK3VpuDF/NbHsV98czE+Yslgljr5wYOj8IRaVyZtm0ISbMoNfVRTqAD8+qfEbA KlLkc0NkVa1TmnS/T7dG2p9iIyXzXyk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686164595; a=rsa-sha256; cv=none; b=3hk6bhTFjh1HejSVomLQt6xEnDhbXMzts9cM4YuP9u5EsHxWRxRBJMEQQbbC8faG2QqtT9 hEexWNvDUJZyMuAkAQ2oRrj5+YlV18B2MFBt1zwDrr6c6JrF+5th6qGFPrH7mDAn+pIyAX +O72t3SUa6ViGlnW1yFrbP0OCkEDGts= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=Ssml13aG; spf=pass (imf04.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D68E9616A7; Wed, 7 Jun 2023 19:03:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D38B2C433D2; Wed, 7 Jun 2023 19:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1686164593; bh=6rM3c0MzWmypFl9SNFBILYmJFrC7/yHDs2cmHU7fDRE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Ssml13aGyZyJ3ub78D/30u0UL0IB0MjCmCDTGHBI1B8L+zNeaRQzmtYap1KIiZzbx iwFHzqzJ92fkaq893W+6Uo0nFRdBZC7b8EpitBAsS/01f3s27OicNfWuDXwzFKTj1R gw6wXPo7gPLbJ2AOYwKqRyVsaoO4q6ZVJ3EHYaIc= Date: Wed, 7 Jun 2023 12:03:12 -0700 From: Andrew Morton To: Mike Kravetz Cc: Gerd Hoffmann , Junxiao Chang , kirill.shutemov@linux.intel.com, mhocko@suse.com, jmarchan@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, muchun.song@linux.dev, Vivek Kasireddy , Dongwon Kim , James Houghton , dri-devel@lists.freedesktop.org Subject: Re: [PATCH] mm: fix hugetlb page unmap count balance issue Message-Id: <20230607120312.6da5cea7677ec1a3da35b92c@linux-foundation.org> In-Reply-To: <20230516223440.GA30624@monkey> References: <20230512072036.1027784-1-junxiao.chang@intel.com> <20230512232947.GA3927@monkey> <20230515170259.GA3848@monkey> <20230516223440.GA30624@monkey> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3FBEB40021 X-Rspam-User: X-Stat-Signature: 7i1t7py76t1wajkfndi3q33rjax89eac X-Rspamd-Server: rspam03 X-HE-Tag: 1686164594-405887 X-HE-Meta: U2FsdGVkX19yE9swY3XhkvP/5QUuOdSSsS3oKvnq17rYn5Aw7JReMhde55i/+DGkBzUCHPHeuwPgW/tdkHnl/iV16eZbUOA5AnQSiOgn/FkogINJA6MlHvjyiJ86hN16R7Px6u79Kucc408HEnVqoU9W5bl1zjS2P1NLjYS3nrYYFCaqm8iF2TwulzCrnuI6JRx8Hi82xUk+ZBrGYsrvMi9LrgbUbB8EMJnfnQL0s9/rDSsDfLnVCoGMOn8kuEBLszd7u117626LZtA+SI0wYT2jNnEx13tCKTauyVpX+Vl95M7GYy6+jQiY+OZr3eFRXViNGl538lv6jpWU7T8b7izsr5aiCho1BIHXufDmuSwBAVKh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z4Qy/Glfmiy5ET1f59kZE= 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: On Tue, 16 May 2023 15:34:40 -0700 Mike Kravetz wrote: > On 05/15/23 10:04, Mike Kravetz wrote: > > On 05/12/23 16:29, Mike Kravetz wrote: > > > On 05/12/23 14:26, James Houghton wrote: > > > > On Fri, May 12, 2023 at 12:20 AM Junxiao Chang wrote: > > > > > > > > This alone doesn't fix mapcounting for PTE-mapped HugeTLB pages. You > > > > need something like [1]. I can resend it if that's what we should be > > > > doing, but this mapcounting scheme doesn't work when the page structs > > > > have been freed. > > > > > > > > It seems like it was a mistake to include support for hugetlb memfds in udmabuf. > > > > > > IIUC, it was added with commit 16c243e99d33 udmabuf: Add support for mapping > > > hugepages (v4). Looks like it was never sent to linux-mm? That is unfortunate > > > as hugetlb vmemmap freeing went in at about the same time. And, as you have > > > noted udmabuf will not work if hugetlb vmemmap freeing is enabled. > > > > > > Sigh! > > > > > > Trying to think of a way forward. > > > -- > > > Mike Kravetz > > > > > > > > > > > [1]: https://lore.kernel.org/linux-mm/20230306230004.1387007-2-jthoughton@google.com/ > > > > > > > > - James > > > > Adding people and list on Cc: involved with commit 16c243e99d33. > > > > There are several issues with trying to map tail pages of hugetllb pages > > not taken into account with udmabuf. James spent quite a bit of time trying > > to understand and address all the issues with the HGM code. While using > > the scheme proposed by James, may be an approach to the mapcount issue there > > are also other issues that need attention. For example, I do not see how > > the fault code checks the state of the hugetlb page (such as poison) as none > > of that state is carried in tail pages. > > > > The more I think about it, the more I think udmabuf should treat hugetlb > > pages as hugetlb pages. They should be mapped at the appropriate level > > in the page table. Of course, this would impose new restrictions on the > > API (mmap and ioctl) that may break existing users. I have no idea how > > extensively udmabuf is being used with hugetlb mappings. > > Verified that using udmabug on a hugetlb mapping with vmemmap optimization will > BUG as: BUGs aren't good. Can we please find a way to push this along? Have we heard anything from any udmabuf people?