From patchwork Mon Aug 12 14:56:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13760756 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 974A118454A for ; Mon, 12 Aug 2024 14:57:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474629; cv=none; b=YYAymTV0LovHKeAph2RiaZTJIuOorlxNFFfTm2jLLTf8M7dXEivwUROGHs4zzNExNMhg9p/ZUOGT9F5Aah8jLjBmkBl64mcQGHWLy7hJNI2SVLlfxVYO3Q1XrZN8KfeF/n/rSi3arz9ThHjQucr+97YEz+jQIuatk1mUDBFa6Ho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474629; c=relaxed/simple; bh=OtbThwHzrLrDJ6N9iYZP2xMzyRCuIQDSqBSKqkos4uU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=StGVDrqCk5/FkuRHOvf1tnhcNlydsROqLVhmLXBK6Wi2XJnyT/PVecVz3EPlYzUbCOSOfU9rFb1p/TY8Zmo6LGeEDlnE8dx9yjzUKr1wTYBi2lhRNOZjj5MPMMiFdDQNUH6FgoCigV562EPWaggcSkeMxFIk+nsCgJVRx0i/2Ms= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=I5kQnO0q; arc=none smtp.client-ip=209.85.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="I5kQnO0q" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-7a0b2924e52so2129039a12.2 for ; Mon, 12 Aug 2024 07:57:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1723474626; x=1724079426; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P2QGcPk3A8tZFSKtHIPQmg9Fxaym0vKQef3yjN2SS5E=; b=I5kQnO0q9t1WdsqNw/jMjMOnGt+ttsRx1yfVW7JzuJo11gtOrC2c3cOIHotcaGff3g b/8oTXvXWdn/lpaJPZlsOTU5x6vR0mUbyrjoxfFCCxgTt6ZZt1bSihBZ+htbwPLdFjzD eX5GZ8m1i8dkaixV+gK998sudjnB58IFdP73w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723474626; x=1724079426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P2QGcPk3A8tZFSKtHIPQmg9Fxaym0vKQef3yjN2SS5E=; b=AXOP7fSa3TanciCkw+buRWRBDnebQecFerrxnD4hmA+vdGStLO83mg6/sdda42MULn dbaJ1AFYxpBP494muwyGbmnzyFRK+vZlY9hRhDy8Cr0zIstMy85dPrJVDEvuLtG6VxXB mF04PFCPbNz0Xb4yMurlNmr4KvcMUgmDd1FOGLHoY5TQQP6+eFNYnkUKreWPsFB1vD0D nd8cSc1A58jqmlrIrC/kN20e9F+/+a5guzMLQrOUJ4SWlZ257dmWuMhl2t7umyw4KnQV K20mOe18n7BxXmImtv+/0Zg2Kb5F/Rpot6xFWDtm1SQ0YGUVmgY7yHVy8r0ihwYClSxW I73w== X-Gm-Message-State: AOJu0YwnBlEoD6dZG3ptBKaTeqm2ABhdWzl3jNijbQqUFnqXN42vaSGK gRM6Ix/Lk5+q3ZTVTcTqMJsq86kq6XBVt7clzB5RYJGG9Uej6szZ0uijJvpMJLtPlU+zZRwaVx6 aKonTY0LEKRmS4HcEVw7gZnsjXWvBolL4oFN+Cjibm+8A9OQaE5b4HgQG2INYhJZb5WtwLpIoiA os3yCNtyE90m2BM/4cFQweEzZrvL5e6RFkMnwqRw== X-Google-Smtp-Source: AGHT+IH/Va6oFceymPtFVikZ4XT7EW9N4zXQhzcHxdCn7/yQShCgpfo1zip9Na9QsbzCb+pTwYHNwg== X-Received: by 2002:a17:902:ec91:b0:1fd:9c2d:2f1b with SMTP id d9443c01a7336-201ca1cb0d8mr5835315ad.52.1723474626441; Mon, 12 Aug 2024 07:57:06 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-200bb8fd835sm39006955ad.89.2024.08.12.07.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 07:57:06 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , Daniel Borkmann , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next 1/6] netdevice: Add napi_affinity_no_change Date: Mon, 12 Aug 2024 14:56:22 +0000 Message-Id: <20240812145633.52911-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240812145633.52911-1-jdamato@fastly.com> References: <20240812145633.52911-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Several drivers have their own, very similar, implementations of determining if IRQ affinity has changed. Create napi_affinity_no_change to centralize this logic in the core. This will be used in following commits for various drivers to eliminate duplicated code. Signed-off-by: Joe Damato --- include/linux/netdevice.h | 8 ++++++++ net/core/dev.c | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 0ef3eaa23f4b..dc714a04b90a 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -464,6 +464,14 @@ enum rx_handler_result { typedef enum rx_handler_result rx_handler_result_t; typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb); +/** + * napi_affinity_no_change - determine if CPU affinity changed + * @irq: the IRQ whose affinity may have changed + * + * Return true if the CPU affinity has NOT changed, false otherwise. + */ +bool napi_affinity_no_change(unsigned int irq); + void __napi_schedule(struct napi_struct *n); void __napi_schedule_irqoff(struct napi_struct *n); diff --git a/net/core/dev.c b/net/core/dev.c index 751d9b70e6ad..9c56ad49490c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -89,6 +89,7 @@ #include #include #include +#include #include #include #include @@ -6210,6 +6211,19 @@ void __napi_schedule_irqoff(struct napi_struct *n) } EXPORT_SYMBOL(__napi_schedule_irqoff); +bool napi_affinity_no_change(unsigned int irq) +{ + int cpu_curr = smp_processor_id(); + const struct cpumask *aff_mask; + + aff_mask = irq_get_effective_affinity_mask(irq); + if (unlikely(!aff_mask)) + return true; + + return cpumask_test_cpu(cpu_curr, aff_mask); +} +EXPORT_SYMBOL(napi_affinity_no_change); + bool napi_complete_done(struct napi_struct *n, int work_done) { unsigned long flags, val, new, timeout = 0; From patchwork Mon Aug 12 14:56:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13760757 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 572B818455F for ; Mon, 12 Aug 2024 14:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474630; cv=none; b=mSk+Az4fkl2lTbJ5fLz50GlWaJWEyjTSPjvQal3ysYmR42cVtuXr4h+SGyL4gsUEXCoxb4+D/xwvni6ycxyhCvhOgOnmSimM1lRCxDnYUiBHjY0crhIeQK9wddJEzn6nIz2553wIWgZRg1u1qYB8zmke2xvMGY5br/ArQxNuE+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474630; c=relaxed/simple; bh=qttIpi4HRsWevPJvdgv7JnCbSSNPmNcCGu3sxRJxwIQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hLLNkMhUNOCN6TKqdNJHi2HvpmjA8QrURQG/Ri6Ukt2/q57gON/BEi8TZN5XelgQecHOjzAB1+qN2QAqoi5PU3/7Z9zlSoBenpXC/O5mHzgCW+TAltmuvc4bQtyjgK27PtG7zbdZMN6lrmwmi/hctG9QtYQQCzrwHbLd7/Dmxk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=jFX0zuWg; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="jFX0zuWg" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-7105043330aso3573446b3a.0 for ; Mon, 12 Aug 2024 07:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1723474628; x=1724079428; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=krsVPmGJ7mUpHzCKNJF3hcG8Is07gdPgaERGEpodORE=; b=jFX0zuWgifE0wxa+qx0p21VDtTATsMsRg2biF4fCKZWSZcCXaV72F8/iyjB9AWyHyb bx4g3+K1HEunDLIIxjU+wrhXchD6KFpHs4cLG7TjNm7JsU6ctO2gCyL14FQowBc8OH0V U28Lhvuuo018y03Anf55v/9zAUCFGWIcrniZo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723474628; x=1724079428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=krsVPmGJ7mUpHzCKNJF3hcG8Is07gdPgaERGEpodORE=; b=UoaG0i11glTR5ozk7Q1Fj2f9QuEtKa2ExIVlSU/x0zA5cw+zZR85HVeoiPdyQSNlsH e/7Hwg/ybCtCV+tVjvv6sQINVcYTGuKsNnoM9yCK3uJ4KS9R/gBq0PItwZqU2fvXEmnC B/q2I0ipXTczbZWpyJT/8NkkxTCq/Ky52DPA4hMPTrJX4hGm0k4vpVd+FoWjnPCY6qmw +LA5HZPWL2kvn/Faog9FQnYkR3+/9aEC5FiU+Vm9XgyfBtstI6jMCEM3AGeCMPcvqEXh 1qIVFUpAeFHrliR/qHYP0aQEuWMjawmx7HZI/IKfLmeKmsozNAVkL6FQ+5DcAmKx8qTE vtzg== X-Gm-Message-State: AOJu0Yz82EmcaKS+0gEm5UTLJF6tQ7OV7wEkRFLVC/ke1GicN9qJhAEW 32cs3rix8zLkIBsJhUyLxA2NALZV+zCnMUqBKkgMYTESiUM1xG51zpMDva+tUGMgMCxmAnzJJ0U mHk19P6ecG/TFBCgI9Su4Cq02dpJhpUvAnTq/ClcDgw5nhVYmZh/BrlTMCCJeSGpFqTsCNS/oCZ AOmqmdIuW1J5H1ub+91AvQUWXhLqlja6vR8yTuow== X-Google-Smtp-Source: AGHT+IGI1VKC/hH97K8mVlaBVtWBUX28eQCqGKnY+VncEcLp2Gvi+LfAg0ooVhF0BwcGRliS31Rfvw== X-Received: by 2002:a17:902:d4cd:b0:1fa:449:1dd6 with SMTP id d9443c01a7336-201ca1c77edmr6127215ad.48.1723474628092; Mon, 12 Aug 2024 07:57:08 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-200bb8fd835sm39006955ad.89.2024.08.12.07.57.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 07:57:07 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , Saeed Mahameed , Leon Romanovsky , Tariq Toukan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-rdma@vger.kernel.org (open list:MELLANOX MLX5 core VPI driver), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next 2/6] mlx5: Use napi_affinity_no_change Date: Mon, 12 Aug 2024 14:56:23 +0000 Message-Id: <20240812145633.52911-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240812145633.52911-1-jdamato@fastly.com> References: <20240812145633.52911-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Use napi_affinity_no_change instead of mlx5's internal implementation, simplifying and centralizing the logic. Signed-off-by: Joe Damato --- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 9 +-------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 7832f6b6c8a8..c288e3f45a06 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h @@ -767,7 +767,7 @@ struct mlx5e_channel { spinlock_t async_icosq_lock; /* data path - accessed per napi poll */ - const struct cpumask *aff_mask; + unsigned int irq; struct mlx5e_ch_stats *stats; /* control */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 6f686fabed44..7b217aafbdfd 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2684,8 +2684,8 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, c->mkey_be = cpu_to_be32(mdev->mlx5e_res.hw_objs.mkey); c->num_tc = mlx5e_get_dcb_num_tc(params); c->xdp = !!params->xdp_prog; + c->irq = irq; c->stats = &priv->channel_stats[ix]->ch; - c->aff_mask = irq_get_effective_affinity_mask(irq); c->lag_port = mlx5e_enumerate_lag_port(mdev, ix); netif_napi_add(netdev, &c->napi, mlx5e_napi_poll); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c index 5873fde65c2e..ee453d019c3b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c @@ -39,13 +39,6 @@ #include "en/xsk/tx.h" #include "en_accel/ktls_txrx.h" -static inline bool mlx5e_channel_no_affinity_change(struct mlx5e_channel *c) -{ - int current_cpu = smp_processor_id(); - - return cpumask_test_cpu(current_cpu, c->aff_mask); -} - static void mlx5e_handle_tx_dim(struct mlx5e_txqsq *sq) { struct mlx5e_sq_stats *stats = sq->stats; @@ -201,7 +194,7 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) busy |= busy_xsk; if (busy) { - if (likely(mlx5e_channel_no_affinity_change(c))) { + if (likely(napi_affinity_no_change(c->irq))) { work_done = budget; goto out; } From patchwork Mon Aug 12 14:56:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13760758 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFCC6186E5E for ; Mon, 12 Aug 2024 14:57:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474634; cv=none; b=KWhUI+dlcJR09w/9Pa/RovTOsgbo4rV0qS01FzjT/wnbhwoWLjPZa5il9huGxsh9ABnqX2NIlNZlvWtbN+J+d2Wk5SykmmVBhWy03RoEeLTOwoCE7BqcIRfb0jpWF2efdgK+esVDmyW0SHVSGWjSUly8OlkY9AKo/tKpRfAAdsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474634; c=relaxed/simple; bh=engWj6aKpokwgpyXiw7CBwh7X6sCJ2Bs/kMc9vpl9io=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sEuD0X3+GCye30icdUGZPoaCASk8MF/adDu+JW8oqrTC97VOTN4Y+aeZggA5VizwrMI6p9ndP/UnPETWUsys0+3DigSOlzzeYQqSVKU+ocPxylkM5dQHaTYkz23WNRUf/LBXBGvKFysYlGPJTah4bQ1foFvPdoNKnze75bI+4ds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=PIv5ZcAE; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="PIv5ZcAE" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1fc66fc35f2so37680185ad.0 for ; Mon, 12 Aug 2024 07:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1723474632; x=1724079432; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fNdFpdWlE48RXxg9UImVWM9Gm44fXtqN26asQqpjAN8=; b=PIv5ZcAE+hzMIwUzA76X/OHZY8HzfWCiIq9iBnpFgI/SNroekB8X9Rw/SfA87SzQOK drfw+D2fu6AU7+7SskYbrLFARhsPnPHvhEG2ZOJ/kvacg+u0lrgkEmHSW/mYWRSx7c4Q bcGxYS+FH98OM+ohoQ0sNKlky1sqmDoGH4Inw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723474632; x=1724079432; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fNdFpdWlE48RXxg9UImVWM9Gm44fXtqN26asQqpjAN8=; b=OeVkdOEoFgwQK78PjrjyvTPwdjcq1eIxKEacOVhHQliO8MtXAvW6JeKICFwWZeva55 /Fhf/mxlGKp4kU1IMsDTElU3o8qTf5fW9vN8B2ibxbEqGeTXMS3i25g8CVrBkKOSw2iV evJesPM1q9bFeHr3P51C+OcUNmBVwKSrH9zGsY1VjfAiue0JmrH262mo19egYj6HR18Q friLJTp0MSESVKf8EFmaY4iKJsVTuQUuUmYovr5QCRms/M3xaSsYzsc1HcNAq4IIZ1QO YkKt9jE77kYOfIulYLJi9u+r7XWgLwdmGbKbN85Zf8ZPfyxDuvSyyBv8iOyJbmQbBDIJ 1EZw== X-Gm-Message-State: AOJu0YzMarBjjCOe0U5idTol1TLEACwH5f3qCaW7vWNOAv/20/s9f3qa hedRmmRYhdkrUnPMcM5klydB0nvn6kn3rii0irrLaMBAnlGba2tU/IYKAMT/Y1v/38R/cD7qS/8 aW5NYTyZ9cqobJEol8vH5znRwEGqX7y9LZ5eie2i+SiATRCKa2K/oNnyTBLHcHv+3qmLro0om8+ pFVORvILVQhfvYjTtzTvcEMA2Ac+KdhTwy94QVUw== X-Google-Smtp-Source: AGHT+IGFUCfRefG7wAmf5ZDyJMJag39OJ6iIfluMa7A4Bgkrj1RT59JVL+xgUytd9tdtjDfEBNrsIw== X-Received: by 2002:a17:903:41c8:b0:1fd:74ac:e6b8 with SMTP id d9443c01a7336-201ca90ec88mr5485365ad.7.1723474631777; Mon, 12 Aug 2024 07:57:11 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-200bb8fd835sm39006955ad.89.2024.08.12.07.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 07:57:11 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , Jeroen de Borst , Praveen Kaligineedi , Shailend Chand , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Harshitha Ramamurthy , Ziwei Xiao , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next 3/6] gve: Use napi_affinity_no_change Date: Mon, 12 Aug 2024 14:56:24 +0000 Message-Id: <20240812145633.52911-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240812145633.52911-1-jdamato@fastly.com> References: <20240812145633.52911-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Use napi_affinity_no_change instead of gve's internal implementation, simplifying and centralizing the logic. Signed-off-by: Joe Damato --- drivers/net/ethernet/google/gve/gve_main.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c index 661566db68c8..ad5e85b8c6a5 100644 --- a/drivers/net/ethernet/google/gve/gve_main.c +++ b/drivers/net/ethernet/google/gve/gve_main.c @@ -298,18 +298,6 @@ static irqreturn_t gve_intr_dqo(int irq, void *arg) return IRQ_HANDLED; } -static int gve_is_napi_on_home_cpu(struct gve_priv *priv, u32 irq) -{ - int cpu_curr = smp_processor_id(); - const struct cpumask *aff_mask; - - aff_mask = irq_get_effective_affinity_mask(irq); - if (unlikely(!aff_mask)) - return 1; - - return cpumask_test_cpu(cpu_curr, aff_mask); -} - int gve_napi_poll(struct napi_struct *napi, int budget) { struct gve_notify_block *block; @@ -383,7 +371,7 @@ int gve_napi_poll_dqo(struct napi_struct *napi, int budget) /* Reschedule by returning budget only if already on the correct * cpu. */ - if (likely(gve_is_napi_on_home_cpu(priv, block->irq))) + if (likely(napi_affinity_no_change(block->irq))) return budget; /* If not on the cpu with which this queue's irq has affinity From patchwork Mon Aug 12 14:56:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13760759 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EF4118732C for ; Mon, 12 Aug 2024 14:57:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474635; cv=none; b=VEpg12gnf7uISmXsMFjMcocR3n1TvqvRvjf7/iLnKUJr5P6WvL+01HmzaV4Np4r2ZJ2ksjQYAxoItlBD0lwOxZLAdRcnRJCN2+mzHufSaPZVriu+W0+5sxLYwvWxXi4YQ5xUhMnCmCLC0tonzqijr3ZtjMuP/V9sfpQVMDxHj90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474635; c=relaxed/simple; bh=qTGf9RDPSjjOFdWiZLiVw5Crk632AJNyAaTUhFpJaJ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KiivX3Ul9yWatgyOTITiCzsuwp9h4F97RBu04XuFGFrYJFitufL7OyVc2jAevhT2zIMcfoV5sE2twE7FEI6Zvu+j3IL/ZNbme5LFw+w/la0hilh+R6fAqgBL8Qa0ERmgRSfCQl9N6tFnzoNoMhpA/SIUpzDhBO4sZraQFoVrN+c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=wdtHwJbU; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="wdtHwJbU" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1fda7fa60a9so37001355ad.3 for ; Mon, 12 Aug 2024 07:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1723474633; x=1724079433; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Yv3Kiio+O9ZPFfr1NuylJH0Fc+893bNyrbJKgz9J96Y=; b=wdtHwJbU1ue0IyWc8TzxBlkAXwSPGZ0lXYXgaXV0ekmVh7rOF4aiwHMKYKn4K1EGxR vIno4Vbzu0oJqwWAYEsR7hs7B2vYFii2tQidKi1DUWQkOu6/JNXcEic++6Iy5zDZ548x QTuGY4VAtYtD5idIJUAeFo1lxF8/S/TbimUkQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723474633; x=1724079433; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yv3Kiio+O9ZPFfr1NuylJH0Fc+893bNyrbJKgz9J96Y=; b=Ng37I1tjc4DiUV7QE1Lv60Ntcs0fMF21m2Z432lh6lHwkc4xtdilOFkM1rVTC9tI9G dMbkX4yTrd+/dCSM1o/EVDIbvcTaXnhPUTnfpLEGTq1gUfoDunuSR7v+9K5OCQkkcpjg lfMt6wZzK7JVllHgT9WsNLWrAhwZjKWBbcdqREfc7e+Y4t7jhUAU6sv/QqfI6p9SNqpq jEqx8buNOZLg0p72MNxorTged3Uv0UfOrCQEWnqL6YxDcuodnkCeTWh58EhO2yCAeBbw ECXl1nhpcR+8BoYIEQjm4BgoMRiZ3xUPU7EEDMYK3xvrJoQ//qQiLGVh4pvLrKBwCN4N OGGQ== X-Gm-Message-State: AOJu0YyRCY6Kf+71KAGkmqbMPSFshigosG28M3mFcx3Gx40ZAl74XJ2b CVTpLIaxDZ4V/SI8Jbu/Wt4+Al6a7HgaAKK0GCUapU6Cvn0BhCq3LqDcOq2QcYKmUJPJIQ5w1rl RI/w+3qJxY6rnoFf0x8uJRreo4h++Oc60R5/78AXI7uz/zh4FV521Y8GwTcE0u08ztBGkCow1bN am8SviCp5ZpNSOPlA3ACogZ/oDV1pAGtsW/wMw1A== X-Google-Smtp-Source: AGHT+IFq7CVQngrprbj/jbujEv0pCxSX/9ljktjnxugPkA8tcIxxNL7KoLqZldHeiN0wb9s0yFwN0w== X-Received: by 2002:a17:902:ea12:b0:1fb:8a0e:7730 with SMTP id d9443c01a7336-201ca1b12d6mr7854895ad.26.1723474633362; Mon, 12 Aug 2024 07:57:13 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-200bb8fd835sm39006955ad.89.2024.08.12.07.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 07:57:13 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , Tony Nguyen , Przemek Kitszel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org (moderated list:INTEL ETHERNET DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next 4/6] i40e: Use napi_affinity_no_change Date: Mon, 12 Aug 2024 14:56:25 +0000 Message-Id: <20240812145633.52911-5-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240812145633.52911-1-jdamato@fastly.com> References: <20240812145633.52911-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Use napi_affinity_no_change instead of i40e's internal implementation, simplifying and centralizing the logic. To facilitate this, fix the type of irq_num to be unsigned int. Signed-off-by: Joe Damato --- drivers/net/ethernet/intel/i40e/i40e.h | 2 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index d546567e0286..326bb7ffab26 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -955,7 +955,7 @@ struct i40e_q_vector { char name[I40E_INT_NAME_STR_LEN]; bool arm_wb_state; bool in_busy_poll; - int irq_num; /* IRQ assigned to this q_vector */ + unsigned int irq_num; /* IRQ assigned to this q_vector */ } ____cacheline_internodealigned_in_smp; /* lan device */ diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index cbcfada7b357..a120fdd87c3e 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -4137,10 +4137,10 @@ static int i40e_vsi_request_irq_msix(struct i40e_vsi *vsi, char *basename) int q_vectors = vsi->num_q_vectors; struct i40e_pf *pf = vsi->back; int base = vsi->base_vector; + unsigned int irq_num; int rx_int_idx = 0; int tx_int_idx = 0; int vector, err; - int irq_num; int cpu; for (vector = 0; vector < q_vectors; vector++) { diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c index c006f716a3bd..8fc39cf4c5d3 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c @@ -2810,8 +2810,6 @@ int i40e_napi_poll(struct napi_struct *napi, int budget) /* If work not completed, return budget and polling will return */ if (!clean_complete) { - int cpu_id = smp_processor_id(); - /* It is possible that the interrupt affinity has changed but, * if the cpu is pegged at 100%, polling will never exit while * traffic continues and the interrupt will be stuck on this @@ -2819,7 +2817,7 @@ int i40e_napi_poll(struct napi_struct *napi, int budget) * continue to poll, otherwise we must stop polling so the * interrupt can move to the correct cpu. */ - if (!cpumask_test_cpu(cpu_id, &q_vector->affinity_mask)) { + if (!napi_affinity_no_change(q_vector->irq_num)) { /* Tell napi that we are done polling */ napi_complete_done(napi, work_done); From patchwork Mon Aug 12 14:56:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13760760 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D472187552 for ; Mon, 12 Aug 2024 14:57:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474637; cv=none; b=YNMbeV51uZHticbuyARzjD1FkjhrBUyTon9ZleEEyhPsGvXx1+xxoBpk1mvIUmn24LGHwNUtvE4ofU5UppJm8gQk+C0dDIXDXHnYdPESfSrCQxgL+PcfdmUr8LKuHiJ5OALOKGFZ3YXlrb35itf6QQn0QMTB2otUrLyXbC777as= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474637; c=relaxed/simple; bh=td4IsMjxeMQ6Pb6ByC9aYsEdMEh9ogovdqECp/o7xSU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TPfB/LLle0Y23dR6UXEfRMilQzOnIibCFpDR3hebj9lqg5Aw0pjQn3InSHW7XoVYbm1juSmvZ1tmtWJT7tFZiQnf3nlXYDAWDNuHzvitptG+ptHJu2jdzmNcVMfmTJejN+lJtBF7pAzA6FsnjuDM+A8DA0MhZsA2zzXXlgAm0XA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=bkhKUbz8; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="bkhKUbz8" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-70d316f0060so3467107b3a.1 for ; Mon, 12 Aug 2024 07:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1723474635; x=1724079435; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DrcLy1oab8U1SIQex97TmW2YjriWxSFP0Rv3hsdafno=; b=bkhKUbz8jQPQ4OloRxO/3M0Rhi6XHTHiI6nIEidYLwQLMHrzWQTHeQ7T8JjUfedWwv UgoggQl0f7uu1DWeQU20TWDc0mbo7mssOcKQAkzDvjOjwDTaOLKdnSoO7DF8AHugD7Ml XK0aJMM/Oo2bKPcnGM+DrjZ4vCEgtJS2dSQTc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723474635; x=1724079435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DrcLy1oab8U1SIQex97TmW2YjriWxSFP0Rv3hsdafno=; b=rdF+/GBKs0uk+qYLZaB22RXplNys4D1pTw0LVGDk5PssiOJKiOoj0XOKAY9fZ4+44y CMoOxFhD3+4d6SdIIMf2LM0SJByeUyvWDZ++Iut0ze0i5bNcyng+oeXuxpVZg6LWa22j rhWUkUV1fFGBTkujRO2xDh/QGaqLhBv5dF+Hqh3pBvsjPKd58DGCYzq5FZ6LlCQlXjEf hpjDC1Pv5xFWG0IwM0XpbbuxakGfjKhlx3OCyrTlHhUiuMlnCkWVZWkhQkQdpPJ9LNWJ IL4EU84HQohHMHDoEPIfnmrvUSTQGhpzV5l8nj4XlxxKvfUZsVZJjrlJQtslXwQ//Fbq gLHw== X-Gm-Message-State: AOJu0Yz76XeXmm0L0wZ7aIhp1rN6GIr4FgGfvSHX1uzhaybOmjx8Oovx iJP2jikB7zjgJJ3kftr1jUaqkbD4jUT0jAE11X/nus7UyHrT7AE/TWNnC8jUNv2KIm8hDLFmiLx 9DlZGVRW76fbxVwt92B5ZRHlpflmF6Jw7nrFbr3idwUtn8WovjX2WNkfdlwzWHU4LcyiF85arVA 7JUKcTA0P89Nx8EkuQIGr6yomiQ4AGPVLc9uPi2g== X-Google-Smtp-Source: AGHT+IFYynzfBMLo6xho+itYUwLn3K/YaUpQ+DqK2Cu71wzV3u7gXENwfqrtXKcgSmW4HC1IOzt8TQ== X-Received: by 2002:a17:902:d4ce:b0:1fc:4680:820d with SMTP id d9443c01a7336-201ca92cd81mr5391865ad.9.1723474635006; Mon, 12 Aug 2024 07:57:15 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-200bb8fd835sm39006955ad.89.2024.08.12.07.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 07:57:14 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , Tony Nguyen , Przemek Kitszel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org (moderated list:INTEL ETHERNET DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next 5/6] iavf: Use napi_affinity_no_change Date: Mon, 12 Aug 2024 14:56:26 +0000 Message-Id: <20240812145633.52911-6-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240812145633.52911-1-jdamato@fastly.com> References: <20240812145633.52911-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Use napi_affinity_no_change instead of iavf's internal implementation, simplifying and centralizing the logic. To support this, struct iavf_q_vector has been extended to store the IRQ number, and irq_num's type is changed to unsigned int. Signed-off-by: Joe Damato --- drivers/net/ethernet/intel/iavf/iavf.h | 1 + drivers/net/ethernet/intel/iavf/iavf_main.c | 4 +++- drivers/net/ethernet/intel/iavf/iavf_txrx.c | 4 +--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h index 23a6557fc3db..b066bac6fa7c 100644 --- a/drivers/net/ethernet/intel/iavf/iavf.h +++ b/drivers/net/ethernet/intel/iavf/iavf.h @@ -113,6 +113,7 @@ struct iavf_q_vector { bool arm_wb_state; cpumask_t affinity_mask; struct irq_affinity_notify affinity_notify; + unsigned int irq_num; }; /* Helper macros to switch between ints/sec and what the register uses. diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c index ff11bafb3b4f..6c7733025ce3 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -565,7 +565,8 @@ iavf_request_traffic_irqs(struct iavf_adapter *adapter, char *basename) { unsigned int vector, q_vectors; unsigned int rx_int_idx = 0, tx_int_idx = 0; - int irq_num, err; + unsigned int irq_num; + int err; int cpu; iavf_irq_disable(adapter); @@ -601,6 +602,7 @@ iavf_request_traffic_irqs(struct iavf_adapter *adapter, char *basename) "Request_irq failed, error: %d\n", err); goto free_queue_irqs; } + q_vector->irq_num = irq_num; /* register for affinity change notifications */ q_vector->affinity_notify.notify = iavf_irq_affinity_notify; q_vector->affinity_notify.release = diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c index 26b424fd6718..5eb78ac1f39d 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c @@ -1408,8 +1408,6 @@ int iavf_napi_poll(struct napi_struct *napi, int budget) /* If work not completed, return budget and polling will return */ if (!clean_complete) { - int cpu_id = smp_processor_id(); - /* It is possible that the interrupt affinity has changed but, * if the cpu is pegged at 100%, polling will never exit while * traffic continues and the interrupt will be stuck on this @@ -1417,7 +1415,7 @@ int iavf_napi_poll(struct napi_struct *napi, int budget) * continue to poll, otherwise we must stop polling so the * interrupt can move to the correct cpu. */ - if (!cpumask_test_cpu(cpu_id, &q_vector->affinity_mask)) { + if (!napi_affinity_no_change(q_vector->irq_num)) { /* Tell napi that we are done polling */ napi_complete_done(napi, work_done); From patchwork Mon Aug 12 14:56:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13760761 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 045D7187875 for ; Mon, 12 Aug 2024 14:57:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474639; cv=none; b=feVpJGmdjCK3wR1v/63NgMHUGVRepuEb5reHPrJtyCya2oxdacis1K31lRDwTuBmBsJoVWZQ0l/GShe/QXS+QXBqSC+Vd43/+Vg2wCxmDrzr48uaOWUo+AgZVB8ffe5jSKZRCMYkZrBXKUnB+SJVc/eO5rTlXFrEB7hBc7ddX8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723474639; c=relaxed/simple; bh=PeMx/Nmrr+6PvU9tabl/ApT3ymGjWp++nP1TeXixLcg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UAf5hHm0V32zg0qE9nZKiNvVX5/BrbR9QTv4ICMczjADKDOZJkH/y3nR3a3ZrX9hjSa4qUE8XMUu2Rwqxhqu51BrTX8qwyohfx19Ox2RKuHNeETN1zmrq4FIVcq8I/wqi74Ri+4ze+aeNCcp3kYwx8St7DnxXX+oW3iqK6NhnHs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=sINuLwcJ; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="sINuLwcJ" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1fc491f9b55so29934005ad.3 for ; Mon, 12 Aug 2024 07:57:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1723474637; x=1724079437; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ItAoJGLSfkfsRS38y1iOZ6bIC8SZzEF77FLkXtuBPRA=; b=sINuLwcJeSQGnGBwzWl718E6dw9yDkDHrpFVideUBn1utxXetRMMhsP+K0iuRR7Zp9 AKMH2C4BUqnEjpa/9JGheD74KZ/4PYXF9jxu3ENpTXKM+Pafgvf+jveAiKWY/CVcU0/o AaKaH7DVxEDztASzbI/zBNmLxJzs2LUuvH1BU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723474637; x=1724079437; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ItAoJGLSfkfsRS38y1iOZ6bIC8SZzEF77FLkXtuBPRA=; b=QaWjjYo9FaTGY0mpM8hz4gAnpqn4eiiKktBYVQCdP7QolelKk9XHZ+HIbd9gU5en// 12XNWvKI5U9zzhYj28FNy1dMTJ4ZSfO9hgmPBk194M79oZ2ro1nLWhrf3C2CBe4z2tpU flob1miCucpdkAkhKI27P+XwBeXSCSYXF1mXs/I2EARYoCzs/a/BN5viv4mkRoaRwanh 7u/0N6dnMHMyCFZ5jnYxmi6RNEIheVGENISCX/95hE9s+qt6iInVMvVny8tJRXu3tJar fmqjQZ1aEfjUP0cezAHJLVqtdvQlzcwjyEqrzIF52FOW2xsuwAu1V+kc/7+K3fwgEWS5 Dn0A== X-Gm-Message-State: AOJu0Yz+4biPIAsyZ5AkPPP09Hix/hs5+yU8BTB0mW9FnKwgbkScMy1r 1RVlNyh2WBTEtzgV/+AKM7TUXrGPdO8txXPA0oqRBoLIy7SqPrw06MWHsvHd92EVipQiIlLqlLJ Vhma6SdWWdia1w3yDO5Ook8/YYfpM04VN50GFJbso4nXhFgmnv7KVKuCZMEZKVzms6SrbIGwqg8 UFaNvqiBzPVC4g+caMoMjBkBsxiKrxImISm4NVCg== X-Google-Smtp-Source: AGHT+IF6+BtyPaJDNmgeJnbxo3+hA+k0daqI0HbQdgRptG4H/1cOc+4ZuJzFbF2axrgf7+g7HivGWg== X-Received: by 2002:a17:903:1447:b0:1f9:f906:9088 with SMTP id d9443c01a7336-201ca13c3f4mr7492035ad.22.1723474636902; Mon, 12 Aug 2024 07:57:16 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-200bb8fd835sm39006955ad.89.2024.08.12.07.57.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 07:57:16 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: Joe Damato , Tariq Toukan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yishai Hadas , linux-rdma@vger.kernel.org (open list:MELLANOX MLX4 core VPI driver), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next 6/6] mlx4: Use napi_affinity_no_change Date: Mon, 12 Aug 2024 14:56:27 +0000 Message-Id: <20240812145633.52911-7-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240812145633.52911-1-jdamato@fastly.com> References: <20240812145633.52911-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Use napi_affinity_no_change instead of mlx4's internal implementation, simplifying and centralizing the logic. To support this, some type changes were made, which might have been bugs: - mlx4_eq_get_irq should return unsigned int (since the field it returns is u16) - fix the type of irq (from int to unsigned int) in mlx4_en_activate_cq Signed-off-by: Joe Damato --- drivers/net/ethernet/mellanox/mlx4/en_cq.c | 6 ++++-- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 6 +----- drivers/net/ethernet/mellanox/mlx4/eq.c | 2 +- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 + include/linux/mlx4/device.h | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ethernet/mellanox/mlx4/en_cq.c index 461cc2c79c71..9c3e1c810412 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c @@ -90,9 +90,10 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, int cq_idx) { struct mlx4_en_dev *mdev = priv->mdev; - int irq, err = 0; - int timestamp_en = 0; bool assigned_eq = false; + int timestamp_en = 0; + unsigned int irq; + int err = 0; cq->dev = mdev->pndev[priv->port]; cq->mcq.set_ci_db = cq->wqres.db.db; @@ -144,6 +145,7 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, goto free_eq; cq->cq_idx = cq_idx; + cq->irq = irq; cq->mcq.event = mlx4_en_cq_event; switch (cq->type) { diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 15c57e9517e9..4c296327b75b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -1022,14 +1022,10 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget) /* If we used up all the quota - we're probably not done yet... */ if (done == budget || !clean_complete) { - int cpu_curr; - /* in case we got here because of !clean_complete */ done = budget; - cpu_curr = smp_processor_id(); - - if (likely(cpumask_test_cpu(cpu_curr, cq->aff_mask))) + if (likely(napi_affinity_no_change(cq->irq))) return budget; /* Current cpu is not according to smp_irq_affinity - diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c index 9572a45f6143..feca4ea30750 100644 --- a/drivers/net/ethernet/mellanox/mlx4/eq.c +++ b/drivers/net/ethernet/mellanox/mlx4/eq.c @@ -1539,7 +1539,7 @@ int mlx4_assign_eq(struct mlx4_dev *dev, u8 port, int *vector) } EXPORT_SYMBOL(mlx4_assign_eq); -int mlx4_eq_get_irq(struct mlx4_dev *dev, int cq_vec) +unsigned int mlx4_eq_get_irq(struct mlx4_dev *dev, int cq_vec) { struct mlx4_priv *priv = mlx4_priv(dev); diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index 28b70dcc652e..1f9830b23c9c 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -381,6 +381,7 @@ struct mlx4_en_cq { const struct cpumask *aff_mask; int cq_idx; + unsigned int irq; }; struct mlx4_en_port_profile { diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index 27f42f713c89..1f2e9e954768 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h @@ -1433,7 +1433,7 @@ int mlx4_assign_eq(struct mlx4_dev *dev, u8 port, int *vector); void mlx4_release_eq(struct mlx4_dev *dev, int vec); int mlx4_is_eq_shared(struct mlx4_dev *dev, int vector); -int mlx4_eq_get_irq(struct mlx4_dev *dev, int vec); +unsigned int mlx4_eq_get_irq(struct mlx4_dev *dev, int vec); int mlx4_get_phys_port_id(struct mlx4_dev *dev); int mlx4_wol_read(struct mlx4_dev *dev, u64 *config, int port);