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 1B577D30004 for ; Fri, 18 Oct 2024 12:50:16 +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:MIME-Version:References:In-Reply-To:Message-ID:Subject:CC:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cdUMeUPbWFqqxjWrw2nhvaZWYWFBjXs2fwFXNTbEmfg=; b=fNAqwmWd2g53UehGzG6KzdnRZO KzNHAS+5Gb9fh/mjX4Hat3DwIFlwn6TT2gFPmpbDMyRKQaxiCXFBlpHU5ge1EgHoqPI5In9cgICyJ 3A/bm5Rd5o43/TVR14nbQkj1atnD9HtkW95fwyRiyF3K9fJXGJKCa87aXHlirVPTly4bElTTB71VQ ab7lTrEC/hR1GdLVhdLVQ9XEbkekBrGyB4Zdu9qnOXm5m0wijviksBcSW1vgLgGms+TbxpFPSzlNA D7kvVQuLFaCvr17jUO85LgPWtnI+sMdQYtERjpg2T6b9fY9aSsXnuk0fs0S9JbI7aXTAKGAdLHYG8 pFAAogtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1mQf-00000000nC4-06nF; Fri, 18 Oct 2024 12:50:05 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1mPC-00000000n1I-2woG for linux-arm-kernel@lists.infradead.org; Fri, 18 Oct 2024 12:48:36 +0000 Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XVPXC6xG4z6J85l; Fri, 18 Oct 2024 20:43:55 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id E0B37140B38; Fri, 18 Oct 2024 20:48:28 +0800 (CST) Received: from localhost (10.203.177.66) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 18 Oct 2024 14:48:28 +0200 Date: Fri, 18 Oct 2024 13:48:26 +0100 From: Jonathan Cameron To: Yicong Yang CC: , , , , , , , Subject: Re: [PATCH 2/8] drivers/perf: hisi: Improve the detection of associated CPUs Message-ID: <20241018134826.00000841@Huawei.com> In-Reply-To: <20241018095745.57057-3-yangyicong@huawei.com> References: <20241018095745.57057-1-yangyicong@huawei.com> <20241018095745.57057-3-yangyicong@huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.177.66] X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To frapeml500008.china.huawei.com (7.182.85.71) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241018_054835_066257_9400B341 X-CRM114-Status: GOOD ( 24.29 ) 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 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. > + */ > + 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); > + }