Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp1158424rdb; Wed, 16 Aug 2023 03:40:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEjxWOWJhdVtbwR1GcNcXVKsZOv9/EhZl/xAVf3Y0FMp6ToZZAdUcENPtmYiOdrn7khJJR X-Received: by 2002:a17:906:8a51:b0:99d:f79c:38e3 with SMTP id gx17-20020a1709068a5100b0099df79c38e3mr524349ejc.19.1692182401679; Wed, 16 Aug 2023 03:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692182401; cv=none; d=google.com; s=arc-20160816; b=E/JWu+RuHNWmkaHlFdUnX1tZpAL+s37l2bDZXSZuHKP2cNHR2Dnz02t319iYvQuipR R9J4uT+IkB0KohMr88Z8k0oyP8rZ2CW6rxkg4oSK3u7hmcVtEaWHBTiHQMoomZnaLrbo KrhPOCEPatMQgMuDPSPzva91H8ppmgo53OO4id9PQoJYV8BPU3x9PQXn+l5HEuWUSDI8 nemu9o0pZpp5k1SNAcSW/PoQlBTsNo009wimGtmqecoYMj7Qg4PVGv0FXRrp1YSHyZGG fvker4BfOO4/sOaGyvYVR8ehVNe94D5uLsz5fQZ61Ox6IGCnFaPiGnQD38L1xLJOYytK zN1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:to:subject :cc; bh=HkUD8v453hNzz3V1wtIkfdsPtWhnkwYkMJ/HaUzLWGo=; fh=luxM+jII5o0rA4XCHcgMqisHnhR6AkH37AIauB3YlxQ=; b=QPvtfjc8usSpY5hiECwJbGoDmb67oBhPZef5c/O1jJTvuPCdctLbJu1liwvPaO3etD Li5NpYBRkP1rLoW2Ov/rKuAnpQ+1HRU1GZShAPh7FE5eU/B3OCZAN5dN9Qt/bkSaZVaL rb6TVI0Dz1GGnwX3oPx4xh6ptQ3tvFFNyuYtBdDvd/ylbpe7u0ETgSa2+OchKXMQKag6 er98BjRKs2kyZzyiawXRdoNfQPIWUWhiKK1FdRcdHGDsP7NqqiB3RqXQ6Ne3J4uUbeat N+sDKV/Bl1kc1lYAnovia8vHzQ596baxpFYM4t8DuhWrm8Gyt8GCuQC5A7i9Go4mtigF IwIw== 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 d16-20020a17090694d000b00991e694a0a2si10967931ejy.240.2023.08.16.03.39.36; Wed, 16 Aug 2023 03:40:01 -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 S237403AbjHONOu (ORCPT + 99 others); Tue, 15 Aug 2023 09:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237406AbjHONOp (ORCPT ); Tue, 15 Aug 2023 09:14:45 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8480F1999 for ; Tue, 15 Aug 2023 06:14:44 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RQBXf1NYRzrShH; Tue, 15 Aug 2023 21:13:22 +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.2507.31; Tue, 15 Aug 2023 21:14:41 +0800 CC: , , , , , Subject: Re: [PATCH v2] drivers/perf: hisi: Schedule perf session according to locality To: , , References: <20230815130613.535-1-yangyicong@huawei.com> From: Yicong Yang Message-ID: <2eb98cd6-21a1-8e2c-ddf4-41dad5f2a2cb@huawei.com> Date: Tue, 15 Aug 2023 21:14:41 +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: <20230815130613.535-1-yangyicong@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS 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, Please ignore this due to the wrong format of the changelog. Has resend. Sorry for the noise. On 2023/8/15 21:06, Yicong Yang wrote: > From: Yicong Yang > > The PCIe PMUs locate on different NUMA node but currently we don't > consider it and likely stack all the sessions on the same CPU: > > [root@localhost tmp]# cat /sys/devices/hisi_pcie*/cpumask > 0 > 0 > 0 > 0 > 0 > 0 > > This can be optimize a bit to use a local CPU for the PMU. > > Signed-off-by: Yicong Yang > Change since v2: > - Make interrupt affinity consistent with CPU in online handler > Link: https://lore.kernel.org/all/20230808125147.2080-1-yangyicong@huawei.com/ > > --- > drivers/perf/hisilicon/hisi_pcie_pmu.c | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c > index e10fc7cb9493..5a00adb2de8c 100644 > --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c > +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c > @@ -665,8 +665,8 @@ static int hisi_pcie_pmu_online_cpu(unsigned int cpu, struct hlist_node *node) > struct hisi_pcie_pmu *pcie_pmu = hlist_entry_safe(node, struct hisi_pcie_pmu, node); > > if (pcie_pmu->on_cpu == -1) { > - pcie_pmu->on_cpu = cpu; > - WARN_ON(irq_set_affinity(pcie_pmu->irq, cpumask_of(cpu))); > + pcie_pmu->on_cpu = cpumask_local_spread(0, dev_to_node(&pcie_pmu->pdev->dev)); > + WARN_ON(irq_set_affinity(pcie_pmu->irq, cpumask_of(pcie_pmu->on_cpu))); > } > > return 0; > @@ -676,14 +676,23 @@ static int hisi_pcie_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node) > { > struct hisi_pcie_pmu *pcie_pmu = hlist_entry_safe(node, struct hisi_pcie_pmu, node); > unsigned int target; > + cpumask_t mask; > + int numa_node; > > /* Nothing to do if this CPU doesn't own the PMU */ > if (pcie_pmu->on_cpu != cpu) > return 0; > > pcie_pmu->on_cpu = -1; > - /* Choose a new CPU from all online cpus. */ > - target = cpumask_any_but(cpu_online_mask, cpu); > + > + /* Choose a local CPU from all online cpus. */ > + numa_node = dev_to_node(&pcie_pmu->pdev->dev); > + if (cpumask_and(&mask, cpumask_of_node(numa_node), cpu_online_mask) && > + cpumask_andnot(&mask, &mask, cpumask_of(cpu))) > + target = cpumask_any(&mask); > + else > + target = cpumask_any_but(cpu_online_mask, cpu); > + > if (target >= nr_cpu_ids) { > pci_err(pcie_pmu->pdev, "There is no CPU to set\n"); > return 0; >