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 CD2C3C636D3 for ; Mon, 6 Feb 2023 23:09:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 534836B0074; Mon, 6 Feb 2023 18:09:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E42C6B0075; Mon, 6 Feb 2023 18:09:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AC036B0078; Mon, 6 Feb 2023 18:09:35 -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 2BA3F6B0074 for ; Mon, 6 Feb 2023 18:09:35 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EA3C240368 for ; Mon, 6 Feb 2023 23:09:34 +0000 (UTC) X-FDA: 80438410668.19.6A2D127 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id ABDCFA0010 for ; Mon, 6 Feb 2023 23:09:32 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ksbBOWUa; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675724973; 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=0GLkpausOL50rFms1QQl79CmjPet3ErIFHwQ+5mV7UE=; b=lDn2AsgGYKwNmGcf3CPogi2sARQC1/+Kmq6AJE1gLX2DwVi/1mMi/u9xoP09+Mwb6muhGD MAaW/c5k3Aq0uvF1wiIjXA4u2PCT1GtGPLLu52ELg+VhlZBQpyau3WK7sdeqvchmngg74y ghjR62PyApl6Xi3atOQyM5vBnv1WKss= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ksbBOWUa; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675724973; a=rsa-sha256; cv=none; b=nyVnoWIePT3ZECXrEeeVFv1kIfAb9roY6RDsisuF42Tnixgx/6jVC2ncifA5OUbJzf8vOy Abp3nQovAoeWLYA+Qkk0NzRFK6DPsx/0fq7oLMHep+Al+LAyPUCoR+9e3W38/X1becpCh8 01xqcO+vijJNCygofPYkxfL8yfdtIFY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0GLkpausOL50rFms1QQl79CmjPet3ErIFHwQ+5mV7UE=; b=ksbBOWUaJuRziYHFk2mr2hDXWr RSQjIXtvlpWmP/o4C2MIkTEZkuVrm+aku4lHRdYyVAXxYrG/57xLGtTy5Qtll27EJ36UUPp74VTl5 7JhBym7Ee18msmOGQNb/Hd7v+FYLYl2P2msop4XZSdx5PsyPtlwqcZdic7wy+GGIXzY2hU4kx1hqS 803fvPXCWDj9XNtETLEr02vjwVXisTASE3ToyQ+S3kEw2ACyUOGBhfKMSEweQV5e955yyLEc59MSC yYHHfxyWKGxaWUCxR79RSCG6mtp+XnRJF6YE5ayZIinP1YLyvK1iizYILpldGNA6YFZuhF+1iFP2Z yd0Aahbw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPAc3-00HE2q-Rl; Mon, 06 Feb 2023 23:09:27 +0000 Date: Mon, 6 Feb 2023 23:09:27 +0000 From: Matthew Wilcox To: Yang Shi Cc: linux-mm@kvack.org, Vishal Moola , Hugh Dickins , Rik van Riel , David Hildenbrand , "Yin, Fengwei" Subject: Re: Folio mapcount Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: ABDCFA0010 X-Stat-Signature: y747r5efs7m9q5beuaoctxzqgkqi4wgt X-HE-Tag: 1675724972-390778 X-HE-Meta: U2FsdGVkX19X7uYmGyPTviBKBMJqIYFnmkC+Urxouf9VHQdA5ewcbFPmqj0VNjsFseqFvvkS/LETpeIP4tcWgIqPc2QkSag8N0NZeWpW9lgsXw7iNs8D0rTpjYfc+M21h2V6FyLz8el1dhV/kHiaO4sdE0GILjx/Z638RCnCPpZe8DQ1SKVryBPrRZKwAc2Ix9NZV+sgGrLRrePHomYs1DTd6ihHWUqqItaggAneq7P3X+WG3MuGbSbBlqzYiwmmRD1TWWVq1wG7vNN8IruhHE9nCFv6jbzdU25Olr6a+HPsl83kwT8EP/1X73tx6GhL4AimybFdq0cKwKcZ1SMxM+k1EV9PlaQXxwNFNComOgfyeN4XHUMfySjeqz40HW8pUmT6EmryaDLQ4eJ0rDvIp5lsnXCJtF8GgOV/ILkW58flZRVLrkawuHFIGrMlJt1EMhQppPpAA/PNmBQUfORw16eeLD6yo94+9io9tuqRyRMIBTJAIP4dYFD5CnHdtVek8e7HVoaqm/TEGyvDtpaokPyTt1HaG/+nDXZ+lV8+31sFtsRMTC7e6OxoIqM3Cz/cVa8JYAug8HpeGzvo4cfaLcyQyADMdqUR+OnnJnk+zYkogOedjGCZPdcmI36IY+iTdVqR9spmjngR32wLeSPADgxCt1eNAPcIegj3DePhp5Odvfx+QjrWKfV1aWa7goEB+FS7JzxwcguC/ZpsbourxW2enSvnLmyo9HTJzI1ZuZPOIGSWLMqG4g7VTnhyCz/llZL8PJFfakQ1tAsYiIgIwkynyWOMA/NF//WSkne/h2UwOn1wDO5bt7bcQ9H66czXcUMomo3gVxvKFdJiHJDUUQoVsUtbrKYoF4oHJp+Zp1t4CGd3lMexJNrK/M3fe2dJGsLIj4ANLDKcxgs8SR3W3cCu+MMEH8UaGuGY9tnSlc44pnOhL9X0LBooDdTA5mmCYpdyJnSX9SxLOIhfWUc srrM1k2L XzgUg7Erw7cx5euZJsIrUqEyeLcHdezsNk8RCqjUMwxUnET476jb4TkOnpoejCNc2sFUxPsjfnlXHk2PVh687zQWvZW7YYU8YkSCFaKyHJpnkWDQKZYruPumb2T1fdIIcbyvNEx7x5LolGkxD7Tj55evd+Gc1PUyOn0l4FfhLhWB3PMYiaDNJoNlZETexjFAVqMgOMku3MQ7pfTHZCvx1yfv/ZW+pIQbYXaoG 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 Mon, Feb 06, 2023 at 02:55:09PM -0800, Yang Shi wrote: > > I've been thinking about this a lot more, and I have changed my > > mind. It works fine to answer the question "Is any page in this > > folio mapped", but it's now hard to answer the question "I have it > > mapped, does anybody else?" That question is asked, for example, > > in madvise_cold_or_pageout_pte_range(). > > > > With this definition, if the mapcount is 1, it's definitely only mapped > > by us. If it's more than 2, it's definitely mapped by somebody else (*). > > If it's 2, maybe we have the folio mapped twice, and maybe we have it > > mapped once and somebody else has it mapped once, so we have to consult > > the rmap to find out. Not fun times. > > > > (*) If we support folios larger than PMD size, then the answer is more > > complex. > > > > I now think the mapcount has to be defined as "How many VMAs have > > one-or-more pages of this folio mapped". > > IIRC it may be still possible the folio's mapcount is two, but it is > only mapped by us (for example, two VMAs from the same process). That's true, but it's also true for single-page folios that are mapped by two VMAs from the same process. I don't want to change the definition that much!