linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 2.4.23 *_task_struct() observations ...
@ 2003-12-01 17:26 Herbert Poetzl
  2003-12-01 17:51 ` Russell King
  0 siblings, 1 reply; 2+ messages in thread
From: Herbert Poetzl @ 2003-12-01 17:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marcelo Tosatti


Hi All!

just wanted to get an opinion on the following ...

include/asm-i386/processor.h  defines ...

  #define alloc_task_struct() ((struct task_struct *) \
				__get_free_pages(GFP_KERNEL,1))
  #define free_task_struct(p)  free_pages((unsigned long) (p), 1)
  #define get_task_struct(tsk) atomic_inc(&virt_to_page(tsk)->count)

now there seems to be no put_task_struct(), but
there are some examples where get/free is used 
where I would expect a put_* ...

fs/proc/base.c for example does:

        read_lock(&tasklist_lock);
        task = find_task_by_pid(pid);
        if (task)
                get_task_struct(task);
        read_unlock(&tasklist_lock);
        if (!task)
                goto out;

        inode = proc_pid_make_inode(dir->i_sb, task, PROC_PID_INO);

        free_task_struct(task);

which is a little suspicious ...

please could anybody explain the logic behind that?
(if it isn't a widespread bug(tm))

TIA,
Herbert



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: 2.4.23 *_task_struct() observations ...
  2003-12-01 17:26 2.4.23 *_task_struct() observations Herbert Poetzl
@ 2003-12-01 17:51 ` Russell King
  0 siblings, 0 replies; 2+ messages in thread
From: Russell King @ 2003-12-01 17:51 UTC (permalink / raw)
  To: linux-kernel, Marcelo Tosatti

On Mon, Dec 01, 2003 at 06:26:20PM +0100, Herbert Poetzl wrote:
> just wanted to get an opinion on the following ...
> 
> include/asm-i386/processor.h  defines ...
> 
>   #define alloc_task_struct() ((struct task_struct *) \
> 				__get_free_pages(GFP_KERNEL,1))
>   #define free_task_struct(p)  free_pages((unsigned long) (p), 1)
>   #define get_task_struct(tsk) atomic_inc(&virt_to_page(tsk)->count)
> 
> now there seems to be no put_task_struct(), but
> there are some examples where get/free is used 
> where I would expect a put_* ...

put_* is free_*.  The reference count for the task struct is the page
count (virt_to_page(tsk)->count).

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-12-01 17:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-01 17:26 2.4.23 *_task_struct() observations Herbert Poetzl
2003-12-01 17:51 ` Russell King

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).