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 EA54EECAAD5 for ; Mon, 29 Aug 2022 10:02:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71DE2940007; Mon, 29 Aug 2022 06:02:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A0DB94000A; Mon, 29 Aug 2022 06:02:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EE97940008; Mon, 29 Aug 2022 06:02:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2BE46940008 for ; Mon, 29 Aug 2022 06:02:27 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 00238120AC0 for ; Mon, 29 Aug 2022 10:02:26 +0000 (UTC) X-FDA: 79852190292.27.DAE4BE5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 9CA01A0020 for ; Mon, 29 Aug 2022 10:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661767346; 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=EHQWTqx1hJ/KNsFe7kL4o8M725RFp/teHXSfvZJ6uuM=; b=Q+BFzAd1ADtLvKr0A2TzEx37RVQd9038QK8iBJPO8in/bDNGFMWvqVlZlFgC6inNJhjle5 aHRKlmamXnV2Tn/GTG+5FZKpGCohG6cvedtLE8sbLYLzIup7kAQctwSVcic2x3Hi6JVrrh vfmo3Lh6p4i8IS/IkzcKKVMSxvBSMeA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-660-K87ukbfTO9aDPVTRVhCzyQ-1; Mon, 29 Aug 2022 06:02:25 -0400 X-MC-Unique: K87ukbfTO9aDPVTRVhCzyQ-1 Received: by mail-wr1-f72.google.com with SMTP id e13-20020adfa44d000000b002260797ca0cso978139wra.20 for ; Mon, 29 Aug 2022 03:02:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=EHQWTqx1hJ/KNsFe7kL4o8M725RFp/teHXSfvZJ6uuM=; b=hyA4WJ38+1j+Oer7hsftPdNNJheRjtlsy8MuellnXW74TYEMZXW6NZUaVZ2WP4nJFX QlaW+Uc3im2mGvTf0cnBfK8q6dMJT94IX5wahE1Fr09a9MgHJ6rojNvkoHBd2IWzPAn6 CA9WM2SUQ837SyjZH3UUI4SIBdqSO4qS6Bb2/6X4FQr0YNzmi5Fcv/k4szOp9twuwl7j N1GZHWeHt2iMMJdvh81wMyHVEg1/QVN7P9XUaJBA7CnE/yTNOk5okIzhu7KMTi4MjrVA 4MDw6zCLK1wseDgRNFTL2ojNPnMSjB/YQvR2jd5Nisd6BLuk1xuoeser8XQ07pPSGVtW EHpw== X-Gm-Message-State: ACgBeo3HPZLdmTJGF0uOwvosV/X5gc114YszQbbigt8ThpkL2ogGTflI L+2hd+I2sG1wph0j0ilHUqVIVT/2eHu6cMo6kQw8sqDi/2BrRATouOaZBL+fiu/rNdZu78NSHCf 8R1aXFkhiCIc= X-Received: by 2002:a5d:498c:0:b0:226:d522:ae4 with SMTP id r12-20020a5d498c000000b00226d5220ae4mr4042665wrq.84.1661767343867; Mon, 29 Aug 2022 03:02:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR6NVshlmvckCXyQ/ibbvM+hwHWz+l6Mr1r8C40Y1pvr4x0hOtw751gci5QcYA7r2t95lVIuwA== X-Received: by 2002:a5d:498c:0:b0:226:d522:ae4 with SMTP id r12-20020a5d498c000000b00226d5220ae4mr4042638wrq.84.1661767343537; Mon, 29 Aug 2022 03:02:23 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:3900:658b:bed0:4260:4c25? (p200300cbc7073900658bbed042604c25.dip0.t-ipconnect.de. [2003:cb:c707:3900:658b:bed0:4260:4c25]) by smtp.gmail.com with ESMTPSA id q13-20020adff78d000000b0022533c4fa48sm6548900wrp.55.2022.08.29.03.02.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Aug 2022 03:02:22 -0700 (PDT) Message-ID: <42c164c6-8c69-7b4b-d965-ac62d1607061@redhat.com> Date: Mon, 29 Aug 2022 12:02:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [RFC 2/3] mm: changes to split_huge_page() to free zero filled tail pages To: Rik van Riel , alexlzhu@fb.com, linux-mm@kvack.org Cc: willy@infradead.org, hannes@cmpxchg.org, akpm@linux-foundation.org, kernel-team@fb.com, linux-kernel@vger.kernel.org References: <490fcdd204ae129a2e43614a569a1cf4bdde9196.1661461643.git.alexlzhu@fb.com> <6448b9a8dba8ef39e42e56a3c0ce0633fff7c6a6.camel@surriel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <6448b9a8dba8ef39e42e56a3c0ce0633fff7c6a6.camel@surriel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661767346; 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=EHQWTqx1hJ/KNsFe7kL4o8M725RFp/teHXSfvZJ6uuM=; b=6L9PzbPF0m3E0CnM8nFZR3SZLXXkjvlV2chBchWgDntNQ7nDOTIqyoJH8xYSMkpfPavdya 0f+bgpazabw+JmGf/7kj6PepK0dLHCnvheDiIgyToCAcij0WL1C+XXcKQQGHPXx48GGH7W 2MWHSFkOTBmrMgvCREHJQpV475paTx4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q+BFzAd1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661767346; a=rsa-sha256; cv=none; b=02S6wBjngJJkTBQVh4yasAyWJ20Gcq7/ua9snTC0L991Jbmndnl2OUkMCO+eWfxz/4gbxS hhqH6TelW5AF5w1EQ1woakEdoydGDsBlfz8hPHmflhl6Mm6Qq8KIQ4/PBSK/FnndOsrrjs 8PBgdWs8l6cmm9NSVY+fuQ0nMOJOaqA= X-Stat-Signature: e7me3xuepfbks5rd1xbpnqgs9j6bgnyw X-Rspamd-Queue-Id: 9CA01A0020 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q+BFzAd1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam03 X-Rspam-User: X-HE-Tag: 1661767346-106791 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 26.08.22 23:18, Rik van Riel wrote: > On Fri, 2022-08-26 at 12:18 +0200, David Hildenbrand wrote: >> On 25.08.22 23:30, alexlzhu@fb.com wrote: >>> From: Alexander Zhu >>> >>> Currently, split_huge_page() does not have a way to identify zero >>> filled >>> pages within the THP. Thus these zero pages get remapped and >>> continue to >>> create memory waste. In this patch, we identify and free tail pages >>> that >>> are zero filled in split_huge_page(). In this way, we avoid mapping >>> these >>> pages back into page table entries and can free up unused memory >>> within >>> THPs. >>> >> >> Isn't this to some degree splitting the THP (PMDs->PTEs + dissolve >> compound page) and then letting KSM replace the zero-filled page by >> the >> shared zeropage? >> > Many systems do not run KSM, though, and even on the systems > where it does, KSM only covers a subset of the memory in the > system. Right, however there seems to be a push from some folks to enable it more widely. > > I could see wanting to maybe consolidate the scanning between > KSM and this thing at some point, if it could be done without > too much complexity, but keeping this change to split_huge_page > looks like it might make sense even when KSM is enabled, since > it will get rid of the unnecessary memory much faster than KSM could. > > Keeping a hundred MB of unnecessary memory around for longer > would simply result in more THPs getting split up, and more > memory pressure for a longer time than we need. Right. I was wondering if we want to map the shared zeropage instead of the "detected to be zero" page, similar to how KSM would do it. For example, with userfaultfd there would be an observable difference. (maybe that's already done in this patch set) -- Thanks, David / dhildenb