On Fri, 2006-08-04 at 19:56 -0700, Paul Menage wrote: > What's the recommended safe way to access current->res_group (or even > an arbitrary task->res_group) without racing against a concurrent > set_res_group() call from a different process?
I simplified some amount of locking in the last post. May be we overlooked some situations. Will look into it. > > For example, when calling numtasks_allow_fork(current->res_group) in > numtasks, I don't see anything that guarantees that current will > remain in the same res_group, or even that the res_group will persist > for the lifetime of the call. (OK, so numtasks_allow_fork() isn't > exactly a very long function call, but it's the principle that counts > ...) I totally agree. > > How about using task->alloc_lock to protect task->res_group? So all > manipulation would either have to be done inside task->alloc_lock, or > else would need to use a function such as: > > struct resource_group *task_get_res_group(struct task_struct *task) { > struct resource_group *res; > lock_task(task); > res = task->res_group; > if (res) kref_get(&res->ref); > unlock_task(task); > return res; > } > > An alternative (more efficient but more complex) approach would be to use RCU. > > Paul > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > ckrm-tech mailing list > https://lists.sourceforge.net/lists/listinfo/ckrm-tech -- ---------------------------------------------------------------------- Chandra Seetharaman | Be careful what you choose.... - [EMAIL PROTECTED] | .......you may get it. ---------------------------------------------------------------------- ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ ckrm-tech mailing list https://lists.sourceforge.net/lists/listinfo/ckrm-tech