Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1357238pxy; Thu, 6 May 2021 06:29:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVvRZNFLko76zu1AHB193xeTndOmiereGGqAWpiptVe87Nhk5dklUPt5mcxctF1yf1Rw1e X-Received: by 2002:a17:906:33d8:: with SMTP id w24mr4356019eja.28.1620307740094; Thu, 06 May 2021 06:29:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620307740; cv=none; d=google.com; s=arc-20160816; b=B6a7F6tcWQEii6nlTOK2a5ADLBk5LBPFwQGtcvICEP4MIqQrKv5YafgT+bSVBGm+OB JSWZ80CUAilXnGyg9NSDL1jJaXFIB9YJ7++4xJdvEmN1NUbxRmIw9CHIaRmC+YT4Z57b EL/ZKOSo/XIyOFhIe6spUfCzXWiBb5JUwacU6eLWLXlPSwCeXvSsF9QXD2XH101LSIcK 5KYOfLseM0TAHMCgQb9KobUamcUfrf57hWaSxoKZifCoOifoHSVCYSFbwkSUTmXt2sRm g+5Ed5m4/Sl6t2m4Uw6jb6u8kEon2wh2C6gFMafkp0CGYuvB1BKMpQ7Zrb8RvnHIQgBN /yFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:message-id; bh=DigP32A8sY+oWmdNIRY7TUQFF1cMJDjMtTC/QJirlIQ=; b=ziLwLR+lCh+j+yd5RsVYeLGeB5v0u+1z9AZVfuRGVUVG42pKh1Jdq8axzEMqb5RuZi 4erBGwaiIkPNtUmJEWr89+hEwZ9hrfBY1ITDs+ExWy7N0+F8N48JfwZ82bLQMul4LjwO RnjpeqkXbAr2pydJyTPEPXGO0M8R6D7TRks8ebxpaqDMUsdABRLJULdyPE3qD88PLTh7 wS4Owpy1w2yTXh0A8whiZzahdfEnUIg+xzBIOmPqDxOF5RJ66GhE15tD02+XsjbSolUi cNa+0mxOIwVhsD1nrdv/DqoXcp4mpu55eZlwYpUpC+e6LBxo4bnkMG/76bFogleccxIY Vxbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn13si2401435edb.270.2021.05.06.06.28.34; Thu, 06 May 2021 06:29:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233890AbhEFN2e (ORCPT + 99 others); Thu, 6 May 2021 09:28:34 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:36323 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233811AbhEFN2d (ORCPT ); Thu, 6 May 2021 09:28:33 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4FbZBW72S8z9sVL; Thu, 6 May 2021 15:27:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FUbtJ3WmSgka; Thu, 6 May 2021 15:27:31 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4FbZBW68cWz9sV0; Thu, 6 May 2021 15:27:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B31AF8B801; Thu, 6 May 2021 15:27:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id BIwZu-HeAFJI; Thu, 6 May 2021 15:27:31 +0200 (CEST) Received: from po15610vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6C6798B800; Thu, 6 May 2021 15:27:31 +0200 (CEST) Received: by po15610vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 455096489F; Thu, 6 May 2021 13:27:31 +0000 (UTC) Message-Id: <848f18d213b8341939add7302dc4ef80cc7a12e3.1620307636.git.christophe.leroy@csgroup.eu> From: Christophe Leroy Subject: [PATCH] powerpc/32s: Speed up likely path of kuap_update_sr() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 6 May 2021 13:27:31 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In most cases, kuap_update_sr() will update a single segment register. We know that first update will always be done, if there is no segment register to update at all, kuap_update_sr() is not called. Avoid recurring calculations and tests in that case. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/32/kup.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/32/kup.h b/arch/powerpc/include/asm/book3s/32/kup.h index 1670dfe9d4f1..c1f7c2e625a6 100644 --- a/arch/powerpc/include/asm/book3s/32/kup.h +++ b/arch/powerpc/include/asm/book3s/32/kup.h @@ -15,11 +15,13 @@ static inline void kuap_update_sr(u32 sr, u32 addr, u32 end) { addr &= 0xf0000000; /* align addr to start of segment */ barrier(); /* make sure thread.kuap is updated before playing with SRs */ - while (addr < end) { + for (;;) { mtsr(sr, addr); + addr += 0x10000000; /* address of next segment */ + if (addr >= end) + break; sr += 0x111; /* next VSID */ sr &= 0xf0ffffff; /* clear VSID overflow */ - addr += 0x10000000; /* address of next segment */ } isync(); /* Context sync required after mtsr() */ } -- 2.25.0