From: adrienverge@gmail.com (Adrien Vergé)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 6/6] ARM CoreSight: ETM: Allocate a trace buffer only when necessary
Date: Fri, 24 Jan 2014 11:40:56 -0500 [thread overview]
Message-ID: <1390581656-16372-7-git-send-email-adrienverge@gmail.com> (raw)
In-Reply-To: <1390581656-16372-1-git-send-email-adrienverge@gmail.com>
Some user applications try to retrieve trace data often, there
is no need to call vmalloc() when there is 0 byte to fetch.
Signed-off-by: Adrien Verg? <adrienverge@gmail.com>
---
arch/arm/kernel/etm.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/arch/arm/kernel/etm.c b/arch/arm/kernel/etm.c
index 54b5128..bc97240 100644
--- a/arch/arm/kernel/etm.c
+++ b/arch/arm/kernel/etm.c
@@ -309,7 +309,7 @@ static ssize_t etb_read(struct file *file, char __user *data,
long length;
struct tracectx *t = file->private_data;
u32 first = 0;
- u32 *buf;
+ u32 *buf = NULL;
mutex_lock(&t->mutex);
@@ -327,12 +327,14 @@ static ssize_t etb_read(struct file *file, char __user *data,
etb_writel(t, first, ETBR_READADDR);
length = min(total * 4, (int)len);
- buf = vmalloc(length);
+ if (length != 0)
+ buf = vmalloc(length);
dev_dbg(t->dev, "ETB buffer length: %d\n", total);
dev_dbg(t->dev, "ETB status reg: %x\n", etb_readl(t, ETBR_STATUS));
- for (i = 0; i < length / 4; i++)
- buf[i] = etb_readl(t, ETBR_READMEM);
+ if (buf)
+ for (i = 0; i < length / 4; i++)
+ buf[i] = etb_readl(t, ETBR_READMEM);
/* the only way to deassert overflow bit in ETB status is this */
etb_writel(t, 1, ETBR_CTRL);
@@ -345,7 +347,8 @@ static ssize_t etb_read(struct file *file, char __user *data,
etb_lock(t);
length -= copy_to_user(data, buf, length);
- vfree(buf);
+ if (buf)
+ vfree(buf);
out:
mutex_unlock(&t->mutex);
--
1.8.5.2
prev parent reply other threads:[~2014-01-24 16:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-24 16:40 [PATCH V2 0/6] ARM CoreSight: Enhance ETM tracing control Adrien Vergé
2014-01-24 16:40 ` [PATCH V2 1/6] ARM CoreSight: ETM: Use device attributes Adrien Vergé
2014-01-24 16:40 ` [PATCH V2 2/6] ARM CoreSight: ETM: Rename 'comparator' to 'address comparator' Adrien Vergé
2014-01-24 16:40 ` [PATCH V2 3/6] ARM CoreSight: ETM: Add address control support Adrien Vergé
2014-01-24 16:40 ` [PATCH V2 4/6] ARM: Make PID_IN_CONTEXTIDR incompatible with PID_NS Adrien Vergé
2014-01-24 16:43 ` Will Deacon
2014-01-24 17:16 ` Adrien Vergé
2014-01-24 17:17 ` Will Deacon
2014-01-24 17:52 ` Christopher Covington
2014-01-24 19:12 ` Christopher Covington
2014-01-24 19:34 ` Adrien Vergé
2014-01-24 16:40 ` [PATCH V2 5/6] ARM CoreSight: ETM: Add PID control support Adrien Vergé
2014-01-24 16:40 ` Adrien Vergé [this message]
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=1390581656-16372-7-git-send-email-adrienverge@gmail.com \
--to=adrienverge@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).