Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3686206ybi; Mon, 29 Jul 2019 10:46:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4QSYwYvTeYgsnz7fqTRCKPMuLjUqw5OJoGrna1ijuMqB7hk8eMpf5EYP7ib3N4f1fiBPR X-Received: by 2002:a62:5883:: with SMTP id m125mr37508807pfb.248.1564422381195; Mon, 29 Jul 2019 10:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564422381; cv=none; d=google.com; s=arc-20160816; b=NbhtvexuVyAUcKJ9jnEzZjarJr7kXlIBnNtyeqRHtOERZ5fSjO8DtfZFvl/xfn3ZDx sknxISkRw5u2Mlr7zqXyXsqf1FaehZVNI3OrW8ITv4dKlTwaZiZdFz1elmyvWD7f2ObS JRdv7vfayMM49mcJqwRDzsKfBIJejuhBeniCnrRyx2oUlYz2FPpU8/LK7aKgCJK9q0vc lwNd2nQvdeAK731vXW/5nKp7uCuXd7vb+MGdRCOt5sLKXJHdGud82VWdbYCIVZR/Ws9d vdtmMnVh1NEIX0d4A4+kAoOCxQJjB/yD2AtL12P6r+HjUUerTcAdhiswZFmlZmT+3WVI OvSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Cgd07V1X1aWq4Nq8OV+7HBCsrLjmlGfJU51VxLF3KME=; b=ZknF62iFCn069+RNtkeEMv9Sg5/eX7KfnxlQjYstZ7zmkSoJyO72zKXJZUlLheRe4V 6kinT3wPfV+alWywCiVJBa/Y+qfuozXaHBWNgbw6mg7/9K1hOwyMT12WqgjsF0XHB6ye vCT/tRI2rwJiyd5C0jf3r7Vnc/SivR3roXY7VSNtybUcRwMrSYSHjVTG5smMTcD+E5fF HfV8yo32VR7TmksYTRAv+Lxm+ZOxwkbO1RLppC9du2g2m3JN9lwkpgxky79VQFbhezxx iTFizdtn4w7J7k9s/zQZ3W216zc/TC2SrtPO2ZvwxLMX3OrP0RXSZN7v3uuw2kSYXe39 6Crg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=HQ7rJIh3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si29474475pgb.245.2019.07.29.10.46.06; Mon, 29 Jul 2019 10:46:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=HQ7rJIh3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727935AbfG2O2B (ORCPT + 99 others); Mon, 29 Jul 2019 10:28:01 -0400 Received: from merlin.infradead.org ([205.233.59.134]:46958 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbfG2O2A (ORCPT ); Mon, 29 Jul 2019 10:28:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Cgd07V1X1aWq4Nq8OV+7HBCsrLjmlGfJU51VxLF3KME=; b=HQ7rJIh3bHrwXb5N+hm1m1ta2 3xN8kgOWRqh7smEYAmFrsJkadsRGpGLLsb9/LHLQ7ywUfoljVN6vzmX+Bzw/03Co2DXcMu0BJRZyE qox34odUC6mRHsYT2mmBBcIq58sAF1mXYmXtJm6jQ5YwJ96Fqx8c3dLNZR3ODeLP5LnWEYNF0xod5 eMq1JAQ/NAdU6bQ20v8FDHnuKmDlCGL1lXRg2R4BEu9qLOWxqHU7b/51x4ducyTPTFmu+731k6hXA KwDWNZRXZr96XzMPdBleNmGzRwcOAlMP6kGNFFVV+gpKnCWbcVoyyamjgy+CHXCAQbcBJ8izHsMPN R71FeIoDw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hs6d3-0002u2-Ca; Mon, 29 Jul 2019 14:27:57 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2974320AFFEAD; Mon, 29 Jul 2019 16:27:56 +0200 (CEST) Date: Mon, 29 Jul 2019 16:27:56 +0200 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Phil Auld Subject: Re: [PATCH v2] sched/core: Don't use dying mm as active_mm of kthreads Message-ID: <20190729142756.GF31425@hirez.programming.kicks-ass.net> References: <20190727171047.31610-1-longman@redhat.com> <20190729085235.GT31381@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190729085235.GT31381@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 29, 2019 at 10:52:35AM +0200, Peter Zijlstra wrote: > On Sat, Jul 27, 2019 at 01:10:47PM -0400, Waiman Long wrote: > > It was found that a dying mm_struct where the owning task has exited > > can stay on as active_mm of kernel threads as long as no other user > > tasks run on those CPUs that use it as active_mm. This prolongs the > > life time of dying mm holding up memory and other resources like swap > > space that cannot be freed. > > Sure, but this has been so 'forever', why is it a problem now? > > > Fix that by forcing the kernel threads to use init_mm as the active_mm > > if the previous active_mm is dying. > > > > The determination of a dying mm is based on the absence of an owning > > task. The selection of the owning task only happens with the CONFIG_MEMCG > > option. Without that, there is no simple way to determine the life span > > of a given mm. So it falls back to the old behavior. > > > > Signed-off-by: Waiman Long > > --- > > include/linux/mm_types.h | 15 +++++++++++++++ > > kernel/sched/core.c | 13 +++++++++++-- > > mm/init-mm.c | 4 ++++ > > 3 files changed, 30 insertions(+), 2 deletions(-) > > > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > index 3a37a89eb7a7..32712e78763c 100644 > > --- a/include/linux/mm_types.h > > +++ b/include/linux/mm_types.h > > @@ -623,6 +623,21 @@ static inline bool mm_tlb_flush_nested(struct mm_struct *mm) > > return atomic_read(&mm->tlb_flush_pending) > 1; > > } > > > > +#ifdef CONFIG_MEMCG > > +/* > > + * A mm is considered dying if there is no owning task. > > + */ > > +static inline bool mm_dying(struct mm_struct *mm) > > +{ > > + return !mm->owner; > > +} > > +#else > > +static inline bool mm_dying(struct mm_struct *mm) > > +{ > > + return false; > > +} > > +#endif > > + > > struct vm_fault; > > Yuck. So people without memcg will still suffer the terrible 'whatever > it is this patch fixes'. Also; why then not key off that owner tracking to free the resources (and leave the struct mm around) and avoid touching this scheduling hot-path ?