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 74E95D15D89 for ; Mon, 21 Oct 2024 12:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type: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=s7yqVW9ObP24xSAPLm9G/3V7Myga3VJ5eNorHlvsloU=; b=2dOLZb9QI9KHfjNP88ZT5gbtw7 WjxbIbUxSmZCd5CfCk2w6SmZjlAtLn6nJBdqlPTfAFP6a/OwFPLvfE9FUvugY4dt6d5YANiZkvZQP 0E43Nh7kvOtwFaijZueKEG/rTSii/x36yfnPkmfWihfqnUXyRRcJmoo76O36agEMaq1eQl899Xg1I nbIm654xXS067CMvvH7+IOEIb+NptudWHeviWJFrH/Z3E9f/sGyPu5BhryyU0wjVJ4+dTEbJThgGW uZr9xsUe7cdBty4ZtATp2nukzXpwaUVX2siQhwIKRc2Zc220dJUow8SlqsaO7M5K6iNaVQGt5Ow8f ZbxHSkrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2rzt-00000007LIs-2hX3; Mon, 21 Oct 2024 12:58:57 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2rj6-00000007ICh-2W1T for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2024 12:41:39 +0000 Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XXFHj3kX4zpWdr; Mon, 21 Oct 2024 20:39:29 +0800 (CST) Received: from kwepemd200014.china.huawei.com (unknown [7.221.188.8]) by mail.maildlp.com (Postfix) with ESMTPS id D97EA14022E; Mon, 21 Oct 2024 20:41:26 +0800 (CST) Received: from [10.67.121.177] (10.67.121.177) by kwepemd200014.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Mon, 21 Oct 2024 20:41:26 +0800 CC: , , , , , , , Subject: Re: [PATCH 2/8] drivers/perf: hisi: Improve the detection of associated CPUs To: Jonathan Cameron References: <20241018095745.57057-1-yangyicong@huawei.com> <20241018095745.57057-3-yangyicong@huawei.com> <20241018134826.00000841@Huawei.com> From: Yicong Yang Message-ID: Date: Mon, 21 Oct 2024 20:41:25 +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: <20241018134826.00000841@Huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.121.177] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemd200014.china.huawei.com (7.221.188.8) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_054137_194284_74A336CE X-CRM114-Status: GOOD ( 21.99 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2024/10/18 20:48, Jonathan Cameron wrote: > On Fri, 18 Oct 2024 17:57:39 +0800 > Yicong Yang wrote: > >> From: Yicong Yang >> >> Currently we detect the associated CPUs in the cpuhp online callback. > Should really avoid we in patch descriptions. > > Currently associated CPUs are detected in the cphup online callback. > etc > >> If the CPU's sccl_id or the ccl_id matches the PMU's, they're >> associated. There's an exception that some PMUs locate on the SICL >> and will match no CPUs. The events of these PMUs can be opened on >> any online CPUs. To handle this we just check whether the PMU's >> sccl_id is -1, if so we know it locates on SICL and make any CPU >> associated to it. >> >> This can be tweaked so in this patch just do the below changes: >> - If the PMU doesn't match any CPU then associated it to online CPUs >> - Choose the target CPU according to the NUMA affinity for opening >> events >> >> The function is implemented by hisi_pmu_init_associated_cpus() and >> invoked in hisi_pmu_init(). >> >> Also we maintained the associated_cpus with all the online CPUs. This >> is redundant since we'll always schedule the events on the online CPUs. >> Get rid of this and make associated_cpus contain offline CPUs as well. >> >> Signed-off-by: Yicong Yang > > One trivial comment inline otherwise LGTM > > Reviewed-by: Jonathan Cameron > >> /* >> * The Super CPU Cluster (SCCL) and CPU Cluster (CCL) IDs can be >> @@ -446,10 +467,6 @@ static bool hisi_pmu_cpu_is_associated_pmu(struct hisi_pmu *hisi_pmu) >> { >> int sccl_id, ccl_id; >> >> - /* If SCCL_ID is -1, the PMU is in a SICL and has no CPU affinity */ >> - if (hisi_pmu->sccl_id == -1) >> - return true; >> - >> if (hisi_pmu->ccl_id == -1) { >> /* If CCL_ID is -1, the PMU only shares the same SCCL */ >> hisi_read_sccl_and_ccl_id(&sccl_id, NULL); >> @@ -467,13 +484,29 @@ int hisi_uncore_pmu_online_cpu(unsigned int cpu, struct hlist_node *node) >> struct hisi_pmu *hisi_pmu = hlist_entry_safe(node, struct hisi_pmu, >> node); >> >> - if (!hisi_pmu_cpu_is_associated_pmu(hisi_pmu)) >> - return 0; >> + /* >> + * If the CPU is not in the associated_cpus, it maybe a new CPU we didn't >> + * access. Test whether it's associated or not. > it maybe a new CPU. Test whether... > > I'm not sure what the "didn't access" adds. I mean the newly onlined CPU hasn't been "tested" by us. Will refine the comments. Thanks. > >> + */ >> + if (!cpumask_test_cpu(cpu, &hisi_pmu->associated_cpus)) { >> + if (!hisi_pmu_cpu_is_associated_pmu(hisi_pmu)) >> + return 0; >> + >> + /* >> + * We found an associated CPU so we don't need to use the dummy >> + * associated CPUs. Update it. >> + */ >> + if (hisi_pmu->dummy_associated_cpus) { >> + cpumask_clear(&hisi_pmu->associated_cpus); >> + hisi_pmu->dummy_associated_cpus = false; >> + } >> >> - cpumask_set_cpu(cpu, &hisi_pmu->associated_cpus); >> + cpumask_set_cpu(cpu, &hisi_pmu->associated_cpus); >> + } > . >