[lttng-dev] [MODULES RFC PATCH] Extract the bitmask of FDs set in select syscall

Julien Desfossez julien.desfossez at polymtl.ca
Wed Oct 7 14:37:23 EDT 2015


> > .../x86-64-syscalls-3.10.0-rc7_pointers_override.h | 56 ++++++++++++++++++++++
> 
> Does it have to be a x86-64 specific override, or it could be used
> as an override for all architectures ?
Indeed I will move it as an override for all architectures.

> > +	TP_code(
> > +		sc_inout(
> > +		{
> > +			unsigned long nr;
> > +			int ret;
> > +
> > +			nr = FDS_BYTES(n);
> > +			tp_locvar->nb_in = 0;
> > +			tp_locvar->nb_out = 0;
> > +			tp_locvar->nb_ex = 0;
> 
> You could initialize them to 0 in TP_locvar (definition).
Good point.

> > +			if (inp) {
> > +				ret = copy_from_user(tp_locvar->fds_in, inp, nr);
> 
> Why use copy_from_user() here rather than get_fd_set() ?
I had a problem with the memset to 0 on error, I don't remember why,
I'll try again with that.

> > +	TP_FIELDS(
> > +		sc_exit(ctf_integer(long, ret, ret))
> > +		sc_in(ctf_integer(int, n, n))
> > +		sc_inout(ctf_sequence_hex(unsigned long, fdset_in,
> > +				&tp_locvar->fds_in, unsigned long, tp_locvar->nb_in))
> 
> If we want to make this code portable, is it really an array of unsigned long in the
> trace ? What is the layout on a 32-bit architecture ?
This way of working is what is done by select() itself. On 64-bit we
have a maximum of 16 unsigned longs (to handle up to 16*8 = 1024 FDs),
on 32-bit it is 32 unsigned longs (32 * 4 = 1024).

I would also prefer a way to extract a clean list of FDs instead of a
bitmask and potentially waste stack space, but I don't see how without
needing to allocate/free memory or have an arbitrary limit.

Thanks

Julien



More information about the lttng-dev mailing list