From: Kirill Korotaev <kirillx@7ka.mipt.ru>
To: linux-kernel@vger.kernel.org
Subject: Q: kernel/pids.c code
Date: Thu, 15 Apr 2004 00:13:36 +0400 [thread overview]
Message-ID: <807045345.20040415001336@7ka.mipt.ru> (raw)
In-Reply-To: <1310277139.20040415001215@7ka.mipt.ru>
Hello all,
I have two questions both concerning code located in kernel/pids.c:
1. why do we hold task.struct pid_link pids[].pid in task_struct?
I looked through the code and found that such solution is ugly at
least because:
- it occupies at least 7*4=28 more integers in task_struct then could
be. Note that this memory is not used everytime.
- pids can held reference to task_struct thus making it's lifetime longer
and less predictable. Memory consumption is unpredictable.
- the code is really unreadable and messy
Why struct pid is not allocated in kmem_cache instead?
2. function switch_exec_pids() calls _detach_pid() 6 times
and attach_pid() 8 times, i.e. we put 6 references and take 8.
is it bug? if so, then it looks like
pids (SID and PGID) can leak (with corresponding task_structs)?
void switch_exec_pids(task_t *leader, task_t *thread)
{
_detach_pid(leader, PIDTYPE_PID);
_detach_pid(leader, PIDTYPE_TGID);
_detach_pid(leader, PIDTYPE_PGID);
_detach_pid(leader, PIDTYPE_SID);
_detach_pid(thread, PIDTYPE_PID);
_detach_pid(thread, PIDTYPE_TGID);
leader->pid = leader->tgid = thread->pid;
thread->pid = thread->tgid;
attach_pid(thread, PIDTYPE_PID, thread->pid);
attach_pid(thread, PIDTYPE_TGID, thread->tgid);
attach_pid(thread, PIDTYPE_PGID, thread->pgrp);
attach_pid(thread, PIDTYPE_SID, thread->session);
attach_pid(leader, PIDTYPE_PID, leader->pid);
attach_pid(leader, PIDTYPE_TGID, leader->tgid);
attach_pid(leader, PIDTYPE_PGID, leader->pgrp);
attach_pid(leader, PIDTYPE_SID, leader->session);
}
Kirill
parent reply other threads:[~2004-04-14 20:12 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <1310277139.20040415001215@7ka.mipt.ru>]
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=807045345.20040415001336@7ka.mipt.ru \
--to=kirillx@7ka.mipt.ru \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®