mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
ANDROID: KVM: arm64: Empty buffer support for hyp tracing trace file
Previously, hyp/per_cpu/cpu*/trace files would return an error when no buffer has been allocated (i.e. when no tracing has ever started). Return an empty header instead. Bug: 249050813 Change-Id: Ic88bbdf8c876b8f26101ce2b33d3aca26fb88c94 Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
This commit is contained in:
@@ -398,6 +398,9 @@ static void *ht_next(struct seq_file *m, void *v, loff_t *pos)
|
||||
|
||||
(*pos)++;
|
||||
|
||||
if (!iter->buf_iter)
|
||||
return NULL;
|
||||
|
||||
evt = ring_buffer_iter_peek(iter->buf_iter, &ts);
|
||||
if (!evt)
|
||||
return NULL;
|
||||
@@ -415,7 +418,8 @@ static void *ht_start(struct seq_file *m, loff_t *pos)
|
||||
struct ht_iterator *iter = m->private;
|
||||
|
||||
if (*pos == 0) {
|
||||
ring_buffer_iter_reset(iter->buf_iter);
|
||||
if (iter->buf_iter)
|
||||
ring_buffer_iter_reset(iter->buf_iter);
|
||||
(*pos)++;
|
||||
iter->ent = NULL;
|
||||
|
||||
@@ -439,10 +443,12 @@ static int ht_show(struct seq_file *m, void *v)
|
||||
struct ht_iterator *iter = v;
|
||||
|
||||
if (!iter->ent) {
|
||||
unsigned long entries, overrun;
|
||||
unsigned long entries = 0, overrun = 0;
|
||||
|
||||
entries = ring_buffer_entries_cpu(hyp_trace_buffer, iter->cpu);
|
||||
overrun = ring_buffer_overrun_cpu(hyp_trace_buffer, iter->cpu);
|
||||
if (hyp_trace_buffer) {
|
||||
entries = ring_buffer_entries_cpu(hyp_trace_buffer, iter->cpu);
|
||||
overrun = ring_buffer_overrun_cpu(hyp_trace_buffer, iter->cpu);
|
||||
}
|
||||
|
||||
seq_printf(m, "# entries-in-buffer/entries-written: %lu/%lu\n",
|
||||
entries, overrun + entries);
|
||||
@@ -469,17 +475,15 @@ static int hyp_trace_open(struct inode *inode, struct file *file)
|
||||
|
||||
mutex_lock(&hyp_trace_lock);
|
||||
|
||||
if (!hyp_trace_buffer) {
|
||||
ret = -ENODEV;
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
iter = __seq_open_private(file, &hyp_trace_ops, sizeof(*iter));
|
||||
if (!iter) {
|
||||
ret = -ENOMEM;
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
if (!hyp_trace_buffer)
|
||||
goto unlock_and_read;
|
||||
|
||||
iter->buf_iter = ring_buffer_read_prepare(hyp_trace_buffer, cpu, GFP_KERNEL);
|
||||
if (!iter->buf_iter) {
|
||||
seq_release_private(inode, file);
|
||||
@@ -491,7 +495,7 @@ static int hyp_trace_open(struct inode *inode, struct file *file)
|
||||
|
||||
ring_buffer_read_prepare_sync();
|
||||
ring_buffer_read_start(iter->buf_iter);
|
||||
|
||||
unlock_and_read:
|
||||
hyp_trace_readers++;
|
||||
unlock:
|
||||
mutex_unlock(&hyp_trace_lock);
|
||||
@@ -504,7 +508,8 @@ int hyp_trace_release(struct inode *inode, struct file *file)
|
||||
struct seq_file *m = file->private_data;
|
||||
struct ht_iterator *iter = m->private;
|
||||
|
||||
ring_buffer_read_finish(iter->buf_iter);
|
||||
if (iter->buf_iter)
|
||||
ring_buffer_read_finish(iter->buf_iter);
|
||||
|
||||
mutex_lock(&hyp_trace_lock);
|
||||
hyp_trace_readers--;
|
||||
|
||||
Reference in New Issue
Block a user