<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 14, 2019 at 6:04 PM Alex Williamson <<a href="mailto:alex.williamson@redhat.com">alex.williamson@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, 14 Jun 2019 17:06:15 +0200<br>
Christophe de Dinechin <<a href="mailto:cdupontd@redhat.com" target="_blank">cdupontd@redhat.com</a>> wrote:<br>
<br>
> > On 14 Jun 2019, at 16:23, Alex Williamson <<a href="mailto:alex.williamson@redhat.com" target="_blank">alex.williamson@redhat.com</a>> wrote:<br>
> > <br>
> > On Fri, 14 Jun 2019 11:54:42 +0200<br>
> > Christophe de Dinechin <<a href="mailto:cdupontd@redhat.com" target="_blank">cdupontd@redhat.com</a>> wrote:<br>
> >   <br>
> >> That is true irrespective of the usage, isn’t it? In other words, when you<br>
> >> invoke `mdevctl create-mdev`, you assert “I own that specific parent/type”.<br>
> >> At least, that’s how I read the way the script behaves today. Whether you<br>
> >> invoke uuidgen inside or outside the script does not change that assertion<br>
> >> (at least with today’s code).  <br>
> > <br>
> > What gives you this impression?  <br>
> <br>
> That your code does nothing to avoid any race today?<br>
> <br>
> Maybe I was confused with the existing `uuidgen` example in you README,<br>
> but it looks to me like the usage model involves much more than just<br>
> create-mdev, and that any race that might exist is not in create-mdev itself<br>
> (or in uuidgen for that matter).<br>
<br>
I believe I mentioned this was an early release, error handling is<br>
lacking.  Still, I think the races are minimal, they largely involve<br>
uuid collisions.  Separate users can create mdevs under the same parent<br>
concurrently, they would need to have a uuid collision to conflict.<br>
Otherwise there's the resource issue on the parent, but that's left of<br>
the kernel to manage.  If an mdev fails to be created at the kernel,<br>
mdevctl should unwind, but we're not going to pretend that we have a<br>
lock on the parent's sysfs mdev interfaces.<br>
<br>
> > Where is the parent/type ownership implied?  <br>
> <br>
> I did not imply it, but I read some concern about ownership<br>
> on your part in "they need to guess that an mdev device<br>
> with the same parent and type is *theirs*.” (emphasis mine)<br>
> <br>
> I personally see no change on the “need to guess” implied<br>
> by the fact that you run uuidgen inside the script, so<br>
> that’s why I tried to guess what you meant.<br>
<br>
As I noted in the reply to the pull request, putting `uuidgen` inline<br>
was probably a bad example.  However, the difference is that the user<br>
has imposed the race on themselves if they invoke mdevctl like this,<br>
they've provided a uuid but they didn't record what it is.  This is the<br>
user's problem.  Pushing uuid selection into mdevctl makes it mdevctl's<br>
problem because the interface is fundamentally broken.<br>
<br>
> > The intended semantics are<br>
> > "try to create this type of device under this parent”.  <br>
> <br>
> Agreed. Which is why I don’t see why trying to create<br>
> with some new UUID introduces any race (as long as<br>
> the script prints out that UUID, which I admit my patch<br>
> entirely failed to to)<br>
<br>
And that's the piece that makes it fundamentally broken.  Beyond that,<br>
it seems unnecessary.  I don't see this as the primary invocation of<br>
mdevctl and the functionality it adds is trivially accomplished in a<br>
wrapper, so what's the value?<br>
<br>
> >>> How do you resolve two instances of this happening in parallel and both<br>
> >>> coming to the same conclusion which is their device.  If a user wants<br>
> >>> this sort of headache they can call mdevctl with `uuidgen` but I don't<br>
> >>> think we should encourage it further.    <br>
> >> <br>
> >> I agree there is a race, but if anything, having a usage where you don’t<br>
> >> pass the UUID on the command line is a step in the right direction.<br>
> >> It leaves the door open for the create-mdev script to do smarter things,<br>
> >> like deferring the allocation of the mdevs to an entity that has slightly<br>
> >> more knowledge of the global system state than uuidgen.  <br>
> > <br>
> > A user might (likely) require a specific uuid to match their VM<br>
> > configuration.  I can only think of very niche use cases where a user<br>
> > doesn't care what uuid they get.  <br>
> <br>
> They do care. But I typically copy-paste my UUIDs, and then<br>
> <br>
> 1. copy-pasting at the end is always faster than between<br>
> the command and other arguments (3-args case). <br>
> <br>
> 2. copy-pasting the output of the previous command is faster<br>
> than having one extra step where I need to copy the same thing twice<br>
> (2-args case).<br>
> <br>
> So to me, if the script is intended to be used by humans, my<br>
> proposal makes it slightly more comfortable to use. Nothing more.<br>
<br>
This is your preference, but I wouldn't call it universal.  Specifying<br>
the uuid last seems backwards to me, we're creating an object so let's<br>
first name that object.  We then specify where that object should be<br>
created and what type it has.  This seems very logical to me, besides,<br>
it's also the exact same order we use when listing mdevs :P<br>
<br>
Clearly there's personal preference here, so let's not arbitrarily pick<br>
a different preference.  If copy/paste order is more important to you<br>
then submit a patch to give mdevctl real argument processing so you can<br>
specify --uuid, --parent, --type in whatever order you want.<br>
<br>
> >> In other words, in my mind, `mdevctl create-mdev parent type` does not<br>
> >> imply “this will use uuidgen” but rather, if anything, implies “this will do the<br>
> >> right thing to prevent the race in the future, even if that’s more complex<br>
> >> than just calling uuidgen”.  <br>
> > <br>
> > What race are you trying to prevent, uuid collision?  <br>
> <br>
> Of course not ;-)<br>
> <br>
> I only added the part of the discussion below trying to figure out what<br>
> race you were seeing that was present only with my proposed changes.<br>
> <br>
> I (apparently incorrectly) supposed that you had some kind of mdev<br>
> management within the script in mind. Obviously I misinterpreted.<br>
> That will teach me to guess when I don’t understand instead of just<br>
> ask…<br>
<br>
The management mdevctl provides is persistence, interrogation, and<br>
interaction with mdevs and parent devices.  Like every other tool, I'm<br>
going to defer policy related decisions to someone else.  Picking a<br>
uuid is policy.  Picking a parent device is policy.<br>
<br>
> >> However, I believe that this means we should reorder the args further.<br>
> >> I would suggest something like:<br>
> >> <br>
> >>    mdevctl create-mdev <mdev-type> [<parent-device> [<mdev-uuid>]]<br>
> >> <br>
> >> where  <br>
> > <br>
> > Absolutely not, now you've required mdevctl to implement policy in mdev<br>
> > placement.  <br>
> <br>
> No, I’m not requiring it. I’m leaving the door open if one day, say, we decide<br>
> to have libvirt tell us about the placement. That usage needs not go in right away,<br>
> I marked it as “(future)”.<br>
> <br>
> Basically, all I’m saying is that since it’s early, we can reorder the<br>
> arguments so that the one you are most likely to change when you reuse<br>
> the command are the one that are last on the command-line, so that it<br>
> makes editing or copy-pasting easier. There isn’t more to it, and that’s<br>
> why I still do not see any new race introduced by that change.<br>
<br>
This is just compounding a shortcut made for this initial version,<br>
clearly the solution is to allow arbitrary option ordering, not to pick<br>
a different ordering for a perceived copy/paste efficiency<br>
<br>
> >  mdevctl follows the unix standard, do one thing and do it<br>
> > well.  If someone wants to layer placement policy on top of mdevctl,<br>
> > great, but let's not impose that within mdevctl.  <br>
> <br>
> I’m not imposing anything (I believe). I was only trying to guess<br>
> where you saw things going that would imply there was a race with<br>
> my proposal that was not there without :-)<br>
> <br>
> >   <br>
> >> 1 arg means you let mdevctl choose the parent device for you (future)<br>
> >>   (e.g. I want a VGPU of this type, I don’t really care where it comes from)<br>
> >> 2 args mean you want that specific type/parent combination<br>
> >> 3 args mean you assert you own that device<br>
> >> <br>
> >> That also implies that mdevctl create-mdev should output what it allocated<br>
> >> so that some higher-level software can tell “OK, that’s the instance I got”.  <br>
> > <br>
> > I don't think we're aligned on what mdevctl is attempting to provide.<br>
> > Maybe you're describing a layer you'd like to see above mdevctl?<br>
> > Thanks,  <br>
> <br>
> No, again, I’m just trying to understand where you see a race.<br>
> <br>
> Maybe instead of guessing, I should just ask: where is the race in<br>
> the two-args variant (assuming it prints the UUID it used) that does not<br>
> exist with the three-args variant?<br>
<br>
Currently users deterministically know the uuid of the mdev they<br>
create, they specify it.  They're not racing other users that<br>
potentially created the same type on the same parent to guess which<br>
mdev might be theirs, potentially picking the wrong one, potentially<br>
picking the same as their counterpart.  Returning the uuid solves this<br>
race, but as you noted, implies a much broader uuid allocation scheme<br>
and policy which I'm not interested in providing in mdevctl until you<br>
can convince me otherwise.  Thanks,<br>
<br></blockquote><div><br></div><div>There are multiples reasons why I'd prefer to pass UUIDs to mdevctl and not ask it to provide them.</div><div>At least, sometimes, we don't want to have UUID4's for mdevs. Some other times, we would just want to recreate some mdev with the exact same UUID than a previous one.</div><div>So, yeah, having mdevctl asking for a UUID but also returning it would be good for me.</div><div><br></div><div>-Sylvain</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Alex<br>
</blockquote></div></div>