Re: Help adding trace events to xHCI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2013-07-26 at 11:19 +0200, Johannes Berg wrote:

> My original though here was that we should be able to reserve (maximum)
> space on the per-CPU buffer, and then relinquish some of it after the
> tracepoint was written to the data, but I never had the time to check if
> that was possible to implement. It would make it a little inefficient at
> page boundaries, but that seems OK given that our maximum size is only
> ~100 bytes or so now.
> 

Yes that would be trivial to implement. If the max buffer is ~100 bytes,
allocate 256 byte buffers per cpu. Also have a per cpu index, and then
have something like this:


	index = local_add_return(this_cpu_ptr(trace_index), len);

	if (index >= MAX_BUF) {
		/* write tracepoint with failed buffer */
		local_sub(this_cpu_ptr(trace_index));
		return;
	}

	index -= len;

	memcpy(this_cpu_ptr(trace_buf) + index, string, len);

	/* write tracepoint with trace_buf */

	local_sub(this_cpu_ptr(trace_index), len);


This way the trace_buf will work like a stack allocator. The
local_add_return() will reserve the space in the buffer such that if an
interrupt were to come in, it would allocate after that space. The check
for MAX_BUF tests for the case that the buffer was too big and had to
bail. Still trace that event to let the user (yourself) know you need a
bigger buffer.

-- Steve


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux