From: Renata Saiakhova <Renata.Saiakhova@ekinops.com>
To: Anatoly Burakov <anatoly.burakov@intel.com>,
Harman Kalra <hkalra@marvell.com>,
Bruce Richardson <bruce.richardson@intel.com>,
Ray Kinsella <mdr@ashroe.eu>, Neil Horman <nhorman@tuxdriver.com>
Cc: dev@dpdk.org, Renata Saiakhova <Renata.Saiakhova@ekinops.com>
Subject: [dpdk-dev] [PATCH v2 1/1] librte_eal: rte_intr_callback_unregister_sync() - wrapper around rte_intr_callback_unregister().
Date: Mon, 17 Aug 2020 16:08:27 +0200 [thread overview]
Message-ID: <20200817140828.9769-2-Renata.Saiakhova@ekinops.com> (raw)
In-Reply-To: <20200817140828.9769-1-Renata.Saiakhova@ekinops.com>
Avoid race with unregister interrupt hanlder if interrupt
source has some active callbacks at the moment, use wrapper
around rte_intr_callback_unregister() to check for -EAGAIN
return value and to loop until rte_intr_callback_unregister()
succeeds.
Signed-off-by: Renata Saiakhova <Renata.Saiakhova@ekinops.com>
---
drivers/bus/pci/linux/pci_vfio.c | 2 +-
lib/librte_eal/freebsd/eal_interrupts.c | 12 ++++++++++++
lib/librte_eal/include/rte_interrupts.h | 25 +++++++++++++++++++++++++
lib/librte_eal/linux/eal_interrupts.c | 12 ++++++++++++
lib/librte_eal/rte_eal_version.map | 1 +
5 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index 07e072e13..a4bfdf553 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -415,7 +415,7 @@ pci_vfio_disable_notifier(struct rte_pci_device *dev)
return -1;
}
- ret = rte_intr_callback_unregister(&dev->vfio_req_intr_handle,
+ ret = rte_intr_callback_unregister_sync(&dev->vfio_req_intr_handle,
pci_vfio_req_handler,
(void *)&dev->device);
if (ret < 0) {
diff --git a/lib/librte_eal/freebsd/eal_interrupts.c b/lib/librte_eal/freebsd/eal_interrupts.c
index 6d53d33c8..7d99bdaff 100644
--- a/lib/librte_eal/freebsd/eal_interrupts.c
+++ b/lib/librte_eal/freebsd/eal_interrupts.c
@@ -345,6 +345,18 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,
return ret;
}
+int
+rte_intr_callback_unregister_sync(const struct rte_intr_handle *intr_handle,
+ rte_intr_callback_fn cb_fn, void *cb_arg)
+{
+ int ret = 0;
+
+ while ((ret = rte_intr_callback_unregister(intr_handle, cb_fn, cb_arg)) == -EAGAIN)
+ rte_pause();
+
+ return ret;
+}
+
int
rte_intr_enable(const struct rte_intr_handle *intr_handle)
{
diff --git a/lib/librte_eal/include/rte_interrupts.h b/lib/librte_eal/include/rte_interrupts.h
index e3b406abc..cc3bf45d8 100644
--- a/lib/librte_eal/include/rte_interrupts.h
+++ b/lib/librte_eal/include/rte_interrupts.h
@@ -94,6 +94,31 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,
rte_intr_callback_fn cb_fn, void *cb_arg,
rte_intr_unregister_callback_fn ucb_fn);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Loop until rte_intr_callback_unregister() succeeds.
+ * After a call to this function,
+ * the callback provided by the specified interrupt handle is unregistered.
+ *
+ * @param intr_handle
+ * pointer to the interrupt handle.
+ * @param cb
+ * callback address.
+ * @param cb_arg
+ * address of parameter for callback, (void *)-1 means to remove all
+ * registered which has the same callback address.
+ *
+ * @return
+ * - On success, return the number of callback entities removed.
+ * - On failure, a negative value.
+ */
+__rte_experimental
+int
+rte_intr_callback_unregister_sync(const struct rte_intr_handle *intr_handle,
+ rte_intr_callback_fn cb, void *cb_arg);
+
/**
* It enables the interrupt for the specified handle.
*
diff --git a/lib/librte_eal/linux/eal_interrupts.c b/lib/librte_eal/linux/eal_interrupts.c
index 13db5c4e8..c99d5dbd4 100644
--- a/lib/librte_eal/linux/eal_interrupts.c
+++ b/lib/librte_eal/linux/eal_interrupts.c
@@ -662,6 +662,18 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,
return ret;
}
+int
+rte_intr_callback_unregister_sync(const struct rte_intr_handle *intr_handle,
+ rte_intr_callback_fn cb_fn, void *cb_arg)
+{
+ int ret = 0;
+
+ while ((ret = rte_intr_callback_unregister(intr_handle, cb_fn, cb_arg)) == -EAGAIN)
+ rte_pause();
+
+ return ret;
+}
+
int
rte_intr_enable(const struct rte_intr_handle *intr_handle)
{
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index bf0c17c23..b1d824f59 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -325,6 +325,7 @@ EXPERIMENTAL {
rte_fbarray_find_rev_biggest_free;
rte_fbarray_find_rev_biggest_used;
rte_intr_callback_unregister_pending;
+ rte_intr_callback_unregister_sync;
rte_realloc_socket;
# added in 19.08
--
2.17.2
next prev parent reply other threads:[~2020-08-17 14:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-17 14:08 [dpdk-dev] [PATCH v2 0/1] pci_vfio_disable_notifier(): avoid race with unregister Renata Saiakhova
2020-08-17 14:08 ` Renata Saiakhova [this message]
2020-10-08 7:47 ` [dpdk-dev] [PATCH v2 1/1] librte_eal: rte_intr_callback_unregister_sync() - wrapper around rte_intr_callback_unregister() David Marchand
2020-10-20 13:40 ` David Marchand
2020-10-28 20:36 ` [dpdk-dev] [EXT] " Harman Kalra
2020-11-30 17:20 ` Renata Saiakhova
2021-02-11 10:48 ` [dpdk-dev] " Burakov, Anatoly
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=20200817140828.9769-2-Renata.Saiakhova@ekinops.com \
--to=renata.saiakhova@ekinops.com \
--cc=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=hkalra@marvell.com \
--cc=mdr@ashroe.eu \
--cc=nhorman@tuxdriver.com \
/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;
as well as URLs for NNTP newsgroup(s).