Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3755280imm; Mon, 30 Jul 2018 02:56:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf6tfctxGEQPTciZsNY57FF5nEA06gtAuoerzop2j2MribMTeQzmuXdFzLt26dEC2Lzz5Pp X-Received: by 2002:a65:5286:: with SMTP id y6-v6mr15809512pgp.65.1532944612088; Mon, 30 Jul 2018 02:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532944612; cv=none; d=google.com; s=arc-20160816; b=zhoK6cMeGqn8CraGauRN2+0ae9nLD111gKXbd9d8yijV5g+1mzo45VI9PxAzC3U7N3 ixroC8UzAV97vPzoKt+/784Ww+LEL0MfyDtQULLvhFkeDHKVFmZEiibhBRLlr7ISqCS9 G0s953yVRX5OW5P2G/y1TNiWkrE7zOEjBPZ8yfQEQVO5IDapI+WYf67I+SccEBWgkR41 eb1PYPUXGl1vL+vwA0LBRsCTywEfONBe0y/blSdjtf2TIoKm+6M49sViKqm6CRSQPjqV S59B5uWT+0v3kLNETuh6IUCm6muuTuoBSee73eJqwSPLuqe8NpFsMBK0LyBoYlfPDX4P bqWw== 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:arc-authentication-results; bh=rYRMSz+HVK4nu0hq6MV3VwjWNnI+ajHDuoPoW28AXRo=; b=QikPIFaU5gFLcA8JjC9cHNQgxYug6VKH/gq5lUL5Di55EoYfWRE2FBIndndVyVdvfU M52e9ycWBrPVr6xuNEXF4AEwbiqq3LLL/QJp18fzd/K+IMEPy21JjkypJjJF090EQ6O0 Aoyg95r/nRxrgA4sCKj+vlDKGrTj6K2pkOh4NjADL3dDsjHJJBgjTqNSddfbEc59VzOo /GPEj2MzXmRu3XqaiNh19cZoAGRPkwMk31T85ghFsuiJgFMwDi/cRHD7Fs3g9OFGcA3N xdh7s613WkmAw+W0dOjrofO/2MTI6uCBswu16c/p6YAGBYUZ+J+6HnMj/1y7x6buHpzj nRXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=FUB37tPp; 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 m6-v6si10099307pgn.603.2018.07.30.02.56.37; Mon, 30 Jul 2018 02:56:52 -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=FUB37tPp; 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 S1726993AbeG3L3g (ORCPT + 99 others); Mon, 30 Jul 2018 07:29:36 -0400 Received: from merlin.infradead.org ([205.233.59.134]:41012 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726709AbeG3L3g (ORCPT ); Mon, 30 Jul 2018 07:29:36 -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=rYRMSz+HVK4nu0hq6MV3VwjWNnI+ajHDuoPoW28AXRo=; b=FUB37tPp56tHLNggLhGeDnm5b S4dP2Gk2oTB87ZThJXH4z5wovygsJFWXxkSYZRVQ+FYGnhrDy2huPPGkmdXjel5eAKZksWH/4Ruf0 Lx1Qpy/ujs6fC5bATZtygy7vH0SuXuqTB1T1TktQW8KBeLWW1WRGSalVURwLrk8Ep/fmqt201G9KQ VAid49MT8jGK9LmCX4I9H1V7ULOCqsXvKK/cDR5FpX5r5NgTCmgdt3dnkX5/YBUNoqzV2fvLr9Ujy M3QqU1Iat7bGvcZZttrdUNfq2A1Lk78+1q3z+X7m2gk8VGHW5Cy0ZOrqudzAhM9W/3+NY9qm1kZlT R7IKIkCXg==; 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.90_1 #2 (Red Hat Linux)) id 1fk4tO-0005Os-0j; Mon, 30 Jul 2018 09:55:06 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E338F202883BF; Mon, 30 Jul 2018 11:55:02 +0200 (CEST) Date: Mon, 30 Jul 2018 11:55:02 +0200 From: Peter Zijlstra To: Rik van Riel Cc: Andy Lutomirski , LKML , kernel-team , X86 ML , Vitaly Kuznetsov , Ingo Molnar , Mike Galbraith , Dave Hansen , Catalin Marinas , Benjamin Herrenschmidt Subject: Re: [PATCH v2 11/11] mm,sched: conditionally skip lazy TLB mm refcounting Message-ID: <20180730095502.GG2494@hirez.programming.kicks-ass.net> References: <20180728215357.3249-1-riel@surriel.com> <20180728215357.3249-11-riel@surriel.com> <20180729155452.37eddc11@imladris.surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180729155452.37eddc11@imladris.surriel.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 29, 2018 at 03:54:52PM -0400, Rik van Riel wrote: > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index c45de46fdf10..11724c9e88b0 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -2691,7 +2691,7 @@ static struct rq *finish_task_switch(struct task_struct *prev) > */ > if (mm) { > membarrier_mm_sync_core_before_usermode(mm); > - mmdrop(mm); > + drop_lazy_mm(mm); > } > if (unlikely(prev_state == TASK_DEAD)) { > if (prev->sched_class->task_dead) > @@ -2805,7 +2805,7 @@ context_switch(struct rq *rq, struct task_struct *prev, > */ > if (!mm) { > next->active_mm = oldmm; > - mmgrab(oldmm); > + grab_lazy_mm(oldmm); > enter_lazy_tlb(oldmm, next); > } else > switch_mm_irqs_off(oldmm, mm, next); What happened to the rework I did there? That not only avoided fiddling with active_mm, but also avoids grab/drop cycles for the other architectures when doing task->kthread->kthread->task things. I agree with Andy that if you avoid the refcount fiddling, then you should also not muck with active_mm. That is, if you keep active_mm for now (which seems a reasonable first step) then at least ensure you keep ->mm == ->active_mm at all times.