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 38964C433EF for ; Mon, 11 Oct 2021 11:23:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2015260C49 for ; Mon, 11 Oct 2021 11:23:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236169AbhJKLZG (ORCPT ); Mon, 11 Oct 2021 07:25:06 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:52492 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236114AbhJKLZF (ORCPT ); Mon, 11 Oct 2021 07:25:05 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 51AD31FE9C; Mon, 11 Oct 2021 11:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1633951384; h=from:from:reply-to: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=Xw+IlCOw0VN11+4gbW0CcFkV8zMbAYmFEqOL5u+s6vo=; b=oek9t6K1RiKpfTX6tBopWgwd3n6/EwyBZJnKr6ToCyP5ri0SKHrqxbbaWEEwFJ3nrq+mOD NTkafHAmMEmGnugMTQVjryBJQWTNC4rlvnR1DdoZVTnpZ//kMXfRWGKaMmPmVeDMOOpVU4 JbsCJY/PLvR9mf8eRghX1hU+TEswqwo= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C86B3A3B83; Mon, 11 Oct 2021 11:23:03 +0000 (UTC) Date: Mon, 11 Oct 2021 13:23:00 +0200 From: Michal Hocko To: David Hildenbrand Cc: ultrachin@163.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, brookxu.cn@gmail.com, chen xiaoguang , zeng jingxiang , lu yihui , Claudio Imbrenda , Daniel Jordan Subject: Re: [PATCH] mm: Free per cpu pages async to shorten program exit time Message-ID: References: <20211008063933.331989-1-ultrachin@163.com> <278a6cda-3095-5e27-e136-2765f73bc67d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <278a6cda-3095-5e27-e136-2765f73bc67d@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 11-10-21 11:40:12, David Hildenbrand wrote: > On 11.10.21 11:28, Michal Hocko wrote: > > On Fri 08-10-21 10:17:50, 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. > > > > > > There is mmdrop_async(), and I wondered if one could reuse that concept when > > > tearing down a process -- I didn't look into feasibility, however, so it's > > > just some very rough idea. > > > > This is not a new problem. Large process tear down can take ages. The > > primary road block has been accounting. This lot of work has to be > > accounted to the proper domain (e.g. cpu cgroup). > > In general, yes. For some setups where admins don't care about that > accounting (e.g., enabled via some magic toggle for large VMs), I guess this > accounting isn't the major roadblock, correct? Right, I would be careful about magic toggles though. Besides there are ways to achive this in the userspace. We used to have a request to help paralleling process exit from a DB vendor and Vlastimil has come up with a clone(CLONE_VM) and madvise(DONT_NEED) from several threads as a "workaround". This would work properly from the accounting POV. Admittedly a bit of an involved approach though. -- Michal Hocko SUSE Labs