Re: [RFC Patch 1/1] trace_printk and trace_dump interface - v2

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: K.Prasad
Date: Tuesday, May 20, 2008 - 12:53 pm

On Mon, May 19, 2008 at 04:21:49PM -0700, Andrew Morton wrote:
Must be an act of my mail client. Will re-send with proper word-wrapping
and spacing during the next iteration.

Ok. Will change.

Yes, I missed it. Will modify to look like this:

	if (strlen(name) > TRACE_NAME_SIZE)
		return ERR_PTR(-ENOMEM);

	temp = kzalloc(sizeof(struct trace_dir), GFP_KERNEL);
	if (temp == NULL)
		return ERR_PTR(-ENOMEM);
	
Ok.

Ok. Will name this instance,
struct trace_dir *tdd;


The name 'trace' (previously GTSC), I gather that it was the chosen after
much deliberation (http://tinyurl.com/6odoh4), however I'm open to the
idea of changing the name (say dbg_printk/dbg_dump?).

Kindly let me know of your suggestions for this, and I will change them
during the next version.

That 'inline' was unintentional. I will remove it.

Ok. Will modify it:
	uninitialized_var(flags);
Will something like this look better?

static int trace_dump_per_cpu_channel(struct trace_printk_data *tpk,
				const void *output, const int output_len)
{
	char *record;
	int ret = 0;
	
	record = relay_reserve(tpk->ti->rchan, output_len);

	if (record && trace_running(tpk->ti))
		memcpy(record, output, output_len);
	else {
		if (record)
			ret = -EPERM;
		else
			ret = -ENOMEM;
	}
	return ret;
}

static int trace_dump_global_channel(struct trace_printk_data *tpk,
				const void *output, const int output_len)
{
	int ret;
	uninitialized_var(flags);
	
	spin_lock_irqsave(&tpk->ti->trace_lock, flags);
	ret = trace_dump_per_cpu_channel(tpk, output, output_len);
	spin_unlock_irqrestore(&tpk->ti->trace_lock, flags);

	return ret;
}

int trace_dump(struct trace_printk_data *tpk, const void *output,
							const int output_len)
{
	unsigned long flags = 0;
	int ret = 0;

	ret = init_trace_interface(tpk);
	if (unlikely(ret))
		return ret;

	/* Now do the actual printing */
	rcu_read_lock();
	/* Take a spinlock for the global buffer used by relay */
	if (tpk->flags & TRACE_GLOBAL_CHANNEL)
		ret = trace_dump_global_channel(tpk, output, output_len);
	else
		ret = trace_dump_per_cpu_channel(tpk, output, output_len);
	
	rcu_read_unlock();

	return ret;
}

Ok. This is adapted from legacy code in samples/trace/fork_trace.c.
I will modify the code in both files.


Thanks for looking into the patches. I will send out the next version of
the patch after hearing from you on the above.

Thanks,
K.Prasad
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [RFC Patch 1/1] trace_printk and trace_dump interface - v2, K.Prasad, (Tue May 20, 12:53 pm)