DragonFly BSD
DragonFly commits List (threaded) for 2009-12
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: git: kernel - misc MPSAFe work


From: Michael Neumann <michaelneuma@xxxxxxxxxxxxxx>
Date: Sun, 20 Dec 2009 13:51:03 +0100

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



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]