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 8D2EBC636CC for ; Tue, 7 Feb 2023 23:08:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E462F6B008A; Tue, 7 Feb 2023 18:08:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF5C96B008C; Tue, 7 Feb 2023 18:08:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBDCE6B0096; Tue, 7 Feb 2023 18:08:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id BC6306B008A for ; Tue, 7 Feb 2023 18:08:43 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 811EE80411 for ; Tue, 7 Feb 2023 23:08:43 +0000 (UTC) X-FDA: 80442037326.13.58DF228 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id 01C601C0016 for ; Tue, 7 Feb 2023 23:08:40 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tvjFdYJ4; spf=none (imf18.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=1675811321; 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=C3BsFQyecrkZzgAyrCIlG/af65onsRh3bS9rFTtLbRw=; b=D5K6SdIsUfw3P5J6jWAxgPUtQDpPUTP9gxlLquVOFHrJzbT81E5saWhfPiYAsb9VsRDJUf Aw50sKfdu/pgiGGRPKoG8ACaX3Oh4uUzD98tGHp8VaYbjF9/6LWtkYhtEmHorxya0GwS07 SnUZO61tUAF13E5qx3lyo5pKRKZShf0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tvjFdYJ4; spf=none (imf18.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=1675811322; a=rsa-sha256; cv=none; b=B/HsGPpgcMfbZbk9apGcWo6fL9Hu4a/nPhl4tHj8bucDzb8o/tRDaTR+nloZ9x2ypYERWw RFkCO9NHJDSaFGLoI8+sgTo8Db7Q5QsozyODFdaZrPQaXNxxN/0OmIjrbVTmfDA7bEp4lW D1NSYR9N5tQHcdPrqGNdDgO0ww1QYYQ= 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=C3BsFQyecrkZzgAyrCIlG/af65onsRh3bS9rFTtLbRw=; b=tvjFdYJ4hcezkUnkTVnwAkOlH+ IPjXoEoBfP6hKtxq4MSRqjwtROQMUuF38/cR6OOkuqSc50fWwzygx4p7FCKYLTnCBNPiWSL6RUPsp yhJtGzilVpW6rtMTW/Qoo2FTmHuCxQJkf2YE0xiVLcKm+T9snJKnGYa6ji/avhPoGI0CUgLx8p56N LBpOjyYCsEHfGYF+bap9P1q+O/lAkZg5lVdWVNXJ6ewS5OpEOgFzc0TvP3KI5SAdL3bHYo/t0cWZ2 KnGfvR1hQokr94O73mQAgvvr7vQSFRn0qCeHnvIruMrkguE+VXVBZ0YV94X9xH4vR/P0cPUNHnsfA hE4appwQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPX4m-000eOi-8O; Tue, 07 Feb 2023 23:08:36 +0000 Date: Tue, 7 Feb 2023 23:08:36 +0000 From: Matthew Wilcox To: James Houghton 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 01C601C0016 X-Rspam-User: X-Stat-Signature: ti65pkgmpmfqq3o5bnux6q4mpb5bwi4s X-HE-Tag: 1675811320-689316 X-HE-Meta: U2FsdGVkX1/QLaak4+yHuaxwVINynRkBgKpRpIHRo7fpcDhcZZHQCTVFj4Jdya6v3jIF0Q9p3KRKJw+T7gWQYlaGYYFXFRDQOWo0zlVcIJvhquAjw8EtOXT3y4Gm1P4peQISpear6JJ25VvhsP5yUUEGzoCt8+bAGv6iH5y4G5EBvAQ3t36cYi7OcO93LtoIEzt6hLpLDmK6jxUETmMdb0QRwxbh2CpeSD+a7i77RWpsrMa02zsEkkG1/zm87V0pe4bRoCiGsLV3wtFKFT1lkWZKhNS2iOapbWEbTylGcqRH9BW7n447VnwAZPMIh9luP2iannxtVNMa8kIK6BZEuDuty/Knyks3Y3LRskmRRUXXTeqrT3LmSHK2b7Dt7XXDmJNG/gB9MfEJQHjn69UzHHP5LCthX0/Mdj5G7tjlFfZW4LgSsfeZdMjpFFhB/m4V4yrv9LaamNwL0MKErRJLVJnvw+YTaJAdOWqkHp2cRAgwLewS0hx2Pt7NcCRYQAS+H3vlGaHj53vsrjHGbj+VJvlch0UNiBp8lob3FUzCP5U6UpnbyG4Q+EpN9za+XUTTTThuLiixhBzIUiVXVr5q2J6ZUDkz21P3a4AgUQ16tFm6D3akojE4SK6OBTURs22T73Xhuvf+jCywMS/S0OmRD3VupBdzT53h12z3JbbuhLKa/mNdooJnED+Hr9+OTczVJwM30le8k0GPO0MNVJPdfs+I4mglJY+yMz0slIkAuCNREsmP/vgZFk/3qAfvcOVQS7HrzD2WNfbkoi7YonYjxyIlLp8tvfle2zVVo5DeDZ5rt9qEGP5Om9irWCKVEzt/RHwiXVZVdxjbF2grjg7FlFhLwyO48wZSab52+OITonJKTILzMB6ckZv3y2Zt4ug/cAkPiMH8zLWD1qYkVkBfizTO9xEFzSBWrdhrTc0mcmF+wbtiOM4JGNAGnuMgqQW6iTgwzaJ/iy7Se3zDoIU osWGM9PJ IgbT/1Zox9sxljXAA25E/7bTatWGp2c3VKLmKDNGvRYiDPGOs1uXBDe/JVKqJ00gjWw9J39urv0i5yj9CiMrvt7fbdi0vhMcAz8buhg1KoJeH/aFJSP9nS/o2tdUjgSXKjpplvpXuS1aCmRps1MH556x2iTUWkMIAosztVVoNRDRnmX6rhABW+FomhyBgzeigan53hahHbJshCbWaDbL9LxymGE1DEhRadpLObq4WAd9JM6rkdBt80dHqZYjdRQUJPwBGalY0foPPm4KtbgQGHvVQyA== 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, Feb 07, 2023 at 02:56:52PM -0800, James Houghton wrote: > Hi Matthew, > > On Mon, Feb 6, 2023 at 12:34 PM Matthew Wilcox wrote: > > I now think the mapcount has to be defined as "How many VMAs have > > one-or-more pages of this folio mapped". > > > > That means that our future folio_add_file_rmap_range() looks a bit > > like this: > > > > { > > bool add_mapcount = true; > > > > if (nr < folio_nr_pages(folio)) > > add_mapcount = !folio_has_ptes(folio, vma); > > Can you elaborate on how folio_has_ptes() might be implemented? ... oh. First I called it folio_has_ptes() and then I went looking for inspiration on how to implement it, and I found page_mapped_in_vma() and so I thought folio_mapped_in_vma() would be a better name, but I forgot to change it here. Sorry. > It seems like for a naturally aligned THP, we can see if the PMD is > pmd_present(), otherwise, do we need to check (potentially) all the > PTEs? Does this introduce an ordering requirement, where we have to > update the page table always before/after we call > folio_add_file_rmap_range()? Actually, you _mustn't_ update the page table first, or it will see the PTEs and say "Ah, the folio is already mapped, I should not increment mapcount". So we keep the calling order as it is now; folio_add_X_rmap() followed by a call to set_ptes().