Dave Jiang <[email protected]> wrote: > +static void __key_put(struct key *key, bool sync) > +{ > + if (key) { > + key_check(key); > + > + if (refcount_dec_and_test(&key->usage)) { > + schedule_work(&key_gc_work); > + if (sync) > + flush_work(&key_gc_work); > + } > + } > +}
I'm not sure this is a good way to go about it. This assumes that the gc will do an entire pass before returning to the dispatcher, but that won't necessarily always be the case. Further, it might take two passes to get rid of a key that has expired, been revoked or been invalidated: the first pass removes the links and then a second pass might be needed to remove the key, depending on the serial number of the key relative to the serial numbers of the keyrings linking to it. RCU synchronisation is then performed before the key can actually be cleaned up. A better way might be to add a global waitqueue and then use that to watch for an indication that a key is about to be finally destroyed. A flag can be set on the key to ask for the waitqueue to be poked David. _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
