Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp560923pxf; Thu, 8 Apr 2021 08:32:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXNdHCebJ8+uFTnZRXC4pnNmVQF1PfywjyaglE3OLqN7qvGJw/KfYy1Itywppq81gZCTmd X-Received: by 2002:a17:90b:4a52:: with SMTP id lb18mr8992589pjb.1.1617895924159; Thu, 08 Apr 2021 08:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617895924; cv=none; d=google.com; s=arc-20160816; b=EN7aui1hTD4cQSRx/nD5R2xGC+tI1XjgHSXd1a+vyr40ZPXBLqHAQ1Ykq4WwqApAzE 2Gtr9+/I3S7K2EP4qthCjkm1BHVfOwIJArCphBjPPaV/nA9H+811sPbAlGCs4OfTmV6h a6JMHQkaQMEvsQNZiU0Yy5WAa6BUKmlCjUl0i1Gcb516B2WueubLx9QdeoC3GnFFX0ET 3E9ZNnYwMLDz+ANJ6QYpP1y4uyIuTRdhT9lEGNUQaVt2bcwwjadelYnH7dv2KtowpVX6 rCJ4FgUuZ3OgSnTOnKr9g3HsXXlFDDBOilBQ9sWQMvlQSUCQNHHsbrzoXUdCqcZWZgXt obPA== 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:references:in-reply-to :message-id; bh=M7FJWAEvFH0qKQYdTC0AnmcbzJiifz8OHB9Cwex0vB8=; b=ZBW91foqhAd0mC7+be1WLrY5KPb7I/7oGpnFCDUIsZEahUswniQerpeWjmCG75VbO2 XNG1sYu2e6QUzpRnHHmaXM/UF77QEXj/LlTe6UDviUPma1feDlHe2F+h57NQby9rex0p i6oEhDa+umH1My04InTaJdcUVxeJPVbtoNe2zIyE3DWOdLV2Ug5hPxvqU1Z4ETxw01Gb mpbHvirY30lqgqIRGi/BadegoPuUXHjP+lDtVv9Ze2u9UXv9eWKSKN8H5caDBr3y7DQj Xc6FUV3BwSNFMTzkevmSAILfCr2Hoqd2phsbzs7FLHLoWrqzIqeUcTJbrQvsGpKP9OLV nMfQ== 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 60si27177431plc.296.2021.04.08.08.31.51; Thu, 08 Apr 2021 08:32:04 -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 S232116AbhDHPbM (ORCPT + 99 others); Thu, 8 Apr 2021 11:31:12 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:11667 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232021AbhDHPal (ORCPT ); Thu, 8 Apr 2021 11:30:41 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4FGQFJ0V0Wz9txf8; Thu, 8 Apr 2021 17:30:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id NSCVrtUycyuL; Thu, 8 Apr 2021 17:30:28 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4FGQFH6pCXz9txf2; Thu, 8 Apr 2021 17:30:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 82E198B7D4; Thu, 8 Apr 2021 17:30:29 +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 lQM7cJNku8cq; Thu, 8 Apr 2021 17:30:29 +0200 (CEST) Received: from po16121vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4B97C8B7D1; Thu, 8 Apr 2021 17:30:29 +0200 (CEST) Received: by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 27544679BA; Thu, 8 Apr 2021 15:30:29 +0000 (UTC) Message-Id: In-Reply-To: <7bf6f1600acad146e541a4e220940062f2e5b03d.1617895813.git.christophe.leroy@csgroup.eu> References: <7bf6f1600acad146e541a4e220940062f2e5b03d.1617895813.git.christophe.leroy@csgroup.eu> From: Christophe Leroy Subject: [PATCH v2 5/9] powerpc/mem: Optimise flush_dcache_icache_hugepage() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 8 Apr 2021 15:30:29 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org flush_dcache_icache_hugepage() is a static function, with only one caller. That caller calls it when PageCompound() is true, so bugging on !PageCompound() is useless if we can trust the compiler a little. Remove the BUG_ON(!PageCompound()). The number of elements of a page won't change over time, but GCC doesn't know about it, so it gets the value at every iteration. To avoid that, call compound_nr() outside the loop and save it in a local variable. Whether the page is a HIGHMEM page or not doesn't change over time. But GCC doesn't know it so it does the test on every iteration. Do the test outside the loop. When the page is not a HIGHMEM page, page_address() will fallback on lowmem_page_address(), so call lowmem_page_address() directly and don't suffer the call to page_address() on every iteration. Signed-off-by: Christophe Leroy --- arch/powerpc/mm/cacheflush.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/mm/cacheflush.c b/arch/powerpc/mm/cacheflush.c index 811045c50d82..3268a3e55c3f 100644 --- a/arch/powerpc/mm/cacheflush.c +++ b/arch/powerpc/mm/cacheflush.c @@ -162,14 +162,14 @@ static void __flush_dcache_icache(void *p) static void flush_dcache_icache_hugepage(struct page *page) { int i; + int nr = compound_nr(page); void *start; - BUG_ON(!PageCompound(page)); - - for (i = 0; i < compound_nr(page); i++) { - if (!PageHighMem(page)) { - __flush_dcache_icache(page_address(page+i)); - } else { + if (!PageHighMem(page)) { + for (i = 0; i < nr; i++) + __flush_dcache_icache(lowmem_page_address(page + i)); + } else { + for (i = 0; i < nr; i++) { start = kmap_atomic(page+i); __flush_dcache_icache(start); kunmap_atomic(start); -- 2.25.0