Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4586685rwd; Tue, 30 May 2023 07:23:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4g0HFcyGKf6pAUbWLevJcKxMASApckx2OxWupyEqOLU/Yr11nqEmVMem4abtjDZprlyJYV X-Received: by 2002:a05:6a20:7d86:b0:10a:c09c:bd with SMTP id v6-20020a056a207d8600b0010ac09c00bdmr3045726pzj.55.1685456586987; Tue, 30 May 2023 07:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685456586; cv=none; d=google.com; s=arc-20160816; b=MqYiAPlm14+YBB/QEspfOEp3PDyAjJl2S2P3c6t+ruNfb57SpBqnybAImqsZX2nKoG 8xHRrKkOBT7hxqA/YHsYW8MV+pT3ns6dzyZZIOX+0+zHIBwCeu4rzj1SJuthqESPC2uM SkFkxt2hXsLSWUFO59J77Y9YSOl1mEa1J/kJB5i3728UL0YQZ/CnirXAVbwcVVlYkhTs 6Qw14SaOIuLvXuSg3WJO9Mn2s5/Mww44SQaPoYxldOdAtpPlMxPey2x7x7kbXIiJqqKN C0zWvhpVhY7eUJQ5WKBZXBFhxLNCpVRguZokPNVi74VGlxxnKRE10ZwjCglWiGF3C9fF +taA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=wgNmlnzM68PDsJG+HcQuJljh3SnmTa2L0UPeNNGH4OE=; b=cce+gttiuUYP9ufaL24sUu7bp8njGyXikMPxKuQ7mw3x2V2nP85eM4+fQPC1Sj5dj+ W3Miq7wAU+11vgtyuYdUeT2CLGMzoM6JOdTaNRUlc+cNJ2rwTNFKGG87qZsV9ZvZ0XwS yW1zbxuM6yQpus5Xa6dmnF7Ns1BAgwAIquLSlVUgQHj0yAlh2QvRw8kT1Z2yfGXv8TLx T3EYtQRkoZGb2NG3euq+Sc1GYVsE8x3btJZVtUigjO7syyANQ+0XM0//LgxceY/Nkow6 KDiRNbDBfhp9NJkuipvyDiOjFYK9pfGt6OfrxwOsVvWlGirjgxEqb+fGq68ypT2BdiPN mixQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m16-20020a637d50000000b0053f01e23c47si10649567pgn.607.2023.05.30.07.22.54; Tue, 30 May 2023 07:23:06 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231728AbjE3NuZ (ORCPT + 99 others); Tue, 30 May 2023 09:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232716AbjE3NuI (ORCPT ); Tue, 30 May 2023 09:50:08 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56E89E8; Tue, 30 May 2023 06:50:05 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4QVtyb5x5Cz6D8wn; Tue, 30 May 2023 21:48:23 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 30 May 2023 14:50:02 +0100 Date: Tue, 30 May 2023 14:50:01 +0100 From: Jonathan Cameron To: Namhyung Kim CC: Liang Kan , , , , , , , , , , , Davidlohr Bueso , "Dave Jiang" , Stephane Eranian Subject: Re: [PATCH v7 4/5] perf: CXL Performance Monitoring Unit driver Message-ID: <20230530145001.00002560@Huawei.com> In-Reply-To: References: <20230526095824.16336-1-Jonathan.Cameron@huawei.com> <20230526095824.16336-5-Jonathan.Cameron@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.202.227.76] X-ClientProxiedBy: lhrpeml500002.china.huawei.com (7.191.160.78) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 Hi, Tidied up the typos. Thanks, > > +static int cxl_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node) > > +{ > > + struct cxl_pmu_info *info = hlist_entry_safe(node, struct cxl_pmu_info, node); > > + unsigned int target; > > + > > + if (info->on_cpu != cpu) > > + return 0; > > + > > + info->on_cpu = -1; > > + target = cpumask_any_but(cpu_online_mask, cpu); > > + if (target >= nr_cpu_ids) { > > + dev_err(info->pmu.dev, "Unable to find a suitable CPU\n"); > > + return 0; > > + } > > + > > + perf_pmu_migrate_context(&info->pmu, cpu, target); > > + info->on_cpu = target; > > + /* > > + * CPU HP lock is held so we should be guaranteed that this CPU hasn't yet > > + * gone away. > > + */ > > + WARN_ON(irq_set_affinity(info->irq, cpumask_of(target))); > > + > > + return 0; > > +} > > IIUC a CXL PMU hardware (say cxl_pmu_mem0.0) is shared across > all CPUs and it would return the same value when read from any CPU, > right? Correct, it will return the same value when used from any CPU. I'm not sure what issue you are indicating. My understanding is that, even for such cases, perf uses percpu variables that mean we still have to ensure that the interrupt handling occurs on the CPU we have migrated the context to. There are a lot of similar driver in perf already from a quick git grep cpumask_any_but\(cpu_online_mask, It might be nice to enable perf to operate for these devices without the percpu context though. I haven't looked into whether that is worth doing. Jonathan > > Thanks, > Namhyung > > > > + > > +static __init int cxl_pmu_init(void) > > +{ > > + int rc; > > + > > + rc = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, > > + "AP_PERF_CXL_PMU_ONLINE", > > + cxl_pmu_online_cpu, cxl_pmu_offline_cpu); > > + if (rc < 0) > > + return rc; > > + cxl_pmu_cpuhp_state_num = rc; > > + > > + rc = cxl_driver_register(&cxl_pmu_driver); > > + if (rc) > > + cpuhp_remove_multi_state(cxl_pmu_cpuhp_state_num); > > + > > + return rc; > > +} > > + > > +static __exit void cxl_pmu_exit(void) > > +{ > > + cxl_driver_unregister(&cxl_pmu_driver); > > + cpuhp_remove_multi_state(cxl_pmu_cpuhp_state_num); > > +} > > + > > +MODULE_LICENSE("GPL"); > > +MODULE_IMPORT_NS(CXL); > > +module_init(cxl_pmu_init); > > +module_exit(cxl_pmu_exit); > > +MODULE_ALIAS_CXL(CXL_DEVICE_PMU); > > -- > > 2.39.2 > > >