kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: miloody@gmail.com (loody)
To: kernelnewbies@lists.kernelnewbies.org
Subject: some questions about container_of and user_struct
Date: Mon, 13 Feb 2012 15:34:19 +0800	[thread overview]
Message-ID: <CANudz+t_yXA621maPO+Cn5hGtsyL-ebn2hzFv+2XxOA9KyL2Fw@mail.gmail.com> (raw)

hi all:
I add below function in free_uid to get which task try to free user_struct

struct task_struct *p;
struct cred *c;
c = container_of(up,struct cred, user);
p = container_of(c,struct task_struct,real_cred);
printk("%s user %p, cred->user = %p p->pid = %d\n",__func__,up, c->user,p->pid);

but p->pid is always 0.
I think it is wrong for me to get cred and task by using container_of.

1. from kernel definition below, is it ok that member is pointer?
#define container_of(ptr, type, member)

2. is there already exist macros or functions I can use for #1 above?

3. what is user_struct used for? When and under what circumstances
kernel will try to release it.

4. since user_struct is allocated by kmem_cache_zalloc, is there api
or tool I can monitor it?

Thanks for your help,

             reply	other threads:[~2012-02-13  7:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-13  7:34 loody [this message]
2012-02-20  2:18 ` some questions about container_of and user_struct Peter Teoh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANudz+t_yXA621maPO+Cn5hGtsyL-ebn2hzFv+2XxOA9KyL2Fw@mail.gmail.com \
    --to=miloody@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).