LWN.net Logo

Some 2.6.11 API changes

A few small internal API changes have been merged for 2.6.11. For the record, here's what they are.

The completion mechanism allows a thread in the kernel to block until a specific event happens. Three new functions, some of which appear to be aiming for the "longest name in the kernel" prize, have been added:

int wait_for_completion_interruptible(struct completion *c);
unsigned long wait_for_completion_timeout(struct completion *c,
	                                  unsigned long timeout);
unsigned long wait_for_completion_interruptible_timeout(struct completion *c,
                                                        unsigned long timeout);

Each of these functions should be relatively straightforward to understand: they add interruptible and timeout variants to the basic wait_for_completion() function. They were added it make it easier to convert more semaphore users over to the completion API, which is more appropriate for cases where a one-shot operation is being waited for. This change is another small bit of fallout from the realtime preemption work.

The kernel has long had an implementation of bcopy():

    void bcopy(const char *src, char *dest, int size);

Arjan van de Ven and Adrian Bunk recently noticed a couple of things: (1) nothing in the kernel was actually using bcopy(), and (2) the implementation was broken. bcopy() is supposed to be able to handle overlapping source and destination areas, but, for a number of architectures, the kernel implementation would not do the right thing with such areas. So a patch was merged which removes bcopy(). No other in-kernel changes were needed, but out-of-tree modules which use bcopy() will need to be changed.

Chip Salzenberg (and others) noticed that a couple of networking functions - skb_copy_datagram() and sock_alloc_send_pskb() - are no longer exported to modules in the 2.6.11 prepatches. This change breaks the out-of-tree VMWare modules. Fixes for VMWare have already been merged.

On the PCI front, a patch from Pavel Machek which changes the prototype of the suspend() method in struct pci_driver was merged. The new prototype is:

    int (*suspend)(struct pci_dev *dev, pm_message_t state);

By changing the type of the state parameter, the patch allows the removal of some translation code and lets PCI drivers know what is really going on at the higher power management levels. Pavel is looking for help in fixing PCI drivers to use the new interface.

A few spinlock primitives have seen changes. For starters, the macro rwlock_is_locked() has been removed. It was never clear whether the macro referred to read or write locking, so Linus dealt with the confusion by just taking it out altogether. Then a new set of primitives was added:

    int read_can_lock(rwlock_t *rw);
    int write_can_lock(rwlock_t *rw);

These test whether an attempt to obtain a read or write lock at that time would have succeeded. In addition, there is a version for regular spinlocks:

    int spin_can_lock(spinlock_t *lock);

This function returns a nonzero value if an attempt to obtain lock would have succeeded, but does not actually modify the lock.

Finally, the name of the internal lock field in the spinlock structure was renamed to slock. This change was made to force the compiler to complain when rwlock primitives are used on a regular spinlock (and vice versa). This sort of type safety could also have been achieved by using inline functions, rather than macros, but some performance problems with gcc prevented that approach from being used.


(Log in to post comments)

Some 2.6.11 API changes

Posted Jul 11, 2008 10:27 UTC (Fri) by YogeshDC (guest, #52855) [Link]

could anyone please elaborate on what is precisely achieved by 
int wait_for_completion_interruptible(struct completion *c);

Copyright © 2005, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds