Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6102023ybi; Wed, 31 Jul 2019 08:22:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmtOt+uI4FEVn3jtPYbP0zo57zxHNSx6VNN+xvZ9+nNEBRxOrL+y/8gxNU2nD61+dGW0Mk X-Received: by 2002:a17:902:b789:: with SMTP id e9mr117951481pls.294.1564586552699; Wed, 31 Jul 2019 08:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564586552; cv=none; d=google.com; s=arc-20160816; b=ZZY5GXVJkn6NK3LlfSpDLeZSFL6hfxVfdWWOV79lKJckpI7MT8ouQehAK7xY70+KX1 kPK/lYn3MlLR31OiUIeQC4r39nhClMBnq5icDajfWvA83DgOzqit18SeMX0O1RSfX8ff 27QxX7Nq0teQQYphaPq286e+UAnG418eZPj2veqHca5zIRRwnuSiwQtgUdgnI8UvBFUB LenNkb6MgsuQCB1DWpPHiVaSjNDiv1iRhv36W/gZC/vcKX5U7yPeqeIHkSomM9dhujac Eb0Um5BRat7KaB09IZz64+e7nfqgpxydZ/ph0PI0SifbujTqHxUnpDoMjAQcYvMI/BBP MEXg== 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=M9Vk9zC8MZ3jn34/iSg0F5Cu3MhGkHBnusKieaHiGuc=; b=tkjM7DSHvLC0uIAELZ+0Bjz0XG9/77WRbTK/AmCgRLyes7OIjDFMflNmktX0vRcgf3 mv6iPmqCncYrOAhfmfJOS3sLrofTaftQ9IkgoB/+i7vqV5c9/SmyibkLfMWiG9QMMc6L 7JWsZuJJ9d9noicnOADUIcwMLp1+LIU0oS8WjWhEfoham7bl0VEi7SMuYhSxy6OB3vXT pXih+p7wKZQngTR9bujzCdEF0LPbPrW0lpOD34NDwfLYZnnQK1AMULgs7EBhTnkhZnXR rrpzPGNK481ZRTSNswgeAnpmZ7xOHGnKXzwWl2EW2XKT4bFwILASav2N3JMeonZDQVa/ VWng== 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 v33si17398291pgk.152.2019.07.31.08.22.17; Wed, 31 Jul 2019 08:22:32 -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 S1726663AbfGaOPc (ORCPT + 99 others); Wed, 31 Jul 2019 10:15:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48324 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbfGaOPc (ORCPT ); Wed, 31 Jul 2019 10:15:32 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 019922BF02; Wed, 31 Jul 2019 14:15:32 +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 BD30E5D9C5; Wed, 31 Jul 2019 14:15:17 +0000 (UTC) Subject: Re: [PATCH v3] sched/core: Don't use dying mm as active_mm of kthreads To: Rik van Riel , Peter Zijlstra , Ingo Molnar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Phil Auld , Michal Hocko References: <20190729210728.21634-1-longman@redhat.com> <3e2ff4c9-c51f-8512-5051-5841131f4acb@redhat.com> <8021be4426fdafdce83517194112f43009fb9f6d.camel@surriel.com> From: Waiman Long Organization: Red Hat Message-ID: <01125822-c883-18ce-42e4-942a4f28c128@redhat.com> Date: Wed, 31 Jul 2019 10:15:17 -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: 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 31 Jul 2019 14:15:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/31/19 9:48 AM, Rik van Riel wrote: > On Tue, 2019-07-30 at 17:01 -0400, Waiman Long wrote: >> On 7/29/19 8:26 PM, Rik van Riel wrote: >>> On Mon, 2019-07-29 at 17:42 -0400, Waiman Long wrote: >>> >>>> What I have found is that a long running process on a mostly idle >>>> system >>>> with many CPUs is likely to cycle through a lot of the CPUs >>>> during >>>> its >>>> lifetime and leave behind its mm in the active_mm of those >>>> CPUs. My >>>> 2-socket test system have 96 logical CPUs. After running the test >>>> program for a minute or so, it leaves behind its mm in about half >>>> of >>>> the >>>> CPUs with a mm_count of 45 after exit. So the dying mm will stay >>>> until >>>> all those 45 CPUs get new user tasks to run. >>> OK. On what kernel are you seeing this? >>> >>> On current upstream, the code in native_flush_tlb_others() >>> will send a TLB flush to every CPU in mm_cpumask() if page >>> table pages have been freed. >>> >>> That should cause the lazy TLB CPUs to switch to init_mm >>> when the exit->zap_page_range path gets to the point where >>> it frees page tables. >>> >> I was using the latest upstream 5.3-rc2 kernel. It may be the case >> that >> the mm has been switched, but the mm_count field of the active_mm of >> the >> kthread is not being decremented until a user task runs on a CPU. > Is that something we could fix from the TLB flushing > code? > > When switching to init_mm, drop the refcount on the > lazy mm? > > That way that overhead is not added to the context > switching code. I have thought about that. That will require changing the active_mm of the current task to point to init_mm, for example. Since TLB flush is done in interrupt context, proper coordination between interrupt and process context will require some atomic instruction which will defect the purpose. Cheers, Longman