Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3728973ybi; Mon, 29 Jul 2019 11:32:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFsFCnEBVKCHtukpdiURW+6CpXhzm4Cm6aLnw6ZE1RY9G3+6pz8PZojNgYF/W61mW6Cq8x X-Received: by 2002:aa7:81d4:: with SMTP id c20mr38238286pfn.235.1564425153690; Mon, 29 Jul 2019 11:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564425153; cv=none; d=google.com; s=arc-20160816; b=lQECV6Fsw8/r+3hNT8eL92HgQGNK3wjLGkuyOwEwC7HNHA6Ej2BYt4ar+GHH1SCqQe KsGdBYdNL4sl2iGqBJi1hzPWpNX/pLW1EYdxwjRGhGfmCVodpn+D439JCdhAQqo21X0P KvY0aZUX62ddgJd3Q9JQFo8ft3B804DDp/cfW80UgrzT/IploEQ6oVuGlcA4lVeJE8bE zvB+aDICmcrRWvyc2XdgpSc2RyvJ1zFZoPYPFPP76kUnSBSxr+25ZrTETckuzOSnJxrY oYndR8VcpJIvU+j4h5v8kgw8s1lHuIeLT9FVVtf4BeUt2/OWtSM1nTHSQSWfEGXhZAD2 a3cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=4IjsqtjQCWeJkRMu8+GmBdYpmkxRimt1RfXx+3B80zk=; b=f/K7iXQSLkCNo1PIWCPLNzBuzNjUlXJR5XfoDEkKSteyZqRC6Nv7g5qxEBQCCJ/c/n i9mEuusJwXstYXiYGJtsaBUvdKCVBYJfUQ7VY7hWPxCZiHK/iqwdHydSHJKzm64J2r5i ddYrRRjI1dOzg0MZlHc6F16iLGV1k0ln+FUcrIOhyn/SO4MhrbIBwLqQkVz5kGhih7fy tFYMEHF11AjIBPcilGBhIXvaKEfdHZS54X6x5FppgsAe9NPDQAqzoq1aTfuTi6z3Z61a I7klTyvFpPo4TFosBR0dyYGRsr4oI5P2LE1bplJ9JGdh3FLZmybqv4TXB98iQdSspRkj EgbA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o8si26261214pgc.179.2019.07.29.11.32.05; Mon, 29 Jul 2019 11:32:33 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387892AbfG2PWS (ORCPT + 99 others); Mon, 29 Jul 2019 11:22:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34034 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728023AbfG2PWR (ORCPT ); Mon, 29 Jul 2019 11:22:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F24B882EA; Mon, 29 Jul 2019 15:22:17 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-160.bos.redhat.com [10.18.17.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 017A85D6A0; Mon, 29 Jul 2019 15:22:16 +0000 (UTC) Subject: Re: [PATCH v2] sched/core: Don't use dying mm as active_mm of kthreads To: Peter Zijlstra Cc: Ingo Molnar , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Phil Auld References: <20190727171047.31610-1-longman@redhat.com> <20190729085235.GT31381@hirez.programming.kicks-ass.net> <20190729142756.GF31425@hirez.programming.kicks-ass.net> From: Waiman Long Organization: Red Hat Message-ID: <2bc722b9-3eff-6d99-4ee7-1f4cab8b6c21@redhat.com> Date: Mon, 29 Jul 2019 11:22:16 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190729142756.GF31425@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 29 Jul 2019 15:22:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/29/19 10:27 AM, Peter Zijlstra wrote: > 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 ? The resources are pinned by the reference count. Making a special case will certainly mess up the existing code. It is actually a problem for systems that are mostly idle. Only the kernel->kernel case needs to be updated. If the CPUs isn't busy running user tasks, a little bit more overhead shouldn't really hurt IMHO. Cheers, Longman