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 A1303C433F5 for ; Tue, 23 Nov 2021 16:57:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FBAD6B0072; Tue, 23 Nov 2021 11:57:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 25C8A6B0074; Tue, 23 Nov 2021 11:57:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AFAD6B0075; Tue, 23 Nov 2021 11:57:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id ECBD06B0072 for ; Tue, 23 Nov 2021 11:57:15 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A99B288491 for ; Tue, 23 Nov 2021 16:57:05 +0000 (UTC) X-FDA: 78840800010.20.3E89690 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id E8D98300012C for ; Tue, 23 Nov 2021 16:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637686624; 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=kBe6B7tioYmsVYZehpfCmsk72UQ7pq5qaHIGMHZWKy0=; b=KRJO9YVjL/PkR9puzExnNE5stbKt9vs3ElOou6xbCWKtp+i1emCHE+JVhLH/fLnqrGWIKr voXRJ0BGXpTA2EeCqlNTqYaK5YbcRoIuTpptCKV9MBn5BrkaxSWetQl2UdQx0uJoidD3PB F7vElWVAYdZVmqm9vbP+QEsKebf5qew= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-428-IWwmnQoJNUqz0zHhmKtrfw-1; Tue, 23 Nov 2021 11:57:01 -0500 X-MC-Unique: IWwmnQoJNUqz0zHhmKtrfw-1 Received: by mail-wm1-f72.google.com with SMTP id g11-20020a1c200b000000b003320d092d08so8729906wmg.9 for ; Tue, 23 Nov 2021 08:57:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=kBe6B7tioYmsVYZehpfCmsk72UQ7pq5qaHIGMHZWKy0=; b=YXoY381abdNuqmg/MP1ok/eQ+9C+M+YqdLEY4vaFQB/C+FThMU+cDpbqq89XKD8VuM xqZdUwkL46dOIXJUPtoAMqC2rRLiCpOoMgm0h6zRBEPNxp4sjQ69PVTwfXrMIwgl1oAt ifD42600OnXmTg+D5BKIdd7gklGZDPhf3cDwa2BYETVAeBWzqCcj6sITCkJEjAyQbK6u aClF6K9MctWLA9D4keQfeaNMIbn8YQMFrXdsXFlN0H0YoZoWF9olfcf7xQyFkPfGmRLV rdWo2LrCBI5uObJGQIYcGhxm0JUvuecFS3N+6oSM+9sWUQ6XX1jzJ4JxkuFwswI32LZ9 6Dqg== X-Gm-Message-State: AOAM530lh6gIpIJTU0GU2GniS1UfR/nSnTK0frf+Hin/FvwNwHL88kDe x6/yUzswyMTPPzeCBkaFyT+wdrhAmtTvMc/IaY/2Cu64BKA0JJzY9OmNZnxmyAFXk6JKed/7qRd MUX8JFRBkgiQ= X-Received: by 2002:a5d:6691:: with SMTP id l17mr8965994wru.227.1637686620063; Tue, 23 Nov 2021 08:57:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJye4oqj76B1MxVHvgWDKFfXjG01NzklIImpNF9/LDZIMaoUKCg3jJ1/+KHx39xNy7a836cW9w== X-Received: by 2002:a5d:6691:: with SMTP id l17mr8965955wru.227.1637686619809; Tue, 23 Nov 2021 08:56:59 -0800 (PST) Received: from [192.168.3.132] (p5b0c6765.dip0.t-ipconnect.de. [91.12.103.101]) by smtp.gmail.com with ESMTPSA id c5sm12987518wrd.13.2021.11.23.08.56.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Nov 2021 08:56:59 -0800 (PST) Message-ID: <92fe0c31-b083-28c4-d306-da8a3cd891a3@redhat.com> Date: Tue, 23 Nov 2021 17:56:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH] mm: split thp synchronously on MADV_DONTNEED To: Shakeel Butt Cc: "Kirill A . Shutemov" , Yang Shi , Zi Yan , Matthew Wilcox , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20211120201230.920082-1-shakeelb@google.com> <25b36a5c-5bbd-5423-0c67-05cd6c1432a7@redhat.com> <1b30d06d-f9c0-1737-13e6-2d1a7d7b8507@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E8D98300012C X-Stat-Signature: 4w3ms191k73m86zmzggpgj8itr5ee8sw Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KRJO9YVj; spf=none (imf09.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1637686621-29029 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: >> I do wonder which purpose the deferred split serves nowadays at all. >> Fortunately, there is documentation: Documentation/vm/transhuge.rst: >> >> " >> Unmapping part of THP (with munmap() or other way) is not going to free >> memory immediately. Instead, we detect that a subpage of THP is not in >> use in page_remove_rmap() and queue the THP for splitting if memory >> pressure comes. Splitting will free up unused subpages. >> >> Splitting the page right away is not an option due to locking context in >> the place where we can detect partial unmap. It also might be >> counterproductive since in many cases partial unmap happens during >> exit(2) if a THP crosses a VMA boundary. >> >> The function deferred_split_huge_page() is used to queue a page for >> splitting. The splitting itself will happen when we get memory pressure >> via shrinker interface. >> " >> >> I do wonder which these locking contexts are exactly, and if we could >> also do the same thing on ordinary munmap -- because I assume it can be >> similarly problematic for some applications. > > This is a good question regarding munmap. One main difference is > munmap takes mmap_lock in write mode and usually performance critical > applications avoid such operations. Maybe we can extend it too most page zapping, if that makes things simpler. > >> The "exit()" case might >> indeed be interesting, but I really do wonder if this is even observable >> in actual number: I'm not so sure about the "many cases" but I might be >> wrong, of course. > > I am not worried about the exit(). The whole THP will get freed and be > removed from the deferred list as well. Note that deferred list does > not hold reference to the THP and has a hook in the THP destructor. Yes, you're right. We'll run into the de-constructor either way. -- Thanks, David / dhildenb