From: Robert Love <robert.w.love@intel.com>
To: linux-scsi@vger.kernel.org
Cc: Kiran Patil <kiran.patil@intel.com>
Subject: [PATCH 06/12] fcoe: Round-robin based selection of CPU for post-processing of incoming commands
Date: Mon, 20 Jun 2011 16:30:39 -0700 [thread overview]
Message-ID: <20110620233039.31635.45069.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20110620233007.31635.60206.stgit@localhost6.localdomain6>
From: Kiran Patil <kiran.patil@intel.com>
Problem: Earlier mechanism of selection of CPU was, to select the same CPU
which has received incoming request. Hence in case of rx_id = 0xFFFF,
request was always posted to same NetRx queue, hence only 1 CPU is utilized
for handling the command. It was also causing problem of "running out of
exchanges from per CPU pool of exchanges (in case of DDP offload)
Fix: Implemented new algo. to select CPU for post-processing of incoming commands
when rx_id is unknown. This is simple Round robin algo. for CPU selection.
Notes/Dependencies: N/A
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
---
drivers/scsi/fcoe/fcoe.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 38 insertions(+), 1 deletions(-)
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 6378c58..da73115 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -1245,6 +1245,36 @@ static int fcoe_cpu_callback(struct notifier_block *nfb,
}
/**
+ * fcoe_select_cpu() - Selects CPU to handle post-processing of incoming
+ * command.
+ * @curr_cpu: CPU which received request
+ *
+ * This routine selects next CPU based on cpumask.
+ *
+ * Returns: int (CPU number). Caller to verify if returned CPU is online or not.
+ */
+static unsigned int fcoe_select_cpu(unsigned int curr_cpu)
+{
+ static unsigned int selected_cpu;
+
+ if (num_online_cpus() == 1)
+ return curr_cpu;
+ /*
+ * Doing following check, to skip "curr_cpu (smp_processor_id)"
+ * from selection of CPU is intentional. This is to avoid same CPU
+ * doing post-processing of command. "curr_cpu" to just receive
+ * incoming request in case where rx_id is UNKNOWN and all other
+ * CPU to actually process the command(s)
+ */
+ do {
+ selected_cpu = cpumask_next(selected_cpu, cpu_online_mask);
+ if (selected_cpu >= nr_cpu_ids)
+ selected_cpu = cpumask_first(cpu_online_mask);
+ } while (selected_cpu == curr_cpu);
+ return selected_cpu;
+}
+
+/**
* fcoe_rcv() - Receive packets from a net device
* @skb: The received packet
* @netdev: The net device that the packet was received on
@@ -1320,9 +1350,16 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,
*/
if (ntoh24(fh->fh_f_ctl) & FC_FC_EX_CTX)
cpu = ntohs(fh->fh_ox_id) & fc_cpu_mask;
- else
+ else {
cpu = smp_processor_id();
+ if ((fh->fh_type == FC_TYPE_FCP) &&
+ (ntohs(fh->fh_rx_id) == FC_XID_UNKNOWN)) {
+ do {
+ cpu = fcoe_select_cpu(cpu);
+ } while (!cpu_online(cpu));
+ }
+ }
fps = &per_cpu(fcoe_percpu, cpu);
spin_lock_bh(&fps->fcoe_rx_list.lock);
if (unlikely(!fps->thread)) {
next prev parent reply other threads:[~2011-06-20 23:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-20 23:30 [PATCH 00/12] libfc, libfcoe and fcoe updates for scsi-misc Robert Love
2011-06-20 23:30 ` [PATCH 01/12] tcm_fc: Fix warning in file tfc_io Robert Love
2011-06-20 23:30 ` [PATCH 02/12] libfc: Enhancement to RPORT state machine applicable only for VN2VN mode Robert Love
2011-06-20 23:30 ` [PATCH 03/12] libfc, tcm_fc: add ddp_targ() to libfc function template to supprot FCoE DDP in target mode Robert Love
2011-06-20 23:30 ` [PATCH 04/12] fcoe: support ndo_fcoe_ddp_target() for DDP in FCoE targe Robert Love
2011-06-20 23:30 ` [PATCH 05/12] fcoe: Unable to select the exchangeID from offload pool for storage targets Robert Love
2011-06-20 23:30 ` Robert Love [this message]
2011-06-20 23:30 ` [PATCH 07/12] fcoe: Amends previous patch, Round-robin based selection of CPU for post processing of incoming request for FCoE target Robert Love
2011-06-20 23:30 ` [PATCH 08/12] libfc:Fix for exchange/seq loopup failure when FCoE stack is used as target and connected to windows initaitor Robert Love
2011-06-20 23:55 ` [PATCH 00/12] libfc, libfcoe and fcoe updates for scsi-misc Love, Robert W
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110620233039.31635.45069.stgit@localhost6.localdomain6 \
--to=robert.w.love@intel.com \
--cc=kiran.patil@intel.com \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox