<font size=2 face="Times New Roman">So, now we have at least 4 ways to
improve mutliapth efficiency:</font>
<br><font size=2 face="Times New Roman">1) Filtering uevents;</font>
<br><font size=2 face="Times New Roman">2) Merger uevents;</font>
<br><font size=2 face="Times New Roman">3) Using separate locks for
mpvec and pathvec;</font>
<br><font size=2 face="Times New Roman">4) Get rid of the gazillion
waiter threads.</font>
<br>
<br><font size=2 face="Times New Roman">This is exciting, but how do we
achieve this blueprint? </font>
<br><font size=2 face="Times New Roman">Can we set up some working groups
and develop it in parallel </font>
<div><font size=2 face="Times New Roman">to implement each improvement
since most of them are independent?</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">发件人:
</font><font size=1 face="sans-serif">"Benjamin
Marzinski" <bmarzins@redhat.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">收件人:
</font><font size=1 face="sans-serif">Martin Wilck
<mwilck@suse.com>, </font>
<br><font size=1 color=#5f5f5f face="sans-serif">抄送:
</font><font size=1 face="sans-serif">dm-devel@redhat.com,
tang.junhui@zte.com.cn</font>
<br><font size=1 color=#5f5f5f face="sans-serif">日期:
</font><font size=1 face="sans-serif">2016/11/19
06:33</font>
<br><font size=1 color=#5f5f5f face="sans-serif">主题:
</font><font size=1 face="sans-serif">Re: [dm-devel]
Improve processing efficiency for addition and deletion of multipath devices</font>
<br><font size=1 color=#5f5f5f face="sans-serif">发件人:
</font><font size=1 face="sans-serif">dm-devel-bounces@redhat.com</font>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>My $.02<br>
<br>
I'm not sure that we want to wait for a predetermined time to grab the<br>
uevents. If they are coming in slowly, multipathd is more responsive
by<br>
processing them immediately, and if they are coming in a storm, they<br>
will naturally pile up faster than we deal with them. I also don't<br>
really like the idea of waiting when we get an event to see if another<br>
one comes along, for the same reasons. That being said, I wouldn't NACK<br>
an config option (turned off by default) that set a minimum wait time<br>
between uevent dispatches, because I might be wrong here. However,
It<br>
sees like what uevent_dispatch() dispatch already does is the right<br>
thing, which is to pull all oustanding uevents off the uevent queue into<br>
a new list.<br>
<br>
The issue is that we simply need to work on processing the whole list at<br>
a time. Martin's filtering definitely has a place here. He is correct<br>
that if we get a delete uevent for a device, we don't need to process<br>
any of the earlier ones. We do need to look at both the add and change<br>
uevents individually. For instance, one of the change uevents out of a<br>
group could be for changing the read-only status of a device. If we just<br>
took the most recent, we would miss that information. The good news
is<br>
that we don't need to actually call uev_add_path and uev_update_path<br>
once for each of these events. All we need to do is read through
the<br>
uev environment variables for all of them to find the information we<br>
need (like change in ro status), and then call the function once with<br>
that information.<br>
<br>
Hannes pointed out that for adding paths we don't need to do any locking<br>
until we want to add the path to the pathvec. We could grab all the<br>
outstanding add events from the list that gets passed to service_uevq,<br>
and collect the pathinfo for all the paths, add them all into the<br>
pathvec, and then create or update the multipath devices. delete uevents<br>
could work similarly, where we find all the paths for a multipath device<br>
in our list, remove them all, and reload the device once.<br>
<br>
I'm not sure how much a separate thread for doing the multipath work<br>
would buy us, however. It's true that we could have a seperate lock for<br>
the mpvec, so we didn't need to hold the pathvec lock while updating the<br>
mpvec, but actually updating the mpvec only takes a moment. The time<br>
consuming part is building the multipath device and passing it to the<br>
kernel. For this, we do need the the paths locked. Otherwise what would<br>
keep a path from getting removed while the multipath device was using it<br>
to set get set up. If working with multipath devices and proccessing<br>
path uevents is happening at the same time, this is a very real<br>
possibility.<br>
<br>
But even if we keep one thread processing the uevents, simply avoiding<br>
calling uev_add_path and uev_update_path for repeated add and change<br>
events, and batching multiple add and delete events together could<br>
provide a real speedup, IMHO.<br>
<br>
Now, the holy grail of multipathd efficiency would be to totally rework<br>
multipathd's locking into something sensible. We could have locks
for<br>
the vectors that only got held when you were actually traversing or<br>
manipulating the vectors, coupled with reference counts on the<br>
individual paths and multipaths, so that they didn't get removed while<br>
they were in use, and probably locks on the individual paths and<br>
multipaths for just the sections that really needed to be protected.<br>
The problem is that this would take a huge amount of code auditting to<br>
get mostly right, and then a while to flush out all the missed corner<br>
cases. At least I think it would. But I dismissed decoupling the
config<br>
structure from the vecs lock as too painful, and clearly that was<br>
possible.<br>
<br>
At any rate, I'd rather get rid of the gazillion waiter threads first.<br>
<br>
-Ben<br>
<br>
On Thu, Nov 17, 2016 at 11:48:32AM +0100, Martin Wilck wrote:<br>
> Hi Tang,<br>
> <br>
> > As to process several uevents for the same physical devices,
I think<br>
> > the opinions <br>
> > different between us is "FILTER" or "MERGER".
Personally, I think<br>
> > Merger is more <br>
> > accuracy, for example, we receive 4 paths addition uevent messages<br>
> > from the same <br>
> > physical devices: <br>
> > 1)uevent add sdb <br>
> > 2)uevent add sdc <br>
> > 3)uevent add sdd <br>
> > 4)uevent add sde <br>
> > <br>
> > We cannot just filter the 1)2)3) uevent messages but only process
the<br>
> > 4)uevent message, <br>
> > which would cause losing paths of this multipath devices. <br>
> <br>
> Of course. My "filtering" idea was meant for cases where
several events<br>
> for the same device are queued, e.g.<br>
> <br>
> 1) add sda<br>
> 2) change sda<br>
> 3) delete sda<br>
> <br>
> Is it always sufficient to look only at the last event in such a case?<br>
> I think so, but I'm not 100% certain.<br>
> <br>
> Regards<br>
> Martin<br>
<br>
--<br>
dm-devel mailing list<br>
dm-devel@redhat.com<br>
</font></tt><a href="https://www.redhat.com/mailman/listinfo/dm-devel"><tt><font size=2>https://www.redhat.com/mailman/listinfo/dm-devel</font></tt></a><tt><font size=2><br>
</font></tt>
<br></div>