The purpose of the oprofile.ipc patch is to: - Add in the OProfile daemon some form of IPC capability. - Use this IPC mechanism to describe module mappings of jitted kernel code. Have opreport show performance counters within such code. NOTES: ------ - Discussions about this work can be found at: http://sourceforge.net/mailarchive/forum.php?thread_id=5907057&forum_id=3252 - *.old* patches are older patch backups. Don't use them. BUGS: ----- - This patch applies against 0.8.2cvs. It is created from a checkout on 11/8/2004. - This work is currently experimental. It has been verified that module mappings for JIT code are added, and samples files for them are created using a 2.4 kernel. However opreport shows output in the format: 00000000 53 0.0621 sys_brk_jit (no symbols) 00000002 4 7.5472 00000012 6 11.3208 0000001f 8 15.0943 00000023 1 1.8868 00000024 7 13.2075 0000002a 27 50.9434 instead of... c013fd6c 51 0.0597 vmlinux path_walk c013fd6c 27 52.9412 c013fd6e 7 13.7255 c013fd73 1 1.9608 c013fd7f 10 19.6078 c013fd81 1 1.9608 c013fd86 5 9.8039 daemon/opd_ipc_commands.c(opd_ipc_process_command_add_mapping) is most likely the function to blame for not getting output in offsets rather than absolute addresses. This appears to happen with all loadable modules in OProfile anyway. - The patch does not include autoconf macros for detecting presence of pthreads, since using pthreads is still under debate. John Levon proposed using select()/read() rather than a multithreaded daemon. - Could probably reuse routines from libutil/op_fileio.h to read from the pipe and improve daemon/opd_ipc.c(opd_ipc_pipe_read_thread) with op_try_open_file() - There's no locking at all when a module mapping is added. This is definitely wrong! Who knows what should be locked. The modules database at a minimum. - Removing the named pipe file does not seem to work. - I had a hard time debugging this, since calling opd_create_module() within opd_ipc_commands.c resulted the 2.6 version being called, while all other modules where loaded using the liblegacy(2.4) version. I had to rename opd_create_module() accordingly. This may not be the right thing to do. - There are some extra verbprintf()s currently used for debugging that should be removed if this work is accepted by the OProfile team. CHANGELOG ENTRY: ---------------- Kristis Makris Implemented an IPC capability in the OProfile daemon using a named pipe. A thread (using pthreads) blocks reading daemon control commands (in text-based format) from the pipe. The only command currently accepted is in the format: add_mapping my_jitted_code_module_name 0xstart_address 0xend_address Thus one can add mappings while oprofiled is running by executing: $ echo add_mapping sys_brk_jit 0xdac4b5e0 0xdac4b610 > /var/lib/oprofile/oprofiled.ipc" Added some very basic documentation in the internals document of the IPC feature. daemon/oprofiled.c(main): Initialize IPC daemon/opd_ipc.c: IPC implementation using a named pipe daemon/opd_ipc_commands.c: Handling of daemon control commands send through the pipe. daemon/liblegacy/init.c(opd_24_exit): Cleaning up IPC. daemon/liblegacy/init.c(opd_sigterm): Cleaning up IPC. daemon/init.c(opd_26_exit): Cleaning up IPC. daemon/init.c(opd_sigterm): Cleaning up IPC. daemon/liblegacy/opd_kernel.c(opd_create_module_24): Renamed from opd_create_module(). daemon/liblegacy/opd_kernel.c(opd_handle_module_sample): Reread module mapping commands provided through IPC. daemon/liblegacy/opd_kernel.c(opd_add_kernel_map): Reread module mapping commands provided through IPC. daemon/liblegacy/opd_kernel.h(opd_create_module_24): Renamed from opd_create_module(). daemon/liblegacy/opd_kernel.c(struct opd_module): Moved into daemon/liblegacy/opd_kernel.h so that daemon/opd_ipc_commands.c(opd_ipc_process_command_add_mapping) can use it. daemon/liblegacy/opd_kernel.c(opd_find_module_by_name): Minor grammar changes. daemon/opd_kernel.c(opd_create_module_26): Renamed from opd_create_module(). daemon/opd_kernel.h(opd_create_module_26): Renamed from opd_create_module(). daemon/opd_trans.c(code_module_loaded): Reread module mapping commands provided through IPC.