From: Jan Kiszka <jan.kiszka@domain.hid>
To: Philippe Gerum <rpm@xenomai.org>
Cc: Xenomai core <Xenomai-core@domain.hid>
Subject: [Xenomai-core] [PULL] native: Fix msendq fastlock leakage
Date: Mon, 23 May 2011 15:53:19 +0200 [thread overview]
Message-ID: <4DDA66CF.2010307@domain.hid> (raw)
The following changes since commit aec30a2543afa18fa7832deee85e187b0faeb1f0:
xeno-test: fix reference to @XENO_TEST_DIR@ (2011-05-15 21:20:41 +0200)
are available in the git repository at:
git://git.xenomai.org/xenomai-jki.git for-upstream
Jan Kiszka (1):
native: Fix msendq fastlock leakage
include/native/task.h | 5 +++++
ksrc/skins/native/task.c | 13 ++++++-------
2 files changed, 11 insertions(+), 7 deletions(-)
------8<------
When a native task terminates without going through rt_task_delete, we
leaked the fastlock so far. Fix it by moving the release into the delete
hook. As the ppd is already invalid at that point, we have to save the
heap address in the task data structure.
Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---
include/native/task.h | 5 +++++
ksrc/skins/native/task.c | 13 ++++++-------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/include/native/task.h b/include/native/task.h
index 519aaec..0d44ccf 100644
--- a/include/native/task.h
+++ b/include/native/task.h
@@ -22,6 +22,7 @@
#ifndef _XENO_TASK_H
#define _XENO_TASK_H
+#include <nucleus/heap.h>
#include <nucleus/sched.h>
#include <native/types.h>
@@ -166,6 +167,10 @@ typedef struct rt_task {
xnsynch_t mrecv,
msendq;
+#ifdef CONFIG_XENO_FASTSYNCH
+ xnheap_t *msendq_fastlock_heap;
+#endif /* CONFIG_XENO_FASTSYNCH */
+
int flowgen; /* !< Flow id. generator. */
#endif /* CONFIG_XENO_OPT_NATIVE_MPS */
diff --git a/ksrc/skins/native/task.c b/ksrc/skins/native/task.c
index 1192509..6970363 100644
--- a/ksrc/skins/native/task.c
+++ b/ksrc/skins/native/task.c
@@ -79,6 +79,9 @@ static void __task_delete_hook(xnthread_t *thread)
hooks are done. */
xnsynch_destroy(&task->mrecv);
xnsynch_destroy(&task->msendq);
+#ifdef CONFIG_XENO_FASTSYNCH
+ xnheap_free(task->msendq_fastlock_heap, task->msendq.fastlock);
+#endif /* CONFIG_XENO_FASTSYNCH */
#endif /* CONFIG_XENO_OPT_NATIVE_MPS */
xnsynch_destroy(&task->safesynch);
@@ -301,7 +304,8 @@ int rt_task_create(RT_TASK *task,
#ifdef CONFIG_XENO_OPT_NATIVE_MPS
#ifdef CONFIG_XENO_FASTSYNCH
/* Allocate lock memory for in-kernel use */
- fastlock = xnheap_alloc(&xnsys_ppd_get(0)->sem_heap,
+ task->msendq_fastlock_heap = &xnsys_ppd_get(0)->sem_heap;
+ fastlock = xnheap_alloc(task->msendq_fastlock_heap,
sizeof(*fastlock));
if (fastlock == NULL)
return -ENOMEM;
@@ -328,7 +332,7 @@ int rt_task_create(RT_TASK *task,
err = xnthread_register(&task->thread_base, name ? task->rname : "");
if (err) {
#if defined(CONFIG_XENO_OPT_NATIVE_MPS) && defined(CONFIG_XENO_FASTSYNCH)
- xnheap_free(&xnsys_ppd_get(0)->sem_heap, fastlock);
+ xnheap_free(task->msendq_fastlock_heap, fastlock);
#endif
xnpod_delete_thread(&task->thread_base);
} else
@@ -640,11 +644,6 @@ int rt_task_delete(RT_TASK *task)
if (err)
goto unlock_and_exit;
-#if defined(CONFIG_XENO_OPT_NATIVE_MPS) && defined(CONFIG_XENO_FASTSYNCH)
- xnheap_free(&xnsys_ppd_get(0)->sem_heap,
- task->msendq.fastlock);
-#endif
-
/* Does not return if task is current. */
xnpod_delete_thread(&task->thread_base);
--
1.7.1
next reply other threads:[~2011-05-23 13:53 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-23 13:53 Jan Kiszka [this message]
2011-05-24 4:31 ` [Xenomai-core] [PULL] native: Fix msendq fastlock leakage Gilles Chanteperdrix
2011-05-24 9:13 ` Jan Kiszka
2011-05-24 9:32 ` Gilles Chanteperdrix
2011-05-24 9:36 ` Jan Kiszka
2011-05-24 9:58 ` Gilles Chanteperdrix
2011-05-24 10:36 ` Jan Kiszka
2011-05-24 10:41 ` Gilles Chanteperdrix
2011-05-24 12:23 ` Jan Kiszka
2011-05-24 12:30 ` Gilles Chanteperdrix
2011-05-24 13:52 ` Jan Kiszka
2011-05-24 14:03 ` Gilles Chanteperdrix
2011-05-25 11:20 ` Jan Kiszka
2011-05-25 11:58 ` Gilles Chanteperdrix
2011-05-25 12:12 ` Jan Kiszka
2011-05-25 12:19 ` Gilles Chanteperdrix
2011-05-25 12:22 ` Jan Kiszka
2011-05-25 18:48 ` Gilles Chanteperdrix
2011-05-26 7:18 ` Jan Kiszka
2011-05-26 7:29 ` Gilles Chanteperdrix
2011-05-26 7:37 ` Jan Kiszka
2011-05-26 7:58 ` Gilles Chanteperdrix
2011-06-19 10:14 ` Gilles Chanteperdrix
2011-06-19 11:17 ` Gilles Chanteperdrix
2011-06-19 13:00 ` Gilles Chanteperdrix
2011-06-20 17:07 ` Jan Kiszka
2011-06-20 17:46 ` Gilles Chanteperdrix
2011-06-20 20:52 ` Jan Kiszka
2011-06-23 9:37 ` Jan Kiszka
2011-06-23 11:11 ` Gilles Chanteperdrix
2011-06-23 11:15 ` Jan Kiszka
2011-06-23 17:32 ` Gilles Chanteperdrix
2011-06-23 18:13 ` Philippe Gerum
2011-06-23 18:24 ` Philippe Gerum
2011-06-23 18:56 ` Gilles Chanteperdrix
2011-06-23 19:08 ` Gilles Chanteperdrix
2011-06-24 7:01 ` Gilles Chanteperdrix
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=4DDA66CF.2010307@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=Xenomai-core@domain.hid \
--cc=rpm@xenomai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.