From patchwork Fri Apr 23 08:35:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhouchuangao X-Patchwork-Id: 12219893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08627C433B4 for ; Fri, 23 Apr 2021 08:35:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2B5F61459 for ; Fri, 23 Apr 2021 08:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241568AbhDWIfy (ORCPT ); Fri, 23 Apr 2021 04:35:54 -0400 Received: from mail-m118208.qiye.163.com ([115.236.118.208]:50452 "EHLO mail-m118208.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241550AbhDWIfx (ORCPT ); Fri, 23 Apr 2021 04:35:53 -0400 Received: from ubuntu.localdomain (unknown [36.152.145.182]) by mail-m118208.qiye.163.com (Hmail) with ESMTPA id D00C1E0141; Fri, 23 Apr 2021 16:35:15 +0800 (CST) From: zhouchuangao To: Huacai Chen , Aleksandar Markovic , Thomas Bogendoerfer , linux-mips@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: zhouchuangao Subject: [PATCH] mips/kvm: Use BUG_ON instead of if condition followed by BUG Date: Fri, 23 Apr 2021 01:35:09 -0700 Message-Id: <1619166910-70744-1-git-send-email-zhouchuangao@vivo.com> X-Mailer: git-send-email 2.7.4 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZQ0kZSlYdSUNJShodSE4ZTBlVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 hKTFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NBQ6ISo5LT8VOAxWOjYhS00d QhQaCkNVSlVKTUpCSk1NQkpNSE5NVTMWGhIXVQETFA4YEw4aFRwaFDsNEg0UVRgUFkVZV1kSC1lB WUhNVUpOSVVKT05VSkNJWVdZCAFZQUpMQks3Bg++ X-HM-Tid: 0a78fdde6dbf2c17kusnd00c1e0141 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org BUG_ON uses unlikely in if(), it can be optimized at compile time. Usually, the condition in if() is not satisfied. In my opinion, this can improve the efficiency of the multi-stage pipeline. Signed-off-by: zhouchuangao --- arch/mips/kvm/tlb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/mips/kvm/tlb.c b/arch/mips/kvm/tlb.c index 1088114..a3b50d5 100644 --- a/arch/mips/kvm/tlb.c +++ b/arch/mips/kvm/tlb.c @@ -58,8 +58,7 @@ static int _kvm_mips_host_tlb_inv(unsigned long entryhi) tlb_probe_hazard(); idx = read_c0_index(); - if (idx >= current_cpu_data.tlbsize) - BUG(); + BUG_ON(idx >= current_cpu_data.tlbsize); if (idx >= 0) { write_c0_entryhi(UNIQUE_ENTRYHI(idx));