From patchwork Mon Feb 19 09:40:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Mattias_R=C3=B6nnblom?= X-Patchwork-Id: 136874 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9635243B4B; Mon, 19 Feb 2024 10:48:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8230340A67; Mon, 19 Feb 2024 10:48:39 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2061.outbound.protection.outlook.com [40.107.6.61]) by mails.dpdk.org (Postfix) with ESMTP id AE18A4067C for ; Mon, 19 Feb 2024 10:48:36 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZYS5jmdzbKKrMK5V5x2osPONPg7yYO5dPDSCbd5lPGT5MEhx3rNZCgCeacmSYX3WbwylGHU43l5hbd2cWT5bQRZJbcivVXaQQNZbYupboWfS10WPHjlBC2OsnLKmkTjvybEWdkdq+3jei6CO07X5QJQ5CLYgErodSuShPmPL3qlA+H8vlQFYmSkLLD739jildyhD1qSsmBr2+nuv1ga3XztW4a4ZrEJHlKFef4kUfltjsNrefhj8p8mfDKr7JR9px393H1buAbpIortPuqaEszNs9gWJNsqRQvJScRN/xZydOFWJAjh/5G/aMQYwX88WImbelxUhMHLtoTG7wDblNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6M5eDI/e9A/eoZGR022N1+fXYGp1IWmdBUcIORrYIWg=; b=iMicWX9by392OOkpEqjcFzwXOlJcQLpIABhhrR7fWs5k9Su3oQhhbr3o3dZKHN6gTf8WK8MEz9c2mwT3mfQRPyNE1tejXh2FUkXiEMoSZrv6FN3y91TSA0YjuEGoDvHqWKlaUvX6eZXjrxFSLs3BjbUkzc3PC3rvVGHjvMzkaLJwvmIvrrsuZicmFgpcUhzSIv6CKlgxL2w1cXUWM/XAJa34pZnhZlKojq/QgN5D/2UN8+usCGcgVcCeXiqReiyGAOTQfISi0Xtl092yOK+YsAG5Z2etEtWsrZh+zq3m21Xj97ylcNgSWEre6Pc1HQTcEev8LLinsfUiHJbcrVWzOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=dpdk.org smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6M5eDI/e9A/eoZGR022N1+fXYGp1IWmdBUcIORrYIWg=; b=AN56n4zog9jOOQicfzGz58O/x58thGL272wGN0ZTvhAwk0mygvOe72una3IraskZZUFdy49sOxSqNsjeJDZmwFqi4/rLP08Uz6KuoSMf6FxF7GHMVx6EkX11z9w6MZRq6c8rQwPnLjJNy0zExA0+bBfjpMgk5hzNhRUAb3ZTMUmoMkOdwzTKVV4T4PoJ4VgwQuSPO0moA/rt0zCpXBwYMwoRgNuzTyl+6d2Yr+UYncGLG/c/1Eb7EuANi/oa+TW1sDwdrDUyRjRWN6jg2yOzdbFA98ThQ0EphDN2b7WfHt+elFSdFem4Cv8vyU4397wGunmjwUSkuxSNtxM/pNArIA== Received: from AS4P250CA0011.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::13) by DBBPR07MB7418.eurprd07.prod.outlook.com (2603:10a6:10:1e0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.29; Mon, 19 Feb 2024 09:48:35 +0000 Received: from AM4PEPF00027A61.eurprd04.prod.outlook.com (2603:10a6:20b:5df:cafe::f7) by AS4P250CA0011.outlook.office365.com (2603:10a6:20b:5df::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.37 via Frontend Transport; Mon, 19 Feb 2024 09:48:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; pr=C Received: from oa.msg.ericsson.com (192.176.1.74) by AM4PEPF00027A61.mail.protection.outlook.com (10.167.16.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Mon, 19 Feb 2024 09:48:35 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.64) with Microsoft SMTP Server id 15.2.1258.12; Mon, 19 Feb 2024 10:48:34 +0100 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 2393D1C006A; Mon, 19 Feb 2024 10:48:34 +0100 (CET) From: =?utf-8?q?Mattias_R=C3=B6nnblom?= To: CC: , =?utf-8?q?Morten_Br=C3=B8rup?= , Stephen Hemminger , =?utf-8?q?Mattias_R=C3=B6nn?= =?utf-8?q?blom?= Subject: [RFC v2 4/5] power: keep per-lcore state in lcore variable Date: Mon, 19 Feb 2024 10:40:35 +0100 Message-ID: <20240219094036.485727-5-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240219094036.485727-1-mattias.ronnblom@ericsson.com> References: <20240208181644.455233-2-mattias.ronnblom@ericsson.com> <20240219094036.485727-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM4PEPF00027A61:EE_|DBBPR07MB7418:EE_ X-MS-Office365-Filtering-Correlation-Id: 28dbbdd3-aee7-47b5-0703-08dc312ff0ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fFWAT+1mfhnjrnnFtgMIjkaZc0HuD6TAnAvbbZavQY06IdikezYgJBTLeozYVYGIkXYejvUGjfqBaYtT3QpOT2pjkUyb0jzDEB6stm0ttdNtFtCIjoZBuUxjsRFyyzVgITtaqjdKLcW09+ZLCZ2D8XcymM3+fkONjfxEMBwtQzKVw94vlz+ziuYh1oi/bBEqgQSct3hh3CtTLUe7bR3KpCpJkNfbTXGZMAsxd58he3TqQAI+nG3wov5zfEA7R/QVdETqvCjkBwQH9eHZ3g9iskzDT3A6xv/Ul/fPZ7EDSo9DztlrR+wkJVbUSW6qz8sPr6bDz3Y9JO27FFSG1E974y8K8iiY4nzauPaQ+lfi3SLgrYAMYbhJj0h76Q7/i5KS0jl3oRL5C/mk5OfG4HlItbQ24BblJIibKz+5X6kMjyLHEYQKyfjMKaWp2dkMEn8VJ/t1j4Xi9287gZWqOwmiaZ3lnxu3o2HeS9kxv2ee/KfBcZcPUmptLPOfhRPIVeGyuP8PZRdzZfwe4oAalu4k41GZjtZWsvwA8aiIY6b0zIy0RHMApHL2TH4kAWtFmIqDzRl9vYgFrJ0IejMwVucNord7BEVKZXmE+MzXwiQGBhYfLgP91i/2eXBlxpswUdUXaF7oX2aSn+Oa5wo7CJ/OtdnOH9TU7WCaMozeuv/dDPM= X-Forefront-Antispam-Report: CIP:192.176.1.74; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:oa.msg.ericsson.com; PTR:office365.se.ericsson.net; CAT:NONE; SFS:(13230031)(4636009)(376002)(39860400002)(136003)(346002)(396003)(230922051799003)(1800799012)(82310400011)(451199024)(186009)(64100799003)(36860700004)(40470700004)(46966006)(4326008)(5660300002)(8936002)(8676002)(2906002)(82960400001)(336012)(356005)(83380400001)(1076003)(26005)(36756003)(86362001)(107886003)(82740400003)(2616005)(6266002)(70586007)(7636003)(6916009)(54906003)(70206006)(316002)(478600001)(41300700001); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2024 09:48:35.0238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28dbbdd3-aee7-47b5-0703-08dc312ff0ad X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: AM4PEPF00027A61.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7418 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Signed-off-by: Mattias Rönnblom --- lib/power/rte_power_pmd_mgmt.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index 591fc69f36..bb20e564de 100644 --- a/lib/power/rte_power_pmd_mgmt.c +++ b/lib/power/rte_power_pmd_mgmt.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -68,8 +69,8 @@ struct pmd_core_cfg { /**< Number of queues ready to enter power optimized state */ uint64_t sleep_target; /**< Prevent a queue from triggering sleep multiple times */ -} __rte_cache_aligned; -static struct pmd_core_cfg lcore_cfgs[RTE_MAX_LCORE]; +}; +static RTE_LCORE_VAR_HANDLE(struct pmd_core_cfg, lcore_cfgs); static inline bool queue_equal(const union queue *l, const union queue *r) @@ -252,12 +253,11 @@ clb_multiwait(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused, struct rte_mbuf **pkts __rte_unused, uint16_t nb_rx, uint16_t max_pkts __rte_unused, void *arg) { - const unsigned int lcore = rte_lcore_id(); struct queue_list_entry *queue_conf = arg; struct pmd_core_cfg *lcore_conf; const bool empty = nb_rx == 0; - lcore_conf = &lcore_cfgs[lcore]; + lcore_conf = RTE_LCORE_VAR_PTR(lcore_cfgs); /* early exit */ if (likely(!empty)) @@ -317,13 +317,12 @@ clb_pause(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused, struct rte_mbuf **pkts __rte_unused, uint16_t nb_rx, uint16_t max_pkts __rte_unused, void *arg) { - const unsigned int lcore = rte_lcore_id(); struct queue_list_entry *queue_conf = arg; struct pmd_core_cfg *lcore_conf; const bool empty = nb_rx == 0; uint32_t pause_duration = rte_power_pmd_mgmt_get_pause_duration(); - lcore_conf = &lcore_cfgs[lcore]; + lcore_conf = RTE_LCORE_VAR_PTR(lcore_cfgs); if (likely(!empty)) /* early exit */ @@ -358,9 +357,8 @@ clb_scale_freq(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused, struct rte_mbuf **pkts __rte_unused, uint16_t nb_rx, uint16_t max_pkts __rte_unused, void *arg) { - const unsigned int lcore = rte_lcore_id(); const bool empty = nb_rx == 0; - struct pmd_core_cfg *lcore_conf = &lcore_cfgs[lcore]; + struct pmd_core_cfg *lcore_conf = RTE_LCORE_VAR_PTR(lcore_cfgs); struct queue_list_entry *queue_conf = arg; if (likely(!empty)) { @@ -518,7 +516,7 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id, goto end; } - lcore_cfg = &lcore_cfgs[lcore_id]; + lcore_cfg = RTE_LCORE_VAR_LCORE_PTR(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ ret = cfg_queues_stopped(lcore_cfg); @@ -619,7 +617,7 @@ rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id, } /* no need to check queue id as wrong queue id would not be enabled */ - lcore_cfg = &lcore_cfgs[lcore_id]; + lcore_cfg = RTE_LCORE_VAR_LCORE_PTR(lcore_id, lcore_cfgs); /* check if other queues are stopped as well */ ret = cfg_queues_stopped(lcore_cfg); @@ -772,10 +770,13 @@ RTE_INIT(rte_power_ethdev_pmgmt_init) { size_t i; int j; + RTE_LCORE_VAR_ALLOC(lcore_cfgs); + /* initialize all tailqs */ - for (i = 0; i < RTE_DIM(lcore_cfgs); i++) { - struct pmd_core_cfg *cfg = &lcore_cfgs[i]; - TAILQ_INIT(&cfg->head); + for (i = 0; i < RTE_MAX_LCORE; i++) { + struct pmd_core_cfg *lcore_cfg = + RTE_LCORE_VAR_LCORE_PTR(i, lcore_cfgs); + TAILQ_INIT(&lcore_cfg->head); } /* initialize config defaults */