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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AFEAC433EF for ; Sun, 10 Oct 2021 22:42:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8686B60F14 for ; Sun, 10 Oct 2021 22:42:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8686B60F14 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id ABA45900002; Sun, 10 Oct 2021 18:42:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A69976B0072; Sun, 10 Oct 2021 18:42:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95878900002; Sun, 10 Oct 2021 18:42:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 866846B006C for ; Sun, 10 Oct 2021 18:42:07 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1F23C2DD8A for ; Sun, 10 Oct 2021 22:42:07 +0000 (UTC) X-FDA: 78682002294.08.1760596 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf08.hostedemail.com (Postfix) with ESMTP id BB66C3004A40 for ; Sun, 10 Oct 2021 22:42:06 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id EC5F860F0F; Sun, 10 Oct 2021 22:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1633905724; bh=JlESLPD7yjmMAz+qz4CiD4yeMC2Nn8eK3Msu1ni+Lek=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tCcTqAdFqhRaotyRQV+GWKeJRaNGhCMhkj0RHPCdueU1PADTvxl+9hvLy5h4CcK5b B15Hxl9JE4SzO1hLJFjZ0EIQ3FLCslRx85bR1J8fOB+lX/zQ6JfEPLAmX+8KEUUpBK LG0rOAd7G5/ftpSK+Ooy+0vFwz6q+MTljk1xJvM4= Date: Sun, 10 Oct 2021 15:42:01 -0700 From: Andrew Morton To: Vlastimil Babka Cc: David Hildenbrand , ultrachin@163.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, brookxu.cn@gmail.com, chen xiaoguang , zeng jingxiang , lu yihui , Claudio Imbrenda Subject: Re: [PATCH] mm: Free per cpu pages async to shorten program exit time Message-Id: <20211010154201.6a1940a17da6669154d9109c@linux-foundation.org> In-Reply-To: <8f30837b-5186-e836-21bc-9964456400c1@suse.cz> References: <20211008063933.331989-1-ultrachin@163.com> <8f30837b-5186-e836-21bc-9964456400c1@suse.cz> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=tCcTqAdF; spf=pass (imf08.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: BB66C3004A40 X-Stat-Signature: 6ymunntrxcccewbq8dnfkxprjjjgg3kp X-HE-Tag: 1633905726-127865 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 Fri, 8 Oct 2021 14:38:15 +0200 Vlastimil Babka wrote: > On 10/8/21 10:17, David Hildenbrand wrote: > > On 08.10.21 08:39, ultrachin@163.com wrote: > >> From: chen xiaoguang > >> > >> The exit time is long when program allocated big memory and > >> the most time consuming part is free memory which takes 99.9% > >> of the total exit time. By using async free we can save 25% of > >> exit time. > >> > >> Signed-off-by: chen xiaoguang > >> Signed-off-by: zeng jingxiang > >> Signed-off-by: lu yihui > > > > I recently discussed with Claudio if it would be possible to tear down the > > process MM deferred, because for some use cases (secure/encrypted > > virtualization, very large mmaps) tearing down the page tables is already > > the much more expensive operation. > > OK, but what exactly is the benefit here? The cpu time will have to be spent > in any case, but we move it to a context that's not accounted to the exiting > process. Is that good? Also if it's a large process and restarts > immediately, allocating all the memory back again, it might not be available > as it's still being freed in the background, leading to a risk of OOM? Yes, concerns. Some way of blocking the oom-killer if this freeing is in progress sounds needed. Dumb question: can the exiting process just clone(CLONE_MM) then exit? Let the child take the burden of all the cleanup?