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 D90E7C64EC4 for ; Wed, 8 Mar 2023 22:10:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A8356B0071; Wed, 8 Mar 2023 17:10:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 557D46B0072; Wed, 8 Mar 2023 17:10:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F881280002; Wed, 8 Mar 2023 17:10:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 306AD6B0071 for ; Wed, 8 Mar 2023 17:10:50 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E493E80772 for ; Wed, 8 Mar 2023 22:10:49 +0000 (UTC) X-FDA: 80547126618.26.AE47153 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id DF3F6C0017 for ; Wed, 8 Mar 2023 22:10:47 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FFriEMG3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678313447; 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=eLI1QWpHEK+fkiyGobonFz4t1x0nPDcqaex7e9/jd/s=; b=n6E/QymElFqHNnqctVUxs51AyV9N7+f+oh+AgAUdZhTya72hOlP9x3JMJrLcVjK5MT2yMC ch033MoM5y3IFgsoKfVpXG9UiPWN+WEaEj329IjwPNdosjAP2Uw0h510Zk8tGYCzpdnfRs i3DsBKCWlZkr/SYm8wf05sWBT1nxrCw= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FFriEMG3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678313447; a=rsa-sha256; cv=none; b=R/lLF/KqQIjEp3YndSuscSzcZND7Sj7xi3ndz3Regr99NzqoyXZBA5e/vMnFpv09OxNhmU JCXIkf+MqC2TZHF1vCAvr+uE5xTeN+kXhzjEo+FaFwi1NiUjJ6C3Lt6OhkaXl9/tOtH28X Z3ukXt53N0fd0WPL4P7ma2VUJfn42Yk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678313447; 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: in-reply-to:in-reply-to:references:references; bh=eLI1QWpHEK+fkiyGobonFz4t1x0nPDcqaex7e9/jd/s=; b=FFriEMG3S1zHxRpeiuihWlSjWDA2l0d8e8RlfW3Q3H2N4Kuj4x2EVo38/iM4dINR+rH+mo qX/piZeKhWTMfS4VMrNy2/4ju0EK5pSl4iR3RllDsfFN4JGU0uhpuEGxzizGgasK3moi4f WIsyTZE6JREbYHOO8SjOc/VI5WK7GEw= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-423-p9sUiFY9PhCnicSK4fKGQw-1; Wed, 08 Mar 2023 17:10:44 -0500 X-MC-Unique: p9sUiFY9PhCnicSK4fKGQw-1 Received: by mail-qk1-f197.google.com with SMTP id x5-20020a05620a01e500b007428997e800so83174qkn.10 for ; Wed, 08 Mar 2023 14:10:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678313443; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=eLI1QWpHEK+fkiyGobonFz4t1x0nPDcqaex7e9/jd/s=; b=Y94xuonY6FGIRBOIJ6tKJR4321Qm3i2n543WjR26f5SnrG8sQlCyjEMJw+kYskXA3L 2M+44Ukg8OaE10oKhQRedjyT+GtAehOZj7lgcLOpX3NAfwQ+mMoZimuGB34q7/YrTwvl KkYDXxII+23ny9e/kpI9+uygtKLw1GkIDyMtnvcr1kPbKnuXHrGna59y9ZqBMNXPRJXd 9z3LuCf/DF3c4rfXlmp3cICOdvDesR2uu4u6HbkT20HS9eNuSw0YHXGrNHODUbp2DCQv ITsIFi2dLJJKFZXSpd7gJ5dBSL0ZRNTNfMpO6pdX23EDk8mJwd+5f0iUZ06RkJENfW0K m0yg== X-Gm-Message-State: AO0yUKVtZ/45Qbaq0Hy3UBidhYIDF6LtleSVt+U7Vjq7+rFOILe3RPTu GT6qfk7x/tJBbyLMQQH9L7oQRY4PIomxbp+XaAB7B8GMkbx/bv+jZrVX+12pWVwYJoHmsG2VO0s 7E3Y7jty9OC8= X-Received: by 2002:a05:622a:148:b0:3bf:da3a:4e0f with SMTP id v8-20020a05622a014800b003bfda3a4e0fmr39521215qtw.0.1678313443612; Wed, 08 Mar 2023 14:10:43 -0800 (PST) X-Google-Smtp-Source: AK7set9nA/PJr6/P2QgGqqNjvT5/5QEJGMCQvFsq7BnOQ74jn8PmCHuaIjguwIy5yx3L8S2JOLWqjQ== X-Received: by 2002:a05:622a:148:b0:3bf:da3a:4e0f with SMTP id v8-20020a05622a014800b003bfda3a4e0fmr39521165qtw.0.1678313443276; Wed, 08 Mar 2023 14:10:43 -0800 (PST) Received: from x1n (bras-base-aurron9127w-grc-56-70-30-145-63.dsl.bell.ca. [70.30.145.63]) by smtp.gmail.com with ESMTPSA id b3-20020ac85bc3000000b003bfb820f17csm12660930qtb.63.2023.03.08.14.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 14:10:42 -0800 (PST) Date: Wed, 8 Mar 2023 17:10:41 -0500 From: Peter Xu To: James Houghton Cc: Mike Kravetz , Hugh Dickins , Muchun Song , "Matthew Wilcox (Oracle)" , Andrew Morton , "Kirill A . Shutemov" , David Hildenbrand , David Rientjes , Axel Rasmussen , Jiaqi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/2] mm: rmap: merge HugeTLB mapcount logic with THPs Message-ID: References: <20230306230004.1387007-1-jthoughton@google.com> MIME-Version: 1.0 In-Reply-To: <20230306230004.1387007-1-jthoughton@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: DF3F6C0017 X-Stat-Signature: bmt4mp41haj7i5f915aemrg8nz17qghn X-HE-Tag: 1678313447-788250 X-HE-Meta: U2FsdGVkX19f9MtkDNXFJNAqJ7Ov/43QnpBbQabq4RqCEcbH5LhM4eGcJU4Bo9WHSfXAJBhP/epr/31cHgCnQYxbly4hk3QB1weNW/0st63GF6TqGRNhpHsT1HPf9vLVOwohhFVZDpr2Le8VFpEYoBCzfphoIj7jBFdsDWNZlO0C5qhOh7HdAdCWjXdy7ptkfdIIOl17RGL2s/kMz9o2Ny/S7k0dSBC6dR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Io4S6cZpA11lgu76T+e66T/T2jnA9x9uvLSGFFy7ILuW6M60WHjfdmdBugCmdKh 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 Mon, Mar 06, 2023 at 11:00:02PM +0000, James Houghton wrote: > HugeTLB pages may soon support being mapped with PTEs. To allow for this > case, merge HugeTLB's mapcount scheme with THP's. > > The first patch of this series comes from the HugeTLB high-granularity > mapping series[1], though with some updates, as the original version > was buggy[2] and incomplete. > > I am sending this change as part of this smaller series in hopes that it > can be more thoroughly scrutinized. > > I haven't run any THP performance tests with this series applied. > HugeTLB pages don't currently support being mapped with > `compound=false`, but this mapcount scheme will make collapsing > compound=false mappings in HugeTLB pages quite slow. This can be > optimized with future patches (likely by taking advantage of HugeTLB's > alignment guarantees). > > Matthew Wilcox is working on a mapcounting scheme[3] that will avoid > the use of each subpage's mapcount. If this series is applied, Matthew's > new scheme will automatically apply to HugeTLB pages. Is this the plan? I may have not followed closely on the latest development of Matthew's idea. The thing is if the design requires ptes being installed / removed at the same time for the whole folio, then it may not work directly for HGM if HGM wants to support at least postcopy, iiuc, because if we install the whole folio ptes at the same time it seems to beat the whole purpose of having HGM.. The patch (especially patch 1) looks good. So it's a pure question just to make sure we're on the same page. IIUC your other mapcount proposal may work, but it still needs to be able to take care of ptes in less-than-folio sizes whatever it'll look like at last. A trivial comment on patch 2 since we're at it: does "a future plan on some arch to support 512GB huge page" justify itself? It would be better justified, IMHO, when that support is added (and decided to use HGM)? What I feel like is missing (rather than patch 2 itself) is some guard to make sure thp mapcountings will not be abused with new hugetlb sizes coming. How about another BUG_ON() squashed into patch 1 (probably somewhere in page_add_file|anon_rmap()) to make sure folio_size() is always smaller than COMPOUND_MAPPED / 2)? -- Peter Xu