From: Balbir Singh <balbir@in.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: nagar@watson.ibm.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, tgraf@suug.ch, hadi@cyberus.ca
Subject: Re: [Patch 5/8] generic netlink interface for delay accounting
Date: Thu, 30 Mar 2006 11:59:22 +0530 [thread overview]
Message-ID: <20060330062922.GA30151@in.ibm.com> (raw)
In-Reply-To: <20060329222629.0a730997.akpm@osdl.org>
On Wed, Mar 29, 2006 at 10:26:29PM -0800, Andrew Morton wrote:
> Balbir Singh <balbir@in.ibm.com> wrote:
> >
> > > The kmem_cache_free() can happen outside the lock.
> >
> >
> > kmem_cache_free() and setting to NULL outside the lock is prone to
> > race conditions. Consider the following scenario
> >
> > A thread group T1 has exiting processes P1 and P2
> >
> > P1 is exiting, finishes the delay accounting by calling taskstats_exit_pid()
> > and gives up the mutex and calls kmem_cache_free(), but before it can set
> > tsk->delays to NULL, we try to get statistics for the entire thread group.
> > This task will show up in the thread group with a dangling tsk->delays.
>
> Yes, the `tsk->delays = NULL;' needs to happen inside the lock. But the
> kmem_cache_free() does not. It pointlessly increases the lock hold time.
Understood will fix it
>
> > > > + if (info->attrs[TASKSTATS_CMD_ATTR_PID]) {
> > > > + u32 pid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_PID]);
> > > > + rc = fill_pid((pid_t)pid, NULL, &stats);
> > >
> > > We shouldn't have a typecast here. If it generates a warning then we need
> > > to get in there and find out why.
> >
> > The reason for a typecast is that pid is passed as a u32 from userspace.
> > genetlink currently supports most unsigned types with little or no
> > support for signed types. We exchange data as u32 and do the correct
> > thing in the kernel. Would you like us to move away from this?
> >
>
> I think it's best to avoid the cast unless it's actually needed to avoid a
> warning or compile error, or to do special things with sign extension.
> Because casts clutter up the code and can hide real bugs. In this case the
> compiler should silently perform the conversion.
Yep, the compiler was doing it for me, but I tried to be smart and cast
things around. Will fix it.
Thanks,
Balbir
next prev parent reply other threads:[~2006-03-30 6:32 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-30 0:32 [Patch 0/8] per-task " Shailabh Nagar
2006-03-30 0:35 ` [Patch 1/8] Setup Shailabh Nagar
2006-03-30 5:03 ` Andrew Morton
2006-03-30 15:07 ` Shailabh Nagar
2006-03-30 0:37 ` [Patch 2/8] Block I/O, swapin delays Shailabh Nagar
2006-03-30 5:03 ` Andrew Morton
2006-03-30 15:21 ` Shailabh Nagar
2006-03-30 0:42 ` [Patch 3/8] cpu delays Shailabh Nagar
2006-03-30 5:03 ` Andrew Morton
2006-03-30 16:01 ` Shailabh Nagar
2006-03-30 16:00 ` Dave Hansen
2006-03-30 16:03 ` Shailabh Nagar
2006-03-30 0:48 ` [Patch 4/8] generic netlink utility functions Shailabh Nagar
2006-03-30 0:52 ` [Patch 5/8] generic netlink interface for delay accounting Shailabh Nagar
2006-03-30 5:04 ` Andrew Morton
2006-03-30 6:10 ` Balbir Singh
2006-03-30 6:26 ` Andrew Morton
2006-03-30 6:29 ` Balbir Singh [this message]
2006-03-30 16:24 ` Shailabh Nagar
2006-03-30 0:54 ` [Patch 6/8] virtual cpu run time Shailabh Nagar
2006-03-30 5:04 ` Andrew Morton
2006-03-30 16:10 ` Shailabh Nagar
2006-03-30 0:56 ` [Patch 7/8] proc interface for block I/O delays Shailabh Nagar
2006-03-30 5:04 ` Andrew Morton
2006-03-30 0:59 ` [Patch 8/8] documentation, userspace utility Shailabh Nagar
2006-03-30 5:03 ` [Patch 0/8] per-task delay accounting Andrew Morton
2006-03-30 6:23 ` Balbir Singh
2006-03-30 6:47 ` Andrew Morton
2006-03-30 9:55 ` Paul Jackson
2006-03-30 13:23 ` [Lse-tech] " Dipankar Sarma
2006-03-30 17:23 ` Shailabh Nagar
2006-03-31 2:54 ` Peter Chubb
2006-03-31 5:27 ` Shailabh Nagar
2006-03-31 8:17 ` Peter Chubb
2006-03-31 16:03 ` Shailabh Nagar
[not found] ` <442CCF54.3000501@watson.ibm.com>
2006-03-31 7:31 ` Guillaume Thouvenin
2006-03-31 17:01 ` Shailabh Nagar
[not found] ` <442D8E39.8080606@engr.sgi.com>
[not found] ` <442DED81.5060009@engr.sgi.com>
2006-04-10 17:15 ` Jay Lan
2006-04-10 21:44 ` Shailabh Nagar
2006-04-10 22:33 ` [Lse-tech] " Jay Lan
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=20060330062922.GA30151@in.ibm.com \
--to=balbir@in.ibm.com \
--cc=akpm@osdl.org \
--cc=hadi@cyberus.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=nagar@watson.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
/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
Powered by JetHome