Since ipc_lock() can gain a reference to a semaphore as it is being removed, a grace period must elapse between the removal and the actual freeing of the corresponding data structures, as illustrated by Figure 12, which shows a simplified version of ipc_rcu_free() function. The actual function is more complex due to the fact that blocks of memory larger than a page must be freed with vfree() rather than kfree(). Line 4 computes a pointer to the beginning of the structure (see Figure 9), which is an ipc_rcu_kmalloc(), which in turn is just a wrapper around an rcu_head structure (see Figure 4). This wrapping allows more common code between the kmalloc() and vmalloc() cases. Lines 5-7 then pass to call_rcu() pointers to the rcu_head structure, to the kfree() function, and to the semaphore structure. The call_rcu() function uses the rcu_head structure to queue up the semaphore structure during the grace period. The actual invocation of the kfree() function on the semaphore structure is deferred until after the end of a subsequent grace period.