Re: Finding out the number of used file descriptors
Re: Finding out the number of used file descriptors
- Subject: Re: Finding out the number of used file descriptors
- From: Terry Lambert <email@hidden>
- Date: Fri, 27 Mar 2009 09:15:27 -0700
Number of actual open fds relative to the default administrative limit
on the number of open fds is not a useful measure of overall load.
Among other reasons is that we do not scale the administrative limit
on the basis of hardware capability. Another is that not all types of
fds consume equivalent per-fd resources, so even if the limit were
scaled you couldn't trust it to be meaningful across different
workload profiles..
-- Terry
On Mar 27, 2009, at 2:22 AM, Thierry bultel
<email@hidden> wrote:
Hi all,
I would really appreciate if you could take some time to comment on
the problems I have:
In order to implement an early detection of the system load, before
launching any job that would put the machine to its limits or
worse ;-) ,
we would like to find out the current usage of file descriptors, in
the entire system.
If we could access that information, we would be able to compare it
with the max limit and therefore decide if we continue or not,
depending on a configurable threshold.
I have done some investigations around sysctl (CTL_KERN + KERN_FILE)
but it sounds like that part of the interface is not supported,
because the matching structures of the returned buffer are not public.
Notice that I am thinking about having a kind of heuristic that
would determine the number of files, by only using
the size of the 'struct extern_file', dividing, and forgetting the
filehead, whose size is small comparing to the sum of
the others.
If I want to be more accurate than that, for simplicity of code, and
also, performances concerns, I do not want to base it on lsof.
(As I think that spawning executables and parsing output is
generally a bas idea ...).
Therefore I also have investigated on other ways how to possibly
access the global kernel variable "nfiles", for example from a kext.
Although It was relatively quick and easy to have a kind of "hello
world" kernel extension, I have not been able to access the aimed
variable. I guess it is not public or something of the same flavour.
So my questions are:
1) What is your advice to get the current usage of file descriptors ?
2) As a general question: Is there a special way to access the
kernel symbols from a kext ? How are (if any) public symbols
declared in the kernel ?
3) Is it possible to declare a new syscall from a kext ? I have not
found any examples on the web ...
Any help would be greatly appreciated ...
Cheers,
Thierry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden