[dpdk-dev] [PATCH V4 5/9] bus: add helper to handle sigbus
Gaëtan Rivet
gaetan.rivet at 6wind.com
Fri Jun 29 14:52:00 CEST 2018
On Fri, Jun 29, 2018 at 12:21:39PM +0000, Ananyev, Konstantin wrote:
>
>
> > -----Original Message-----
> > From: Guo, Jia
> > Sent: Friday, June 29, 2018 12:23 PM
> > To: Ananyev, Konstantin <konstantin.ananyev at intel.com>; stephen at networkplumber.org; Richardson, Bruce
> > <bruce.richardson at intel.com>; Yigit, Ferruh <ferruh.yigit at intel.com>; gaetan.rivet at 6wind.com; Wu, Jingjing
> > <jingjing.wu at intel.com>; thomas at monjalon.net; motih at mellanox.com; matan at mellanox.com; Van Haaren, Harry
> > <harry.van.haaren at intel.com>; Zhang, Qi Z <qi.z.zhang at intel.com>; He, Shaopeng <shaopeng.he at intel.com>; Iremonger, Bernard
> > <bernard.iremonger at intel.com>
> > Cc: jblunck at infradead.org; shreyansh.jain at nxp.com; dev at dpdk.org; Zhang, Helin <helin.zhang at intel.com>
> > Subject: Re: [PATCH V4 5/9] bus: add helper to handle sigbus
> >
> > hi, konstantin
> >
> >
> > On 6/29/2018 6:51 PM, Ananyev, Konstantin wrote:
> > >> +int
> > >> +rte_bus_sigbus_handler(const void *failure_addr)
> > >> +{
> > >> + struct rte_bus *bus;
> > >> + int old_errno = rte_errno;
> > >> + int ret = 0;
> > >> +
> > >> + rte_errno = 0;
> > >> +
> > >> + bus = rte_bus_find(NULL, bus_handle_sigbus, failure_addr);
> > >> + if (bus == NULL) {
> > >> + RTE_LOG(ERR, EAL, "No bus can handle the sigbus error!");
> > >> + ret = -1;
> > >> + } else if (rte_errno != 0) {
> > >> + RTE_LOG(ERR, EAL, "Failed to handle the sigbus error!");
> > >> + ret = -1;
> > >> + }
> > >> +
> > >> + /* if sigbus not be handled, return back old errno. */
> > >> + if (ret)
> > >> + rte_errno = old_errno;
> > > Hmm, not sure why we need to set/restore rte_errno here?
> >
> > restore old_errno just use to let caller know that the generic sigbus
> > still not handler by bus hotplug handler, that involve find a bus
> > handle but failed and can not find a hander, and can corresponding use
> > the previous sigbus handler to process it.
> > that is also unwser your question in other patch. do you think that make
> > sense?
>
> Sorry, still don't understand the intention.
> Suppose rte_bus_find() will return NULL, in that case you'll setup rte_errno
> to what it was before calling that function.
> If the returned bus is not NULL, but bus_find() set's an rte_errno,
> you still would restore rte_ernno?
> What is the prupose?
> Why do you need to touch rte_errno at all in that function?
> Konstantin
>
The way it is written here does not work, but the intention is
to make sure that a previous error is still catched. Something like
that:
int old_errno = rte_errno;
rte_errno = 0;
rte_eal_call();
if (rte_errno)
return -1;
else {
rte_errno = old_errno;
return 0;
}
If someone calls the function while rte_errno is already set, then an
earlier error would be hidden by setting rte_errno to 0 within the
function.
I'm not sure this is useful, but sometimes when using errno within a
library call I'm bothered that I am masking previous issues.
Should it be avoided?
--
Gaëtan Rivet
6WIND
More information about the dev
mailing list