Skip to contentSkip to conversation

max size for pipes and rt-fifos?

Xenomai-help Jeff Webb 4 participants 12 messages Sep 6, 2006 – Sep 12, 2006

lore
Share & tools
lore

Jeff Webb

author
#0 lore raw

Here are a couple of questions that I hope someone can answer:

It appears that the maximum pipe size that can be created using rt_pipe_create() is 16 MB. Is this correct? If so, what is the cause of this limitation, and are there any work-arounds? I am using a 128 MB FIFO in my rtlinux simulation. Any ideas on how I can port this?

It appears that the maximum size for RT-FIFOs created with the rtai skin's rtf_create() is much less than 16 MB. It's hard to quantify, since the errors are given at FIFO write time, and not creation time, but it appears to be around 100 kB or so. Why is this not the same as for rt_pipe_create()? Also, why is the memory allocation not done at creation time? It looks like the memory allocation is done on the first rtf_put() -- which is called from my real-time thread! I assumed the memory allocation would be a non-realtime operation. (It also appears that I am getting some kind of memory leak when the memory allocation fails, because I can not allocate as much memory the next time around. I am cleaning up the FIFO with rtf_destroy, so I don't know what I could be doing wrong...)

Thanks,

Jeff

#1 lore raw
Quoted 6 lines · Jeff Webb

Here are a couple of questions that I hope someone can answer:

It appears that the maximum pipe size that can be created using rt_pipe_create() is 16 MB. Is this correct? If so, what is the cause of this limitation, and are there any work-arounds? I am using a 128 MB FIFO in my rtlinux simulation. Any ideas on how I can port this?

Maybe it's a 2.4-related issue (my 2.4 setup is broken, can't test). On a 2.6.17 kernel I face no problems allocating far larger rt_pipes.

Quoted 13 lines

It appears that the maximum size for RT-FIFOs created with the rtai skin's rtf_create() is much less than 16 MB. It's hard to quantify, since the errors are given at FIFO write time, and not creation time, but it appears to be around 100 kB or so. Why is this not the same as for rt_pipe_create()? Also, why is the memory allocation not done at creation time? It looks like the memory allocation is done on the first rtf_put() -- which is called from my real-time thread! I assumed the memory allocation would be a non-realtime operation. (It also appears that I am getting some kind of memory leak when the memory allocation fails, because I can not allocate as much memory the next time around. I am cleaning up the FIFO with rtf_destroy, so I don't know what I could be doing wrong...)

RTAI FIFO allocate their buffers from the real-time system heap, and that on is 128 KB by default (see kernel config).

Allocation in Xenomai pipes works differently, i.e. always on some real-time heap. We stumbled over this as well when applying it the first time. To get larger pools and decouple them from the system heap, we introduced separated heaps for rt_pipes afterwards. So, as long as your usage pattern of a particular rt_pipe is deterministic, you can predict the success of data transfers.

The potential leak you found needs to be examined. Could you post a simple test that demonstrate it?

Jan

author
#2 lore raw

Thanks for your input, Jan.

Quoted 8 lines · Jan Kiszka
Quoted 4 lines · Jeff Webb

It appears that the maximum pipe size that can be created using rt_pipe_create() is 16 MB. Is this correct? If so, what is the cause of this limitation, and are there any work-arounds? I am using a 128 MB FIFO in my rtlinux simulation. Any ideas on how I can port this?

Maybe it's a 2.4-related issue (my 2.4 setup is broken, can't test). On a 2.6.17 kernel I face no problems allocating far larger rt_pipes.

I have discovered the source of the inconsistency:

xenomai-2.1-rc4: include/nucleus/heap.h:
#define XNHEAP_MAXEXTSZ (1 << 24) /* i.e. 16Mb */

xenomai-2.2.1: include/nucleus/heap.h:
#define XNHEAP_MAXEXTSZ (1 << 31) /* i.e. 2Gb */

Changelog:
2006-07-15 Philippe Gerum <[email protected]>
* include/nucleus/heap.h (XNHEAP_MAXEXTSZ): Raise maximum extent size to 2Gb.

I can now create a 128 MB rt-pipe on my xenomai-2.2.1 / kernel 2.6 dual-core machine, if I boot with vmalloc=256M and add "uppermem 524288" to my grub config. I have not built an updated 2.4 kernel to test on my Fedora Core I machine yet, but I will do this soon.

Quoted 2 lines

RTAI FIFO allocate their buffers from the real-time system heap, and that on is 128 KB by default (see kernel config).

Ah, I see.

I know this is not the ideal solution, but could the system heap be made something big, like 256 MB? That might solve my problem, for the short term. Of course, if there is a memory leak in the FIFO creation/deletion, I will have BIG problems... ;)

Quoted 1 line

Allocation in Xenomai pipes works differently...

Is there some reason the RTAI FIFO emulation is not handled the same way? I believe the real RTL and RTAI FIFOs are handled like the Xenomai pipes are done now -- using kmalloc or vmalloc:

https://www.rtai.org/documentation/magma/html/api/group__fifos__ipc.html#ga8

I know my FIFOs are on the huge side, but I know I'm not the only one using more than 128KB total for all their FIFOs...

Quoted 2 lines

The potential leak you found needs to be examined. Could you post a simple test that demonstrate it?

I'm attaching a sample kernel module that creates a 100KB FIFO on module insertion, and destroys it on module removal. I can only run this one time. The write fails on subsequent runs because the memory cannot be allocated. Is there something I am not cleaning up properly?

Thanks!

-Jeff

/* Linux kernel includes */
#include <linux/module.h>

/* Xenomai includes */
#include <pthread.h>
#include <rtai/fifo.h>

/* Global variables */
pthread_t fifotest_task = NULL;

/* Real-time task */
void * fifotest_routine (void *cookie)
{
int err;

err = rtf_put(1, "hello ", 6);
printk("rtf_put: %d\n", err);
return NULL;
}

static int fifotest_init(void)
{
int err;
pthread_attr_t attr;

  printk("fifotest_init\n");

  /* Create a FIFO */
  err = rtf_create(1, 1024*100);
  printk("rtf_create returned: %d\n", err);

  /* Create a real-time task */
  pthread_attr_init(&attr);
  pthread_attr_setfp_np(&attr, 1);
  err = pthread_create(&fifotest_task, &attr, &fifotest_routine, NULL);
  if (err)
    {
      printk("could not create thread (error code: %d)\n", err);
      err = rtf_destroy(1);
      printk("rtf_destroy returned: %d\n", err);
      return -1;
    }

return 0;
}
static void fifotest_cleanup(void)
{
int err;

  printk("fifotest_cleanup\n");
  
  /* Shut down the real-time thread */
  pthread_cancel (fifotest_task);
  pthread_join (fifotest_task, NULL);  

  /* Destroy the fifo */
  err = rtf_destroy(1);
  printk("rtf_destroy returned: %d\n", err);

}

module_init(fifotest_init);
module_exit(fifotest_cleanup);

#3 lore raw
Quoted 15 lines · Jeff Webb

Thanks for your input, Jan.

Quoted 8 lines · Jan Kiszka
Quoted 4 lines · Jeff Webb

It appears that the maximum pipe size that can be created using rt_pipe_create() is 16 MB. Is this correct? If so, what is the cause of this limitation, and are there any work-arounds? I am using a 128 MB FIFO in my rtlinux simulation. Any ideas on how I can port this?

Maybe it's a 2.4-related issue (my 2.4 setup is broken, can't test). On a 2.6.17 kernel I face no problems allocating far larger rt_pipes.

I have discovered the source of the inconsistency:

xenomai-2.1-rc4: include/nucleus/heap.h:

Quoted 8 lines
   #define XNHEAP_MAXEXTSZ   (1 << 24) /* i.e. 16Mb */

xenomai-2.2.1: include/nucleus/heap.h:

   #define XNHEAP_MAXEXTSZ   (1 << 31) /* i.e. 2Gb */

Changelog: 2006-07-15 Philippe Gerum <[email protected]>
* include/nucleus/heap.h (XNHEAP_MAXEXTSZ): Raise maximum extent
size to 2Gb.

This explains a lot.

Quoted 6 lines

I can now create a 128 MB rt-pipe on my xenomai-2.2.1 / kernel 2.6 dual-core machine, if I boot with vmalloc=256M and add "uppermem 524288" to my grub config. I have not built an updated 2.4 kernel to test on my Fedora Core I machine yet, but I will do this soon.

Quoted 7 lines
Quoted 2 lines

RTAI FIFO allocate their buffers from the real-time system heap, and that on is 128 KB by default (see kernel config).

Ah, I see.

I know this is not the ideal solution, but could the system heap be made something big, like 256 MB? That might solve my problem, for the short

CONFIG_XENO_OPT_SYS_HEAPSZ?

Quoted 9 lines

term. Of course, if there is a memory leak in the FIFO creation/deletion, I will have BIG problems... ;)

Quoted 1 line

Allocation in Xenomai pipes works differently...

Is there some reason the RTAI FIFO emulation is not handled the same way? I believe the real RTL and RTAI FIFOs are handled like the Xenomai pipes are done now -- using kmalloc or vmalloc:

Quoted 5 lines

https://www.rtai.org/documentation/magma/html/api/group__fifos__ipc.html#ga8

I know my FIFOs are on the huge side, but I know I'm not the only one using more than 128KB total for all their FIFOs...

I agree that allocating a dedicated FIFO heap on creation and then working on that heap for data exchange would be more flexible. I guess this RTAI skin is not widely used, thus this issue did not pop up earlier (most users migrate to native or posix).

Quoted 67 lines
Quoted 3 lines

The potential leak you found needs to be examined. Could you post a simple test that demonstrate it?

I'm attaching a sample kernel module that creates a 100KB FIFO on module insertion, and destroys it on module removal. I can only run this one time. The write fails on subsequent runs because the memory cannot be allocated. Is there something I am not cleaning up properly?

Thanks!

-Jeff

------------------------------------------------------------------------

/* Linux kernel includes */
#include <linux/module.h>

/* Xenomai includes */
#include <pthread.h>
#include <rtai/fifo.h>

/* Global variables */
pthread_t fifotest_task = NULL;

/* Real-time task */
void * fifotest_routine (void *cookie)
{
int err;

err = rtf_put(1, "hello ", 6);
printk("rtf_put: %d\n", err);
return NULL;
}

static int fifotest_init(void)
{
int err;
pthread_attr_t attr;

  printk("fifotest_init\n");

  /* Create a FIFO */
  err = rtf_create(1, 1024*100);
  printk("rtf_create returned: %d\n", err);

  /* Create a real-time task */
  pthread_attr_init(&attr);
  pthread_attr_setfp_np(&attr, 1);
  err = pthread_create(&fifotest_task, &attr, &fifotest_routine, NULL);
  if (err)
    {
      printk("could not create thread (error code: %d)\n", err);
      err = rtf_destroy(1);
      printk("rtf_destroy returned: %d\n", err);
      return -1;
    }

return 0;
}
static void fifotest_cleanup(void)
{
int err;

Quoted 5 lines
  printk("fifotest_cleanup\n");
  
  /* Shut down the real-time thread */
  pthread_cancel (fifotest_task);
  pthread_join (fifotest_task, NULL);  

pthread_join requires RT context and will not work as expected. But that's unrelated to this problem.

Quoted 10 lines
  /* Destroy the fifo */
  err = rtf_destroy(1);
  printk("rtf_destroy returned: %d\n", err);

}

module_init(fifotest_init);
module_exit(fifotest_cleanup);

Ok, there is a real problem, actually two: Queuing messages only works if both sides are connected, which is not the case in your scenario. And when this attempt to send some data fails, the related buffer leaks.

But when comparing with RTAI FIFOs (I guess this is true for RTLinux as well), this strict queuing rule is not correct and should be rethought. Moreover, the RTAI skin contains its own deferring mechanism to call xnpipe_send over Linux instead of RT. I don't see any reason for this, the pipe service is RT-safe and does deferred wakeup of Linux readers on its own. Looks like some redesign is required here...

Jan

author
#4 lore raw
Quoted 6 lines · Jan Kiszka
Quoted 3 lines
  /* Shut down the real-time thread */
  pthread_cancel (fifotest_task);
  pthread_join (fifotest_task, NULL);  

pthread_join requires RT context and will not work as expected. But that's unrelated to this problem.

Okay. (I now see this restriction in the docs.) What is the proper way to do this cleanup from kernel-space with Xenomai? (Pardon my asking, as I haven't done much programming using POSIX threads. I believe this syntax was suggested, or at least acceptable, with RTLinux.)

Thanks,

Jeff

#5 lore raw
Quoted 9 lines · Jeff Webb
Quoted 6 lines · Jan Kiszka
Quoted 3 lines
  /* Shut down the real-time thread */
  pthread_cancel (fifotest_task);
  pthread_join (fifotest_task, NULL);  

pthread_join requires RT context and will not work as expected. But that's unrelated to this problem.

Okay. (I now see this restriction in the docs.) What is the proper way to do this cleanup from kernel-space with Xenomai? (Pardon my asking, as I haven't done much programming using POSIX threads. I believe this syntax was suggested, or at least acceptable, with RTLinux.)

Calling pthread_cancel then pthread_join from a module cleanup routine should work. Because the cancelled thread preempts immediately the module cleanup routine, so when pthread_join is called, the thread no longer exists and there is no need to suspend the calling thread.

Signature · 1 line
					    Gilles Chanteperdrix.
#6 lore raw
Quoted 9 lines · Gilles Chanteperdrix
Quoted 8 lines · Jeff Webb
Quoted 6 lines · Jan Kiszka
Quoted 3 lines
  /* Shut down the real-time thread */
  pthread_cancel (fifotest_task);
  pthread_join (fifotest_task, NULL);  

pthread_join requires RT context and will not work as expected. But that's unrelated to this problem.

Quoted 7 lines
Quoted 1 line

Okay. (I now see this restriction in the docs.) What is the proper way to do this cleanup from kernel-space with Xenomai? (Pardon my asking, as I haven't done much programming using POSIX threads. I believe this syntax was suggested, or at least acceptable, with RTLinux.)

Calling pthread_cancel then pthread_join from a module cleanup routine should work. Because the cancelled thread preempts immediately the module cleanup routine, so when pthread_join is called, the thread no longer exists and there is no need to suspend the calling thread.

Yes, but only on UP. What about including a simple polling loop into kernel-space pthread_join, something like rtdm_task_join_nrt?

Jan

#7 lore raw
Quoted 8 lines · Jan Kiszka
Quoted 5 lines

Calling pthread_cancel then pthread_join from a module cleanup routine should work. Because the cancelled thread preempts immediately the module cleanup routine, so when pthread_join is called, the thread no longer exists and there is no need to suspend the calling thread.

Yes, but only on UP. What about including a simple polling loop into kernel-space pthread_join, something like rtdm_task_join_nrt?

Yes, I will include this polling loop.

Signature · 1 line
					    Gilles Chanteperdrix.
#8 lore raw
In reply to Jeff Webb
Quoted 37 lines · Jeff Webb

Thanks for your input, Jan.

Quoted 8 lines · Jan Kiszka
Quoted 4 lines · Jeff Webb

It appears that the maximum pipe size that can be created using rt_pipe_create() is 16 MB. Is this correct? If so, what is the cause of this limitation, and are there any work-arounds? I am using a 128 MB FIFO in my rtlinux simulation. Any ideas on how I can port this?

Maybe it's a 2.4-related issue (my 2.4 setup is broken, can't test). On a 2.6.17 kernel I face no problems allocating far larger rt_pipes.

I have discovered the source of the inconsistency:

  xenomai-2.1-rc4: include/nucleus/heap.h:
    #define XNHEAP_MAXEXTSZ   (1 << 24) /* i.e. 16Mb */

  xenomai-2.2.1: include/nucleus/heap.h:
    #define XNHEAP_MAXEXTSZ   (1 << 31) /* i.e. 2Gb */

Changelog:
2006-07-15 Philippe Gerum <[email protected]>
* include/nucleus/heap.h (XNHEAP_MAXEXTSZ): Raise maximum extent size to 2Gb.

I can now create a 128 MB rt-pipe on my xenomai-2.2.1 / kernel 2.6 dual-core machine, if I boot with vmalloc=256M and add "uppermem 524288" to my grub config. I have not built an updated 2.4 kernel to test on my Fedora Core I machine yet, but I will do this soon.

Quoted 2 lines

RTAI FIFO allocate their buffers from the real-time system heap, and that on is 128 KB by default (see kernel config).

Ah, I see.

I know this is not the ideal solution, but could the system heap be made something big, like 256 MB? That might solve my problem, for the short term. Of course, if there is a memory leak in the FIFO creation/deletion, I will have BIG problems... ;)

Quoted 1 line

Allocation in Xenomai pipes works differently...

Is there some reason the RTAI FIFO emulation is not handled the same way? I believe the real RTL and RTAI FIFOs are handled like the Xenomai pipes are done now -- using kmalloc or vmalloc:

Quoted 9 lines

https://www.rtai.org/documentation/magma/html/api/group__fifos__ipc.html#ga8

I know my FIFOs are on the huge side, but I know I'm not the only one using more than 128KB total for all their FIFOs...

Quoted 2 lines

The potential leak you found needs to be examined. Could you post a simple test that demonstrate it?

I'm attaching a sample kernel module that creates a 100KB FIFO on module insertion, and destroys it on module removal. I can only run this one time. The write fails on subsequent runs because the memory cannot be allocated. Is there something I am not cleaning up properly?

This patch on top of 2.2.2 should fix the leakage. This said, I'm going to rework the fifo emulation a bit to get closer to the RTAI behaviour.

nucleus/pipe.c +11 -11
@@ -306,6 +306,12 @@
 
 	__clrbits(state->status, XNPIPE_KERN_CONN);
 
+	if (state->output_handler != NULL) {
+		while ((holder = getq(&state->outq)) != NULL)
+			state->output_handler(minor, link2mh(holder),
+					      -EPIPE, state->cookie);
+	}
+
 	if (testbits(state->status, XNPIPE_USER_CONN)) {
 		while ((holder = getq(&state->inq)) != NULL) {
 			if (state->input_handler != NULL)
@@ -315,12 +321,6 @@
 				xnfree(link2mh(holder));
 		}
 
-		if (state->output_handler != NULL) {
-			while ((holder = getq(&state->outq)) != NULL)
-				state->output_handler(minor, link2mh(holder),
-						      -EPIPE, state->cookie);
-		}
-
 		if (xnsynch_destroy(&state->synchbase) == XNSYNCH_RESCHED)
 			xnpod_schedule();
 
@@ -369,11 +369,6 @@
 		return -EBADF;
 	}
 
-	if (!testbits(state->status, XNPIPE_USER_CONN)) {
-		xnlock_put_irqrestore(&nklock, s);
-		return -EPIPE;
-	}
-
 	inith(xnpipe_m_link(mh));
 	xnpipe_m_size(mh) = size - sizeof(*mh);
 	state->ionrd += xnpipe_m_size(mh);
@@ -383,6 +378,11 @@
 	else
 		appendq(&state->outq, xnpipe_m_link(mh));
 
+	if (!testbits(state->status, XNPIPE_USER_CONN)) {
+		xnlock_put_irqrestore(&nklock, s);
+		return (ssize_t) size;
+	}
+
 	if (testbits(state->status, XNPIPE_USER_WREAD)) {
 		/* Wake up the userland thread waiting for input
 		   from the kernel side. */
Signature · 1 line
Philippe.
#9 lore raw
Quoted 4 lines · Philippe Gerum
Quoted 3 lines · Jeff Webb

Thanks for your input, Jan.

Jan Kiszka wrote:

[...]

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

Allocation in Xenomai pipes works differently...

Is there some reason the RTAI FIFO emulation is not handled the same way? I believe the real RTL and RTAI FIFOs are handled like the Xenomai pipes are done now -- using kmalloc or vmalloc:

[...]

Quoted 2 lines

This patch on top of 2.2.2 should fix the leakage. This said, I'm going to rework the fifo emulation a bit to get closer to the RTAI behaviour.

The following patch against stock 2.2.2 improves the RTAI fifo emulation. It reduces the overhead induced by sending highly scattered data over a short period of time, and basically provides a much saner implementation.

I'd be interested to have some feedback about this; I plan to change the data streaming mode of message pipes from the native API the same way. TIA,

rtai/fifo.h +3 -1
@@ -26,6 +26,8 @@
 
 #if defined(__KERNEL__) || defined(__XENO_SIM__)
 
+#define RTFIFO_SYNCWAIT  0
+
 typedef struct rt_fifo {
 
     xnholder_t link;		/* !< Link in flush queue. */
@@ -43,7 +45,7 @@
 
     size_t fillsz;		/* !< Bytes written to the buffer.  */
 
-    u_long flushable;		/* !< Flush request flag. */
+    u_long status;		/* !< Status information. */
 
     int (*handler)(unsigned minor); /* !< Input handler. */
 
skins/rtai/fifo.c +107 -119

354 lines not on this page · raw message

nucleus/pipe.h +4 -0
Index: include/nucleus/pipe.h
===================================================================
@@ -130,6 +130,10 @@
 		    size_t size,
 		    int flags);
 
+ssize_t xnpipe_send_more(int minor,
+			 struct xnpipe_mh *mh,
+			 ssize_t size);
+
 ssize_t xnpipe_recv(int minor,
 		    struct xnpipe_mh **pmh,
 		    xnticks_t timeout);
nucleus/pipe.c +81 -30

168 lines not on this page · raw message

Signature · 1 line
Philippe.
author
#10 lore raw
Quoted 8 lines · Philippe Gerum

The following patch against stock 2.2.2 improves the RTAI fifo emulation. It reduces the overhead induced by sending highly scattered data over a short period of time, and basically provides a much saner implementation.

I'd be interested to have some feedback about this; I plan to change the data streaming mode of message pipes from the native API the same way. TIA,

I applied this patch on my linux-2.6 and 2.4 systems. The simple 'fifotestk.c' example I posted now works fine, with no apparent memory leaks. I can now allocate a 128 MB RTAI FIFO, which sure beats 100 KB! Thanks for the fix!

If I try to allocate a FIFO larger than the available vmalloc space, the rtf_create routine now fails with ENOMEM, which is much better than failing on the rtf_put call. Unfortunately, the RT-FIFO device is now EBUSY forever. I can switch to another device, and I can allocate space for my 128 MB FIFO once again, so that is good, at least. Here is the printk output from my program:

[ 128 MB allocation, which works ....]

Sep 11 14:43:26 kernel: fifotest_init
Sep 11 14:43:26 kernel: rtf_create returned: 2
Sep 11 14:43:26 kernel: rtf_put: 6
Sep 11 14:43:29 kernel: fifotest_cleanup
Sep 11 14:43:29 kernel: rtf_destroy returned: 0
Sep 11 14:43:32 kernel: fifotest_init
Sep 11 14:43:32 kernel: rtf_create returned: 2
Sep 11 14:43:32 kernel: rtf_put: 6
Sep 11 14:43:35 kernel: fifotest_cleanup
Sep 11 14:43:35 kernel: rtf_destroy returned: 0

[switched to 256 MB allocation here... should fail]

Sep 11 14:44:29 kernel: fifotest_init
Sep 11 14:44:29 kernel: rtf_create returned: -12
Sep 11 14:44:29 kernel: rtf_put: -22
Sep 11 14:44:33 kernel: fifotest_cleanup
Sep 11 14:44:33 kernel: rtf_destroy returned: -22

[switched back to 128 MB allocation, but the device is now busy...]

Sep 11 14:44:45 kernel: fifotest_init
Sep 11 14:44:45 kernel: rtf_create returned: -16
Sep 11 14:44:45 kernel: rtf_put: -16
Sep 11 14:44:48 kernel: fifotest_cleanup
Sep 11 14:44:48 kernel: rtf_destroy returned: -16

I modified my program to check the return value of rtf_create, but I still have the same problem:

Sep 11 15:15:23 kernel: fifotest_init
Sep 11 15:15:23 kernel: rtf_create returned: 1
Sep 11 15:15:23 kernel: rtf_put: 6
Sep 11 15:15:31 kernel: fifotest_cleanup
Sep 11 15:15:31 kernel: rtf_destroy returned: 0
Sep 11 15:15:33 kernel: fifotest_init
Sep 11 15:15:33 kernel: rtf_create returned: 1
Sep 11 15:15:33 kernel: rtf_put: 6
Sep 11 15:15:35 kernel: fifotest_cleanup
Sep 11 15:15:35 kernel: rtf_destroy returned: 0
Sep 11 15:15:51 kernel: fifotest_init
Sep 11 15:15:51 kernel: rtf_create returned: -12
Sep 11 15:15:51 kernel: could not create FIFO
Sep 11 15:16:05 kernel: fifotest_init
Sep 11 15:16:05 kernel: rtf_create returned: -16
Sep 11 15:16:05 kernel: could not create FIFO

Thanks!

-Jeff

#11 lore raw
Quoted 6 lines · Jeff Webb
Quoted 5 lines · Philippe Gerum

The following patch against stock 2.2.2 improves the RTAI fifo emulation. It reduces the overhead induced by sending highly scattered data over a short period of time, and basically provides a much saner implementation.

Quoted 8 lines
Quoted 3 lines

I'd be interested to have some feedback about this; I plan to change the data streaming mode of message pipes from the native API the same way. TIA,

I applied this patch on my linux-2.6 and 2.4 systems. The simple 'fifotestk.c' example I posted now works fine, with no apparent memory leaks. I can now allocate a 128 MB RTAI FIFO, which sure beats 100 KB! Thanks for the fix!

If I try to allocate a FIFO larger than the available vmalloc space, the rtf_create routine now fails with ENOMEM, which is much better than failing on the rtf_put call. Unfortunately, the RT-FIFO device is now EBUSY forever. I can switch to another device, and I can allocate space for my 128 MB FIFO once again, so that is good, at least. Here is the printk output from my program:

Mm, ok, I see: brain cell shortage on my side, hopefully temporary. Please try the attached patch on top of the previous one.

skins/rtai/fifo.c +1 -1
@@ -134,7 +134,7 @@
 	xnlock_get_irqsave(&nklock, s);
 
 	if (buffer == NULL) {
-		if (!err)
+		if (err >= 0)
 			/* First open, we need to disconnect upon
 			 * error. Caveat: we still hold the lock while
 			 * flushing the message pipe's input and
Signature · 1 line
Philippe.