Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3775747ybi; Mon, 29 Jul 2019 12:24:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyD4yXVegHH4m/ppG7+Sr2295rBm7VD1NGa6osOHJ8vnjYdk+B8FZSAdhz+/uSE0ds7e/om X-Received: by 2002:a17:902:684:: with SMTP id 4mr111799142plh.138.1564428248306; Mon, 29 Jul 2019 12:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428248; cv=none; d=google.com; s=arc-20160816; b=cEtiQ0VtKgInD5wUIZy0jk22i+fj5GBzVF6iQBSKkt3oTVgWPj06lGsM3Q6l9lw679 XkoA9gJMTfKoQ4RbxFd8UXdjgIQ1aBDF8i5l8tMHSuq10pEkuu0fEt4NrxWWsHrELGvL jqhFz7TuAejGgvLZ9m0S2aBMY3MognCwlv6DYKiGhSKi4PXiXJ2HyZguxDVI2KROj8OD Cd+lwcplxqymOxpd5yzYKXoC/Z6xPMoA7yW5iTh/s1dAXInXSnSqUDpT+1XZfGacLrYz R+q1YIQRTUS1nAddXC9p62ZIdmkH18+8ALAe67vJIJ5E+PjRs8QbGC+E3enULaIOalwR EQ+A== 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=kTRobX83JJeBQVwIveyy0p4dpxyy2pND5viOSWqwu2A=; b=laAIqYbbRZn8ed76sVgFP1FoSPSYLekxxeDpjQZ7aJwN3VWqfcVC2R1TDIEiIvtWab 0PjZxKpYux66nwYZMF/DshEaGCZAxZdRJ9YI7+1AI1QQvifmMkmwTj0xmXGQbDdv2f6a 5plBrukrlm4Aq/sxEiD2ucpRDqGbfEkr0fdlVsVT1DOppgS3zQQxc8SXaazVGFfVMVVN Dpf4UqxDE1ETrX01kc8x9O/u1FXVZokeKsq2Dgik/Wa2IEHJlytJcKFdU763V7JJ+813 ftLqFwyUkTvPq5WtO6HAX5LcJmmz4ZMpFvkaFRLxZcDTIGO3ZqFR4N98Fq/8FO9jVXJy 0Jiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="USrawQ6/"; 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 z186si26989912pgd.162.2019.07.29.12.23.53; Mon, 29 Jul 2019 12:24:08 -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=bombadil.20170209 header.b="USrawQ6/"; 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 S1728749AbfG2Pi3 (ORCPT + 99 others); Mon, 29 Jul 2019 11:38:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:47720 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725209AbfG2Pi3 (ORCPT ); Mon, 29 Jul 2019 11:38:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=kTRobX83JJeBQVwIveyy0p4dpxyy2pND5viOSWqwu2A=; b=USrawQ6/HCifS+n9zc9f7rRgp SS5hThycZpx1nxHNxbRjjHd58Mq1C1l4w9QEKwwQNaiogsS9aukVbw35Ie8ufchGdx5QtTCUwFcl3 FfwbK5zDhfFPOG9/uFIYxpbEjq5att4KMnfsyy6QymNjukfSwlA81zJW06X6fuXkyw7GTf3MgE/kA zTAuXCQPr7aW2ZsXCalOGcV2p+X5RugQ0DbW7hKyFEYY5E78e/SGZcaC66r+TSJ8jNyEz/cfCvgHI qo6m3Yc0CFtAMw4MfaFMG+zOuLdhKL8rgV3QbYm+hMBMow6/yIR4aMeSHHAm+RQP9Alg2UCMNJ/r6 cGy0ZFNJQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hs7jH-0001Zh-St; Mon, 29 Jul 2019 15:38:28 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4705420AFFEAE; Mon, 29 Jul 2019 17:38:25 +0200 (CEST) Date: Mon, 29 Jul 2019 17:38:25 +0200 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Phil Auld , Will Deacon , Rik van Riel , Andy Lutomirski Subject: Re: [PATCH v2] sched/core: Don't use dying mm as active_mm of kthreads Message-ID: <20190729153825.GI31398@hirez.programming.kicks-ass.net> References: <20190727171047.31610-1-longman@redhat.com> <20190729085235.GT31381@hirez.programming.kicks-ass.net> <20190729142756.GF31425@hirez.programming.kicks-ass.net> <2bc722b9-3eff-6d99-4ee7-1f4cab8b6c21@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2bc722b9-3eff-6d99-4ee7-1f4cab8b6c21@redhat.com> 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 11:22:16AM -0400, Waiman Long wrote: > On 7/29/19 10:27 AM, Peter Zijlstra wrote: > > 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. But when you cannot find a new owner; you can start to strip mm_struct. That is, what's stopping you from freeing swap reservations when that happens? That is; I think the moment mm_users drops to 0, you can destroy the actual addres space. But you have to keep mm_struct around until mm_count goes to 0. This is going on the comments with mmget() and mmgrab(); they forever confuse me.