[PATCH] x86: Add the check for all the cores in a package in cache information
[linux-2.6/next.git] / include / linux / backing-dev.h
blobf7a1390d67f5b39da938c6be93c80cf0cd66fcf2
1 /*
2 * include/linux/backing-dev.h
4 * low-level device information and state which is propagated up through
5 * to high-level code.
6 */
8 #ifndef _LINUX_BACKING_DEV_H
9 #define _LINUX_BACKING_DEV_H
11 #include <asm/atomic.h>
14 * Bits in backing_dev_info.state
16 enum bdi_state {
17 BDI_pdflush, /* A pdflush thread is working this device */
18 BDI_write_congested, /* The write queue is getting full */
19 BDI_read_congested, /* The read queue is getting full */
20 BDI_unused, /* Available bits start here */
23 typedef int (congested_fn)(void *, int);
25 struct backing_dev_info {
26 unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */
27 unsigned long state; /* Always use atomic bitops on this */
28 unsigned int capabilities; /* Device capabilities */
29 congested_fn *congested_fn; /* Function pointer if device is md/dm */
30 void *congested_data; /* Pointer to aux data for congested func */
31 void (*unplug_io_fn)(struct backing_dev_info *, struct page *);
32 void *unplug_io_data;
37 * Flags in backing_dev_info::capability
38 * - The first two flags control whether dirty pages will contribute to the
39 * VM's accounting and whether writepages() should be called for dirty pages
40 * (something that would not, for example, be appropriate for ramfs)
41 * - These flags let !MMU mmap() govern direct device mapping vs immediate
42 * copying more easily for MAP_PRIVATE, especially for ROM filesystems
44 #define BDI_CAP_NO_ACCT_DIRTY 0x00000001 /* Dirty pages shouldn't contribute to accounting */
45 #define BDI_CAP_NO_WRITEBACK 0x00000002 /* Don't write pages back */
46 #define BDI_CAP_MAP_COPY 0x00000004 /* Copy can be mapped (MAP_PRIVATE) */
47 #define BDI_CAP_MAP_DIRECT 0x00000008 /* Can be mapped directly (MAP_SHARED) */
48 #define BDI_CAP_READ_MAP 0x00000010 /* Can be mapped for reading */
49 #define BDI_CAP_WRITE_MAP 0x00000020 /* Can be mapped for writing */
50 #define BDI_CAP_EXEC_MAP 0x00000040 /* Can be mapped for execution */
51 #define BDI_CAP_VMFLAGS \
52 (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP)
54 #if defined(VM_MAYREAD) && \
55 (BDI_CAP_READ_MAP != VM_MAYREAD || \
56 BDI_CAP_WRITE_MAP != VM_MAYWRITE || \
57 BDI_CAP_EXEC_MAP != VM_MAYEXEC)
58 #error please change backing_dev_info::capabilities flags
59 #endif
61 extern struct backing_dev_info default_backing_dev_info;
62 void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page);
64 int writeback_acquire(struct backing_dev_info *bdi);
65 int writeback_in_progress(struct backing_dev_info *bdi);
66 void writeback_release(struct backing_dev_info *bdi);
68 static inline int bdi_congested(struct backing_dev_info *bdi, int bdi_bits)
70 if (bdi->congested_fn)
71 return bdi->congested_fn(bdi->congested_data, bdi_bits);
72 return (bdi->state & bdi_bits);
75 static inline int bdi_read_congested(struct backing_dev_info *bdi)
77 return bdi_congested(bdi, 1 << BDI_read_congested);
80 static inline int bdi_write_congested(struct backing_dev_info *bdi)
82 return bdi_congested(bdi, 1 << BDI_write_congested);
85 static inline int bdi_rw_congested(struct backing_dev_info *bdi)
87 return bdi_congested(bdi, (1 << BDI_read_congested)|
88 (1 << BDI_write_congested));
91 #define bdi_cap_writeback_dirty(bdi) \
92 (!((bdi)->capabilities & BDI_CAP_NO_WRITEBACK))
94 #define bdi_cap_account_dirty(bdi) \
95 (!((bdi)->capabilities & BDI_CAP_NO_ACCT_DIRTY))
97 #define mapping_cap_writeback_dirty(mapping) \
98 bdi_cap_writeback_dirty((mapping)->backing_dev_info)
100 #define mapping_cap_account_dirty(mapping) \
101 bdi_cap_account_dirty((mapping)->backing_dev_info)
104 #endif /* _LINUX_BACKING_DEV_H */