[PATCH 1/1] creds: print user_struct refcounts

Serge Hallyn serue at us.ibm.com
Mon Oct 13 14:36:05 PDT 2008


print user_struct refcounts at alloc, and print msg at uid free.

Signed-off-by: Serge Hallyn <serue at us.ibm.com>
Signed-off-by: David Howells <dhowells at redhat.com>
---

 kernel/user.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)


diff --git a/kernel/user.c b/kernel/user.c
index d476307..073296e 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -317,6 +317,7 @@ done:
 static inline void free_user(struct user_struct *up, unsigned long flags)
 {
 	/* restore back the count */
+	printk(KERN_NOTICE "%s: freeing a uid (%d)\n", __func__, up->uid);
 	atomic_inc(&up->__count);
 	spin_unlock_irqrestore(&uidhash_lock, flags);
 
@@ -337,6 +338,7 @@ static inline void uids_mutex_unlock(void) { }
  */
 static inline void free_user(struct user_struct *up, unsigned long flags)
 {
+	printk(KERN_NOTICE "%s: freeing a uid (%d)\n", __func__, up->uid);
 	uid_hash_remove(up);
 	spin_unlock_irqrestore(&uidhash_lock, flags);
 	sched_destroy_user(up);
@@ -422,16 +424,24 @@ struct user_struct *alloc_uid(struct user_namespace *ns, uid_t uid)
 			key_put(new->uid_keyring);
 			key_put(new->session_keyring);
 			kmem_cache_free(uid_cachep, new);
+			printk(KERN_NOTICE "%s: reuse a uid (%d) (cnt %u)\n",
+			       __func__, uid, atomic_read(&up->__count));
+
 		} else {
 			uid_hash_insert(new, hashent);
 			up = new;
+			printk(KERN_NOTICE "%s: alloced a uid (%d) (cnt %u)\n",
+			       __func__, uid, atomic_read(&up->__count));
+
 		}
 		spin_unlock_irq(&uidhash_lock);
 
+	} else {
+		printk(KERN_NOTICE "%s: reuse a uid (%d) (cnt %u)\n",
+		       __func__, uid, atomic_read(&up->__count));
 	}
 
 	uids_mutex_unlock();
-
 	return up;
 
 out_destoy_sched:


More information about the Containers mailing list