From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A53DC00144 for ; Fri, 29 Jul 2022 09:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235193AbiG2J6U (ORCPT ); Fri, 29 Jul 2022 05:58:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiG2J6S (ORCPT ); Fri, 29 Jul 2022 05:58:18 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 584F739BBC; Fri, 29 Jul 2022 02:58:16 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LvNDP3QxmzjXTx; Fri, 29 Jul 2022 17:55:17 +0800 (CST) Received: from [10.67.102.169] (10.67.102.169) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 29 Jul 2022 17:58:13 +0800 CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v11 2/8] hwtracing: hisi_ptt: Add trace function support for HiSilicon PCIe Tune and Trace device To: Greg KH References: <20220721130116.43366-1-yangyicong@huawei.com> <20220721130116.43366-3-yangyicong@huawei.com> <33f372f6-36bf-f84e-bca0-86347fa4d579@huawei.com> From: Yicong Yang Message-ID: Date: Fri, 29 Jul 2022 17:58:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ reply again in plain text, sorry for the wrong format ] On 2022/7/29 17:05, Greg KH wrote: > On Fri, Jul 29, 2022 at 03:29:14PM +0800, Yicong Yang wrote: >>>> + /* >>>> + * Handle the interrupt on the same cpu which starts the trace to avoid >>>> + * context mismatch. Otherwise we'll trigger the WARN from the perf >>>> + * core in event_function_local(). >>>> + */ >>>> + WARN_ON(irq_set_affinity(pci_irq_vector(hisi_ptt->pdev, HISI_PTT_TRACE_DMA_IRQ), >>>> + cpumask_of(cpu))); >>> >>> If this hits, you just crashed the machine :( >>> >> >> We'll likely to have a calltrace here without crash the machine and reboot in >> most time, unless user has set panic_on_warn. > > Again, please do not use WARN_ON for this, please read: > https://elixir.bootlin.com/linux/v5.19-rc8/source/include/asm-generic/bug.h#L74 > > If you want a traceback (what would you do with that?), then call the > function to give you that. Don't crash people's boxes. > ok, will change to a dev_warn/err() per documented. >>> Please properly recover from errors if you hit them, like this. Don't >>> just give up and throw a message to userspace and watch the machine >>> reboot with all data lost. >>> >>> Same for the other WARN_ON() instances here. Handle the error and >>> report it properly up the call chain. >>> >> >> The driver use WARN_ON() in two places, once in pmu::start() and another in cpu teardown's >> callback, both when the irq_set_affinity() failed. This is common to behave so when driver >> fails to set irq affinity in pmu::start() and cpu_teardown(): > > Don't repeat broken patterns please. > >> yangyicong@ubuntu:~/mainline_linux/linux/drivers$ grep -rn WARN_ON ./ | grep irq_set_affinity >> ./perf/arm_smmuv3_pmu.c:649: WARN_ON(irq_set_affinity(smmu_pmu->irq, cpumask_of(target))); >> ./perf/arm_smmuv3_pmu.c:895: WARN_ON(irq_set_affinity(smmu_pmu->irq, cpumask_of(smmu_pmu->on_cpu))); >> ./perf/arm-ccn.c:1214: WARN_ON(irq_set_affinity(ccn->irq, cpumask_of(dt->cpu))); >> ./perf/qcom_l2_pmu.c:796: WARN_ON(irq_set_affinity(cluster->irq, cpumask_of(cpu))); >> ./perf/qcom_l2_pmu.c:834: WARN_ON(irq_set_affinity(cluster->irq, cpumask_of(target))); >> ./perf/arm_dmc620_pmu.c:624: WARN_ON(irq_set_affinity(irq->irq_num, cpumask_of(target))); >> ./perf/fsl_imx8_ddr_perf.c:674: WARN_ON(irq_set_affinity(pmu->irq, cpumask_of(pmu->cpu))); >> ./perf/xgene_pmu.c:1793: WARN_ON(irq_set_affinity(xgene_pmu->irq, &xgene_pmu->cpu)); >> ./perf/xgene_pmu.c:1826: WARN_ON(irq_set_affinity(xgene_pmu->irq, &xgene_pmu->cpu)); >> ./perf/hisilicon/hisi_pcie_pmu.c:658: WARN_ON(irq_set_affinity(pcie_pmu->irq, cpumask_of(cpu))); >> ./perf/hisilicon/hisi_pcie_pmu.c:684: WARN_ON(irq_set_affinity(pcie_pmu->irq, cpumask_of(target))); >> ./perf/hisilicon/hisi_uncore_pmu.c:495: WARN_ON(irq_set_affinity(hisi_pmu->irq, cpumask_of(cpu))); >> ./perf/hisilicon/hisi_uncore_pmu.c:528: WARN_ON(irq_set_affinity(hisi_pmu->irq, cpumask_of(target))); > > Great, you can fix all of these up as well any time :) > will have a look on this. Thanks. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B7282C00144 for ; Fri, 29 Jul 2022 09:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:CC:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=GWGxfD1OjbVbZ2/AZSas4TaBZsTQgBQ1EGrlHKNCbnA=; b=cpSUTbdmW1Vo9Snc6jvdOPIclF VOdMHWZjsmzF+NJEjowdhBG6deV4tiL5RSVV8MoqKcsN//U9eYbmWASOJC+YkYY9YGNXk8oXyQtX2 AJnxToH0296mN3iu/YDFva9VhqyhGYzlWt5FFu8QDqP/tyHFKZAJvCdKUek3LR4e5ikF0e/JgjenG ib4+d/ITTMy1Nx2i0LhyD7EhmPvySSVuRQPiPUlVthhLcYiCoQr1nLYgWZH1TjMd/NNT+XuVMoUXI V+YYuUGTfIYBuaEQiOJDix2dJZie3c1UwXnq6/XJJjSpuhz0Sk+CTLd/oKsQMywkYGfchiZUsPeoZ BXdWfbtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHMlD-003w2s-Jb; Fri, 29 Jul 2022 09:58:23 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHMl9-003vzG-F8 for linux-arm-kernel@lists.infradead.org; Fri, 29 Jul 2022 09:58:22 +0000 Received: from canpemm500009.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LvNDP3QxmzjXTx; Fri, 29 Jul 2022 17:55:17 +0800 (CST) Received: from [10.67.102.169] (10.67.102.169) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 29 Jul 2022 17:58:13 +0800 CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v11 2/8] hwtracing: hisi_ptt: Add trace function support for HiSilicon PCIe Tune and Trace device To: Greg KH References: <20220721130116.43366-1-yangyicong@huawei.com> <20220721130116.43366-3-yangyicong@huawei.com> <33f372f6-36bf-f84e-bca0-86347fa4d579@huawei.com> From: Yicong Yang Message-ID: Date: Fri, 29 Jul 2022 17:58:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220729_025819_927463_4B686494 X-CRM114-Status: GOOD ( 14.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org [ reply again in plain text, sorry for the wrong format ] On 2022/7/29 17:05, Greg KH wrote: > On Fri, Jul 29, 2022 at 03:29:14PM +0800, Yicong Yang wrote: >>>> + /* >>>> + * Handle the interrupt on the same cpu which starts the trace to avoid >>>> + * context mismatch. Otherwise we'll trigger the WARN from the perf >>>> + * core in event_function_local(). >>>> + */ >>>> + WARN_ON(irq_set_affinity(pci_irq_vector(hisi_ptt->pdev, HISI_PTT_TRACE_DMA_IRQ), >>>> + cpumask_of(cpu))); >>> >>> If this hits, you just crashed the machine :( >>> >> >> We'll likely to have a calltrace here without crash the machine and reboot in >> most time, unless user has set panic_on_warn. > > Again, please do not use WARN_ON for this, please read: > https://elixir.bootlin.com/linux/v5.19-rc8/source/include/asm-generic/bug.h#L74 > > If you want a traceback (what would you do with that?), then call the > function to give you that. Don't crash people's boxes. > ok, will change to a dev_warn/err() per documented. >>> Please properly recover from errors if you hit them, like this. Don't >>> just give up and throw a message to userspace and watch the machine >>> reboot with all data lost. >>> >>> Same for the other WARN_ON() instances here. Handle the error and >>> report it properly up the call chain. >>> >> >> The driver use WARN_ON() in two places, once in pmu::start() and another in cpu teardown's >> callback, both when the irq_set_affinity() failed. This is common to behave so when driver >> fails to set irq affinity in pmu::start() and cpu_teardown(): > > Don't repeat broken patterns please. > >> yangyicong@ubuntu:~/mainline_linux/linux/drivers$ grep -rn WARN_ON ./ | grep irq_set_affinity >> ./perf/arm_smmuv3_pmu.c:649: WARN_ON(irq_set_affinity(smmu_pmu->irq, cpumask_of(target))); >> ./perf/arm_smmuv3_pmu.c:895: WARN_ON(irq_set_affinity(smmu_pmu->irq, cpumask_of(smmu_pmu->on_cpu))); >> ./perf/arm-ccn.c:1214: WARN_ON(irq_set_affinity(ccn->irq, cpumask_of(dt->cpu))); >> ./perf/qcom_l2_pmu.c:796: WARN_ON(irq_set_affinity(cluster->irq, cpumask_of(cpu))); >> ./perf/qcom_l2_pmu.c:834: WARN_ON(irq_set_affinity(cluster->irq, cpumask_of(target))); >> ./perf/arm_dmc620_pmu.c:624: WARN_ON(irq_set_affinity(irq->irq_num, cpumask_of(target))); >> ./perf/fsl_imx8_ddr_perf.c:674: WARN_ON(irq_set_affinity(pmu->irq, cpumask_of(pmu->cpu))); >> ./perf/xgene_pmu.c:1793: WARN_ON(irq_set_affinity(xgene_pmu->irq, &xgene_pmu->cpu)); >> ./perf/xgene_pmu.c:1826: WARN_ON(irq_set_affinity(xgene_pmu->irq, &xgene_pmu->cpu)); >> ./perf/hisilicon/hisi_pcie_pmu.c:658: WARN_ON(irq_set_affinity(pcie_pmu->irq, cpumask_of(cpu))); >> ./perf/hisilicon/hisi_pcie_pmu.c:684: WARN_ON(irq_set_affinity(pcie_pmu->irq, cpumask_of(target))); >> ./perf/hisilicon/hisi_uncore_pmu.c:495: WARN_ON(irq_set_affinity(hisi_pmu->irq, cpumask_of(cpu))); >> ./perf/hisilicon/hisi_uncore_pmu.c:528: WARN_ON(irq_set_affinity(hisi_pmu->irq, cpumask_of(target))); > > Great, you can fix all of these up as well any time :) > will have a look on this. Thanks. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel