Re: [PATCH] libtracefs: Add ring buffer memory mapping APIs

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

 



On Tue, 23 Jan 2024 09:52:55 +0000
Vincent Donnefort <vdonnefort@xxxxxxxxxx> wrote:

> [...]
> 

> > +	data = tmap->data + tmap->map->subbuf_size * tmap->last_idx;
> > +	kbuffer_load_subbuffer(kbuf, data);

Only the tmap->kbuf is loaded above.


> > +
> > +	/*
> > +	 * The page could have left over data on it that was already
> > +	 * consumed. Move the "read" forward in that case.
> > +	 */
> > +	if (tmap->map->reader.read) {
> > +		int size = kbuffer_start_of_data(kbuf) + tmap->map->reader.read;
> > +		char tmpbuf[size];
> > +		kbuffer_read_buffer(kbuf, tmpbuf, size);
> > +	}  
> 
> We're fast-forwarding tmap->kbuf here. But in tracefs_cpu_read_buf(), we are
> using tcpu->kbuf. So overall, it seems this has no effect on what will be read
> later.
> 
> Sorry, not sure how I missed that when I worked with those changes before.

So we would need to add this in trace_mmap_load_subbuf()?


	if (data != kbuffer_subbuffer(kbuf)) {
		kbuffer_load_subbuffer(kbuf, data);
+		/* Move the read pointer forward if need be */
+		if (kbuffer_curr_index(tmap->kbuf)) {
+			int size = kbuffer_curr_index(tmap->kbuf);
+			char tmpbuf[size];
+			kbuffer_read_buffer(kbuf, tmpbuf, size);
+		}
		
		return 1;
	}

I think that could solve that.

-- Steve




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux