poll 2.6 and beyond

From: Richard B. Johnson
Date: Tue Mar 02 2004 - 16:00:09 EST



Hello all,
The provided driver and test code clearly shows that
poll_wait is returning to the driver as soon as it is
called, therefore not able to return the correct status.

It must remain sleeping until awakened by the driver so
that the driver can provide the correct return status.

This driver code doesn't even provide a method of waking
up poll_wait(). There is no wake_up_interruptible() in
the code at all!!!

The first

Linux Thingy : poll() called
Linux Thingy : poll() returned

... group occurred when the user-mode code called poll(). The
second identical group occurred when ^C was used to signal
termination.


Script started on Tue Mar 2 15:46:50 2004
# make clean
rm -f *.o THINK tester
# make
gcc -Wall -O2 -D__KERNEL__ -DMODULE -DMAJOR_NR=199 -I/usr/src/linux-2.4.24/include -c -o thingy.o thingy.c
gcc -Wall -o tester -O2 tester.c
rm -f THING
mknod THING c 199 0
# insmod thingy.o
# strace ./tester
execve("./tester", ["./tester"], [/* 32 vars */]) = 0
brk(0) = 0x8049710
open("/etc/ld.so.preload", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
old_mmap(NULL, 0, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
old_mmap(NULL, 4096, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4000c000
munmap(0x4000c000, 4096) = 0
old_mmap(NULL, 644232, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4000c000
mprotect(0x40097000, 74888, PROT_NONE) = 0
old_mmap(0x40097000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x8b000) = 0x40097000
old_mmap(0x4009d000, 50312, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4009d000
close(3) = 0
mprotect(0x4000c000, 569344, PROT_READ|PROT_WRITE) = 0
mprotect(0x4000c000, 569344, PROT_READ|PROT_EXEC) = 0
personality(PER_LINUX) = 0
getpid() = 2122
open("THING", O_RDONLY) = 3
poll(
<unfinished ...>
# dmesg | tail
Linux Thingy : module removed
Linux Thingy : initialization complete
Linux Thingy : poll() called
Linux Thingy : poll() returned
Linux Thingy : poll() called
Linux Thingy : poll() returned
# exit
exit

Script done on Tue Mar 2 15:47:48 2004


Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.

Attachment: module.tar.gz
Description: Binary data