AIO completion signal notification The current 2.6 kernel does not support notification of user space via an RT signal upon an asynchronous IO completion. The POSIX specification states that when an AIO request completes, a signal can be delivered to the application as notification. This patch adds a struct sigevent *aio_sigeventp to the iocb. The relevant fields (pid, signal number and value) are stored in the kiocb for use when the request completes. That sigevent structure is filled by the application as part of the AIO request preparation. Upon request completion, the kernel notifies the application using those sigevent parameters. If SIGEV_NONE has been specifi= ed, then the old behaviour is retained and the application must rely on polling the completion queue using io_getevents(). A struct sigevent *aio_sigeventp field is added to struct iocb in include/linux/aio_abi.h A struct aio_notify containing the sigevent parameters is defined in aio.= h: struct aio_notify { struct task_struct *target; __u16 signo; __u16 notify; sigval_t value; }; A struct aio_notify ki_notify is added to struct kiocb in include/linux/a= io.h In io_submit_one(), if the application provided a sigevent then setup_sigevent() is called which does the following: - check access to the user sigevent and make a local copy - if the requested notification is SIGEV_NONE, then nothing to do - fill in the kiocb->ki_notify fields (notify, signo, value) - check sigevent consistency, get the signal target task and save it in kiocb->ki_notify.target - preallocate a sigqueue for this event using sigqueue_alloc() Upon request completion, in aio_complete(), if notification is needed for this request (iocb->ki_notify.notify !=3D SIGEV_NONE), then aio_send_signal is called to signal the target task as follows: - fill in the siginfo struct to be sent to the task - if notify is SIGEV_THREAD_ID then send signal to specific task using send_sigqueue() - else send signal to task group using send_5group_sigqueue() Notes concerning sigqueue preallocation: To ensure reliable delivery of completion notification, the sigqueue is preallocated in the submission path so that there is no chance it can fail in the completion path. Unlike the posix-timers case (currently the single other user of sigqueue preallocation), where the sigqueue is allocated for the lifetime of the timer and freed at timer destruction time, the aio case is a bit more tricky due to the async nature of the whole thing. In the aio case, the sigqueue exists for the lifetime of the request, therefore it must be freed only once the signal for the request completion has been delivered. This involves changing __sigqueue_free() to free the sigqueue when the signal is collected if si_code is SI_ASYNCIO even if it was preallocated as well as explicitly calling sigqueue_free() in submission and completion error paths.