Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4152222imm; Mon, 30 Jul 2018 09:29:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfT+bssnW9pLxThX7bwKXEn5xnWj2Lm5M93OaPtLPgbofTPv63uidQX6e8usuLDvEqLD7Bx X-Received: by 2002:a17:902:8d98:: with SMTP id v24-v6mr17022984plo.250.1532968173630; Mon, 30 Jul 2018 09:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532968173; cv=none; d=google.com; s=arc-20160816; b=vlPLkWLJQlGKWxmML2Kl+E+A/RnqBROK6i+vap8FNn7Iu8thlUtIkbaewmHiQcGOlZ 5NEt5SzNTD/El7geHOX5B0NjEDmMfgIrU4J5jHLqwwLZbfKUKZ3CNBSopR726I+bItxM SoibdRBNrSzyvogZcdNYFfmosMeeCJTsU5lkPS7owvse8gnNjVhaC+spbAoajXC6Sm/B UCblsN+4Icw2yeyBDHe+g2OpPhlgEi5y9HBXMHkSbLAoCAv9MZe8DNyqWE/AzCxwkRuM /ZOMQOznbqiMhd3p4mbjc4SdVNlgL8lCjcLpYCWGwpfHk5b9gl16o72eafIH7afk8qGK El6A== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=8JNH8wh6d/fdHM0JnjGlO3CfUiTjQD86h9nXFLQokgo=; b=pulrBFfYG3AKP684qxvsfriBgRXs+uBvsBGG5tOyj1UL5PGQL2FTqNsofESiHiMB0K sYkg1nCdN3GxsREUZmoRGffQ/VFZdehFllQhkSszhgHX6EBT0r2PK6z1jC6Dnf70WmXL 37nxVzNXnxu6StC0imUkiUf0LGSRgocVy3FYxSiut+ejkv9v6BrfKnO0rGFShEnR24WV 5oCai7hymDqX+ja7i7ImHov/fHnqxtGQbLMf6pUgYE1r+7QIUnA7Hv6jaYbU759UdCkt BOo4jZbSOwG2sApGMbPJazJIPL/b39x8cUbwa7/jnJu81Qe01dwq0klwLNUVov6f6pnh Mt5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=XEozG7dk; 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 3-v6si1497020plz.351.2018.07.30.09.29.19; Mon, 30 Jul 2018 09:29: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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=XEozG7dk; 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 S1732037AbeG3SC6 (ORCPT + 99 others); Mon, 30 Jul 2018 14:02:58 -0400 Received: from merlin.infradead.org ([205.233.59.134]:46332 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbeG3SC6 (ORCPT ); Mon, 30 Jul 2018 14:02:58 -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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To: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=8JNH8wh6d/fdHM0JnjGlO3CfUiTjQD86h9nXFLQokgo=; b=XEozG7dkYw6Wox5VAJoMxBWaaA Wwuyuf96TQZ8HdC0rNBMHXltopMNO2B8SL6kHCxaBnOjzcZT1tJ/1LcehIvjm39qsCAnFM4fB48I5 Pkv34x8edSl9slopu8MauSf71kVZ5utVoAWJljVn3T9ilNdwn+4ysQKknmapUI8Qm05b77notg8UW NVJc4/HkoKlCvAsq+s5bqRveGQO3Cg5gzMZxnEosDnfUBznloF0WbyVLbFcFehUUeUG6VLpgzk59p TkE7uBMg4gcr74QuM+VSeEF6XrwvnMbDGg+Pm2CDnv8rN3cAwi8oxHvtL7JZ37Ahv9bpSOnhhJ4o/ ayhmiUbA==; 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 1fkB0Z-0007bn-GQ; Mon, 30 Jul 2018 16:26:55 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 11A9320275F3E; Mon, 30 Jul 2018 18:26:53 +0200 (CEST) Date: Mon, 30 Jul 2018 18:26:53 +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: <20180730162653.GM2494@hirez.programming.kicks-ass.net> References: <20180728215357.3249-1-riel@surriel.com> <20180728215357.3249-11-riel@surriel.com> <20180729155452.37eddc11@imladris.surriel.com> <20180730095502.GG2494@hirez.programming.kicks-ass.net> <1532961011.28585.30.camel@surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <1532961011.28585.30.camel@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 Mon, Jul 30, 2018 at 10:30:11AM -0400, Rik van Riel wrote: > > 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. >=20 > I don't think I saw that. I only saw your email from > July 20th with this fragment of code, which does not > appear to avoid the grab/drop cycles, and still fiddles > with active_mm: Yeah, that's it. Note how it doesn't do a grab+drop for kernel->kernel, where the current could would have. And also note that it only fiddles with active_mm if it does the grab+drop thing (the below should have s/ifdef/ifndef/ to make more sense maybe). So for ARCH_NO_ACTIVE_MM we never touch ->active_mm and therefore ->active_mm =3D=3D ->mm. > + /* > + * kernel -> kernel lazy + transfer active > + * user -> kernel lazy + mmgrab() active > + * > + * kernel -> user switch + mmdrop() active > + * user -> user switch > + */ > + if (!next->mm) { // to kernel > + enter_lazy_tlb(prev->active_mm, next); > + #ifndef ARCH_NO_ACTIVE_MM > + next->active_mm =3D prev->active_mm; > + if (prev->mm) // from user > + mmgrab(prev->active_mm); else prev->active_mm =3D NULL; > +#endif > + } else { // to user > + switch_mm_irqs_off(prev->active_mm, next->mm, next); > + #ifndef ARCH_NO_ACTIVE_MM > + if (!prev->mm) { // from kernel > + /* will mmdrop() in finish_task_switch(). */ > + rq->prev_mm =3D prev->active_mm; > + prev->active_mm =3D NULL; > + } > +#endif