On Tue, 28 Nov 2000, Tigran Aivazian wrote:

> Hi,
> 
> A simple experiment:
> 
> a) insert a code like this in the open() routine of some driver:
> 
>        struct files_struct *files = current->files;
>        extern int count_open_files(struct files_struct *, int);
> 
>        printk(KERN_ERR "%s has %d files open\n",
>                         current->comm, count_open_files(files, files->max_fdset));
> 
> b) write a program that opens that device and sleeps indefinitely. Run it,
> you will see:
> 
> op has 32 files open
> 
> c)  # lsof -p 659 | nl
>      1  COMMAND PID   USER   FD   TYPE DEVICE    SIZE   NODE NAME
>      2  op      659 tigran  cwd    DIR    3,6    4096 225730
> /home/tigran/C/files
>      3  op      659 tigran  rtd    DIR    3,6    4096      2 /
>      4  op      659 tigran  txt    REG    3,6   14142 225732
> /home/tigran/C/files/op
>      5  op      659 tigran  mem    REG    3,6  434945 295227
> /lib/ld-2.1.92.so
>      6  op      659 tigran  mem    REG    3,6 4776568 295234
> /lib/libc-2.1.92.so
>      7  op      659 tigran    0u   CHR    4,9         348027 /dev/tty9
>      8  op      659 tigran    1u   CHR    4,9         348027 /dev/tty9
>      9  op      659 tigran    2u   CHR    4,9         348027 /dev/tty9
>     10  op      659 tigran    3r   CHR 10,184          98313
> /dev/cpu/microcode
> 
> so, we see that the process has only 9 files open and yet
> count_open_files() claims there are 32. Is this a bug of
> count_open_files() or is this a minimal granularity (because there are 32
> builtin descriptors in files_struct->fd_array[])?
> 
> I know that there is no problem due to the way it is called in
> copy_files() -- it would only be above 32. But for what I want to use it,
> I need the _correct_ number of open file descriptors and not some "rounded
> up to 32" one.   
> 
> (kernel assumed test12-pre2)
> 
> Regards,
> Tigran
> 

Yes. This is probably related to the previously-reported MOD_INC_USE_COUNT
macro in the drivers. The open count is now handled in the call to
the driver's open(). The MOD_INC_USE_COUNT and the MOD_DEC_USE_COUNT
should now be defined to do nothing for kernels that already handle
the counts in the calls.
 

Cheers,
Dick Johnson

Penguin : Linux version 2.4.0 on an i686 machine (799.54 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/

Reply via email to