Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9029412ybi; Tue, 23 Jul 2019 20:22:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAXg/yEcdSjN9z33qdf2VntSD1u0xqB3aeBDr4JjsuJtHa2sCa9NebUfVGcpF3gY339iOj X-Received: by 2002:a63:3009:: with SMTP id w9mr4610962pgw.260.1563938525965; Tue, 23 Jul 2019 20:22:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563938525; cv=none; d=google.com; s=arc-20160816; b=imRPwcgOJxg2CkoM/gLreMwcBx6amWwDAMj8KSPqgr1v3OihdrahLwoRvtiVMrU8Qo MjXi7EWY9JYJrZwG2ySIkolMDOboGLQLWrdAUq/jVh68+4CpoLmjUd0H8hgWgB6/J53M 2MorDOzx8Q8kVC5kpJG4DOTqTbnZwWenAEVhO0LC3f21tAU5EnZgU6n8+W+2HO69ux5W eZ5BfSEAKb0xnuLulJ6Ihozk6TTtKujCD5UQf3qp//qJxPrasbL3Vn4GenN6O9HwAA84 QCTunKg76e3ipPcCHM0o2eEogPIDHMbI/EyGiUYVNu9jf1u0d2gnE9YrNStfloHuyuBG rwuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=W4tSyr8NoiXn2Q45tU1rejePR6++JjMVVni4Ggl16fI=; b=M3SexwuMJJ0bcNDYWGnPNwVgYAlTsKXzyyHCbrwaD/AAn1ExsTtwfGVEfDQ0N35nBQ vXB4KrZafteuTiYX/moIo4CPbLIbfq3qraJbgSx9uCsexJ6+Yx9SBlTGojsaLRrl9tpZ p6cdssSPNtx94famjOY3+D7CVglzM6Qgs6YszCLd1U0Fek7VPgtNIDljshw54y3I/vbq IlLiowd1VafakQICVseBsWaECjbXSnzpK61O8iWvlY7Xueu3OnM0af96fROK3kQB+gvX RIo69pzAOZ1CevN1tdu2xMnY8Q5YuMT8DehPBQuhYSCiPMNXCI/wK3HKhas9mgIS/Q8n YjIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w66si13158113pfw.65.2019.07.23.20.21.50; Tue, 23 Jul 2019 20:22:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726640AbfGXDVH (ORCPT + 99 others); Tue, 23 Jul 2019 23:21:07 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:50728 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726461AbfGXDVB (ORCPT ); Tue, 23 Jul 2019 23:21:01 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 9EDD0AF284D8CD6EC3E7; Wed, 24 Jul 2019 11:20:52 +0800 (CST) Received: from localhost.localdomain (10.67.212.132) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Wed, 24 Jul 2019 11:20:44 +0800 From: Huazhong Tan To: CC: , , , , , Yunsheng Lin , Peng Li , Huazhong Tan Subject: [PATCH net-next 08/11] net: hns3: add interrupt affinity support for misc interrupt Date: Wed, 24 Jul 2019 11:18:44 +0800 Message-ID: <1563938327-9865-9-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1563938327-9865-1-git-send-email-tanhuazhong@huawei.com> References: <1563938327-9865-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.212.132] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin The misc interrupt is used to schedule the reset and mailbox subtask, and a 1 sec timer is used to schedule the service subtask, which does periodic work. This patch sets the above three subtask's affinity using the misc interrupt' affinity. Also this patch setups a affinity notify for misc interrupt to allow user to change the above three subtask's affinity. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Huazhong Tan --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 59 ++++++++++++++++++++-- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 4 ++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index f345095..fe45986 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1270,6 +1270,12 @@ static int hclge_configure(struct hclge_dev *hdev) hclge_init_kdump_kernel_config(hdev); + /* Set the init affinity based on pci func number */ + i = cpumask_weight(cpumask_of_node(dev_to_node(&hdev->pdev->dev))); + i = i ? PCI_FUNC(hdev->pdev->devfn) % i : 0; + cpumask_set_cpu(cpumask_local_spread(i, dev_to_node(&hdev->pdev->dev)), + &hdev->affinity_mask); + return ret; } @@ -2502,14 +2508,16 @@ static void hclge_mbx_task_schedule(struct hclge_dev *hdev) { if (!test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state) && !test_and_set_bit(HCLGE_STATE_MBX_SERVICE_SCHED, &hdev->state)) - schedule_work(&hdev->mbx_service_task); + queue_work_on(cpumask_first(&hdev->affinity_mask), system_wq, + &hdev->mbx_service_task); } static void hclge_reset_task_schedule(struct hclge_dev *hdev) { if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) && !test_and_set_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state)) - schedule_work(&hdev->rst_service_task); + queue_work_on(cpumask_first(&hdev->affinity_mask), system_wq, + &hdev->rst_service_task); } static void hclge_task_schedule(struct hclge_dev *hdev) @@ -2517,7 +2525,8 @@ static void hclge_task_schedule(struct hclge_dev *hdev) if (!test_bit(HCLGE_STATE_DOWN, &hdev->state) && !test_bit(HCLGE_STATE_REMOVING, &hdev->state) && !test_and_set_bit(HCLGE_STATE_SERVICE_SCHED, &hdev->state)) - (void)schedule_work(&hdev->service_task); + queue_work_on(cpumask_first(&hdev->affinity_mask), system_wq, + &hdev->service_task); } static int hclge_get_mac_link_status(struct hclge_dev *hdev) @@ -2921,6 +2930,39 @@ static void hclge_get_misc_vector(struct hclge_dev *hdev) hdev->num_msi_used += 1; } +static void hclge_irq_affinity_notify(struct irq_affinity_notify *notify, + const cpumask_t *mask) +{ + struct hclge_dev *hdev = container_of(notify, struct hclge_dev, + affinity_notify); + + cpumask_copy(&hdev->affinity_mask, mask); + del_timer_sync(&hdev->service_timer); + hdev->service_timer.expires = jiffies + HZ; + add_timer_on(&hdev->service_timer, cpumask_first(&hdev->affinity_mask)); +} + +static void hclge_irq_affinity_release(struct kref *ref) +{ +} + +static void hclge_misc_affinity_setup(struct hclge_dev *hdev) +{ + irq_set_affinity_hint(hdev->misc_vector.vector_irq, + &hdev->affinity_mask); + + hdev->affinity_notify.notify = hclge_irq_affinity_notify; + hdev->affinity_notify.release = hclge_irq_affinity_release; + irq_set_affinity_notifier(hdev->misc_vector.vector_irq, + &hdev->affinity_notify); +} + +static void hclge_misc_affinity_teardown(struct hclge_dev *hdev) +{ + irq_set_affinity_notifier(hdev->misc_vector.vector_irq, NULL); + irq_set_affinity_hint(hdev->misc_vector.vector_irq, NULL); +} + static int hclge_misc_irq_init(struct hclge_dev *hdev) { int ret; @@ -6151,7 +6193,10 @@ static void hclge_set_timer_task(struct hnae3_handle *handle, bool enable) struct hclge_dev *hdev = vport->back; if (enable) { - mod_timer(&hdev->service_timer, jiffies + HZ); + del_timer_sync(&hdev->service_timer); + hdev->service_timer.expires = jiffies + HZ; + add_timer_on(&hdev->service_timer, + cpumask_first(&hdev->affinity_mask)); } else { del_timer_sync(&hdev->service_timer); cancel_work_sync(&hdev->service_task); @@ -8809,6 +8854,11 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) INIT_WORK(&hdev->rst_service_task, hclge_reset_service_task); INIT_WORK(&hdev->mbx_service_task, hclge_mailbox_service_task); + /* Setup affinity after service timer setup because add_timer_on + * is called in affinity notify. + */ + hclge_misc_affinity_setup(hdev); + hclge_clear_all_event_cause(hdev); hclge_clear_resetting_state(hdev); @@ -8970,6 +9020,7 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) struct hclge_dev *hdev = ae_dev->priv; struct hclge_mac *mac = &hdev->hw.mac; + hclge_misc_affinity_teardown(hdev); hclge_state_uninit(hdev); if (mac->phydev) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 6a12285..14df23c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -864,6 +864,10 @@ struct hclge_dev { DECLARE_KFIFO(mac_tnl_log, struct hclge_mac_tnl_stats, HCLGE_MAC_TNL_LOG_SIZE); + + /* affinity mask and notify for misc interrupt */ + cpumask_t affinity_mask; + struct irq_affinity_notify affinity_notify; }; /* VPort level vlan tag configuration for TX direction */ -- 2.7.4