Michal Hocko wrote:
+bool task_has_external_users(struct task_struct *p)
+{
+ struct mm_struct *mm = NULL;
+ struct task_struct *t;
+ int active_threads = 0;
+ bool ret = true; /* be pessimistic */
+
+ rcu_read_lock();
+ for_each_thread(p, t) {
+ task_lock(t);
+ if (likely(t->mm)) {
+ active_threads++;
+ if (!mm) {
+ mm = t->mm;
+ atomic_inc(&mm->mm_count);
+ }
+ }
+ task_unlock(t);
+ }
+ rcu_read_unlock();
+
I don't like this. We might sleep here long enough to change mm_users.
+ if (mm) {
+ if (atomic_read(&mm->mm_users) <= active_threads)
+ ret = false;
+ mmdrop(mm);
+ }
+ return ret;
+}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>