Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1006774pxb; Sun, 10 Oct 2021 17:51:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBy6lSZtC4YrMba/Y7Z0vgdLs1pqYjeAARNLAx7Fsst7V0RxZdgJRX9IXzwOFVhmf5jgaW X-Received: by 2002:a17:906:ae54:: with SMTP id lf20mr15415766ejb.195.1633913479806; Sun, 10 Oct 2021 17:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633913479; cv=none; d=google.com; s=arc-20160816; b=F0sDX/vXyJjjG6NbM/PA/bdjDHnKXic2hD1Ll6EWb7VoAEbOhuS9NMdb/ng0wSooSs w8inysh0PW/53R9F8mzb51TF39TynqP6fFmSQj2TSqY34zwZtOaGJ/F7J8kSUwk5/0eu GiL5Q/YC5/4FYJZxhDOEzhtmFNVzD4jPvYgbACTGytyX97X+GCa6RFXNBXrZycA27xsQ 1umvLw+TSv5+yZWmq6pO+/wAbuEH+txXBKb4V3szhteP2sGLBFtWCqOISQ5+E8sipEMd uDWjia5mcI7p71jc1P9ZnF5gp9/2vaH336Oh+E/FjwxgtAAI1nBBJsfbWodHQ2RdWGsv B7lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=J5DPZk8UnHDaNd5S9qrzploj//bupLXROElPCR7XF84=; b=g7sCrujn0eY5T9Bi0p0U3yDZvepSLCO/ZhiVxMAxtIKjnRar0CWX7rtNfK2CKHdb1n sgGCuAcfhOR1E0pe7lhWoCmQKyvjRC8XCyNDWXj+Oo1lxRoBIcb4C0G/xQdJIgYn1L3u ca38fr3Llet/qCqvYTcvRiBHjmlE7tHEx6ZWcPxwWBlWdCUagA0R2AmcwKhITNHBf6S8 82iKEHS9i/KF0Wfnt48PYZZ0okBBvcIKdyAlHUw9mndCTq4bu/FzqVArFh91WRU0ZR15 ti7eJIpgb8VEOYUW2O47QUTmrpUmV1fd0Te/fhsHe5kBVyX/Hm8HZPPnuYGtH7eZQxXY 8Tjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=tCcTqAdF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h21si9060503eje.344.2021.10.10.17.50.27; Sun, 10 Oct 2021 17:51:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=tCcTqAdF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232719AbhJJWoD (ORCPT + 99 others); Sun, 10 Oct 2021 18:44:03 -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?