summaryrefslogtreecommitdiffstats
path: root/runtime/transport/procfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/transport/procfs.c')
-rw-r--r--runtime/transport/procfs.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/runtime/transport/procfs.c b/runtime/transport/procfs.c
index 8af2d018..6406908d 100644
--- a/runtime/transport/procfs.c
+++ b/runtime/transport/procfs.c
@@ -115,6 +115,7 @@ static ssize_t _stp_proc_write_cmd (struct file *file, const char __user *buf,
struct _stp_buffer {
struct list_head list;
int len;
+ int type;
char buf[STP_BUFFER_SIZE];
};
@@ -124,6 +125,21 @@ static int _stp_write (int type, void *data, int len)
{
struct _stp_buffer *bptr;
+#define WRITE_AGG
+#ifdef WRITE_AGG
+ spin_lock(&_stp_ready_lock);
+ if (!list_empty(&_stp_ready_q)) {
+ bptr = (struct _stp_buffer *)_stp_ready_q.prev;
+ if (bptr->len + len <= STP_BUFFER_SIZE && bptr->type == type) {
+ memcpy (bptr->buf + bptr->len - 1, data, len);
+ bptr->len += len - 1;
+ spin_unlock(&_stp_ready_lock);
+ return len;
+ }
+ }
+ spin_unlock(&_stp_ready_lock);
+#endif
+
spin_lock(&_stp_pool_lock);
if (list_empty(&_stp_pool_q)) {
spin_unlock(&_stp_pool_lock);
@@ -135,8 +151,8 @@ static int _stp_write (int type, void *data, int len)
list_del_init(&bptr->list);
spin_unlock(&_stp_pool_lock);
- memcpy (bptr->buf, &type, 4);
- memcpy (&bptr->buf[4], data, len);
+ bptr->type = type;
+ memcpy (bptr->buf, data, len);
bptr->len = len;
@@ -151,7 +167,6 @@ static int _stp_write (int type, void *data, int len)
return len;
}
-
static ssize_t
_stp_proc_read_cmd (struct file *file, char __user *buf, size_t count, loff_t *ppos)
{
@@ -176,7 +191,7 @@ _stp_proc_read_cmd (struct file *file, char __user *buf, size_t count, loff_t *p
/* write it out */
len = bptr->len + 4;
- if (copy_to_user(buf, bptr->buf, len)) {
+ if (copy_to_user(buf, &bptr->type, len)) {
/* now what? We took it off the queue then failed to send it */
/* we can't put it back on the queue because it will likely be out-of-order */
/* fortunately this should never happen */
@@ -193,7 +208,6 @@ _stp_proc_read_cmd (struct file *file, char __user *buf, size_t count, loff_t *p
}
-
static struct file_operations _stp_proc_fops_cmd = {
.owner = THIS_MODULE,
.read = _stp_proc_read_cmd,