Oleg Nesterov <[email protected]> writes: > On 10/09, Greg KH wrote: >> >> > +static inline int __kref_put(struct kref *kref) >> > +{ >> > + return atomic_dec_and_test(&kref->refcount); >> > +} >> >> No, this isn't ok, what happened to the release function? Why is this >> needed? > > To avoid the recursion. ->release was already called. > >> > --- a/kernel/pid_namespace.c~pidns-remove-recursion-from-free_pid_ns-v3 >> > +++ a/kernel/pid_namespace.c >> > @@ -139,11 +139,19 @@ void free_pid_ns(struct kref *kref) >> > >> > ns = container_of(kref, struct pid_namespace, kref); >> > >> > - parent = ns->parent; >> > - destroy_pid_namespace(ns); >> > + while (1) { >> > + parent = ns->parent; >> > + destroy_pid_namespace(ns); >> > >> > - if (parent != NULL) >> > - put_pid_ns(parent); >> > + if (parent == &init_pid_ns) >> > + break; >> > + >> > + /* kref_put cannot be used for avoiding recursion */ >> > + if (__kref_put(&parent->kref) == 0) >> > + break; >> >> Someone is abusing something here, please don't change the kref api to >> work around someone using it improperly. >> >> So no, please don't apply this at all. > > Because this is wrong or because not kosher?
Oleg it is easy enough to not use the unnecesary kref abstraction. We can directly use atomic_dec_and_test. Since the pid namespace no longer fits into the narrow confines of the kref abstraction there is no need to use it. What is a shame is that any of this is necessary at all. If gcc could get it's tail-call / sibling-call optimization right the final put_pid_ns whould just perform a tail call, take no space on the stack and all would be good. Eric -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
