This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Locking of global variables


If I access (read or write) a global variable in a probe handler, how long is it locked? From looking at the generated code, I think it's locked until the handler returns. Does this mean we should avoid the use of globals whenever possible?

I'm asking because I'm considering doing something like the following to minimize code duplication in a set of probes handlers. One good thing is the unused globals still get elided, so this method doesn't do unnecessary work. The bad thing, I think, is that the additional locking may affect the performance of the probed function and increase the potential for skipped probes. Am I missing something?

global maxbytes
global dev
global devname
global devmajor
global devminor
global inode
global filename
global pathname
global fstype
global ftype

function get_file_data (file) {
       maxbytes = _file_maxbytes(file)
       dev = _file_dev(file)
       devname = _bdevname(_file_bdev(file))
       devmajor = _dev_major(dev)
       devminor = _dev_minor(dev)
       inode = _file_ino(file)
       filename = _file_filename(file)
       pathname = _file_pathname(file)
       fstype = _file_fstype(file)
       ftype = _file_type(file)
}

global reads, writes

probe kernel.function("vfs_read") {
       get_file_data($file)
       reads[pathname, fstype]++
}

probe kernel.function("vfs_read") {
       get_file_data($file)
       writes[pathname, fstype]++
}

Mike



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]