Re: [PATCH 3/5] perf_counter: rework ioctl()s

From: Paul Mackerras
Date: Tue May 12 2009 - 18:18:38 EST


Corey Ashford writes:

> Another hypothesis is that the old PAPI code would open, mmap, close,
> then reopen, and mmap again. I wonder if because I wasn't munmap'ing
> before the close, that I got some strange behavior from the kernel.

In general an mmap will keep a reference to the file it is mapping,
which means that if you do an mmap on a fd and then close the fd, the
file stays open until the region is munmapped. So your old PAPI code
would have ended up with more counters active than you expected, if
you thought closing the fd would have destroyed the counter.

That is, you don't have to munmap before close, but you do have to do
both close and munmap to destroy the counter.

Paul.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/