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 9C32EC4828F for ; Thu, 1 Feb 2024 16:17:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5A896B0085; Thu, 1 Feb 2024 11:17:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CE3A36B0098; Thu, 1 Feb 2024 11:17:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B856D6B0099; Thu, 1 Feb 2024 11:17:27 -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 A26686B0085 for ; Thu, 1 Feb 2024 11:17:27 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 806B316096D for ; Thu, 1 Feb 2024 16:17:27 +0000 (UTC) X-FDA: 81743740134.04.B4E7063 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by imf14.hostedemail.com (Postfix) with ESMTP id 541C1100021 for ; Thu, 1 Feb 2024 16:17:25 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b="DurO41/f"; dmarc=none; spf=pass (imf14.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.160.178 as permitted sender) smtp.mailfrom=jgg@ziepe.ca ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706804245; a=rsa-sha256; cv=none; b=7Ob9yi6UhB9ZOT2hA+Joltk2T5a8dcEnRypSYvE066b2Eq++ztgbskyH5Rv3EHV/IOG1n6 0zgwOgHKyhCYeSbYrbyEo4cPSvTiuwsDVvYVrzR1otRKGHTYfZpIN+5DXtrxY6RmEcDLTz pXBkrLWxMUag552UvdWy+nw02v6NrAw= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b="DurO41/f"; dmarc=none; spf=pass (imf14.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.160.178 as permitted sender) smtp.mailfrom=jgg@ziepe.ca ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706804245; 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=7W5+tKC4xgk+RknkUebH1rTjcytt9SCLqKv7nHxHMWo=; b=5fYqddg1OgfLYbEbRP1dMOJ36dbqphrgJPQen6PvPd/kKe0qq6mMUZ/C4XFGhMkrP53Nue 6YOCD1oEoS+h50A9Vyc63qplMMTIwu1eqfn4jEN+bIOWm+zodwwCNOGMaS0jyP1dSLfJrJ n15xQxAZnM6KnvV4+Vaf0O+YSCkN++w= Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-42adb5f806fso11647571cf.3 for ; Thu, 01 Feb 2024 08:17:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1706804244; x=1707409044; darn=kvack.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=7W5+tKC4xgk+RknkUebH1rTjcytt9SCLqKv7nHxHMWo=; b=DurO41/fgWpK2BaImKU6eF8+vBpqnsPmHx49ZJsHXi+YF9VLyJGpqo5Wfo84+h12g/ i2espiBkM0NHPvoMt//UtAtfIVEN1m2Gf5PFPcheH1hyJMuRIY2h8FPJSFDdEs9QM2Q+ C8KXAWXeq3tWodrxS94JRUUVJLdu18P/YqEkgngPWJjOs9NTswhXq+Q41E3V6DOYrRR7 Z3koB//6AG7lxfI66cpTh9NWAytsnUxmw5SYZmWsgXRIO0Mqz1guRwPE5cbM4OxdlL9n PDXTQ4j2uC9xeLY8wvPGfHV8L63/k0/s662WKqOepCqC3bht/qGFSdzuyYgsYjKiFhOJ 9N0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706804244; x=1707409044; 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=7W5+tKC4xgk+RknkUebH1rTjcytt9SCLqKv7nHxHMWo=; b=Uq13Ju6EjBD9dyTqkjFhrxQ28SVXAL2/t5NDSptaestgzIhIWsOiYMUOrTJAcVQ2es Q3HVRDgUtmncTUrNZpjQfg/wPriiaY1MQZ1Aov/f3W4sn76wGPbHrnjuORddJ8GJiB9y hSbRO3pKK+/0yP+9MSUEGqzVRyTUGV0LBshk9BtSvjVx1doBeTgpz+bC5rL5MXpUW7MQ vmOOHPUZ9tVNKRU1Li1rKNk/ifx7VDHIiY2MXBvuvDlYEwfrQ5Vscv9ZZX2i9Qkw6r0W rhNSprse83oViS+Lmkb18YfC3Apuxp3sCqX44fVBTLyBxP2M7BHtR7977t9udyEViTn+ bgXA== X-Gm-Message-State: AOJu0YxphtPpOGqifhdR9vkl5h9eMNUxP8CfLCSKaleILx3qioTjUTqZ CGJXagMYY7KEnJ8Y6EPMCWZ5TaNSU/Y8acs1ku3T9+YEIVDCIeVoJ439jORKuPs= X-Google-Smtp-Source: AGHT+IEbe07g57MUR7tCAxOZa7gGhU3iwDucNtswOKM14BAoRR6PHm2ulq4u2YVFJxjVc7P/fBpUdw== X-Received: by 2002:ac8:7fd4:0:b0:42b:e6d4:e488 with SMTP id b20-20020ac87fd4000000b0042be6d4e488mr5516273qtk.12.1706804244376; Thu, 01 Feb 2024 08:17:24 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWKsmmk7PUpF70MU8Qb2dCX0OQ189bf/Rxz3T8gVYPCdRxRADUMZUKLaSJgYPrp2QlUHVL90s/MJkE5j1tylhk7olfPiZhjynvAEiFiGi6wQNg33iokCTKA3fQEHOFnFtHuCwphMdAOwaoLG01HD6IRDHBhtprP4Mus5HB1pW5cCUiOJa/VUHFAPMQKzh+pK6T1vw== Received: from ziepe.ca (hlfxns017vw-142-68-80-239.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.80.239]) by smtp.gmail.com with ESMTPSA id en9-20020a05622a540900b0042be8b1fdc4sm1721334qtb.84.2024.02.01.08.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 08:17:23 -0800 (PST) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1rVZkg-00Amk7-Nw; Thu, 01 Feb 2024 12:17:22 -0400 Date: Thu, 1 Feb 2024 12:17:22 -0400 From: Jason Gunthorpe To: Matthew Wilcox Cc: David Hildenbrand , lsf-pc@lists.linux-foundation.org, "linux-mm@kvack.org" , Michal Hocko , Dan Williams Subject: Re: [LSF/MM/BPF TOPIC] MM: Mapcount Madness Message-ID: <20240201161722.GH50608@ziepe.ca> References: <049e4674-44b6-4675-b53b-62e11481a7ce@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 541C1100021 X-Stat-Signature: ri3xy4aosge678xk7bekyow741zmtpy8 X-HE-Tag: 1706804245-948385 X-HE-Meta: U2FsdGVkX18fv4S/cv37Cp/2b1HnHcQCKSPV4WG+p/j8jUkPenkGoIUErpYHuqlSnqEes/wghgqX5zp38QoJWsvP63SXQQL2TCoyE9KAG63CuhP7zJ0Wk/Jq+1jD34DFnhWrofVO7dRfdcrtBFAjP55abvijE80HsA6hWhN+sodiOcdOjMGnhiXz3HXwQWWXD/k9u2hdjIKXgvzmLDr6I2XZb+5MhlS40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B0QQdNIcjgPTudkcHQzBqCI3orXXFPzk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000013, 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 Mon, Jan 29, 2024 at 01:49:30PM +0000, Matthew Wilcox wrote: > What do VM_PFNMAP and VM_MIXEDMAP really imply? The documentation here > is a little sparse. And that's sad, because I think we expect device > driver writers to use them, and without clear documentation of what > they actually do, they're going to be misused. In many common driver cases the vm_* core code does set them when installing pfns into a VMA.. PFNMAP means every PTE in a VMA is pure physical address and there is no struct page refcount connected. In many, but not all, cases there is no struct page at all. MIXEDMAP means some PTEs are struct-pageless and others are not, but if it has a struct page the the struct page is used. I've had the feeling this is primarily to support arches that lack the "special" bit CONFIG_ARCH_HAS_PTE_SPECIAL (badly named, but it means the PTE does not have a struct page) and these flags help trigger some guessing to fix it up. The clearest documentation I've seen is in vm_normal_page(). In the majority of cases drivers want PFNMAP. MIXEDMAP is the weird thing. IIRC drivers get forced into MIXMAP if they want to prepopulate a VMA instead of using the fault path, which is unfortunate if drivers are actually working 100% with struct page backed memory (eg why does binder set mixedmap? Does it work with struct-page-less PFNs, where would it even get them from?). I believe this is due to missing driver facing APIs not anything fundamental. Although I seem to recall there was some race inside mmap if you try to prepopulate during the vma mmap op.. With zap, I think. Jason