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 91A31EB64DC for ; Mon, 17 Jul 2023 16:55:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBD856B0072; Mon, 17 Jul 2023 12:55:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1FA38D0002; Mon, 17 Jul 2023 12:55:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A23EB6B0075; Mon, 17 Jul 2023 12:55:15 -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 91B226B0072 for ; Mon, 17 Jul 2023 12:55:15 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 619ED1404AC for ; Mon, 17 Jul 2023 16:55:15 +0000 (UTC) X-FDA: 81021704190.11.6B3FE38 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 1E67340026 for ; Mon, 17 Jul 2023 16:55:12 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MJaPg87t; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689612913; 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=SErOCFj4weTS4sZHmIFn/shbKetVUK2uoB7gkNus/es=; b=xCFE0LUpGC/exQplgzn8tt3ZD+YI5Cq22kIpN1mPVAxP9ztyWHjG4IDGa9xDhxqMFOOxnz 6AoiwqZXExIqmGynMUkq9k8/hXYfkhHKsasPn3YJ555XQxURm0i0AidiTzMUKSIIT0+6cg tJQQIzObQ+CRLCGl9cHNDxwuznvkjtA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MJaPg87t; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689612913; a=rsa-sha256; cv=none; b=Hn5YqUwWzKxgJzNwehBxSHqClTUapOQkfZts0s02UzVLM/bmg/1h6KW4Nvf8JAYgLm6GHZ XSubUoEEJ5A9m/KCVndoxWZl4MlJSnHCkNWppkmwKbvy0gkSlG8bLjRQFoxKTFljnw+pzI V/corqWCaQY9IkjLdpzZ3ha7Sfqf9mA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689612912; 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=SErOCFj4weTS4sZHmIFn/shbKetVUK2uoB7gkNus/es=; b=MJaPg87tP7sne1CiFA9/TlF9w4etIoOIQ6RGeHKw2Bux0zLQjh55G1Gl1HP20f90z3r4iM K0PkHkuuBURhCh0VcJmk7k0bf9y1+5iHdCmHfArJTuCusYMi30gLImmXXonACxiDY0SMZG Ye7hbcF6s4TWztwIf1LAabGKO6lVVPM= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-LqMgqUimPtqIRjk7ZeVYfQ-1; Mon, 17 Jul 2023 12:55:10 -0400 X-MC-Unique: LqMgqUimPtqIRjk7ZeVYfQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fa8db49267so24915725e9.3 for ; Mon, 17 Jul 2023 09:55:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689612909; x=1692204909; 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=SErOCFj4weTS4sZHmIFn/shbKetVUK2uoB7gkNus/es=; b=DtfEKdtf2RKN+2BNeVOHpbpkjGBnfv4W5qhRypTtD6dDsZwRqr2WSdRb5LF39/bcfY Ggv0bj9SrrmxO6O0SEDFHSqvshadDe3t0Rpsv4JnAP+0s0LdEQaOc/Izfa6Kwf5pUNHs XUo6il/LzRgSh+vjfvYn+XH1m8E2/DSc2wMQX0FMRg6Kvx/V/6FIoEYOFQnemCSZ+ari k1G6beuXPHIJWuoEBFOZ9ZhESaSnlQUjsZamMyrhktAqYirdNZAkhOg5g6PEebr0jXP3 Sm8PAgH7+Q5Xy1JRbMmMRhHUlVhbomVixYRKN5cB93Tkyk63wqC590cJpri5wiMDuz9g 28dQ== X-Gm-Message-State: ABy/qLajLj/8crhqrL1pyst/OARDI7wLbWmZtiLcb8a34p1XLrRW6M56 rBfY0uBtCpURFKFW8HrMY0mbvUb+Jb9f8e+Z/KS/9QnXlBSZ28n4NTRhyp3Ta3M5b31Mbaw2Npj 1spNrEupPgvY= X-Received: by 2002:a05:600c:2041:b0:3f8:b6c:84aa with SMTP id p1-20020a05600c204100b003f80b6c84aamr9635469wmg.24.1689612909603; Mon, 17 Jul 2023 09:55:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlEdE39kPxCYKcRdmZ/FpMQpE1xk4SUcvmrmq80wEX/xClSUfOnQK/ncVsEXvVceL/eSsATFSw== X-Received: by 2002:a05:600c:2041:b0:3f8:b6c:84aa with SMTP id p1-20020a05600c204100b003f80b6c84aamr9635448wmg.24.1689612909153; Mon, 17 Jul 2023 09:55:09 -0700 (PDT) Received: from ?IPV6:2003:cb:c735:400:2501:5a2e:13c6:88da? (p200300cbc735040025015a2e13c688da.dip0.t-ipconnect.de. [2003:cb:c735:400:2501:5a2e:13c6:88da]) by smtp.gmail.com with ESMTPSA id 9-20020a05600c020900b003fbc9b9699dsm183220wmi.45.2023.07.17.09.55.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Jul 2023 09:55:08 -0700 (PDT) Message-ID: <6d50e339-bdf9-191a-9389-ea0089fa7118@redhat.com> Date: Mon, 17 Jul 2023 18:55:07 +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: Ryan Roberts , Andrew Morton , Yin Fengwei , Yu Zhao , Yang Shi , "Huang, Ying" , Zi Yan , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230717143110.260162-1-ryan.roberts@arm.com> <20230717143110.260162-2-ryan.roberts@arm.com> <283e4122-c23f-35a1-4782-fddde32f4ad4@arm.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v1 1/3] mm: Allow deferred splitting of arbitrary large anon folios 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-Rspamd-Queue-Id: 1E67340026 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: jfsj63th1eitmip8938guybjzn4xio9o X-HE-Tag: 1689612912-55220 X-HE-Meta: U2FsdGVkX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9w6R6qVw6wb/sJomEWrUwgkciJbNq9iI72ozXUSoNM+4+Z0nEUrFJaMN2VTlhCcQnZAf+NiqI8VYqqur53Urp41cIpcu7cix5xAO+R/pqkBaBK2UvMIBSaATTvS4dV7Isi7x4LcJRUXVC9mrqG960Tkrf4mct2Nfj5/uU9s2fqdyNwOO1VJxCnuhBfcpoh2ia72DuGAjGsoRuzAhM8PqyYw6efMits5lkrhWE/CAFB6UAZIWhyo9K57/BXBn5wJWGya3gT4F3bGTy17DDivgnky5Um8jZ7gjrzdWb+MWXiJ4Oz9hHBvCveyJv6yhfNB53yRQN8cfmBUzsrxRjsnRT+SFvFKXHp9aMdTcFxYP8gtogi53RTTmxVWe0m24KfYwaao8rxwdh4mv0NNzW/1/G6D8vD6U3emqX1bEqkQwS1VkxOij1iQgIPDNXhW40YkugEHngVsOA04a0= 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 17.07.23 17:54, Matthew Wilcox wrote: > On Mon, Jul 17, 2023 at 05:43:40PM +0200, David Hildenbrand wrote: >> On 17.07.23 17:41, Ryan Roberts wrote: >>> On 17/07/2023 16:30, Matthew Wilcox wrote: >>>> On Mon, Jul 17, 2023 at 03:31:08PM +0100, Ryan Roberts wrote: >>>>> In preparation for the introduction of large folios for anonymous >>>>> memory, we would like to be able to split them when they have unmapped >>>>> subpages, in order to free those unused pages under memory pressure. So >>>>> remove the artificial requirement that the large folio needed to be at >>>>> least PMD-sized. >>>>> >>>>> Signed-off-by: Ryan Roberts >>>>> Reviewed-by: Yu Zhao >>>>> Reviewed-by: Yin Fengwei >>>> >>>> Reviewed-by: Matthew Wilcox (Oracle) >>> >>> Thanks! >>> >>>> >>>>> */ >>>>> - if (folio_test_pmd_mappable(folio) && folio_test_anon(folio)) >>>>> + if (folio_test_large(folio) && folio_test_anon(folio)) >>>>> if (!compound || nr < nr_pmdmapped) >>>>> deferred_split_folio(folio); >>>> >>>> I wonder if it's worth introducing a folio_test_deferred_split() (better >>>> naming appreciated ...) to allow us to allocate order-1 folios and not >>>> do horrible things. Maybe it's not worth supporting order-1 folios; >>>> we're always better off going to order-2 immediately. Just thinking. >>> >>> There is more than just _deferred_list in the 3rd page; you also have _flags_2a >>> and _head_2a. I guess you know much better than me what they store. But I'm >>> guessing its harder than jsut not splitting an order-1 page? > > Those are page->flags and page->compound_head for the third page in > the folio. They don't really need a name; nothing refers to them, > but it's important that space not be reused ;-) > > This is slightly different from _flags_1; we do have some flags which > reuse the bits (they're labelled as PF_SECOND). Right now, it's only > PF_has_hwpoisoned, but we used to have PF_double_map. Others may arise. > >>> With the direction of large anon folios (_not_ retrying with every order down to >>> 0), I'm not sure what the use case would be for order-1 anyway? >> >> Just noting that we might need some struct-page space for better >> mapcount/shared tracking, which might get hard for order-1 pages. > > My assumption had been that we'd be able to reuse the _entire_mapcount > and _nr_pages_mapped fields and not spill into the third page, but the We most likely have to keep _entire_mapcount to keep "PMD mapped" working (I don't think we can not account that, some user space relies on that). Reusing _nr_pages_mapped for _total_mapcount would work until we need more bits. But once we want to sort out some other questions like "is this folio mapped shared or mapped exclusive" we might need more space. What I am playing with right now to tackle that would most probably not fit in there (but I'll keep trying ;) ). > third page is definitely available today if we want it. I'm fine with > disallowing order-1 anon/file folios forever. Yes, let's first sort out the open issues before going down that path (might not really be worth it after all). -- Cheers, David / dhildenb