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 52EFEC433F5 for ; Sun, 10 Oct 2021 22:42:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23FC960C4A for ; Sun, 10 Oct 2021 22:42:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232989AbhJJWoE (ORCPT ); Sun, 10 Oct 2021 18:44:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:50312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232586AbhJJWoD (ORCPT ); Sun, 10 Oct 2021 18:44:03 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?