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 533E6C001DD for ; Mon, 3 Jul 2023 20:54:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC82828003D; Mon, 3 Jul 2023 16:54:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C76BA280030; Mon, 3 Jul 2023 16:54:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3ED428003D; Mon, 3 Jul 2023 16:54:45 -0400 (EDT) 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 A03FE280030 for ; Mon, 3 Jul 2023 16:54:45 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 73D4F1A0839 for ; Mon, 3 Jul 2023 20:54:45 +0000 (UTC) X-FDA: 80971504530.19.389B2D4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 89366A0011 for ; Mon, 3 Jul 2023 20:54:42 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dN36pPi7; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688417683; 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=t8mAi8yX+KDn6cHyVjkLZsFx+lDjvSC6TiFEnqUUJaE=; b=Pa9nTHfJXKade1FucLiceShL+2e4qG8kAMom3ehz8Byx0vV+3iIIxCiBu9DM2SYP3PypzO hK1lo5M3Rn4zYcIs96qcvr9Xrd/ZmuOOhoGA1HRrL8Ypr0jNkkqpiJej8RuE+CMzF4E8EF +IIUfpbTBT7VPA8MXd0VVYJrVBxlSik= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688417683; a=rsa-sha256; cv=none; b=U2gpMQ/mGK6dYUAsDPcHUjft/jT1gq+uAqfYNWzlN9M89lQRt+vh0CC3h+hiLtmdc8SFNP 0QvY5Xijk/v0pBd15FlV2xXW4zmTRmDWBuNJktR/AAGFzGwnqXRH8T+pLbjrC8x7uFx6EG Jg0mwLwBa36qt5jKcHiaPr79wM1koeQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dN36pPi7; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688417682; h=from:from: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; bh=t8mAi8yX+KDn6cHyVjkLZsFx+lDjvSC6TiFEnqUUJaE=; b=dN36pPi7Tvud3WmacIsSzJ8KglleTVDjEaPxJjfM8xwYZA1l3DIyogQWooyPW8MhmgF1GL m+FUlXTmStedWuPLSaXtaHqAJv9NySo4yqkdu7IiF3nMYF1rugfuxHdcakEnfsJKUmpFjP gAdjLl/pqvot38+8A3e7oyKx+7x4EuI= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-103-J6aJzKMBOqiqkOTHJhiHEg-1; Mon, 03 Jul 2023 16:54:41 -0400 X-MC-Unique: J6aJzKMBOqiqkOTHJhiHEg-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-314326f6e23so941560f8f.2 for ; Mon, 03 Jul 2023 13:54:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688417680; x=1691009680; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=t8mAi8yX+KDn6cHyVjkLZsFx+lDjvSC6TiFEnqUUJaE=; b=lgPNad+2DhcUm4lYQJMXlcWFlmPFrrn/1hVtsho/n1jrXPKS3c7/IBfUpfDTqMPPC/ wT7KcplBa+a0413pTU6Z1GfG9p43eqgzGBOfcmKP9j5q6zakkcEIdkGR7TfvKVSEVYMb 64aRXoVnJCHO7ouF2ZnYJSmYn6fUN4U636VFsI8eCfO3sNG8K90PwHl6R92b54wfg3ZM 75U3CjYa3wHlR5b1+JW8jJsxBTLtkEXxssxuyaOeY9Vf+2YC9hM19BeUbNEBkWXBe8BQ JJpZINXmrL3qPgGZpu0I126pyFt5hSeuQgMRmAHNZJWkG0KeZWkxrxbUnDXvD/fr73bz 6I+g== X-Gm-Message-State: ABy/qLa1OWWBBocwFHd8BMo/f1BduPDXBZ+AU8WXVFX72xaeYxm6SBjB 3OIPuk5Jel5aeh/zeWoHFHPo0f74AamlP2XrlOnr8qN17Hma0Mn5w4GmrwWYccKDjuBUwkaMNlO c9n94ePRHWrU= X-Received: by 2002:adf:f0d0:0:b0:314:216d:c00e with SMTP id x16-20020adff0d0000000b00314216dc00emr7111428wro.42.1688417680390; Mon, 03 Jul 2023 13:54:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlGvj+PZzZlcsnVLLrdh5aVXW63jlt12FFV79z/G8+RtctZHbbaYShGeEgEFAOCnzCPnmDtwNQ== X-Received: by 2002:adf:f0d0:0:b0:314:216d:c00e with SMTP id x16-20020adff0d0000000b00314216dc00emr7111424wro.42.1688417680001; Mon, 03 Jul 2023 13:54:40 -0700 (PDT) Received: from ?IPV6:2003:d8:2f30:5a00:b30d:e6bc:74c3:d6f2? (p200300d82f305a00b30de6bc74c3d6f2.dip0.t-ipconnect.de. [2003:d8:2f30:5a00:b30d:e6bc:74c3:d6f2]) by smtp.gmail.com with ESMTPSA id d4-20020adffd84000000b003143c06135bsm1244577wrr.50.2023.07.03.13.54.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Jul 2023 13:54:39 -0700 (PDT) Message-ID: <9cedf7ba-d17a-d4c1-38f5-e469f8481f3e@redhat.com> Date: Mon, 3 Jul 2023 22:54:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 To: Matthew Wilcox Cc: "Yin, Fengwei" , Zi Yan , linux-mm@kvack.org, Vishal Moola , Hugh Dickins , Rik van Riel References: <7DCA075B-1E43-47B1-9402-66C54513D52E@nvidia.com> <310c4d8a-e14c-742b-5c6c-018c01ed897e@intel.com> <957ea888-a96b-89cc-29e2-973bb9e36f40@intel.com> <6cec6f68-248e-63b4-5615-9e0f3f819a0a@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: Folio mapcount In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: yqindnnn88ttjy6ow64emuytbfrc5iwm X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 89366A0011 X-Rspam-User: X-HE-Tag: 1688417682-602002 X-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LS278vItNPKhdhqKGre3a9Uwo+x+DyZOYs3pOTiFAj87AzcJ9ASE7WzGSujeArAfrf2J6MAgofNDYnt5EScli5acYAGmHbzOdZrjdFv/GyR5LXEQPsTC00J+Q1Mvw1PuXWLiF3ZzoBhH8CYu29mocWS8siq91rMriawIRKJFUhQdDLnZLEDpGXjdU7Uoyi3jAwWpHaz4WrrPMC0dy7waAPzsMdt+qSPJ9URejxnA18mzT4eHcRiPF0xP3w9gZv3cv0lwleyU3hgS/t0XakuXXaE671ZgodUwOedCeOeLKB+OPWxgOv4XUYC5vELEGr8bCCJFrmKfdCd8TvTRPeOgQAuUMELgdL0 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 02.07.23 14:26, Matthew Wilcox wrote: > On Sun, Jul 02, 2023 at 01:45:48PM +0200, David Hildenbrand wrote: >> Further, for (1) we'd want a 64bit mapcount for large folios, which implies >> a 64bit refcount. For smallish folios, we don't really care. >> >> >> We should most probably use a bi-weekly MM meeting to discuss that. > > We have a bi-weekly meeting to discuss all these things; it's the same > time/day as the MM meeting, but the other weeks in-between. Is there some kind of official invitation with meeting details that I missed? In any case, I'd appreciate a pointer, so I can join. > > Last one, we discussed the idea of having a 64-bit mapcount stored in > a tail page, but having mapcount only contribute 1 to refcount instead > of refcount being incremented for every mapcount. We do this trick with > mm_users and mm_count (for different reasons, but it's not > unprecedented). > Okay, to avoid a 64bit refcount for higher-order folios. > eg we could do this as: > > page_add_anon_rmap: > > if (folio_test_large(folio)) > first = atomic64_inc_and_test(&folio->_mapcount64) > else > first = atomic_inc_and_test(&page->_mapcount); > if (!first) > folio_put(folio); > > which is substantially simpler than what's there now. The accounting > needs a bit of extra work. Some places that check for page_count() == 1 have to be taught about that as well. Also, the rmap vs. refcount handling for __tlb_remove_page() e.g., in zap_pte_range() has to be considered: just because we dropped the mapcount doesn't mean we want to drop the refcount. Maye we could take an extra ref for that. It surely doesn't sound completely crazy, but this needs more thought (and you discussed that in the meeting most probably already). -- Cheers, David / dhildenb