Re: git: kernel - misc MPSAFe work
--0015175cd162ef2989047b286c33
Content-Type: text/plain; charset=ISO-8859-1
2009/12/20 Matthew Dillon <dillon@crater.dragonflybsd.org>
>
> commit 61f96b6ff60acbd1692d0bffe07b5e1f262327dc
> Author: Matthew Dillon <dillon@apollo.backplane.com>
> Date: Sat Dec 19 22:18:37 2009 -0800
>
> kernel - misc MPSAFe work
>
> * prisoncount, prison_hold(), and prison_free() are now MPSAFE
>
I wonder if the change below is really neccessary, as LIST_INSERT_HEAD is
not MP-safe and
the whole function kern_jail must be called with mp_lock hold. It just made
me think that you missed
to make the list insert race free until I saw that the function is always
called with mp_lock held.
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -177,7 +177,7 @@ kern_jail(struct prison *pr, struct jail *j)
LIST_INSERT_HEAD(&allprison, pr, pr_list);
- prisoncount++;
+ atomic_add_int(&prisoncount, 1);
And I wonder if in the error path, there is isn't missing an
atomic_add_int(&prisoncount, -1):
179 LIST_INSERT_HEAD(&allprison, pr, pr_list);
180 atomic_add_int(&prisoncount, 1);
181
182 error = kern_jail_attach(pr->pr_id);
183 if (error) {
184 LIST_REMOVE(pr, pr_list);
+ atomic_add_int(&prisoncount, -1):
185 varsymset_clean(&pr->pr_varsymset);
186 }
Regards,
Michael
--0015175cd162ef2989047b286c33
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
2009/12/20 Matthew Dillon <span dir=3D"ltr"><<a href=3D"mailto:dillon@cr=
ater.dragonflybsd.org">dillon@crater.dragonflybsd.org</a>></span><br><di=
v class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"border-l=
eft: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:=
1ex;">
<br>
commit 61f96b6ff60acbd1692d0bffe07b5e1f262327dc<br>
Author: Matthew Dillon <<a href=3D"mailto:dillon@apollo.backplane.com">d=
illon@apollo.backplane.com</a>><br>
Date: =A0 Sat Dec 19 22:18:37 2009 -0800<br>
<br>
=A0 =A0kernel - misc MPSAFe work<br>
<br>
=A0 =A0* prisoncount, prison_hold(), and prison_free() are now MPSAFE<br><=
/blockquote><div><br>I wonder if the change below is really neccessary, as =
LIST_INSERT_HEAD is not MP-safe and<br>the whole function kern_jail must be=
called with mp_lock hold. It just made me think that you missed <br>
to make the list insert race free until I saw that the function is always c=
alled with mp_lock held.<br><br>--- a/sys/kern/kern_jail.c<br>+++ b/sys/ker=
n/kern_jail.c<br>@@ -177,7 +177,7 @@ kern_jail(struct prison *pr, struct ja=
il *j)<br>
=A0=A0=A0=A0=A0=A0=A0 LIST_INSERT_HEAD(&allprison, pr, pr_list);<br>-=
=A0=A0=A0=A0=A0=A0 prisoncount++;<br>+=A0=A0=A0=A0=A0=A0 atomic_add_int(&am=
p;prisoncount, 1);<br><br>And I wonder if in the error path, there is isn&#=
39;t missing an atomic_add_int(&prisoncount, -1):<br>
=A0<br>=A0179=A0=A0=A0=A0=A0=A0=A0=A0 LIST_INSERT_HEAD(&allprison, pr, =
pr_list);<br>=A0180=A0=A0=A0=A0=A0=A0=A0=A0 atomic_add_int(&prisoncount=
, 1);<br>=A0181 <br>=A0182=A0=A0=A0=A0=A0=A0=A0=A0 error =3D kern_jail_atta=
ch(pr->pr_id);<br>=A0183=A0=A0=A0=A0=A0=A0=A0=A0 if (error) {<br>=A0184=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 LIST_REMOVE(pr, pr_list);<=
br>
=A0+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 =A0=A0=A0 atomic_add_int(=
&prisoncount, -1): <br>=A0185=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 varsymset_clean(&pr->pr_varsymset);<br>=A0186=A0=A0=A0=A0=A0=
=A0=A0=A0 }<br><br><br>Regards,<br><br>=A0 Michael<br><br></div></div>
--0015175cd162ef2989047b286c33--
討論串 (同標題文章)