Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1255347imw; Tue, 5 Jul 2022 06:30:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tzH8pZHhRl8y6yG/jo1sOJxWFI0HVwv3D9Y2XgImB4EgBpnUcuEgApZjkCKCRIvsOFWxyK X-Received: by 2002:a17:906:794f:b0:722:e857:1a8f with SMTP id l15-20020a170906794f00b00722e8571a8fmr33455210ejo.494.1657027856937; Tue, 05 Jul 2022 06:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657027856; cv=none; d=google.com; s=arc-20160816; b=AQg2gK0IJFeqbUo8APQVySUr2YVZlDG5uOdSQNzrLQsm4gmgs71+WBEI20yeToNRxS t+SK+1DTcWBoKoXz0JdCHKUI4o4+ZFQvwupvu7Y3iCqPH7AIf9VeJRNwoyy+yZS5MVct uz2SKy5vt4d7mzfwEMuF0LVSeXAaekS0Q5Wtd4bP+AU7RCrbPP7ez1whwwlBPCZEXEaQ SZaF1UCbm1uwwRjBSWftwiTpwphQ011MYUD/g7xgUn/FgZL1V7f+TQ3TBCLwGvpweVVh 5ZrGpz86qjWcFA9k22XFL7pENFqpeWSOTyeNXqMRyIIu+Tgf+ZuwPQsxBWy+NRgiQ5Q2 Mwsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qcRGTvpcScsDbmg0WPb9/MNtF9nWUG7x3wl4FjsmPnI=; b=ItTqBobo67rz2m6w4AMvksgSQA0eypR14dCpQimFLuateneJEm6nuOYsjPwSrw2TGA EWGYyoYjhH8GqhAn8o2iElSpr5gqU2T8ofOw6v6N8FmsRqDa0ClBOhnV5985Rd2oO8ka EYHpIT616jyUj5rThYlcgui5J/8/wrJ6Z49Ee+shL5vaOpz8+ZfXyrUNBjCdqfoKHFl6 EUv7Lpx/JKM3PQ6z1+MkcWTm+xpSWkx9ldYjtG4hOBog/7Y8VX/mqGgwb5UGlz/vkTUJ reRFP3wpbSJ0/Rc4MmEIYXv3C6W68R25cSyC4I1uLMO4AlcgKrij21kfllJs60s9ygjj deWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qB1l+Ujp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ez17-20020a056402451100b0043a3f424e00si8629946edb.390.2022.07.05.06.30.31; Tue, 05 Jul 2022 06:30:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qB1l+Ujp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234174AbiGEMG7 (ORCPT + 99 others); Tue, 5 Jul 2022 08:06:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233719AbiGEMEH (ORCPT ); Tue, 5 Jul 2022 08:04:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 532BB186E5; Tue, 5 Jul 2022 05:04:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E330261876; Tue, 5 Jul 2022 12:04:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9C35C341C7; Tue, 5 Jul 2022 12:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657022640; bh=SBGXnzZvGHHwCV+Kok1/N8kVkHOVldkENMvkMEhVYh8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qB1l+Ujp6K2mjduK8ljS/GzuMq42E75odaZOH2pNC260T3iMwzNjoF6n2wwL0wkmH Lis8lplvjQwMBXB7VCXHJ6HsUjXG3gMBioeWKU2QM6SmQaXQhqIdUoxJuDhjrqwvLo euaDIUN17UoIQ8wsS4sFi/UwvUxo4Gb4KJNrdAew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tao Liu , Max Gurtovoy , Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 5.4 16/58] linux/dim: Fix divide by 0 in RDMA DIM Date: Tue, 5 Jul 2022 13:57:52 +0200 Message-Id: <20220705115610.721038328@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220705115610.236040773@linuxfoundation.org> References: <20220705115610.236040773@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tao Liu commit 0fe3dbbefb74a8575f61d7801b08dbc50523d60d upstream. Fix a divide 0 error in rdma_dim_stats_compare() when prev->cpe_ratio == 0. CallTrace: Hardware name: H3C R4900 G3/RS33M2C9S, BIOS 2.00.37P21 03/12/2020 task: ffff880194b78000 task.stack: ffffc90006714000 RIP: 0010:backport_rdma_dim+0x10e/0x240 [mlx_compat] RSP: 0018:ffff880c10e83ec0 EFLAGS: 00010202 RAX: 0000000000002710 RBX: ffff88096cd7f780 RCX: 0000000000000064 RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000001 RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 000000001d7c6c09 R13: ffff88096cd7f780 R14: ffff880b174fe800 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff880c10e80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000a0965b00 CR3: 000000000200a003 CR4: 00000000007606e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: ib_poll_handler+0x43/0x80 [ib_core] irq_poll_softirq+0xae/0x110 __do_softirq+0xd1/0x28c irq_exit+0xde/0xf0 do_IRQ+0x54/0xe0 common_interrupt+0x8f/0x8f ? cpuidle_enter_state+0xd9/0x2a0 ? cpuidle_enter_state+0xc7/0x2a0 ? do_idle+0x170/0x1d0 ? cpu_startup_entry+0x6f/0x80 ? start_secondary+0x1b9/0x210 ? secondary_startup_64+0xa5/0xb0 Code: 0f 87 e1 00 00 00 8b 4c 24 14 44 8b 43 14 89 c8 4d 63 c8 44 29 c0 99 31 d0 29 d0 31 d2 48 98 48 8d 04 80 48 8d 04 80 48 c1 e0 02 <49> f7 f1 48 83 f8 0a 0f 86 c1 00 00 00 44 39 c1 7f 10 48 89 df RIP: backport_rdma_dim+0x10e/0x240 [mlx_compat] RSP: ffff880c10e83ec0 Fixes: f4915455dcf0 ("linux/dim: Implement RDMA adaptive moderation (DIM)") Link: https://lore.kernel.org/r/20220627140004.3099-1-thomas.liu@ucloud.cn Signed-off-by: Tao Liu Reviewed-by: Max Gurtovoy Acked-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- include/linux/dim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/include/linux/dim.h +++ b/include/linux/dim.h @@ -17,7 +17,7 @@ * We consider 10% difference as significant. */ #define IS_SIGNIFICANT_DIFF(val, ref) \ - (((100UL * abs((val) - (ref))) / (ref)) > 10) + ((ref) && (((100UL * abs((val) - (ref))) / (ref)) > 10)) /** * Calculate the gap between two values.