On Wednesday 02 July 2008, stephane eranian wrote: > 2- all system calls taking structure parameters have reserved > fields. They can be used to support extensions. > > I see 3 problems with reserved fields: > > - They are supposed to be all zeroes. Let's say, a new > perfmon version uses one to support an extension. > What if value 0 is valid for this extension, and we > execute an old application which does not know about it > and passes 0 in the corresponding reserved field? > > This does not systematically translate into a problem. > Worst case, it may generate events which the old > application does not know about.
A common way to deal with this is to have a "flags" argument in each syscall that may get extended. Each bit in the flags will mean that a certain extension or feature is used, and its arguments are unused otherwise. With this, you may even add new arguments to the syscall, if necessary, in the same way that the 'open' syscall has a 'mode' argument that is only used when the flag contains O_CREAT. For any syscalls that have reserved fields in their data structure, it would be good to pass a flags argument as well, even if the current interface mandates that it has to be zero. > - what if we run out of reserved fields? Then we have not > other choice but to add a new syscall yes, or another argument, but commonly a new syscall would be cleaner in that case. > I am tempted to transform the interface to have a mix of the two > approaches. I could clearly see that load/unload > and start/stop could be implemented by a generic pfm_control(int fd, > int CMD, void *arg, size_t arg_sz) call. To go > further, we could also group the write syscalls : pfm_write_regs(int > fd, int type, void *arg, size_t arg_sz) with type > indicating either config or data registers. > > What do you think? No, please don't do unstructured (void*) arguments in syscalls, they cause all sorts of problems, e.g. in 32 bit emulation (if it becomes necessary to convert the structure), in strace, gdb and anything that tries to make sense of the arguments. Arnd <>< ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ perfmon2-devel mailing list perfmon2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perfmon2-devel