diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/bio.h | 7 | ||||
| -rw-r--r-- | include/linux/bit_spinlock.h | 77 | ||||
| -rw-r--r-- | include/linux/blkdev.h | 2 | ||||
| -rw-r--r-- | include/linux/chio.h | 2 | ||||
| -rw-r--r-- | include/linux/dmapool.h | 3 | ||||
| -rw-r--r-- | include/linux/fs.h | 2 | ||||
| -rw-r--r-- | include/linux/in6.h | 56 | ||||
| -rw-r--r-- | include/linux/input.h | 8 | ||||
| -rw-r--r-- | include/linux/ipv6.h | 2 | ||||
| -rw-r--r-- | include/linux/jbd.h | 1 | ||||
| -rw-r--r-- | include/linux/jiffies.h | 40 | ||||
| -rw-r--r-- | include/linux/radix-tree.h | 4 | ||||
| -rw-r--r-- | include/linux/reiserfs_fs.h | 6 | ||||
| -rw-r--r-- | include/linux/sched.h | 4 | ||||
| -rw-r--r-- | include/linux/slab.h | 3 | ||||
| -rw-r--r-- | include/linux/spinlock.h | 627 | ||||
| -rw-r--r-- | include/linux/spinlock_api_smp.h | 57 | ||||
| -rw-r--r-- | include/linux/spinlock_api_up.h | 80 | ||||
| -rw-r--r-- | include/linux/spinlock_types.h | 67 | ||||
| -rw-r--r-- | include/linux/spinlock_types_up.h | 51 | ||||
| -rw-r--r-- | include/linux/spinlock_up.h | 74 | ||||
| -rw-r--r-- | include/linux/time.h | 9 | ||||
| -rw-r--r-- | include/linux/writeback.h | 2 |
23 files changed, 616 insertions, 568 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h index cdaf03a14a51..6e1c79c8b6bf 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
| @@ -314,9 +314,8 @@ void zero_fill_bio(struct bio *bio); | |||
| 314 | * bvec_kmap_irq and bvec_kunmap_irq!! | 314 | * bvec_kmap_irq and bvec_kunmap_irq!! |
| 315 | * | 315 | * |
| 316 | * This function MUST be inlined - it plays with the CPU interrupt flags. | 316 | * This function MUST be inlined - it plays with the CPU interrupt flags. |
| 317 | * Hence the `extern inline'. | ||
| 318 | */ | 317 | */ |
| 319 | extern inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags) | 318 | static inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags) |
| 320 | { | 319 | { |
| 321 | unsigned long addr; | 320 | unsigned long addr; |
| 322 | 321 | ||
| @@ -332,7 +331,7 @@ extern inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags) | |||
| 332 | return (char *) addr + bvec->bv_offset; | 331 | return (char *) addr + bvec->bv_offset; |
| 333 | } | 332 | } |
| 334 | 333 | ||
| 335 | extern inline void bvec_kunmap_irq(char *buffer, unsigned long *flags) | 334 | static inline void bvec_kunmap_irq(char *buffer, unsigned long *flags) |
| 336 | { | 335 | { |
| 337 | unsigned long ptr = (unsigned long) buffer & PAGE_MASK; | 336 | unsigned long ptr = (unsigned long) buffer & PAGE_MASK; |
| 338 | 337 | ||
| @@ -345,7 +344,7 @@ extern inline void bvec_kunmap_irq(char *buffer, unsigned long *flags) | |||
| 345 | #define bvec_kunmap_irq(buf, flags) do { *(flags) = 0; } while (0) | 344 | #define bvec_kunmap_irq(buf, flags) do { *(flags) = 0; } while (0) |
| 346 | #endif | 345 | #endif |
| 347 | 346 | ||
| 348 | extern inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx, | 347 | static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx, |
| 349 | unsigned long *flags) | 348 | unsigned long *flags) |
| 350 | { | 349 | { |
| 351 | return bvec_kmap_irq(bio_iovec_idx(bio, idx), flags); | 350 | return bvec_kmap_irq(bio_iovec_idx(bio, idx), flags); |
diff --git a/include/linux/bit_spinlock.h b/include/linux/bit_spinlock.h new file mode 100644 index 000000000000..6b20af0bbb79 --- /dev/null +++ b/include/linux/bit_spinlock.h | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | #ifndef __LINUX_BIT_SPINLOCK_H | ||
| 2 | #define __LINUX_BIT_SPINLOCK_H | ||
| 3 | |||
| 4 | /* | ||
| 5 | * bit-based spin_lock() | ||
| 6 | * | ||
| 7 | * Don't use this unless you really need to: spin_lock() and spin_unlock() | ||
| 8 | * are significantly faster. | ||
| 9 | */ | ||
| 10 | static inline void bit_spin_lock(int bitnum, unsigned long *addr) | ||
| 11 | { | ||
| 12 | /* | ||
| 13 | * Assuming the lock is uncontended, this never enters | ||
| 14 | * the body of the outer loop. If it is contended, then | ||
| 15 | * within the inner loop a non-atomic test is used to | ||
| 16 | * busywait with less bus contention for a good time to | ||
| 17 | * attempt to acquire the lock bit. | ||
| 18 | */ | ||
| 19 | preempt_disable(); | ||
| 20 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
| 21 | while (test_and_set_bit(bitnum, addr)) { | ||
| 22 | while (test_bit(bitnum, addr)) { | ||
| 23 | preempt_enable(); | ||
| 24 | cpu_relax(); | ||
| 25 | preempt_disable(); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | #endif | ||
| 29 | __acquire(bitlock); | ||
| 30 | } | ||
| 31 | |||
| 32 | /* | ||
| 33 | * Return true if it was acquired | ||
| 34 | */ | ||
| 35 | static inline int bit_spin_trylock(int bitnum, unsigned long *addr) | ||
| 36 | { | ||
| 37 | preempt_disable(); | ||
| 38 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
| 39 | if (test_and_set_bit(bitnum, addr)) { | ||
| 40 | preempt_enable(); | ||
| 41 | return 0; | ||
| 42 | } | ||
| 43 | #endif | ||
| 44 | __acquire(bitlock); | ||
| 45 | return 1; | ||
| 46 | } | ||
| 47 | |||
| 48 | /* | ||
| 49 | * bit-based spin_unlock() | ||
| 50 | */ | ||
| 51 | static inline void bit_spin_unlock(int bitnum, unsigned long *addr) | ||
| 52 | { | ||
| 53 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
| 54 | BUG_ON(!test_bit(bitnum, addr)); | ||
| 55 | smp_mb__before_clear_bit(); | ||
| 56 | clear_bit(bitnum, addr); | ||
| 57 | #endif | ||
| 58 | preempt_enable(); | ||
| 59 | __release(bitlock); | ||
| 60 | } | ||
| 61 | |||
| 62 | /* | ||
| 63 | * Return true if the lock is held. | ||
| 64 | */ | ||
| 65 | static inline int bit_spin_is_locked(int bitnum, unsigned long *addr) | ||
| 66 | { | ||
| 67 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
| 68 | return test_bit(bitnum, addr); | ||
| 69 | #elif defined CONFIG_PREEMPT | ||
| 70 | return preempt_count(); | ||
| 71 | #else | ||
| 72 | return 1; | ||
| 73 | #endif | ||
| 74 | } | ||
| 75 | |||
| 76 | #endif /* __LINUX_BIT_SPINLOCK_H */ | ||
| 77 | |||
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index aefa26fbae8a..efdc9b5bc05c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
| @@ -728,7 +728,7 @@ static inline unsigned int blksize_bits(unsigned int size) | |||
| 728 | return bits; | 728 | return bits; |
| 729 | } | 729 | } |
| 730 | 730 | ||
| 731 | extern inline unsigned int block_size(struct block_device *bdev) | 731 | static inline unsigned int block_size(struct block_device *bdev) |
| 732 | { | 732 | { |
| 733 | return bdev->bd_block_size; | 733 | return bdev->bd_block_size; |
| 734 | } | 734 | } |
diff --git a/include/linux/chio.h b/include/linux/chio.h index 63035ae67e63..a404c111c937 100644 --- a/include/linux/chio.h +++ b/include/linux/chio.h | |||
| @@ -96,7 +96,7 @@ struct changer_position { | |||
| 96 | */ | 96 | */ |
| 97 | struct changer_element_status { | 97 | struct changer_element_status { |
| 98 | int ces_type; | 98 | int ces_type; |
| 99 | unsigned char *ces_data; | 99 | unsigned char __user *ces_data; |
| 100 | }; | 100 | }; |
| 101 | #define CESTATUS_FULL 0x01 /* full */ | 101 | #define CESTATUS_FULL 0x01 /* full */ |
| 102 | #define CESTATUS_IMPEXP 0x02 /* media was imported (inserted by sysop) */ | 102 | #define CESTATUS_IMPEXP 0x02 /* media was imported (inserted by sysop) */ |
diff --git a/include/linux/dmapool.h b/include/linux/dmapool.h index e60bfdac348d..4932ee5c77f0 100644 --- a/include/linux/dmapool.h +++ b/include/linux/dmapool.h | |||
| @@ -19,7 +19,8 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev, | |||
| 19 | 19 | ||
| 20 | void dma_pool_destroy(struct dma_pool *pool); | 20 | void dma_pool_destroy(struct dma_pool *pool); |
| 21 | 21 | ||
| 22 | void *dma_pool_alloc(struct dma_pool *pool, int mem_flags, dma_addr_t *handle); | 22 | void *dma_pool_alloc(struct dma_pool *pool, unsigned int __nocast mem_flags, |
| 23 | dma_addr_t *handle); | ||
| 23 | 24 | ||
| 24 | void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr); | 25 | void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr); |
| 25 | 26 | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index 7f61227827d7..e0b77c5af9a0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
| @@ -1509,8 +1509,6 @@ extern void do_generic_mapping_read(struct address_space *mapping, | |||
| 1509 | loff_t *, read_descriptor_t *, read_actor_t); | 1509 | loff_t *, read_descriptor_t *, read_actor_t); |
| 1510 | extern void | 1510 | extern void |
| 1511 | file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); | 1511 | file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); |
| 1512 | extern ssize_t generic_file_direct_IO(int rw, struct kiocb *iocb, | ||
| 1513 | const struct iovec *iov, loff_t offset, unsigned long nr_segs); | ||
| 1514 | extern ssize_t generic_file_readv(struct file *filp, const struct iovec *iov, | 1512 | extern ssize_t generic_file_readv(struct file *filp, const struct iovec *iov, |
| 1515 | unsigned long nr_segs, loff_t *ppos); | 1513 | unsigned long nr_segs, loff_t *ppos); |
| 1516 | ssize_t generic_file_writev(struct file *filp, const struct iovec *iov, | 1514 | ssize_t generic_file_writev(struct file *filp, const struct iovec *iov, |
diff --git a/include/linux/in6.h b/include/linux/in6.h index bd32b79d6295..304aaedea305 100644 --- a/include/linux/in6.h +++ b/include/linux/in6.h | |||
| @@ -198,27 +198,43 @@ struct in6_flowlabel_req | |||
| 198 | * MCAST_MSFILTER 48 | 198 | * MCAST_MSFILTER 48 |
| 199 | */ | 199 | */ |
| 200 | 200 | ||
| 201 | /* RFC3542 advanced socket options (50-67) */ | 201 | /* |
| 202 | #define IPV6_RECVPKTINFO 50 | 202 | * Advanced API (RFC3542) (1) |
| 203 | #define IPV6_PKTINFO 51 | 203 | * |
| 204 | #if 0 | 204 | * Note: IPV6_RECVRTHDRDSTOPTS does not exist. see net/ipv6/datagram.c. |
| 205 | #define IPV6_RECVPATHMTU 52 | 205 | */ |
| 206 | #define IPV6_PATHMTU 53 | 206 | |
| 207 | #define IPV6_DONTFRAG 54 | 207 | #define IPV6_RECVPKTINFO 49 |
| 208 | #define IPV6_USE_MIN_MTU 55 | 208 | #define IPV6_PKTINFO 50 |
| 209 | #endif | 209 | #define IPV6_RECVHOPLIMIT 51 |
| 210 | #define IPV6_RECVHOPOPTS 56 | 210 | #define IPV6_HOPLIMIT 52 |
| 211 | #define IPV6_HOPOPTS 57 | 211 | #define IPV6_RECVHOPOPTS 53 |
| 212 | #if 0 | 212 | #define IPV6_HOPOPTS 54 |
| 213 | #define IPV6_RECVRTHDRDSTOPTS 58 /* Unused, see net/ipv6/datagram.c */ | 213 | #define IPV6_RTHDRDSTOPTS 55 |
| 214 | #define IPV6_RECVRTHDR 56 | ||
| 215 | #define IPV6_RTHDR 57 | ||
| 216 | #define IPV6_RECVDSTOPTS 58 | ||
| 217 | #define IPV6_DSTOPTS 59 | ||
| 218 | #if 0 /* not yet */ | ||
| 219 | #define IPV6_RECVPATHMTU 60 | ||
| 220 | #define IPV6_PATHMTU 61 | ||
| 221 | #define IPV6_DONTFRAG 62 | ||
| 222 | #define IPV6_USE_MIN_MTU 63 | ||
| 214 | #endif | 223 | #endif |
| 215 | #define IPV6_RTHDRDSTOPTS 59 | 224 | |
| 216 | #define IPV6_RECVRTHDR 60 | 225 | /* |
| 217 | #define IPV6_RTHDR 61 | 226 | * Netfilter |
| 218 | #define IPV6_RECVDSTOPTS 62 | 227 | * |
| 219 | #define IPV6_DSTOPTS 63 | 228 | * Following socket options are used in ip6_tables; |
| 220 | #define IPV6_RECVHOPLIMIT 64 | 229 | * see include/linux/netfilter_ipv6/ip6_tables.h. |
| 221 | #define IPV6_HOPLIMIT 65 | 230 | * |
| 231 | * IP6T_SO_SET_REPLACE / IP6T_SO_GET_INFO 64 | ||
| 232 | * IP6T_SO_SET_ADD_COUNTERS / IP6T_SO_GET_ENTRIES 65 | ||
| 233 | */ | ||
| 234 | |||
| 235 | /* | ||
| 236 | * Advanced API (RFC3542) (2) | ||
| 237 | */ | ||
| 222 | #define IPV6_RECVTCLASS 66 | 238 | #define IPV6_RECVTCLASS 66 |
| 223 | #define IPV6_TCLASS 67 | 239 | #define IPV6_TCLASS 67 |
| 224 | 240 | ||
diff --git a/include/linux/input.h b/include/linux/input.h index 4767e5429534..e8c296ff6257 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
| @@ -289,6 +289,8 @@ struct input_absinfo { | |||
| 289 | #define KEY_SCROLLDOWN 178 | 289 | #define KEY_SCROLLDOWN 178 |
| 290 | #define KEY_KPLEFTPAREN 179 | 290 | #define KEY_KPLEFTPAREN 179 |
| 291 | #define KEY_KPRIGHTPAREN 180 | 291 | #define KEY_KPRIGHTPAREN 180 |
| 292 | #define KEY_NEW 181 | ||
| 293 | #define KEY_REDO 182 | ||
| 292 | 294 | ||
| 293 | #define KEY_F13 183 | 295 | #define KEY_F13 183 |
| 294 | #define KEY_F14 184 | 296 | #define KEY_F14 184 |
| @@ -335,6 +337,12 @@ struct input_absinfo { | |||
| 335 | #define KEY_KBDILLUMDOWN 229 | 337 | #define KEY_KBDILLUMDOWN 229 |
| 336 | #define KEY_KBDILLUMUP 230 | 338 | #define KEY_KBDILLUMUP 230 |
| 337 | 339 | ||
| 340 | #define KEY_SEND 231 | ||
| 341 | #define KEY_REPLY 232 | ||
| 342 | #define KEY_FORWARDMAIL 233 | ||
| 343 | #define KEY_SAVE 234 | ||
| 344 | #define KEY_DOCUMENTS 235 | ||
| 345 | |||
| 338 | #define KEY_UNKNOWN 240 | 346 | #define KEY_UNKNOWN 240 |
| 339 | 347 | ||
| 340 | #define BTN_MISC 0x100 | 348 | #define BTN_MISC 0x100 |
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 6c5f7b39a4b0..bb6f88e14061 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h | |||
| @@ -68,7 +68,7 @@ struct ipv6_opt_hdr { | |||
| 68 | 68 | ||
| 69 | struct rt0_hdr { | 69 | struct rt0_hdr { |
| 70 | struct ipv6_rt_hdr rt_hdr; | 70 | struct ipv6_rt_hdr rt_hdr; |
| 71 | __u32 bitmap; /* strict/loose bit map */ | 71 | __u32 reserved; |
| 72 | struct in6_addr addr[0]; | 72 | struct in6_addr addr[0]; |
| 73 | 73 | ||
| 74 | #define rt0_type rt_hdr.type | 74 | #define rt0_type rt_hdr.type |
diff --git a/include/linux/jbd.h b/include/linux/jbd.h index 84321a4cac93..de097269bd7f 100644 --- a/include/linux/jbd.h +++ b/include/linux/jbd.h | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <linux/buffer_head.h> | 28 | #include <linux/buffer_head.h> |
| 29 | #include <linux/journal-head.h> | 29 | #include <linux/journal-head.h> |
| 30 | #include <linux/stddef.h> | 30 | #include <linux/stddef.h> |
| 31 | #include <linux/bit_spinlock.h> | ||
| 31 | #include <asm/semaphore.h> | 32 | #include <asm/semaphore.h> |
| 32 | #endif | 33 | #endif |
| 33 | 34 | ||
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index d7a2555a886c..6acfdbba734b 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h | |||
| @@ -254,23 +254,23 @@ static inline u64 get_jiffies_64(void) | |||
| 254 | */ | 254 | */ |
| 255 | static inline unsigned int jiffies_to_msecs(const unsigned long j) | 255 | static inline unsigned int jiffies_to_msecs(const unsigned long j) |
| 256 | { | 256 | { |
| 257 | #if HZ <= 1000 && !(1000 % HZ) | 257 | #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) |
| 258 | return (1000 / HZ) * j; | 258 | return (MSEC_PER_SEC / HZ) * j; |
| 259 | #elif HZ > 1000 && !(HZ % 1000) | 259 | #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) |
| 260 | return (j + (HZ / 1000) - 1)/(HZ / 1000); | 260 | return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); |
| 261 | #else | 261 | #else |
| 262 | return (j * 1000) / HZ; | 262 | return (j * MSEC_PER_SEC) / HZ; |
| 263 | #endif | 263 | #endif |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | static inline unsigned int jiffies_to_usecs(const unsigned long j) | 266 | static inline unsigned int jiffies_to_usecs(const unsigned long j) |
| 267 | { | 267 | { |
| 268 | #if HZ <= 1000000 && !(1000000 % HZ) | 268 | #if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) |
| 269 | return (1000000 / HZ) * j; | 269 | return (USEC_PER_SEC / HZ) * j; |
| 270 | #elif HZ > 1000000 && !(HZ % 1000000) | 270 | #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) |
| 271 | return (j + (HZ / 1000000) - 1)/(HZ / 1000000); | 271 | return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC); |
| 272 | #else | 272 | #else |
| 273 | return (j * 1000000) / HZ; | 273 | return (j * USEC_PER_SEC) / HZ; |
| 274 | #endif | 274 | #endif |
| 275 | } | 275 | } |
| 276 | 276 | ||
| @@ -278,12 +278,12 @@ static inline unsigned long msecs_to_jiffies(const unsigned int m) | |||
| 278 | { | 278 | { |
| 279 | if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) | 279 | if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) |
| 280 | return MAX_JIFFY_OFFSET; | 280 | return MAX_JIFFY_OFFSET; |
| 281 | #if HZ <= 1000 && !(1000 % HZ) | 281 | #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ) |
| 282 | return (m + (1000 / HZ) - 1) / (1000 / HZ); | 282 | return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ); |
| 283 | #elif HZ > 1000 && !(HZ % 1000) | 283 | #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) |
| 284 | return m * (HZ / 1000); | 284 | return m * (HZ / MSEC_PER_SEC); |
| 285 | #else | 285 | #else |
| 286 | return (m * HZ + 999) / 1000; | 286 | return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC; |
| 287 | #endif | 287 | #endif |
| 288 | } | 288 | } |
| 289 | 289 | ||
| @@ -291,12 +291,12 @@ static inline unsigned long usecs_to_jiffies(const unsigned int u) | |||
| 291 | { | 291 | { |
| 292 | if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET)) | 292 | if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET)) |
| 293 | return MAX_JIFFY_OFFSET; | 293 | return MAX_JIFFY_OFFSET; |
| 294 | #if HZ <= 1000000 && !(1000000 % HZ) | 294 | #if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ) |
| 295 | return (u + (1000000 / HZ) - 1) / (1000000 / HZ); | 295 | return (u + (USEC_PER_SEC / HZ) - 1) / (USEC_PER_SEC / HZ); |
| 296 | #elif HZ > 1000000 && !(HZ % 1000000) | 296 | #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) |
| 297 | return u * (HZ / 1000000); | 297 | return u * (HZ / USEC_PER_SEC); |
| 298 | #else | 298 | #else |
| 299 | return (u * HZ + 999999) / 1000000; | 299 | return (u * HZ + USEC_PER_SEC - 1) / USEC_PER_SEC; |
| 300 | #endif | 300 | #endif |
| 301 | } | 301 | } |
| 302 | 302 | ||
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h index 8081a281fa5e..9c51917b1cce 100644 --- a/include/linux/radix-tree.h +++ b/include/linux/radix-tree.h | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | struct radix_tree_root { | 25 | struct radix_tree_root { |
| 26 | unsigned int height; | 26 | unsigned int height; |
| 27 | int gfp_mask; | 27 | unsigned int gfp_mask; |
| 28 | struct radix_tree_node *rnode; | 28 | struct radix_tree_node *rnode; |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| @@ -50,7 +50,7 @@ void *radix_tree_delete(struct radix_tree_root *, unsigned long); | |||
| 50 | unsigned int | 50 | unsigned int |
| 51 | radix_tree_gang_lookup(struct radix_tree_root *root, void **results, | 51 | radix_tree_gang_lookup(struct radix_tree_root *root, void **results, |
| 52 | unsigned long first_index, unsigned int max_items); | 52 | unsigned long first_index, unsigned int max_items); |
| 53 | int radix_tree_preload(int gfp_mask); | 53 | int radix_tree_preload(unsigned int __nocast gfp_mask); |
| 54 | void radix_tree_init(void); | 54 | void radix_tree_init(void); |
| 55 | void *radix_tree_tag_set(struct radix_tree_root *root, | 55 | void *radix_tree_tag_set(struct radix_tree_root *root, |
| 56 | unsigned long index, int tag); | 56 | unsigned long index, int tag); |
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h index 17e458e17e2b..af00b10294cd 100644 --- a/include/linux/reiserfs_fs.h +++ b/include/linux/reiserfs_fs.h | |||
| @@ -2097,7 +2097,7 @@ void reiserfs_free_block(struct reiserfs_transaction_handle *th, struct inode *, | |||
| 2097 | b_blocknr_t, int for_unformatted); | 2097 | b_blocknr_t, int for_unformatted); |
| 2098 | int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *, b_blocknr_t *, int, | 2098 | int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *, b_blocknr_t *, int, |
| 2099 | int); | 2099 | int); |
| 2100 | extern inline int reiserfs_new_form_blocknrs(struct tree_balance *tb, | 2100 | static inline int reiserfs_new_form_blocknrs(struct tree_balance *tb, |
| 2101 | b_blocknr_t * new_blocknrs, | 2101 | b_blocknr_t * new_blocknrs, |
| 2102 | int amount_needed) | 2102 | int amount_needed) |
| 2103 | { | 2103 | { |
| @@ -2113,7 +2113,7 @@ extern inline int reiserfs_new_form_blocknrs(struct tree_balance *tb, | |||
| 2113 | 0); | 2113 | 0); |
| 2114 | } | 2114 | } |
| 2115 | 2115 | ||
| 2116 | extern inline int reiserfs_new_unf_blocknrs(struct reiserfs_transaction_handle | 2116 | static inline int reiserfs_new_unf_blocknrs(struct reiserfs_transaction_handle |
| 2117 | *th, struct inode *inode, | 2117 | *th, struct inode *inode, |
| 2118 | b_blocknr_t * new_blocknrs, | 2118 | b_blocknr_t * new_blocknrs, |
| 2119 | struct path *path, long block) | 2119 | struct path *path, long block) |
| @@ -2130,7 +2130,7 @@ extern inline int reiserfs_new_unf_blocknrs(struct reiserfs_transaction_handle | |||
| 2130 | } | 2130 | } |
| 2131 | 2131 | ||
| 2132 | #ifdef REISERFS_PREALLOCATE | 2132 | #ifdef REISERFS_PREALLOCATE |
| 2133 | extern inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle | 2133 | static inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle |
| 2134 | *th, struct inode *inode, | 2134 | *th, struct inode *inode, |
| 2135 | b_blocknr_t * new_blocknrs, | 2135 | b_blocknr_t * new_blocknrs, |
| 2136 | struct path *path, long block) | 2136 | struct path *path, long block) |
diff --git a/include/linux/sched.h b/include/linux/sched.h index c551e6a1447e..4b83cb230006 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -114,6 +114,7 @@ extern unsigned long nr_iowait(void); | |||
| 114 | #define TASK_TRACED 8 | 114 | #define TASK_TRACED 8 |
| 115 | #define EXIT_ZOMBIE 16 | 115 | #define EXIT_ZOMBIE 16 |
| 116 | #define EXIT_DEAD 32 | 116 | #define EXIT_DEAD 32 |
| 117 | #define TASK_NONINTERACTIVE 64 | ||
| 117 | 118 | ||
| 118 | #define __set_task_state(tsk, state_value) \ | 119 | #define __set_task_state(tsk, state_value) \ |
| 119 | do { (tsk)->state = (state_value); } while (0) | 120 | do { (tsk)->state = (state_value); } while (0) |
| @@ -202,6 +203,8 @@ extern int in_sched_functions(unsigned long addr); | |||
| 202 | 203 | ||
| 203 | #define MAX_SCHEDULE_TIMEOUT LONG_MAX | 204 | #define MAX_SCHEDULE_TIMEOUT LONG_MAX |
| 204 | extern signed long FASTCALL(schedule_timeout(signed long timeout)); | 205 | extern signed long FASTCALL(schedule_timeout(signed long timeout)); |
| 206 | extern signed long schedule_timeout_interruptible(signed long timeout); | ||
| 207 | extern signed long schedule_timeout_uninterruptible(signed long timeout); | ||
| 205 | asmlinkage void schedule(void); | 208 | asmlinkage void schedule(void); |
| 206 | 209 | ||
| 207 | struct namespace; | 210 | struct namespace; |
| @@ -782,6 +785,7 @@ struct task_struct { | |||
| 782 | short il_next; | 785 | short il_next; |
| 783 | #endif | 786 | #endif |
| 784 | #ifdef CONFIG_CPUSETS | 787 | #ifdef CONFIG_CPUSETS |
| 788 | short cpuset_sem_nest_depth; | ||
| 785 | struct cpuset *cpuset; | 789 | struct cpuset *cpuset; |
| 786 | nodemask_t mems_allowed; | 790 | nodemask_t mems_allowed; |
| 787 | int cpuset_mems_generation; | 791 | int cpuset_mems_generation; |
diff --git a/include/linux/slab.h b/include/linux/slab.h index 42a6bea58af3..1f356f3bbc64 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
| @@ -118,7 +118,8 @@ extern void kfree(const void *); | |||
| 118 | extern unsigned int ksize(const void *); | 118 | extern unsigned int ksize(const void *); |
| 119 | 119 | ||
| 120 | #ifdef CONFIG_NUMA | 120 | #ifdef CONFIG_NUMA |
| 121 | extern void *kmem_cache_alloc_node(kmem_cache_t *, int flags, int node); | 121 | extern void *kmem_cache_alloc_node(kmem_cache_t *, |
| 122 | unsigned int __nocast flags, int node); | ||
| 122 | extern void *kmalloc_node(size_t size, unsigned int __nocast flags, int node); | 123 | extern void *kmalloc_node(size_t size, unsigned int __nocast flags, int node); |
| 123 | #else | 124 | #else |
| 124 | static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int flags, int node) | 125 | static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int flags, int node) |
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index d6ba068719b6..cdc99a27840d 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h | |||
| @@ -2,7 +2,48 @@ | |||
| 2 | #define __LINUX_SPINLOCK_H | 2 | #define __LINUX_SPINLOCK_H |
| 3 | 3 | ||
| 4 | /* | 4 | /* |
| 5 | * include/linux/spinlock.h - generic locking declarations | 5 | * include/linux/spinlock.h - generic spinlock/rwlock declarations |
| 6 | * | ||
| 7 | * here's the role of the various spinlock/rwlock related include files: | ||
| 8 | * | ||
| 9 | * on SMP builds: | ||
| 10 | * | ||
| 11 | * asm/spinlock_types.h: contains the raw_spinlock_t/raw_rwlock_t and the | ||
| 12 | * initializers | ||
| 13 | * | ||
| 14 | * linux/spinlock_types.h: | ||
| 15 | * defines the generic type and initializers | ||
| 16 | * | ||
| 17 | * asm/spinlock.h: contains the __raw_spin_*()/etc. lowlevel | ||
| 18 | * implementations, mostly inline assembly code | ||
| 19 | * | ||
| 20 | * (also included on UP-debug builds:) | ||
| 21 | * | ||
| 22 | * linux/spinlock_api_smp.h: | ||
| 23 | * contains the prototypes for the _spin_*() APIs. | ||
| 24 | * | ||
| 25 | * linux/spinlock.h: builds the final spin_*() APIs. | ||
| 26 | * | ||
| 27 | * on UP builds: | ||
| 28 | * | ||
| 29 | * linux/spinlock_type_up.h: | ||
| 30 | * contains the generic, simplified UP spinlock type. | ||
| 31 | * (which is an empty structure on non-debug builds) | ||
| 32 | * | ||
| 33 | * linux/spinlock_types.h: | ||
| 34 | * defines the generic type and initializers | ||
| 35 | * | ||
| 36 | * linux/spinlock_up.h: | ||
| 37 | * contains the __raw_spin_*()/etc. version of UP | ||
| 38 | * builds. (which are NOPs on non-debug, non-preempt | ||
| 39 | * builds) | ||
| 40 | * | ||
| 41 | * (included on UP-non-debug builds:) | ||
| 42 | * | ||
| 43 | * linux/spinlock_api_up.h: | ||
| 44 | * builds the _spin_*() APIs. | ||
| 45 | * | ||
| 46 | * linux/spinlock.h: builds the final spin_*() APIs. | ||
| 6 | */ | 47 | */ |
| 7 | 48 | ||
| 8 | #include <linux/config.h> | 49 | #include <linux/config.h> |
| @@ -13,7 +54,6 @@ | |||
| 13 | #include <linux/kernel.h> | 54 | #include <linux/kernel.h> |
| 14 | #include <linux/stringify.h> | 55 | #include <linux/stringify.h> |
| 15 | 56 | ||
| 16 | #include <asm/processor.h> /* for cpu relax */ | ||
| 17 | #include <asm/system.h> | 57 | #include <asm/system.h> |
| 18 | 58 | ||
| 19 | /* | 59 | /* |
| @@ -35,423 +75,84 @@ | |||
| 35 | #define __lockfunc fastcall __attribute__((section(".spinlock.text"))) | 75 | #define __lockfunc fastcall __attribute__((section(".spinlock.text"))) |
| 36 | 76 | ||
| 37 | /* | 77 | /* |
| 38 | * If CONFIG_SMP is set, pull in the _raw_* definitions | 78 | * Pull the raw_spinlock_t and raw_rwlock_t definitions: |
| 39 | */ | 79 | */ |
| 40 | #ifdef CONFIG_SMP | 80 | #include <linux/spinlock_types.h> |
| 41 | |||
| 42 | #define assert_spin_locked(x) BUG_ON(!spin_is_locked(x)) | ||
| 43 | #include <asm/spinlock.h> | ||
| 44 | |||
| 45 | int __lockfunc _spin_trylock(spinlock_t *lock); | ||
| 46 | int __lockfunc _read_trylock(rwlock_t *lock); | ||
| 47 | int __lockfunc _write_trylock(rwlock_t *lock); | ||
| 48 | |||
| 49 | void __lockfunc _spin_lock(spinlock_t *lock) __acquires(spinlock_t); | ||
| 50 | void __lockfunc _read_lock(rwlock_t *lock) __acquires(rwlock_t); | ||
| 51 | void __lockfunc _write_lock(rwlock_t *lock) __acquires(rwlock_t); | ||
| 52 | |||
| 53 | void __lockfunc _spin_unlock(spinlock_t *lock) __releases(spinlock_t); | ||
| 54 | void __lockfunc _read_unlock(rwlock_t *lock) __releases(rwlock_t); | ||
| 55 | void __lockfunc _write_unlock(rwlock_t *lock) __releases(rwlock_t); | ||
| 56 | |||
| 57 | unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock) __acquires(spinlock_t); | ||
| 58 | unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock) __acquires(rwlock_t); | ||
| 59 | unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock) __acquires(rwlock_t); | ||
| 60 | |||
| 61 | void __lockfunc _spin_lock_irq(spinlock_t *lock) __acquires(spinlock_t); | ||
| 62 | void __lockfunc _spin_lock_bh(spinlock_t *lock) __acquires(spinlock_t); | ||
| 63 | void __lockfunc _read_lock_irq(rwlock_t *lock) __acquires(rwlock_t); | ||
| 64 | void __lockfunc _read_lock_bh(rwlock_t *lock) __acquires(rwlock_t); | ||
| 65 | void __lockfunc _write_lock_irq(rwlock_t *lock) __acquires(rwlock_t); | ||
| 66 | void __lockfunc _write_lock_bh(rwlock_t *lock) __acquires(rwlock_t); | ||
| 67 | |||
| 68 | void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) __releases(spinlock_t); | ||
| 69 | void __lockfunc _spin_unlock_irq(spinlock_t *lock) __releases(spinlock_t); | ||
| 70 | void __lockfunc _spin_unlock_bh(spinlock_t *lock) __releases(spinlock_t); | ||
| 71 | void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) __releases(rwlock_t); | ||
| 72 | void __lockfunc _read_unlock_irq(rwlock_t *lock) __releases(rwlock_t); | ||
| 73 | void __lockfunc _read_unlock_bh(rwlock_t *lock) __releases(rwlock_t); | ||
| 74 | void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) __releases(rwlock_t); | ||
| 75 | void __lockfunc _write_unlock_irq(rwlock_t *lock) __releases(rwlock_t); | ||
| 76 | void __lockfunc _write_unlock_bh(rwlock_t *lock) __releases(rwlock_t); | ||
| 77 | |||
| 78 | int __lockfunc _spin_trylock_bh(spinlock_t *lock); | ||
| 79 | int __lockfunc generic_raw_read_trylock(rwlock_t *lock); | ||
| 80 | int in_lock_functions(unsigned long addr); | ||
| 81 | |||
| 82 | #else | ||
| 83 | 81 | ||
| 84 | #define in_lock_functions(ADDR) 0 | 82 | extern int __lockfunc generic__raw_read_trylock(raw_rwlock_t *lock); |
| 85 | 83 | ||
| 86 | #if !defined(CONFIG_PREEMPT) && !defined(CONFIG_DEBUG_SPINLOCK) | ||
| 87 | # define _atomic_dec_and_lock(atomic,lock) atomic_dec_and_test(atomic) | ||
| 88 | # define ATOMIC_DEC_AND_LOCK | ||
| 89 | #endif | ||
| 90 | |||
| 91 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
| 92 | |||
| 93 | #define SPINLOCK_MAGIC 0x1D244B3C | ||
| 94 | typedef struct { | ||
| 95 | unsigned long magic; | ||
| 96 | volatile unsigned long lock; | ||
| 97 | volatile unsigned int babble; | ||
| 98 | const char *module; | ||
| 99 | char *owner; | ||
| 100 | int oline; | ||
| 101 | } spinlock_t; | ||
| 102 | #define SPIN_LOCK_UNLOCKED (spinlock_t) { SPINLOCK_MAGIC, 0, 10, __FILE__ , NULL, 0} | ||
| 103 | |||
| 104 | #define spin_lock_init(x) \ | ||
| 105 | do { \ | ||
| 106 | (x)->magic = SPINLOCK_MAGIC; \ | ||
| 107 | (x)->lock = 0; \ | ||
| 108 | (x)->babble = 5; \ | ||
| 109 | (x)->module = __FILE__; \ | ||
| 110 | (x)->owner = NULL; \ | ||
| 111 | (x)->oline = 0; \ | ||
| 112 | } while (0) | ||
| 113 | |||
| 114 | #define CHECK_LOCK(x) \ | ||
| 115 | do { \ | ||
| 116 | if ((x)->magic != SPINLOCK_MAGIC) { \ | ||
| 117 | printk(KERN_ERR "%s:%d: spin_is_locked on uninitialized spinlock %p.\n", \ | ||
| 118 | __FILE__, __LINE__, (x)); \ | ||
| 119 | } \ | ||
| 120 | } while(0) | ||
| 121 | |||
| 122 | #define _raw_spin_lock(x) \ | ||
| 123 | do { \ | ||
| 124 | CHECK_LOCK(x); \ | ||
| 125 | if ((x)->lock&&(x)->babble) { \ | ||
| 126 | (x)->babble--; \ | ||
| 127 | printk("%s:%d: spin_lock(%s:%p) already locked by %s/%d\n", \ | ||
| 128 | __FILE__,__LINE__, (x)->module, \ | ||
| 129 | (x), (x)->owner, (x)->oline); \ | ||
| 130 | } \ | ||
| 131 | (x)->lock = 1; \ | ||
| 132 | (x)->owner = __FILE__; \ | ||
| 133 | (x)->oline = __LINE__; \ | ||
| 134 | } while (0) | ||
| 135 | |||
| 136 | /* without debugging, spin_is_locked on UP always says | ||
| 137 | * FALSE. --> printk if already locked. */ | ||
| 138 | #define spin_is_locked(x) \ | ||
| 139 | ({ \ | ||
| 140 | CHECK_LOCK(x); \ | ||
| 141 | if ((x)->lock&&(x)->babble) { \ | ||
| 142 | (x)->babble--; \ | ||
| 143 | printk("%s:%d: spin_is_locked(%s:%p) already locked by %s/%d\n", \ | ||
| 144 | __FILE__,__LINE__, (x)->module, \ | ||
| 145 | (x), (x)->owner, (x)->oline); \ | ||
| 146 | } \ | ||
| 147 | 0; \ | ||
| 148 | }) | ||
| 149 | |||
| 150 | /* with debugging, assert_spin_locked() on UP does check | ||
| 151 | * the lock value properly */ | ||
| 152 | #define assert_spin_locked(x) \ | ||
| 153 | ({ \ | ||
| 154 | CHECK_LOCK(x); \ | ||
| 155 | BUG_ON(!(x)->lock); \ | ||
| 156 | }) | ||
| 157 | |||
| 158 | /* without debugging, spin_trylock on UP always says | ||
| 159 | * TRUE. --> printk if already locked. */ | ||
| 160 | #define _raw_spin_trylock(x) \ | ||
| 161 | ({ \ | ||
| 162 | CHECK_LOCK(x); \ | ||
| 163 | if ((x)->lock&&(x)->babble) { \ | ||
| 164 | (x)->babble--; \ | ||
| 165 | printk("%s:%d: spin_trylock(%s:%p) already locked by %s/%d\n", \ | ||
| 166 | __FILE__,__LINE__, (x)->module, \ | ||
| 167 | (x), (x)->owner, (x)->oline); \ | ||
| 168 | } \ | ||
| 169 | (x)->lock = 1; \ | ||
| 170 | (x)->owner = __FILE__; \ | ||
| 171 | (x)->oline = __LINE__; \ | ||
| 172 | 1; \ | ||
| 173 | }) | ||
| 174 | |||
| 175 | #define spin_unlock_wait(x) \ | ||
| 176 | do { \ | ||
| 177 | CHECK_LOCK(x); \ | ||
| 178 | if ((x)->lock&&(x)->babble) { \ | ||
| 179 | (x)->babble--; \ | ||
| 180 | printk("%s:%d: spin_unlock_wait(%s:%p) owned by %s/%d\n", \ | ||
| 181 | __FILE__,__LINE__, (x)->module, (x), \ | ||
| 182 | (x)->owner, (x)->oline); \ | ||
| 183 | }\ | ||
| 184 | } while (0) | ||
| 185 | |||
| 186 | #define _raw_spin_unlock(x) \ | ||
| 187 | do { \ | ||
| 188 | CHECK_LOCK(x); \ | ||
| 189 | if (!(x)->lock&&(x)->babble) { \ | ||
| 190 | (x)->babble--; \ | ||
| 191 | printk("%s:%d: spin_unlock(%s:%p) not locked\n", \ | ||
| 192 | __FILE__,__LINE__, (x)->module, (x));\ | ||
| 193 | } \ | ||
| 194 | (x)->lock = 0; \ | ||
| 195 | } while (0) | ||
| 196 | #else | ||
| 197 | /* | 84 | /* |
| 198 | * gcc versions before ~2.95 have a nasty bug with empty initializers. | 85 | * Pull the __raw*() functions/declarations (UP-nondebug doesnt need them): |
| 199 | */ | 86 | */ |
| 200 | #if (__GNUC__ > 2) | 87 | #if defined(CONFIG_SMP) |
| 201 | typedef struct { } spinlock_t; | 88 | # include <asm/spinlock.h> |
| 202 | #define SPIN_LOCK_UNLOCKED (spinlock_t) { } | ||
| 203 | #else | 89 | #else |
| 204 | typedef struct { int gcc_is_buggy; } spinlock_t; | 90 | # include <linux/spinlock_up.h> |
| 205 | #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 } | ||
| 206 | #endif | 91 | #endif |
| 207 | 92 | ||
| 93 | #define spin_lock_init(lock) do { *(lock) = SPIN_LOCK_UNLOCKED; } while (0) | ||
| 94 | #define rwlock_init(lock) do { *(lock) = RW_LOCK_UNLOCKED; } while (0) | ||
| 95 | |||
| 96 | #define spin_is_locked(lock) __raw_spin_is_locked(&(lock)->raw_lock) | ||
| 97 | |||
| 98 | /** | ||
| 99 | * spin_unlock_wait - wait until the spinlock gets unlocked | ||
| 100 | * @lock: the spinlock in question. | ||
| 101 | */ | ||
| 102 | #define spin_unlock_wait(lock) __raw_spin_unlock_wait(&(lock)->raw_lock) | ||
| 103 | |||
| 208 | /* | 104 | /* |
| 209 | * If CONFIG_SMP is unset, declare the _raw_* definitions as nops | 105 | * Pull the _spin_*()/_read_*()/_write_*() functions/declarations: |
| 210 | */ | 106 | */ |
| 211 | #define spin_lock_init(lock) do { (void)(lock); } while(0) | 107 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) |
| 212 | #define _raw_spin_lock(lock) do { (void)(lock); } while(0) | 108 | # include <linux/spinlock_api_smp.h> |
| 213 | #define spin_is_locked(lock) ((void)(lock), 0) | ||
| 214 | #define assert_spin_locked(lock) do { (void)(lock); } while(0) | ||
| 215 | #define _raw_spin_trylock(lock) (((void)(lock), 1)) | ||
| 216 | #define spin_unlock_wait(lock) (void)(lock) | ||
| 217 | #define _raw_spin_unlock(lock) do { (void)(lock); } while(0) | ||
| 218 | #endif /* CONFIG_DEBUG_SPINLOCK */ | ||
| 219 | |||
| 220 | /* RW spinlocks: No debug version */ | ||
| 221 | |||
| 222 | #if (__GNUC__ > 2) | ||
| 223 | typedef struct { } rwlock_t; | ||
| 224 | #define RW_LOCK_UNLOCKED (rwlock_t) { } | ||
| 225 | #else | 109 | #else |
| 226 | typedef struct { int gcc_is_buggy; } rwlock_t; | 110 | # include <linux/spinlock_api_up.h> |
| 227 | #define RW_LOCK_UNLOCKED (rwlock_t) { 0 } | ||
| 228 | #endif | 111 | #endif |
| 229 | 112 | ||
| 230 | #define rwlock_init(lock) do { (void)(lock); } while(0) | 113 | #ifdef CONFIG_DEBUG_SPINLOCK |
| 231 | #define _raw_read_lock(lock) do { (void)(lock); } while(0) | 114 | extern void _raw_spin_lock(spinlock_t *lock); |
| 232 | #define _raw_read_unlock(lock) do { (void)(lock); } while(0) | 115 | #define _raw_spin_lock_flags(lock, flags) _raw_spin_lock(lock) |
| 233 | #define _raw_write_lock(lock) do { (void)(lock); } while(0) | 116 | extern int _raw_spin_trylock(spinlock_t *lock); |
| 234 | #define _raw_write_unlock(lock) do { (void)(lock); } while(0) | 117 | extern void _raw_spin_unlock(spinlock_t *lock); |
| 235 | #define read_can_lock(lock) (((void)(lock), 1)) | 118 | |
| 236 | #define write_can_lock(lock) (((void)(lock), 1)) | 119 | extern void _raw_read_lock(rwlock_t *lock); |
| 237 | #define _raw_read_trylock(lock) ({ (void)(lock); (1); }) | 120 | extern int _raw_read_trylock(rwlock_t *lock); |
| 238 | #define _raw_write_trylock(lock) ({ (void)(lock); (1); }) | 121 | extern void _raw_read_unlock(rwlock_t *lock); |
| 239 | 122 | extern void _raw_write_lock(rwlock_t *lock); | |
| 240 | #define _spin_trylock(lock) ({preempt_disable(); _raw_spin_trylock(lock) ? \ | 123 | extern int _raw_write_trylock(rwlock_t *lock); |
| 241 | 1 : ({preempt_enable(); 0;});}) | 124 | extern void _raw_write_unlock(rwlock_t *lock); |
| 242 | 125 | #else | |
| 243 | #define _read_trylock(lock) ({preempt_disable();_raw_read_trylock(lock) ? \ | 126 | # define _raw_spin_unlock(lock) __raw_spin_unlock(&(lock)->raw_lock) |
| 244 | 1 : ({preempt_enable(); 0;});}) | 127 | # define _raw_spin_trylock(lock) __raw_spin_trylock(&(lock)->raw_lock) |
| 245 | 128 | # define _raw_spin_lock(lock) __raw_spin_lock(&(lock)->raw_lock) | |
| 246 | #define _write_trylock(lock) ({preempt_disable(); _raw_write_trylock(lock) ? \ | 129 | # define _raw_spin_lock_flags(lock, flags) \ |
| 247 | 1 : ({preempt_enable(); 0;});}) | 130 | __raw_spin_lock_flags(&(lock)->raw_lock, *(flags)) |
| 248 | 131 | # define _raw_read_lock(rwlock) __raw_read_lock(&(rwlock)->raw_lock) | |
| 249 | #define _spin_trylock_bh(lock) ({preempt_disable(); local_bh_disable(); \ | 132 | # define _raw_write_lock(rwlock) __raw_write_lock(&(rwlock)->raw_lock) |
| 250 | _raw_spin_trylock(lock) ? \ | 133 | # define _raw_read_unlock(rwlock) __raw_read_unlock(&(rwlock)->raw_lock) |
| 251 | 1 : ({preempt_enable_no_resched(); local_bh_enable(); 0;});}) | 134 | # define _raw_write_unlock(rwlock) __raw_write_unlock(&(rwlock)->raw_lock) |
| 252 | 135 | # define _raw_read_trylock(rwlock) __raw_read_trylock(&(rwlock)->raw_lock) | |
| 253 | #define _spin_lock(lock) \ | 136 | # define _raw_write_trylock(rwlock) __raw_write_trylock(&(rwlock)->raw_lock) |
| 254 | do { \ | 137 | #endif |
| 255 | preempt_disable(); \ | ||
| 256 | _raw_spin_lock(lock); \ | ||
| 257 | __acquire(lock); \ | ||
| 258 | } while(0) | ||
| 259 | |||
| 260 | #define _write_lock(lock) \ | ||
| 261 | do { \ | ||
| 262 | preempt_disable(); \ | ||
| 263 | _raw_write_lock(lock); \ | ||
| 264 | __acquire(lock); \ | ||
| 265 | } while(0) | ||
| 266 | |||
| 267 | #define _read_lock(lock) \ | ||
| 268 | do { \ | ||
| 269 | preempt_disable(); \ | ||
| 270 | _raw_read_lock(lock); \ | ||
| 271 | __acquire(lock); \ | ||
| 272 | } while(0) | ||
| 273 | |||
| 274 | #define _spin_unlock(lock) \ | ||
| 275 | do { \ | ||
| 276 | _raw_spin_unlock(lock); \ | ||
| 277 | preempt_enable(); \ | ||
| 278 | __release(lock); \ | ||
| 279 | } while (0) | ||
| 280 | |||
| 281 | #define _write_unlock(lock) \ | ||
| 282 | do { \ | ||
| 283 | _raw_write_unlock(lock); \ | ||
| 284 | preempt_enable(); \ | ||
| 285 | __release(lock); \ | ||
| 286 | } while(0) | ||
| 287 | |||
| 288 | #define _read_unlock(lock) \ | ||
| 289 | do { \ | ||
| 290 | _raw_read_unlock(lock); \ | ||
| 291 | preempt_enable(); \ | ||
| 292 | __release(lock); \ | ||
| 293 | } while(0) | ||
| 294 | |||
| 295 | #define _spin_lock_irqsave(lock, flags) \ | ||
| 296 | do { \ | ||
| 297 | local_irq_save(flags); \ | ||
| 298 | preempt_disable(); \ | ||
| 299 | _raw_spin_lock(lock); \ | ||
| 300 | __acquire(lock); \ | ||
| 301 | } while (0) | ||
| 302 | |||
| 303 | #define _spin_lock_irq(lock) \ | ||
| 304 | do { \ | ||
| 305 | local_irq_disable(); \ | ||
| 306 | preempt_disable(); \ | ||
| 307 | _raw_spin_lock(lock); \ | ||
| 308 | __acquire(lock); \ | ||
| 309 | } while (0) | ||
| 310 | |||
| 311 | #define _spin_lock_bh(lock) \ | ||
| 312 | do { \ | ||
| 313 | local_bh_disable(); \ | ||
| 314 | preempt_disable(); \ | ||
| 315 | _raw_spin_lock(lock); \ | ||
| 316 | __acquire(lock); \ | ||
| 317 | } while (0) | ||
| 318 | |||
| 319 | #define _read_lock_irqsave(lock, flags) \ | ||
| 320 | do { \ | ||
| 321 | local_irq_save(flags); \ | ||
| 322 | preempt_disable(); \ | ||
| 323 | _raw_read_lock(lock); \ | ||
| 324 | __acquire(lock); \ | ||
| 325 | } while (0) | ||
| 326 | |||
| 327 | #define _read_lock_irq(lock) \ | ||
| 328 | do { \ | ||
| 329 | local_irq_disable(); \ | ||
| 330 | preempt_disable(); \ | ||
| 331 | _raw_read_lock(lock); \ | ||
| 332 | __acquire(lock); \ | ||
| 333 | } while (0) | ||
| 334 | |||
| 335 | #define _read_lock_bh(lock) \ | ||
| 336 | do { \ | ||
| 337 | local_bh_disable(); \ | ||
| 338 | preempt_disable(); \ | ||
| 339 | _raw_read_lock(lock); \ | ||
| 340 | __acquire(lock); \ | ||
| 341 | } while (0) | ||
| 342 | |||
| 343 | #define _write_lock_irqsave(lock, flags) \ | ||
| 344 | do { \ | ||
| 345 | local_irq_save(flags); \ | ||
| 346 | preempt_disable(); \ | ||
| 347 | _raw_write_lock(lock); \ | ||
| 348 | __acquire(lock); \ | ||
| 349 | } while (0) | ||
| 350 | 138 | ||
| 351 | #define _write_lock_irq(lock) \ | 139 | #define read_can_lock(rwlock) __raw_read_can_lock(&(rwlock)->raw_lock) |
| 352 | do { \ | 140 | #define write_can_lock(rwlock) __raw_write_can_lock(&(rwlock)->raw_lock) |
| 353 | local_irq_disable(); \ | ||
| 354 | preempt_disable(); \ | ||
| 355 | _raw_write_lock(lock); \ | ||
| 356 | __acquire(lock); \ | ||
| 357 | } while (0) | ||
| 358 | |||
| 359 | #define _write_lock_bh(lock) \ | ||
| 360 | do { \ | ||
| 361 | local_bh_disable(); \ | ||
| 362 | preempt_disable(); \ | ||
| 363 | _raw_write_lock(lock); \ | ||
| 364 | __acquire(lock); \ | ||
| 365 | } while (0) | ||
| 366 | |||
| 367 | #define _spin_unlock_irqrestore(lock, flags) \ | ||
| 368 | do { \ | ||
| 369 | _raw_spin_unlock(lock); \ | ||
| 370 | local_irq_restore(flags); \ | ||
| 371 | preempt_enable(); \ | ||
| 372 | __release(lock); \ | ||
| 373 | } while (0) | ||
| 374 | |||
| 375 | #define _spin_unlock_irq(lock) \ | ||
| 376 | do { \ | ||
| 377 | _raw_spin_unlock(lock); \ | ||
| 378 | local_irq_enable(); \ | ||
| 379 | preempt_enable(); \ | ||
| 380 | __release(lock); \ | ||
| 381 | } while (0) | ||
| 382 | |||
| 383 | #define _spin_unlock_bh(lock) \ | ||
| 384 | do { \ | ||
| 385 | _raw_spin_unlock(lock); \ | ||
| 386 | preempt_enable_no_resched(); \ | ||
| 387 | local_bh_enable(); \ | ||
| 388 | __release(lock); \ | ||
| 389 | } while (0) | ||
| 390 | |||
| 391 | #define _write_unlock_bh(lock) \ | ||
| 392 | do { \ | ||
| 393 | _raw_write_unlock(lock); \ | ||
| 394 | preempt_enable_no_resched(); \ | ||
| 395 | local_bh_enable(); \ | ||
| 396 | __release(lock); \ | ||
| 397 | } while (0) | ||
| 398 | |||
| 399 | #define _read_unlock_irqrestore(lock, flags) \ | ||
| 400 | do { \ | ||
| 401 | _raw_read_unlock(lock); \ | ||
| 402 | local_irq_restore(flags); \ | ||
| 403 | preempt_enable(); \ | ||
| 404 | __release(lock); \ | ||
| 405 | } while (0) | ||
| 406 | |||
| 407 | #define _write_unlock_irqrestore(lock, flags) \ | ||
| 408 | do { \ | ||
| 409 | _raw_write_unlock(lock); \ | ||
| 410 | local_irq_restore(flags); \ | ||
| 411 | preempt_enable(); \ | ||
| 412 | __release(lock); \ | ||
| 413 | } while (0) | ||
| 414 | |||
| 415 | #define _read_unlock_irq(lock) \ | ||
| 416 | do { \ | ||
| 417 | _raw_read_unlock(lock); \ | ||
| 418 | local_irq_enable(); \ | ||
| 419 | preempt_enable(); \ | ||
| 420 | __release(lock); \ | ||
| 421 | } while (0) | ||
| 422 | |||
| 423 | #define _read_unlock_bh(lock) \ | ||
| 424 | do { \ | ||
| 425 | _raw_read_unlock(lock); \ | ||
| 426 | preempt_enable_no_resched(); \ | ||
| 427 | local_bh_enable(); \ | ||
| 428 | __release(lock); \ | ||
| 429 | } while (0) | ||
| 430 | |||
| 431 | #define _write_unlock_irq(lock) \ | ||
| 432 | do { \ | ||
| 433 | _raw_write_unlock(lock); \ | ||
| 434 | local_irq_enable(); \ | ||
| 435 | preempt_enable(); \ | ||
| 436 | __release(lock); \ | ||
| 437 | } while (0) | ||
| 438 | |||
| 439 | #endif /* !SMP */ | ||
| 440 | 141 | ||
| 441 | /* | 142 | /* |
| 442 | * Define the various spin_lock and rw_lock methods. Note we define these | 143 | * Define the various spin_lock and rw_lock methods. Note we define these |
| 443 | * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various | 144 | * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various |
| 444 | * methods are defined as nops in the case they are not required. | 145 | * methods are defined as nops in the case they are not required. |
| 445 | */ | 146 | */ |
| 446 | #define spin_trylock(lock) __cond_lock(_spin_trylock(lock)) | 147 | #define spin_trylock(lock) __cond_lock(_spin_trylock(lock)) |
| 447 | #define read_trylock(lock) __cond_lock(_read_trylock(lock)) | 148 | #define read_trylock(lock) __cond_lock(_read_trylock(lock)) |
| 448 | #define write_trylock(lock) __cond_lock(_write_trylock(lock)) | 149 | #define write_trylock(lock) __cond_lock(_write_trylock(lock)) |
| 449 | 150 | ||
| 450 | #define spin_lock(lock) _spin_lock(lock) | 151 | #define spin_lock(lock) _spin_lock(lock) |
| 451 | #define write_lock(lock) _write_lock(lock) | 152 | #define write_lock(lock) _write_lock(lock) |
| 452 | #define read_lock(lock) _read_lock(lock) | 153 | #define read_lock(lock) _read_lock(lock) |
| 453 | 154 | ||
| 454 | #ifdef CONFIG_SMP | 155 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) |
| 455 | #define spin_lock_irqsave(lock, flags) flags = _spin_lock_irqsave(lock) | 156 | #define spin_lock_irqsave(lock, flags) flags = _spin_lock_irqsave(lock) |
| 456 | #define read_lock_irqsave(lock, flags) flags = _read_lock_irqsave(lock) | 157 | #define read_lock_irqsave(lock, flags) flags = _read_lock_irqsave(lock) |
| 457 | #define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock) | 158 | #define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock) |
| @@ -470,137 +171,59 @@ do { \ | |||
| 470 | #define write_lock_irq(lock) _write_lock_irq(lock) | 171 | #define write_lock_irq(lock) _write_lock_irq(lock) |
| 471 | #define write_lock_bh(lock) _write_lock_bh(lock) | 172 | #define write_lock_bh(lock) _write_lock_bh(lock) |
| 472 | 173 | ||
| 473 | #define spin_unlock(lock) _spin_unlock(lock) | 174 | #define spin_unlock(lock) _spin_unlock(lock) |
| 474 | #define write_unlock(lock) _write_unlock(lock) | 175 | #define write_unlock(lock) _write_unlock(lock) |
| 475 | #define read_unlock(lock) _read_unlock(lock) | 176 | #define read_unlock(lock) _read_unlock(lock) |
| 476 | 177 | ||
| 477 | #define spin_unlock_irqrestore(lock, flags) _spin_unlock_irqrestore(lock, flags) | 178 | #define spin_unlock_irqrestore(lock, flags) \ |
| 179 | _spin_unlock_irqrestore(lock, flags) | ||
| 478 | #define spin_unlock_irq(lock) _spin_unlock_irq(lock) | 180 | #define spin_unlock_irq(lock) _spin_unlock_irq(lock) |
| 479 | #define spin_unlock_bh(lock) _spin_unlock_bh(lock) | 181 | #define spin_unlock_bh(lock) _spin_unlock_bh(lock) |
| 480 | 182 | ||
| 481 | #define read_unlock_irqrestore(lock, flags) _read_unlock_irqrestore(lock, flags) | 183 | #define read_unlock_irqrestore(lock, flags) \ |
| 482 | #define read_unlock_irq(lock) _read_unlock_irq(lock) | 184 | _read_unlock_irqrestore(lock, flags) |
| 483 | #define read_unlock_bh(lock) _read_unlock_bh(lock) | 185 | #define read_unlock_irq(lock) _read_unlock_irq(lock) |
| 186 | #define read_unlock_bh(lock) _read_unlock_bh(lock) | ||
| 484 | 187 | ||
| 485 | #define write_unlock_irqrestore(lock, flags) _write_unlock_irqrestore(lock, flags) | 188 | #define write_unlock_irqrestore(lock, flags) \ |
| 486 | #define write_unlock_irq(lock) _write_unlock_irq(lock) | 189 | _write_unlock_irqrestore(lock, flags) |
| 487 | #define write_unlock_bh(lock) _write_unlock_bh(lock) | 190 | #define write_unlock_irq(lock) _write_unlock_irq(lock) |
| 191 | #define write_unlock_bh(lock) _write_unlock_bh(lock) | ||
| 488 | 192 | ||
| 489 | #define spin_trylock_bh(lock) __cond_lock(_spin_trylock_bh(lock)) | 193 | #define spin_trylock_bh(lock) __cond_lock(_spin_trylock_bh(lock)) |
| 490 | 194 | ||
| 491 | #define spin_trylock_irq(lock) \ | 195 | #define spin_trylock_irq(lock) \ |
| 492 | ({ \ | 196 | ({ \ |
| 493 | local_irq_disable(); \ | 197 | local_irq_disable(); \ |
| 494 | _spin_trylock(lock) ? \ | 198 | _spin_trylock(lock) ? \ |
| 495 | 1 : ({local_irq_enable(); 0; }); \ | 199 | 1 : ({ local_irq_enable(); 0; }); \ |
| 496 | }) | 200 | }) |
| 497 | 201 | ||
| 498 | #define spin_trylock_irqsave(lock, flags) \ | 202 | #define spin_trylock_irqsave(lock, flags) \ |
| 499 | ({ \ | 203 | ({ \ |
| 500 | local_irq_save(flags); \ | 204 | local_irq_save(flags); \ |
| 501 | _spin_trylock(lock) ? \ | 205 | _spin_trylock(lock) ? \ |
| 502 | 1 : ({local_irq_restore(flags); 0;}); \ | 206 | 1 : ({ local_irq_restore(flags); 0; }); \ |
| 503 | }) | 207 | }) |
| 504 | 208 | ||
| 505 | #ifdef CONFIG_LOCKMETER | ||
| 506 | extern void _metered_spin_lock (spinlock_t *lock); | ||
| 507 | extern void _metered_spin_unlock (spinlock_t *lock); | ||
| 508 | extern int _metered_spin_trylock(spinlock_t *lock); | ||
| 509 | extern void _metered_read_lock (rwlock_t *lock); | ||
| 510 | extern void _metered_read_unlock (rwlock_t *lock); | ||
| 511 | extern void _metered_write_lock (rwlock_t *lock); | ||
| 512 | extern void _metered_write_unlock (rwlock_t *lock); | ||
| 513 | extern int _metered_read_trylock (rwlock_t *lock); | ||
| 514 | extern int _metered_write_trylock(rwlock_t *lock); | ||
| 515 | #endif | ||
| 516 | |||
| 517 | /* "lock on reference count zero" */ | ||
| 518 | #ifndef ATOMIC_DEC_AND_LOCK | ||
| 519 | #include <asm/atomic.h> | ||
| 520 | extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock); | ||
| 521 | #endif | ||
| 522 | |||
| 523 | #define atomic_dec_and_lock(atomic,lock) __cond_lock(_atomic_dec_and_lock(atomic,lock)) | ||
| 524 | |||
| 525 | /* | ||
| 526 | * bit-based spin_lock() | ||
| 527 | * | ||
| 528 | * Don't use this unless you really need to: spin_lock() and spin_unlock() | ||
| 529 | * are significantly faster. | ||
| 530 | */ | ||
| 531 | static inline void bit_spin_lock(int bitnum, unsigned long *addr) | ||
| 532 | { | ||
| 533 | /* | ||
| 534 | * Assuming the lock is uncontended, this never enters | ||
| 535 | * the body of the outer loop. If it is contended, then | ||
| 536 | * within the inner loop a non-atomic test is used to | ||
| 537 | * busywait with less bus contention for a good time to | ||
| 538 | * attempt to acquire the lock bit. | ||
| 539 | */ | ||
| 540 | preempt_disable(); | ||
| 541 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
| 542 | while (test_and_set_bit(bitnum, addr)) { | ||
| 543 | while (test_bit(bitnum, addr)) { | ||
| 544 | preempt_enable(); | ||
| 545 | cpu_relax(); | ||
| 546 | preempt_disable(); | ||
| 547 | } | ||
| 548 | } | ||
| 549 | #endif | ||
| 550 | __acquire(bitlock); | ||
| 551 | } | ||
| 552 | |||
| 553 | /* | 209 | /* |
| 554 | * Return true if it was acquired | 210 | * Pull the atomic_t declaration: |
| 211 | * (asm-mips/atomic.h needs above definitions) | ||
| 555 | */ | 212 | */ |
| 556 | static inline int bit_spin_trylock(int bitnum, unsigned long *addr) | 213 | #include <asm/atomic.h> |
| 557 | { | 214 | /** |
| 558 | preempt_disable(); | 215 | * atomic_dec_and_lock - lock on reaching reference count zero |
| 559 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | 216 | * @atomic: the atomic counter |
| 560 | if (test_and_set_bit(bitnum, addr)) { | 217 | * @lock: the spinlock in question |
| 561 | preempt_enable(); | ||
| 562 | return 0; | ||
| 563 | } | ||
| 564 | #endif | ||
| 565 | __acquire(bitlock); | ||
| 566 | return 1; | ||
| 567 | } | ||
| 568 | |||
| 569 | /* | ||
| 570 | * bit-based spin_unlock() | ||
| 571 | */ | ||
| 572 | static inline void bit_spin_unlock(int bitnum, unsigned long *addr) | ||
| 573 | { | ||
| 574 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | ||
| 575 | BUG_ON(!test_bit(bitnum, addr)); | ||
| 576 | smp_mb__before_clear_bit(); | ||
| 577 | clear_bit(bitnum, addr); | ||
| 578 | #endif | ||
| 579 | preempt_enable(); | ||
| 580 | __release(bitlock); | ||
| 581 | } | ||
| 582 | |||
| 583 | /* | ||
| 584 | * Return true if the lock is held. | ||
| 585 | */ | 218 | */ |
| 586 | static inline int bit_spin_is_locked(int bitnum, unsigned long *addr) | 219 | extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock); |
| 587 | { | 220 | #define atomic_dec_and_lock(atomic, lock) \ |
| 588 | #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) | 221 | __cond_lock(_atomic_dec_and_lock(atomic, lock)) |
| 589 | return test_bit(bitnum, addr); | ||
| 590 | #elif defined CONFIG_PREEMPT | ||
| 591 | return preempt_count(); | ||
| 592 | #else | ||
| 593 | return 1; | ||
| 594 | #endif | ||
| 595 | } | ||
| 596 | |||
| 597 | #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED | ||
| 598 | #define DEFINE_RWLOCK(x) rwlock_t x = RW_LOCK_UNLOCKED | ||
| 599 | 222 | ||
| 600 | /** | 223 | /** |
| 601 | * spin_can_lock - would spin_trylock() succeed? | 224 | * spin_can_lock - would spin_trylock() succeed? |
| 602 | * @lock: the spinlock in question. | 225 | * @lock: the spinlock in question. |
| 603 | */ | 226 | */ |
| 604 | #define spin_can_lock(lock) (!spin_is_locked(lock)) | 227 | #define spin_can_lock(lock) (!spin_is_locked(lock)) |
| 605 | 228 | ||
| 606 | #endif /* __LINUX_SPINLOCK_H */ | 229 | #endif /* __LINUX_SPINLOCK_H */ |
diff --git a/include/linux/spinlock_api_smp.h b/include/linux/spinlock_api_smp.h new file mode 100644 index 000000000000..78e6989ffb54 --- /dev/null +++ b/include/linux/spinlock_api_smp.h | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | #ifndef __LINUX_SPINLOCK_API_SMP_H | ||
| 2 | #define __LINUX_SPINLOCK_API_SMP_H | ||
| 3 | |||
| 4 | #ifndef __LINUX_SPINLOCK_H | ||
| 5 | # error "please don't include this file directly" | ||
| 6 | #endif | ||
| 7 | |||
| 8 | /* | ||
| 9 | * include/linux/spinlock_api_smp.h | ||
| 10 | * | ||
| 11 | * spinlock API declarations on SMP (and debug) | ||
| 12 | * (implemented in kernel/spinlock.c) | ||
| 13 | * | ||
| 14 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
| 15 | * Released under the General Public License (GPL). | ||
| 16 | */ | ||
| 17 | |||
| 18 | int in_lock_functions(unsigned long addr); | ||
| 19 | |||
| 20 | #define assert_spin_locked(x) BUG_ON(!spin_is_locked(x)) | ||
| 21 | |||
| 22 | void __lockfunc _spin_lock(spinlock_t *lock) __acquires(spinlock_t); | ||
| 23 | void __lockfunc _read_lock(rwlock_t *lock) __acquires(rwlock_t); | ||
| 24 | void __lockfunc _write_lock(rwlock_t *lock) __acquires(rwlock_t); | ||
| 25 | void __lockfunc _spin_lock_bh(spinlock_t *lock) __acquires(spinlock_t); | ||
| 26 | void __lockfunc _read_lock_bh(rwlock_t *lock) __acquires(rwlock_t); | ||
| 27 | void __lockfunc _write_lock_bh(rwlock_t *lock) __acquires(rwlock_t); | ||
| 28 | void __lockfunc _spin_lock_irq(spinlock_t *lock) __acquires(spinlock_t); | ||
| 29 | void __lockfunc _read_lock_irq(rwlock_t *lock) __acquires(rwlock_t); | ||
| 30 | void __lockfunc _write_lock_irq(rwlock_t *lock) __acquires(rwlock_t); | ||
| 31 | unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock) | ||
| 32 | __acquires(spinlock_t); | ||
| 33 | unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock) | ||
| 34 | __acquires(rwlock_t); | ||
| 35 | unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock) | ||
| 36 | __acquires(rwlock_t); | ||
| 37 | int __lockfunc _spin_trylock(spinlock_t *lock); | ||
| 38 | int __lockfunc _read_trylock(rwlock_t *lock); | ||
| 39 | int __lockfunc _write_trylock(rwlock_t *lock); | ||
| 40 | int __lockfunc _spin_trylock_bh(spinlock_t *lock); | ||
| 41 | void __lockfunc _spin_unlock(spinlock_t *lock) __releases(spinlock_t); | ||
| 42 | void __lockfunc _read_unlock(rwlock_t *lock) __releases(rwlock_t); | ||
| 43 | void __lockfunc _write_unlock(rwlock_t *lock) __releases(rwlock_t); | ||
| 44 | void __lockfunc _spin_unlock_bh(spinlock_t *lock) __releases(spinlock_t); | ||
| 45 | void __lockfunc _read_unlock_bh(rwlock_t *lock) __releases(rwlock_t); | ||
| 46 | void __lockfunc _write_unlock_bh(rwlock_t *lock) __releases(rwlock_t); | ||
| 47 | void __lockfunc _spin_unlock_irq(spinlock_t *lock) __releases(spinlock_t); | ||
| 48 | void __lockfunc _read_unlock_irq(rwlock_t *lock) __releases(rwlock_t); | ||
| 49 | void __lockfunc _write_unlock_irq(rwlock_t *lock) __releases(rwlock_t); | ||
| 50 | void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags) | ||
| 51 | __releases(spinlock_t); | ||
| 52 | void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags) | ||
| 53 | __releases(rwlock_t); | ||
| 54 | void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) | ||
| 55 | __releases(rwlock_t); | ||
| 56 | |||
| 57 | #endif /* __LINUX_SPINLOCK_API_SMP_H */ | ||
diff --git a/include/linux/spinlock_api_up.h b/include/linux/spinlock_api_up.h new file mode 100644 index 000000000000..cd81cee566f4 --- /dev/null +++ b/include/linux/spinlock_api_up.h | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | #ifndef __LINUX_SPINLOCK_API_UP_H | ||
| 2 | #define __LINUX_SPINLOCK_API_UP_H | ||
| 3 | |||
| 4 | #ifndef __LINUX_SPINLOCK_H | ||
| 5 | # error "please don't include this file directly" | ||
| 6 | #endif | ||
| 7 | |||
| 8 | /* | ||
| 9 | * include/linux/spinlock_api_up.h | ||
| 10 | * | ||
| 11 | * spinlock API implementation on UP-nondebug (inlined implementation) | ||
| 12 | * | ||
| 13 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
| 14 | * Released under the General Public License (GPL). | ||
| 15 | */ | ||
| 16 | |||
| 17 | #define in_lock_functions(ADDR) 0 | ||
| 18 | |||
| 19 | #define assert_spin_locked(lock) do { (void)(lock); } while (0) | ||
| 20 | |||
| 21 | /* | ||
| 22 | * In the UP-nondebug case there's no real locking going on, so the | ||
| 23 | * only thing we have to do is to keep the preempt counts and irq | ||
| 24 | * flags straight, to supress compiler warnings of unused lock | ||
| 25 | * variables, and to add the proper checker annotations: | ||
| 26 | */ | ||
| 27 | #define __LOCK(lock) \ | ||
| 28 | do { preempt_disable(); __acquire(lock); (void)(lock); } while (0) | ||
| 29 | |||
| 30 | #define __LOCK_BH(lock) \ | ||
| 31 | do { local_bh_disable(); __LOCK(lock); } while (0) | ||
| 32 | |||
| 33 | #define __LOCK_IRQ(lock) \ | ||
| 34 | do { local_irq_disable(); __LOCK(lock); } while (0) | ||
| 35 | |||
| 36 | #define __LOCK_IRQSAVE(lock, flags) \ | ||
| 37 | do { local_irq_save(flags); __LOCK(lock); } while (0) | ||
| 38 | |||
| 39 | #define __UNLOCK(lock) \ | ||
| 40 | do { preempt_enable(); __release(lock); (void)(lock); } while (0) | ||
| 41 | |||
| 42 | #define __UNLOCK_BH(lock) \ | ||
| 43 | do { preempt_enable_no_resched(); local_bh_enable(); __release(lock); (void)(lock); } while (0) | ||
| 44 | |||
| 45 | #define __UNLOCK_IRQ(lock) \ | ||
| 46 | do { local_irq_enable(); __UNLOCK(lock); } while (0) | ||
| 47 | |||
| 48 | #define __UNLOCK_IRQRESTORE(lock, flags) \ | ||
| 49 | do { local_irq_restore(flags); __UNLOCK(lock); } while (0) | ||
| 50 | |||
| 51 | #define _spin_lock(lock) __LOCK(lock) | ||
| 52 | #define _read_lock(lock) __LOCK(lock) | ||
| 53 | #define _write_lock(lock) __LOCK(lock) | ||
| 54 | #define _spin_lock_bh(lock) __LOCK_BH(lock) | ||
| 55 | #define _read_lock_bh(lock) __LOCK_BH(lock) | ||
| 56 | #define _write_lock_bh(lock) __LOCK_BH(lock) | ||
| 57 | #define _spin_lock_irq(lock) __LOCK_IRQ(lock) | ||
| 58 | #define _read_lock_irq(lock) __LOCK_IRQ(lock) | ||
| 59 | #define _write_lock_irq(lock) __LOCK_IRQ(lock) | ||
| 60 | #define _spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags) | ||
| 61 | #define _read_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags) | ||
| 62 | #define _write_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags) | ||
| 63 | #define _spin_trylock(lock) ({ __LOCK(lock); 1; }) | ||
| 64 | #define _read_trylock(lock) ({ __LOCK(lock); 1; }) | ||
| 65 | #define _write_trylock(lock) ({ __LOCK(lock); 1; }) | ||
| 66 | #define _spin_trylock_bh(lock) ({ __LOCK_BH(lock); 1; }) | ||
| 67 | #define _spin_unlock(lock) __UNLOCK(lock) | ||
| 68 | #define _read_unlock(lock) __UNLOCK(lock) | ||
| 69 | #define _write_unlock(lock) __UNLOCK(lock) | ||
| 70 | #define _spin_unlock_bh(lock) __UNLOCK_BH(lock) | ||
| 71 | #define _write_unlock_bh(lock) __UNLOCK_BH(lock) | ||
| 72 | #define _read_unlock_bh(lock) __UNLOCK_BH(lock) | ||
| 73 | #define _spin_unlock_irq(lock) __UNLOCK_IRQ(lock) | ||
| 74 | #define _read_unlock_irq(lock) __UNLOCK_IRQ(lock) | ||
| 75 | #define _write_unlock_irq(lock) __UNLOCK_IRQ(lock) | ||
| 76 | #define _spin_unlock_irqrestore(lock, flags) __UNLOCK_IRQRESTORE(lock, flags) | ||
| 77 | #define _read_unlock_irqrestore(lock, flags) __UNLOCK_IRQRESTORE(lock, flags) | ||
| 78 | #define _write_unlock_irqrestore(lock, flags) __UNLOCK_IRQRESTORE(lock, flags) | ||
| 79 | |||
| 80 | #endif /* __LINUX_SPINLOCK_API_UP_H */ | ||
diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h new file mode 100644 index 000000000000..9cb51e070390 --- /dev/null +++ b/include/linux/spinlock_types.h | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | #ifndef __LINUX_SPINLOCK_TYPES_H | ||
| 2 | #define __LINUX_SPINLOCK_TYPES_H | ||
| 3 | |||
| 4 | /* | ||
| 5 | * include/linux/spinlock_types.h - generic spinlock type definitions | ||
| 6 | * and initializers | ||
| 7 | * | ||
| 8 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
| 9 | * Released under the General Public License (GPL). | ||
| 10 | */ | ||
| 11 | |||
| 12 | #if defined(CONFIG_SMP) | ||
| 13 | # include <asm/spinlock_types.h> | ||
| 14 | #else | ||
| 15 | # include <linux/spinlock_types_up.h> | ||
| 16 | #endif | ||
| 17 | |||
| 18 | typedef struct { | ||
| 19 | raw_spinlock_t raw_lock; | ||
| 20 | #if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) | ||
| 21 | unsigned int break_lock; | ||
| 22 | #endif | ||
| 23 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
| 24 | unsigned int magic, owner_cpu; | ||
| 25 | void *owner; | ||
| 26 | #endif | ||
| 27 | } spinlock_t; | ||
| 28 | |||
| 29 | #define SPINLOCK_MAGIC 0xdead4ead | ||
| 30 | |||
| 31 | typedef struct { | ||
| 32 | raw_rwlock_t raw_lock; | ||
| 33 | #if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) | ||
| 34 | unsigned int break_lock; | ||
| 35 | #endif | ||
| 36 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
| 37 | unsigned int magic, owner_cpu; | ||
| 38 | void *owner; | ||
| 39 | #endif | ||
| 40 | } rwlock_t; | ||
| 41 | |||
| 42 | #define RWLOCK_MAGIC 0xdeaf1eed | ||
| 43 | |||
| 44 | #define SPINLOCK_OWNER_INIT ((void *)-1L) | ||
| 45 | |||
| 46 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
| 47 | # define SPIN_LOCK_UNLOCKED \ | ||
| 48 | (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \ | ||
| 49 | .magic = SPINLOCK_MAGIC, \ | ||
| 50 | .owner = SPINLOCK_OWNER_INIT, \ | ||
| 51 | .owner_cpu = -1 } | ||
| 52 | #define RW_LOCK_UNLOCKED \ | ||
| 53 | (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED, \ | ||
| 54 | .magic = RWLOCK_MAGIC, \ | ||
| 55 | .owner = SPINLOCK_OWNER_INIT, \ | ||
| 56 | .owner_cpu = -1 } | ||
| 57 | #else | ||
| 58 | # define SPIN_LOCK_UNLOCKED \ | ||
| 59 | (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED } | ||
| 60 | #define RW_LOCK_UNLOCKED \ | ||
| 61 | (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED } | ||
| 62 | #endif | ||
| 63 | |||
| 64 | #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED | ||
| 65 | #define DEFINE_RWLOCK(x) rwlock_t x = RW_LOCK_UNLOCKED | ||
| 66 | |||
| 67 | #endif /* __LINUX_SPINLOCK_TYPES_H */ | ||
diff --git a/include/linux/spinlock_types_up.h b/include/linux/spinlock_types_up.h new file mode 100644 index 000000000000..def2d173a8db --- /dev/null +++ b/include/linux/spinlock_types_up.h | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | #ifndef __LINUX_SPINLOCK_TYPES_UP_H | ||
| 2 | #define __LINUX_SPINLOCK_TYPES_UP_H | ||
| 3 | |||
| 4 | #ifndef __LINUX_SPINLOCK_TYPES_H | ||
| 5 | # error "please don't include this file directly" | ||
| 6 | #endif | ||
| 7 | |||
| 8 | /* | ||
| 9 | * include/linux/spinlock_types_up.h - spinlock type definitions for UP | ||
| 10 | * | ||
| 11 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
| 12 | * Released under the General Public License (GPL). | ||
| 13 | */ | ||
| 14 | |||
| 15 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
| 16 | |||
| 17 | typedef struct { | ||
| 18 | volatile unsigned int slock; | ||
| 19 | } raw_spinlock_t; | ||
| 20 | |||
| 21 | #define __RAW_SPIN_LOCK_UNLOCKED { 1 } | ||
| 22 | |||
| 23 | #else | ||
| 24 | |||
| 25 | /* | ||
| 26 | * All gcc 2.95 versions and early versions of 2.96 have a nasty bug | ||
| 27 | * with empty initializers. | ||
| 28 | */ | ||
| 29 | #if (__GNUC__ > 2) | ||
| 30 | typedef struct { } raw_spinlock_t; | ||
| 31 | |||
| 32 | #define __RAW_SPIN_LOCK_UNLOCKED { } | ||
| 33 | #else | ||
| 34 | typedef struct { int gcc_is_buggy; } raw_spinlock_t; | ||
| 35 | #define __RAW_SPIN_LOCK_UNLOCKED (raw_spinlock_t) { 0 } | ||
| 36 | #endif | ||
| 37 | |||
| 38 | #endif | ||
| 39 | |||
| 40 | #if (__GNUC__ > 2) | ||
| 41 | typedef struct { | ||
| 42 | /* no debug version on UP */ | ||
| 43 | } raw_rwlock_t; | ||
| 44 | |||
| 45 | #define __RAW_RW_LOCK_UNLOCKED { } | ||
| 46 | #else | ||
| 47 | typedef struct { int gcc_is_buggy; } raw_rwlock_t; | ||
| 48 | #define __RAW_RW_LOCK_UNLOCKED (raw_rwlock_t) { 0 } | ||
| 49 | #endif | ||
| 50 | |||
| 51 | #endif /* __LINUX_SPINLOCK_TYPES_UP_H */ | ||
diff --git a/include/linux/spinlock_up.h b/include/linux/spinlock_up.h new file mode 100644 index 000000000000..31accf2f0b13 --- /dev/null +++ b/include/linux/spinlock_up.h | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | #ifndef __LINUX_SPINLOCK_UP_H | ||
| 2 | #define __LINUX_SPINLOCK_UP_H | ||
| 3 | |||
| 4 | #ifndef __LINUX_SPINLOCK_H | ||
| 5 | # error "please don't include this file directly" | ||
| 6 | #endif | ||
| 7 | |||
| 8 | /* | ||
| 9 | * include/linux/spinlock_up.h - UP-debug version of spinlocks. | ||
| 10 | * | ||
| 11 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | ||
| 12 | * Released under the General Public License (GPL). | ||
| 13 | * | ||
| 14 | * In the debug case, 1 means unlocked, 0 means locked. (the values | ||
| 15 | * are inverted, to catch initialization bugs) | ||
| 16 | * | ||
| 17 | * No atomicity anywhere, we are on UP. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifdef CONFIG_DEBUG_SPINLOCK | ||
| 21 | |||
| 22 | #define __raw_spin_is_locked(x) ((x)->slock == 0) | ||
| 23 | |||
| 24 | static inline void __raw_spin_lock(raw_spinlock_t *lock) | ||
| 25 | { | ||
| 26 | lock->slock = 0; | ||
| 27 | } | ||
| 28 | |||
| 29 | static inline void | ||
| 30 | __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags) | ||
| 31 | { | ||
| 32 | local_irq_save(flags); | ||
| 33 | lock->slock = 0; | ||
| 34 | } | ||
| 35 | |||
| 36 | static inline int __raw_spin_trylock(raw_spinlock_t *lock) | ||
| 37 | { | ||
| 38 | char oldval = lock->slock; | ||
| 39 | |||
| 40 | lock->slock = 0; | ||
| 41 | |||
| 42 | return oldval > 0; | ||
| 43 | } | ||
| 44 | |||
| 45 | static inline void __raw_spin_unlock(raw_spinlock_t *lock) | ||
| 46 | { | ||
| 47 | lock->slock = 1; | ||
| 48 | } | ||
| 49 | |||
| 50 | /* | ||
| 51 | * Read-write spinlocks. No debug version. | ||
| 52 | */ | ||
| 53 | #define __raw_read_lock(lock) do { (void)(lock); } while (0) | ||
| 54 | #define __raw_write_lock(lock) do { (void)(lock); } while (0) | ||
| 55 | #define __raw_read_trylock(lock) ({ (void)(lock); 1; }) | ||
| 56 | #define __raw_write_trylock(lock) ({ (void)(lock); 1; }) | ||
| 57 | #define __raw_read_unlock(lock) do { (void)(lock); } while (0) | ||
| 58 | #define __raw_write_unlock(lock) do { (void)(lock); } while (0) | ||
| 59 | |||
| 60 | #else /* DEBUG_SPINLOCK */ | ||
| 61 | #define __raw_spin_is_locked(lock) ((void)(lock), 0) | ||
| 62 | /* for sched.c and kernel_lock.c: */ | ||
| 63 | # define __raw_spin_lock(lock) do { (void)(lock); } while (0) | ||
| 64 | # define __raw_spin_unlock(lock) do { (void)(lock); } while (0) | ||
| 65 | # define __raw_spin_trylock(lock) ({ (void)(lock); 1; }) | ||
| 66 | #endif /* DEBUG_SPINLOCK */ | ||
| 67 | |||
| 68 | #define __raw_read_can_lock(lock) (((void)(lock), 1)) | ||
| 69 | #define __raw_write_can_lock(lock) (((void)(lock), 1)) | ||
| 70 | |||
| 71 | #define __raw_spin_unlock_wait(lock) \ | ||
| 72 | do { cpu_relax(); } while (__raw_spin_is_locked(lock)) | ||
| 73 | |||
| 74 | #endif /* __LINUX_SPINLOCK_UP_H */ | ||
diff --git a/include/linux/time.h b/include/linux/time.h index c10d4c21c183..8e83f4e778bb 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
| @@ -28,17 +28,10 @@ struct timezone { | |||
| 28 | #ifdef __KERNEL__ | 28 | #ifdef __KERNEL__ |
| 29 | 29 | ||
| 30 | /* Parameters used to convert the timespec values */ | 30 | /* Parameters used to convert the timespec values */ |
| 31 | #ifndef USEC_PER_SEC | 31 | #define MSEC_PER_SEC (1000L) |
| 32 | #define USEC_PER_SEC (1000000L) | 32 | #define USEC_PER_SEC (1000000L) |
| 33 | #endif | ||
| 34 | |||
| 35 | #ifndef NSEC_PER_SEC | ||
| 36 | #define NSEC_PER_SEC (1000000000L) | 33 | #define NSEC_PER_SEC (1000000000L) |
| 37 | #endif | ||
| 38 | |||
| 39 | #ifndef NSEC_PER_USEC | ||
| 40 | #define NSEC_PER_USEC (1000L) | 34 | #define NSEC_PER_USEC (1000L) |
| 41 | #endif | ||
| 42 | 35 | ||
| 43 | static __inline__ int timespec_equal(struct timespec *a, struct timespec *b) | 36 | static __inline__ int timespec_equal(struct timespec *a, struct timespec *b) |
| 44 | { | 37 | { |
diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 542dbaee6512..343d883d69c5 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h | |||
| @@ -109,8 +109,6 @@ int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0); | |||
| 109 | int do_writepages(struct address_space *mapping, struct writeback_control *wbc); | 109 | int do_writepages(struct address_space *mapping, struct writeback_control *wbc); |
| 110 | int sync_page_range(struct inode *inode, struct address_space *mapping, | 110 | int sync_page_range(struct inode *inode, struct address_space *mapping, |
| 111 | loff_t pos, size_t count); | 111 | loff_t pos, size_t count); |
| 112 | int sync_page_range_nolock(struct inode *inode, struct address_space | ||
| 113 | *mapping, loff_t pos, size_t count); | ||
| 114 | 112 | ||
| 115 | /* pdflush.c */ | 113 | /* pdflush.c */ |
| 116 | extern int nr_pdflush_threads; /* Global so it can be exported to sysctl | 114 | extern int nr_pdflush_threads; /* Global so it can be exported to sysctl |
