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 091B6C05027 for ; Tue, 14 Feb 2023 18:42:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81D146B0072; Tue, 14 Feb 2023 13:42:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A5B56B0074; Tue, 14 Feb 2023 13:42:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61F546B007E; Tue, 14 Feb 2023 13:42:12 -0500 (EST) 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 4AD3E6B0072 for ; Tue, 14 Feb 2023 13:42:12 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 180E5160FC2 for ; Tue, 14 Feb 2023 18:42:12 +0000 (UTC) X-FDA: 80466767304.09.99983AD Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf21.hostedemail.com (Postfix) with ESMTP id 3CA641C0009 for ; Tue, 14 Feb 2023 18:42:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="ng/23Q8Q"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of shiyn.lin@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=shiyn.lin@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676400130; 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=XRo2ZIqpIDT93AirKwwMrlxztEV/PfuB85SoVUGPU10=; b=QYro0HNxxwutIK1EfuEgPi05oKWSLGNnBP1dbvxC57/RkhDLDp5jp6DmCXJtlaCXCtcZ7U yM+7vCWiQVz/G1bVJ8aA9tYQ6I7EH5qu+FxujP0NkTFxblBx5MmcM3gqxMjlDuceAwdmFU 8irf0QfhpJg7bq+5YNacz4LrsnamE6A= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="ng/23Q8Q"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of shiyn.lin@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=shiyn.lin@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676400130; a=rsa-sha256; cv=none; b=aDsSEzfPyfRJvgYVHFml43CtSN1wSBwOAG1VZlAvZCsFvf91fNncz1lt8SVzQ7s4owhF+G eW4cVBIDgVlNfm08NquLbpFpaxyGmasgWegqPuAe93Gq85BTibQt03mX97x4HGyzb/ZfyG o2jRh6QO0fZsh4v4dHvKS8aRhf/YHRc= Received: by mail-pj1-f51.google.com with SMTP id o13so15966405pjg.2 for ; Tue, 14 Feb 2023 10:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=XRo2ZIqpIDT93AirKwwMrlxztEV/PfuB85SoVUGPU10=; b=ng/23Q8Qt4TxmXdCp7wL5IoDq7dA7lZHBpBmL/ffgTa0J+8/KDU8qEIlDPid9Bwgce tG730uZl/rS13jZC3Mid/9cRn9YiVxYJzZXuBLiDk2kTUehti7SrprkM9sCKHhYJWcep vUI+AK3jPpkTulZJi2YvZ7uUH4rNEqVAp/T0CqpyTsNW+LLdz3DX2eGWUtmfcZ/m9aZx Mirl5J75cBk7zaa0T4bBSpblld0lWp0GnYpH957ZrPg+DQJeg5mu91Y4vd3oh0PkGtsz UvAEo21zaeVaB3pB18ShZpkPgf6I++c5mcd+HT4Clz7GvNDaY0HvrpekYUf9QJ8p8mI+ j88Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=XRo2ZIqpIDT93AirKwwMrlxztEV/PfuB85SoVUGPU10=; b=qMyIaFTvKCR6fxKccJYTJ9feF7MTlB3+TR/tQz9V+sP8GlgO2IVHQXyeMXasRLIxYx BSoI1iEyvMu6zqLYRNX5XnWWslJNR+/d9TuIocBd74KOtXoRLpPdJ+/7efwArt6Yl7Jy r03egmfoMe1nu8Hwn6CKNxBWRhdTbs6IdX7O8FsXaDJuNsh7zFFHDv4XgauWZEP2Haz+ aiMzoDxYl8o362vnHDyMYHu4yx8MXuFr/4qwRhNCDriSpmOOhs3NipiH7UDob7z4oaHE 2YIU6X+pkqgsS8LwEonzA81cE//I79haDCnk1ryH+FvYvbED68MxLBtP4lzODBql+XPS NQEQ== X-Gm-Message-State: AO0yUKXPSKT9brEN+b9fiYm+6mg1R/iLTcDZg7/614GtEQG/2PysJtRX z2qN0PWFnIxWTMbf9ERigyA= X-Google-Smtp-Source: AK7set9TTu2A58Oxz5nlNmqCKWoHdPeE+yJWY3dsd5KsorD9eRx5v1aiBrziy64Xkh2bYWDfq/KFpg== X-Received: by 2002:a17:90b:1b45:b0:22b:e75f:8502 with SMTP id nv5-20020a17090b1b4500b0022be75f8502mr527877pjb.9.1676400128895; Tue, 14 Feb 2023 10:42:08 -0800 (PST) Received: from strix-laptop (2001-b011-20e0-1465-11be-7287-d61f-f938.dynamic-ip6.hinet.net. [2001:b011:20e0:1465:11be:7287:d61f:f938]) by smtp.gmail.com with ESMTPSA id b187-20020a6334c4000000b004fba03ee681sm4091813pga.13.2023.02.14.10.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Feb 2023 10:42:08 -0800 (PST) Date: Wed, 15 Feb 2023 02:41:57 +0800 From: Chih-En Lin To: Pasha Tatashin Cc: David Hildenbrand , Andrew Morton , Qi Zheng , "Matthew Wilcox (Oracle)" , Christophe Leroy , John Hubbard , Nadav Amit , Barry Song , Steven Rostedt , Masami Hiramatsu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Yang Shi , Peter Xu , Vlastimil Babka , Zach O'Keefe , Yun Zhou , Hugh Dickins , Suren Baghdasaryan , Yu Zhao , Juergen Gross , Tong Tiangen , Liu Shixin , Anshuman Khandual , Li kunyu , Minchan Kim , Miaohe Lin , Gautam Menghani , Catalin Marinas , Mark Brown , Will Deacon , Vincenzo Frascino , Thomas Gleixner , "Eric W. Biederman" , Andy Lutomirski , Sebastian Andrzej Siewior , "Liam R. Howlett" , Fenghua Yu , Andrei Vagin , Barret Rhoden , Michal Hocko , "Jason A. Donenfeld" , Alexey Gladkov , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Dinglan Peng , Pedro Fonseca , Jim Huang , Huichun Feng Subject: Re: [PATCH v4 00/14] Introduce Copy-On-Write to Page Table Message-ID: References: <20230207035139.272707-1-shiyn.lin@gmail.com> <62c44d12-933d-ee66-ef50-467cd8d30a58@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 3CA641C0009 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: zfxeyn73xr5ghhem7qu36hq7kqr4aya5 X-HE-Tag: 1676400129-336530 X-HE-Meta: U2FsdGVkX1997C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UTLVNHTt1ryU8mRz08N9XyRrT7zEWydlgD7bdiR4wr8OMoOfn6ijSJv0MbhYj4kHgKWSHuucJibYqKxusJrQNk/OFaED/pPK34tJYUlE1eACs8X+8vmrLLEZzRZtmxf7+lJ66FvK5TssLxQYOt/idrdsRhTTBno3qNs/e2gZHyqxJWaXTJgxKJl1OtwH1XsYdBmsX5ykNdsvYq/ncAfne4mrVJPfkSH6MuWV+mgpwKjHW/4he07MxYMhH0kN+JhRlNMl6mZezgCwUGRjls41lj5WgqMHyobwOSB4SiDgzpWZlfKAXKH8flhl7MK6SkS4YLjl3ZYVS+dQdQ2Gn1u/sB7rzMlDfODjMQHAp9A4h3POHbFLkbxvK/DRU0amJhnXGskihiCUDiqG+3JhndT3ZBQeYoFkZ0vPsqgs2lzvw== 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 Tue, Feb 14, 2023 at 11:30:26AM -0500, Pasha Tatashin wrote: > > > The thing with THP is, that during fork(), we always allocate a backup PTE > > > table, to be able to PTE-map the THP whenever we have to. Otherwise we'd > > > have to eventually fail some operations we don't want to fail -- similar to > > > the case where break_cow_pte() could fail now due to -ENOMEM although we > > > really don't want to fail (e.g., change_pte_range() ). > > > > > > I always considered that wasteful, because in many scenarios, we'll never > > > ever split a THP and possibly waste memory. > > > > > > Optimizing that for THP (e.g., don't always allocate backup THP, have some > > > global allocation backup pool for splits + refill when close-to-empty) might > > > provide similar fork() improvements, both in speed and memory consumption > > > when it comes to anonymous memory. > > > > When collapsing huge pages, do/can they reuse those PTEs for backup? > > So, we don't have to allocate the PTE or maintain the pool. > > It might not work for all pages, as collapsing pages might have had > holes in the user page table, and there were no PTE tables. So if there have holes in the user page table, after we doing the collapsing and then splitting. Do those holes be filled? Assume it is, then, I think it's the reason why it's not work for all the pages. But, after those operations, Will the user get the additional and unexpected memory (which is from the huge page filling)? I'm a little bit confused now. Thanks, Chih-En Lin