From: Gregory Haskins <ghaskins@novell.com>
To: Matthias Behr <linux@mcbehr.de>
Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org,
gregory.haskins@gmail.com, mingo@elte.hu, David.Holmes@sun.com,
jkacur@gmail.com, paulmck@linux.vnet.ibm.com,
peterz@infradead.org, tglx@linutronix.de, rostedt@goodmis.org
Subject: Re: AW: [PATCH RT RFC v4 1/8] add generalized priority-inheritance interface
Date: Tue, 19 Aug 2008 04:34:37 -0400 [thread overview]
Message-ID: <48AA859D.4030005@novell.com> (raw)
In-Reply-To: <073b01c8ffb5$5c597870$150c6950$@de>
[-- Attachment #1: Type: text/plain, Size: 1846 bytes --]
Hi Matthias,
Matthias Behr wrote:
> Hi Greg,
>
> I got a few review comments/questions. Pls see below.
>
> Best Regards,
> Matthias
>
> P.S. I'm a kernel newbie so don't hesitate to tell me if I'm wrong ;-)
>
>
>> +/**
>> + * pi_sink_init - initialize a pi_sink before use
>> + * @sink: a sink context
>> + * @ops: pointer to an pi_sink_ops structure
>> + */
>> +static inline void
>> +pi_sink_init(struct pi_sink *sink, struct pi_sink_ops *ops)
>> +{
>> + atomic_set(&sink->refs, 0);
>> + sink->ops = ops;
>> +}
>>
>
> Shouldn't ops be tested for 0 here? (ASSERT/BUG_ON/...) (get's dereferenced later quite often in the form "if (sink->ops->...)".
>
This is a good idea. I will add this.
>
>> +/**
>> + * pi_sink_put - down the reference count, freeing the sink if 0
>> + * @node: the node context
>> + * @flags: optional flags to modify behavior. Reserved, must be 0.
>> + *
>> + * Returns: none
>> + */
>> +static inline void
>> +pi_sink_put(struct pi_sink *sink, unsigned int flags)
>> +{
>> + if (atomic_dec_and_test(&sink->refs)) {
>> + if (sink->ops->free)
>> + sink->ops->free(sink, flags);
>> + }
>> +}
>>
>
> Shouldn't the atomic/locked part cover the ...->free(...) as well?
Actually, it already does. The free can only be called by the last
reference dropping the ref-count.
> A pi_get right after the atomic_dec_and_test but before the free() could lead to a free() with refs>0?
>
A pi_get() after the ref could have already dropped to zero is broken at
a higher layer. E.g. the caller of pi_get() has to ensure that there
are no races against the reference dropping to begin with. This is the
same as any reference-counted object (for instance, see get_task_struct()).
Thanks for the review, Matthias!
Regards,
-Greg
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
next prev parent reply other threads:[~2008-08-19 8:37 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-01 21:16 [PATCH RT RFC 0/7] Priority Inheritance enhancements Gregory Haskins
2008-08-01 21:16 ` [PATCH RT RFC 1/7] add generalized priority-inheritance interface Gregory Haskins
2008-08-01 21:16 ` [PATCH RT RFC 2/7] sched: add the basic PI infrastructure to the task_struct Gregory Haskins
2008-08-01 21:17 ` [PATCH RT RFC 3/7] rtmutex: formally initialize the rt_mutex_waiters Gregory Haskins
2008-08-01 21:17 ` [PATCH RT RFC 4/7] RT: wrap the rt_rwlock "add reader" logic Gregory Haskins
2008-08-01 21:17 ` [PATCH RT RFC 5/7] rtmutex: use runtime init for rtmutexes Gregory Haskins
2008-08-01 21:17 ` [PATCH RT RFC 6/7] rtmutex: convert rtmutexes to fully use the PI library Gregory Haskins
2008-08-01 21:17 ` [PATCH RT RFC 7/7] rtmutex: pi-boost locks as late as possible Gregory Haskins
2008-08-04 13:21 ` Gregory Haskins
2008-08-05 3:01 ` Gregory Haskins
2008-08-15 12:08 ` [PATCH RT RFC v2 0/8] Priority Inheritance enhancements Gregory Haskins
2008-08-15 12:08 ` [PATCH RT RFC v2 1/8] add generalized priority-inheritance interface Gregory Haskins
2008-08-15 13:16 ` [PATCH RT RFC v3] " Gregory Haskins
2008-08-15 12:08 ` [PATCH RT RFC v2 2/8] sched: add the basic PI infrastructure to the task_struct Gregory Haskins
2008-08-15 12:08 ` [PATCH RT RFC v2 3/8] sched: rework task reference counting to work with the pi infrastructure Gregory Haskins
2008-08-15 12:08 ` [PATCH RT RFC v2 4/8] rtmutex: formally initialize the rt_mutex_waiters Gregory Haskins
2008-08-15 12:08 ` [PATCH RT RFC v2 5/8] RT: wrap the rt_rwlock "add reader" logic Gregory Haskins
2008-08-15 12:08 ` [PATCH RT RFC v2 6/8] rtmutex: use runtime init for rtmutexes Gregory Haskins
2008-08-15 12:08 ` [PATCH RT RFC v2 7/8] rtmutex: convert rtmutexes to fully use the PI library Gregory Haskins
2008-08-15 12:08 ` [PATCH RT RFC v2 8/8] rtmutex: pi-boost locks as late as possible Gregory Haskins
2008-08-15 20:28 ` [PATCH RT RFC v4 0/8] Priority Inheritance enhancements Gregory Haskins
2008-08-15 20:28 ` [PATCH RT RFC v4 1/8] add generalized priority-inheritance interface Gregory Haskins
2008-08-15 20:32 ` Gregory Haskins
2008-08-16 15:32 ` AW: " Matthias Behr
2008-08-19 8:34 ` Gregory Haskins [this message]
2008-08-16 19:56 ` Peter Zijlstra
2008-08-19 8:40 ` Gregory Haskins
2008-08-22 12:55 ` Esben Nielsen
2008-08-22 13:15 ` Gregory Haskins
2008-08-22 16:08 ` Gregory Haskins
2008-08-22 13:17 ` Steven Rostedt
2008-08-15 20:28 ` [PATCH RT RFC v4 2/8] sched: add the basic PI infrastructure to the task_struct Gregory Haskins
2008-08-15 20:28 ` [PATCH RT RFC v4 3/8] sched: rework task reference counting to work with the pi infrastructure Gregory Haskins
2008-08-15 20:28 ` [PATCH RT RFC v4 4/8] rtmutex: formally initialize the rt_mutex_waiters Gregory Haskins
2008-08-15 20:28 ` [PATCH RT RFC v4 5/8] RT: wrap the rt_rwlock "add reader" logic Gregory Haskins
2008-08-15 20:28 ` [PATCH RT RFC v4 6/8] rtmutex: use runtime init for rtmutexes Gregory Haskins
2008-08-15 20:28 ` [PATCH RT RFC v4 7/8] rtmutex: convert rtmutexes to fully use the PI library Gregory Haskins
2008-08-15 20:29 ` [PATCH RT RFC v4 8/8] rtmutex: pi-boost locks as late as possible Gregory Haskins
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=48AA859D.4030005@novell.com \
--to=ghaskins@novell.com \
--cc=David.Holmes@sun.com \
--cc=gregory.haskins@gmail.com \
--cc=jkacur@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=linux@mcbehr.de \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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