From patchwork Wed Jul 26 18:02:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 9865565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 71054601A1 for ; Wed, 26 Jul 2017 18:03:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AE0A287B5 for ; Wed, 26 Jul 2017 18:03:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FB04287C8; Wed, 26 Jul 2017 18:03:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6E12287B5 for ; Wed, 26 Jul 2017 18:03:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750897AbdGZSDv (ORCPT ); Wed, 26 Jul 2017 14:03:51 -0400 Received: from mout.gmx.net ([212.227.15.15]:57127 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750867AbdGZSDu (ORCPT ); Wed, 26 Jul 2017 14:03:50 -0400 Received: from p100.box ([193.159.18.126]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0Lcj9b-1e2efB1k3z-00k7jk; Wed, 26 Jul 2017 20:02:54 +0200 Date: Wed, 26 Jul 2017 20:02:52 +0200 From: Helge Deller To: John David Anglin , linux-parisc@vger.kernel.org, James Bottomley Subject: Re: [PATCH] parisc: Optimize switch_mm Message-ID: <20170726180252.GA1129@p100.box> References: <16F63B59-7A36-48F0-A5C7-670CA2ED9DED@bell.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <16F63B59-7A36-48F0-A5C7-670CA2ED9DED@bell.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:7O5tlHQi38W8gCtduBAjGHM+zIcSBaisQ1QCLprC0h1LkIqmtvz BEBmfG45QvZXB46hioU/EBMnh7B42YgrTAobTHAN6PJ0yWO5ft1jEPDqR9R8xi13JJofvuZ 4byogk7RcpFSGIWzvkw6FsETcjUwGLwC+w+CdzZEeAPj20ZI48cOvOgwZJ7MAhup/lhwo/F 45noR0Lsm+56K84+HULCQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:ueeqkqqzz14=:E8qGqFxQwFv5xFbiMRFfF+ HvWg5wSb1zKGGssoAyBYYk5vWt6LMtInsl4wHU3NHgD9ThZ/nSlJu91YxDVCkwiY1TDEu3Luw ixYVVa8BrJEGNXd4Xd640eozSRV07VNUPe5pveGwy0IUYbK0b7iQtmPrnp4WnO+4eD3aC5XNZ 16LGCixWfD0CmUTMgW1bjdjMz1kK9fL14flQnm05InXP/c/yYqaNfob4aGIg0znnVNsa/Rf50 TGLVzF6jgTSvQOkO3gWKXEDFo1P2d9LTvR1DBQ0nOqFdgKOojZ/QieBdAcWtjDjO9sQiZ+GZV g5Mkdb2OMsOaQMVjavbA0L4HrzQhsoW3aN4bUL6eTJpf6qvh+9OCZmXkRM3A18Dv084qxElr2 OeBB+sKlNh3+TJU91g/EST2Mnna+7aIC6diiHdLtZ3cpfWH2GmMH4LXSt8OgxttmQiSjntpz+ IPWNJpgA1uSANvIHh7S2dI5yp0A62DFw2K3dYw6y+L/QCLYcGETNl3Uo2ol/c6kL5yak3+a5R gB54tFw/8AdjZ7mNzi2VNYDwBw0hECNMauwuA1TIbCsXTs9UkJHRLL4Fh/5UOtTZfPzBuoUsL HrerP6iJE4rCNuzCDq+r8ok67KRBeUM0q/oeBh/4bLroCm7qLPs0paPHaYj6FG/Q0Mg1gu2tq HI76Ox1/5p6BItnKh73FVGo7zWEZcHklah+UQ72hkNErKY3vnT868RHXSEnTmiw2Zb6vfDVAd dXfasAFKXpdMlp93zM9N2t9FlWkyPGxaDAkdweHSNRPNE206tl1nnrGoUEPV9A6SmZrrmxK5V MhwiH3YJhxwABR+NEgGHu575/Zv7g== Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * John David Anglin : > We only need to switch contexts when prev != next, and we don't need to disable interrupts > to do the check. > > Signed-off-by: John David Anglin > > > diff --git a/arch/parisc/include/asm/mmu_context.h b/arch/parisc/include/asm/mmu_context.h > index a81226257878..b1dc6e3f0dd0 100644 > --- a/arch/parisc/include/asm/mmu_context.h > +++ b/arch/parisc/include/asm/mmu_context.h > @@ -49,26 +49,19 @@ static inline void load_context(mm_context_t context) > mtctl(__space_to_prot(context), 8); > } > > -static inline void switch_mm_irqs_off(struct mm_struct *prev, > +static inline void switch_mm(struct mm_struct *prev, > struct mm_struct *next, struct task_struct *tsk) > { > + unsigned long flags; > + > if (prev != next) { > + local_irq_save(flags); > mtctl(__pa(next->pgd), 25); > load_context(next->context); > + local_irq_restore(flags); > } > } > > -static inline void switch_mm(struct mm_struct *prev, > - struct mm_struct *next, struct task_struct *tsk) > -{ > - unsigned long flags; > - > - local_irq_save(flags); > - switch_mm_irqs_off(prev, next, tsk); > - local_irq_restore(flags); > -} > -#define switch_mm_irqs_off switch_mm_irqs_off > - > #define deactivate_mm(tsk,mm) do { } while (0) > > static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next) Instead I'd then suggest the patch below. The if-clause in switch_mm_irqs_off() will then probably be optimized away by the compiler. --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/include/asm/mmu_context.h b/arch/parisc/include/asm/mmu_context.h index a812262..e4a6570 100644 --- a/arch/parisc/include/asm/mmu_context.h +++ b/arch/parisc/include/asm/mmu_context.h @@ -63,6 +63,9 @@ static inline void switch_mm(struct mm_struct *prev, { unsigned long flags; + if (prev == next) + return; + local_irq_save(flags); switch_mm_irqs_off(prev, next, tsk); local_irq_restore(flags);