diff options
Diffstat (limited to 'include/linux')
37 files changed, 381 insertions, 329 deletions
diff --git a/include/linux/aio.h b/include/linux/aio.h index 3372ec6bf53a..a30ef13c9e62 100644 --- a/include/linux/aio.h +++ b/include/linux/aio.h @@ -105,6 +105,7 @@ struct kiocb { wait_queue_t ki_wait; loff_t ki_pos; + atomic_t ki_bio_count; /* num bio used for this iocb */ void *private; /* State that we remember to be able to restart/retry */ unsigned short ki_opcode; diff --git a/include/linux/bio.h b/include/linux/bio.h index 092dbd0e7658..08daf3272c02 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -309,6 +309,7 @@ extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int, gfp_t); extern void bio_set_pages_dirty(struct bio *bio); extern void bio_check_pages_dirty(struct bio *bio); +extern void bio_release_pages(struct bio *bio); extern struct bio *bio_copy_user(struct request_queue *, unsigned long, unsigned int, int); extern int bio_uncopy_user(struct bio *); void zero_fill_bio(struct bio *bio); diff --git a/include/linux/coda_linux.h b/include/linux/coda_linux.h index be512cc98791..4c2632a8d31b 100644 --- a/include/linux/coda_linux.h +++ b/include/linux/coda_linux.h @@ -64,7 +64,7 @@ void coda_sysctl_clean(void); #define CODA_ALLOC(ptr, cast, size) do { \ if (size < PAGE_SIZE) \ - ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \ + ptr = kmalloc((unsigned long) size, GFP_KERNEL); \ else \ ptr = (cast)vmalloc((unsigned long) size); \ if (!ptr) \ diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index 8821e1f75b44..826b15e914e2 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h @@ -30,10 +30,19 @@ void cpuset_update_task_memory_state(void); nodes_subset((nodes), current->mems_allowed) int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl); -extern int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask); -static int inline cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) +extern int __cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask); +extern int __cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask); + +static int inline cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask) +{ + return number_of_cpusets <= 1 || + __cpuset_zone_allowed_softwall(z, gfp_mask); +} + +static int inline cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask) { - return number_of_cpusets <= 1 || __cpuset_zone_allowed(z, gfp_mask); + return number_of_cpusets <= 1 || + __cpuset_zone_allowed_hardwall(z, gfp_mask); } extern int cpuset_excl_nodes_overlap(const struct task_struct *p); @@ -94,7 +103,12 @@ static inline int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl) return 1; } -static inline int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) +static inline int cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask) +{ + return 1; +} + +static inline int cpuset_zone_allowed_hardwall(struct zone *z, gfp_t gfp_mask) { return 1; } diff --git a/include/linux/fb.h b/include/linux/fb.h index 6fe56aaa6685..64177ec9a019 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -929,8 +929,6 @@ extern void fb_bl_default_curve(struct fb_info *fb_info, u8 off, u8 min, u8 max) #define FB_MODE_IS_FIRST 16 #define FB_MODE_IS_FROM_VAR 32 -extern int fbmon_valid_timings(u_int pixclock, u_int htotal, u_int vtotal, - const struct fb_info *fb_info); extern int fbmon_dpms(const struct fb_info *fb_info); extern int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var, struct fb_info *info); diff --git a/include/linux/freezer.h b/include/linux/freezer.h index 393063096134..5e75e26d4787 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -16,16 +16,15 @@ static inline int frozen(struct task_struct *p) */ static inline int freezing(struct task_struct *p) { - return p->flags & PF_FREEZE; + return test_tsk_thread_flag(p, TIF_FREEZE); } /* * Request that a process be frozen - * FIXME: SMP problem. We may not modify other process' flags! */ static inline void freeze(struct task_struct *p) { - p->flags |= PF_FREEZE; + set_tsk_thread_flag(p, TIF_FREEZE); } /* @@ -33,7 +32,7 @@ static inline void freeze(struct task_struct *p) */ static inline void do_not_freeze(struct task_struct *p) { - p->flags &= ~PF_FREEZE; + clear_tsk_thread_flag(p, TIF_FREEZE); } /* @@ -54,7 +53,9 @@ static inline int thaw_process(struct task_struct *p) */ static inline void frozen_process(struct task_struct *p) { - p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN; + p->flags |= PF_FROZEN; + wmb(); + clear_tsk_thread_flag(p, TIF_FREEZE); } extern void refrigerator(void); diff --git a/include/linux/fs.h b/include/linux/fs.h index adce6e1d70c2..186da813541e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -120,6 +120,7 @@ extern int dir_notify_enable; #define MS_PRIVATE (1<<18) /* change to private */ #define MS_SLAVE (1<<19) /* change to slave */ #define MS_SHARED (1<<20) /* change to shared */ +#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */ #define MS_ACTIVE (1<<30) #define MS_NOUSER (1<<31) diff --git a/include/linux/gameport.h b/include/linux/gameport.h index 2cdba0c23957..afad95272841 100644 --- a/include/linux/gameport.h +++ b/include/linux/gameport.h @@ -105,7 +105,7 @@ static inline void gameport_set_phys(struct gameport *gameport, static inline struct gameport *gameport_allocate_port(void) { - struct gameport *gameport = kcalloc(1, sizeof(struct gameport), GFP_KERNEL); + struct gameport *gameport = kzalloc(sizeof(struct gameport), GFP_KERNEL); return gameport; } diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 3d8768b619e9..ca9a602cffd7 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -96,7 +96,10 @@ static inline void memclear_highpage_flush(struct page *page, unsigned int offse kunmap_atomic(kaddr, KM_USER0); } -static inline void copy_user_highpage(struct page *to, struct page *from, unsigned long vaddr) +#ifndef __HAVE_ARCH_COPY_USER_HIGHPAGE + +static inline void copy_user_highpage(struct page *to, struct page *from, + unsigned long vaddr, struct vm_area_struct *vma) { char *vfrom, *vto; @@ -109,6 +112,8 @@ static inline void copy_user_highpage(struct page *to, struct page *from, unsign smp_wmb(); } +#endif + static inline void copy_highpage(struct page *to, struct page *from) { char *vfrom, *vto; diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 7ae3c3326643..d38778f2fbec 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -142,7 +142,6 @@ #define I2C_DRIVERID_MTP008 1023 #define I2C_DRIVERID_DS1621 1024 #define I2C_DRIVERID_ADM1024 1025 -#define I2C_DRIVERID_IT87 1026 #define I2C_DRIVERID_CH700X 1027 /* single driver for CH7003-7009 digital pc to tv encoders */ #define I2C_DRIVERID_FSCPOS 1028 #define I2C_DRIVERID_FSCSCY 1029 diff --git a/include/linux/init_task.h b/include/linux/init_task.h index b5315150199e..6383d2d83bb0 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h @@ -75,7 +75,6 @@ extern struct nsproxy init_nsproxy; .pid_ns = &init_pid_ns, \ .count = ATOMIC_INIT(1), \ .nslock = __SPIN_LOCK_UNLOCKED(nsproxy.nslock), \ - .id = 0, \ .uts_ns = &init_uts_ns, \ .mnt_ns = NULL, \ INIT_IPC_NS(ipc_ns) \ diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h index aa50d89eacd7..246de1d84a26 100644 --- a/include/linux/lockd/bind.h +++ b/include/linux/lockd/bind.h @@ -23,7 +23,7 @@ struct svc_rqst; * This is the set of functions for lockd->nfsd communication */ struct nlmsvc_binding { - u32 (*fopen)(struct svc_rqst *, + __be32 (*fopen)(struct svc_rqst *, struct nfs_fh *, struct file **); void (*fclose)(struct file *); diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index 0c962b82a9de..ac25b5649c59 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h @@ -191,7 +191,7 @@ __be32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *); unsigned long nlmsvc_retry_blocked(void); void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *, nlm_host_match_fn_t match); -void nlmsvc_grant_reply(struct nlm_cookie *, u32); +void nlmsvc_grant_reply(struct nlm_cookie *, __be32); /* * File handling for the server personality diff --git a/include/linux/lockd/sm_inter.h b/include/linux/lockd/sm_inter.h index fc61d40964da..22a645828f26 100644 --- a/include/linux/lockd/sm_inter.h +++ b/include/linux/lockd/sm_inter.h @@ -24,7 +24,7 @@ * Arguments for all calls to statd */ struct nsm_args { - u32 addr; /* remote address */ + __be32 addr; /* remote address */ u32 prog; /* RPC callback info */ u32 vers; u32 proc; diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h index 29e7d9fc9dad..83a1f9f6237b 100644 --- a/include/linux/lockd/xdr.h +++ b/include/linux/lockd/xdr.h @@ -69,7 +69,7 @@ typedef struct nlm_args nlm_args; */ struct nlm_res { struct nlm_cookie cookie; - u32 status; + __be32 status; struct nlm_lock lock; }; @@ -80,9 +80,9 @@ struct nlm_reboot { char * mon; int len; u32 state; - u32 addr; - u32 vers; - u32 proto; + __be32 addr; + __be32 vers; + __be32 proto; }; /* diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 498bfbd3b4e1..ea097dddc44f 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -281,15 +281,25 @@ struct lock_class_key { }; #if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS) extern void early_init_irq_lock_class(void); #else -# define early_init_irq_lock_class() do { } while (0) +static inline void early_init_irq_lock_class(void) +{ +} #endif #ifdef CONFIG_TRACE_IRQFLAGS extern void early_boot_irqs_off(void); extern void early_boot_irqs_on(void); +extern void print_irqtrace_events(struct task_struct *curr); #else -# define early_boot_irqs_off() do { } while (0) -# define early_boot_irqs_on() do { } while (0) +static inline void early_boot_irqs_off(void) +{ +} +static inline void early_boot_irqs_on(void) +{ +} +static inline void print_irqtrace_events(struct task_struct *curr) +{ +} #endif /* diff --git a/include/linux/mount.h b/include/linux/mount.h index e357dc86a4de..1b7e178b0d84 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -27,6 +27,7 @@ struct mnt_namespace; #define MNT_NOEXEC 0x04 #define MNT_NOATIME 0x08 #define MNT_NODIRATIME 0x10 +#define MNT_RELATIME 0x20 #define MNT_SHRINKABLE 0x100 diff --git a/include/linux/n_r3964.h b/include/linux/n_r3964.h index db4f3776978a..de24af79ebd3 100644 --- a/include/linux/n_r3964.h +++ b/include/linux/n_r3964.h @@ -116,7 +116,7 @@ struct r3964_message; struct r3964_client_info { spinlock_t lock; - pid_t pid; + struct pid *pid; unsigned int sig_flags; struct r3964_client_info *next; diff --git a/include/linux/ncp_mount.h b/include/linux/ncp_mount.h index f46bddcdbd3b..a2b549eb1eca 100644 --- a/include/linux/ncp_mount.h +++ b/include/linux/ncp_mount.h @@ -75,7 +75,7 @@ struct ncp_mount_data_kernel { unsigned int int_flags; /* internal flags */ #define NCP_IMOUNT_LOGGEDIN_POSSIBLE 0x0001 __kernel_uid32_t mounted_uid; /* Who may umount() this filesystem? */ - __kernel_pid_t wdog_pid; /* Who cares for our watchdog packets? */ + struct pid *wdog_pid; /* Who cares for our watchdog packets? */ unsigned int ncp_fd; /* The socket to the ncp port */ unsigned int time_out; /* How long should I wait after sending a NCP request? */ diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h index 6c4613f8ad75..55689f39f77a 100644 --- a/include/linux/netfilter_bridge.h +++ b/include/linux/netfilter_bridge.h @@ -68,7 +68,6 @@ struct bridge_skb_cb { } daddr; }; -extern int brnf_deferred_hooks; #else #define nf_bridge_maybe_copy_header(skb) (0) #define nf_bridge_pad(skb) (0) diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h index 5821eb5a0a3e..ceae87a4c891 100644 --- a/include/linux/netfilter_ipv4.h +++ b/include/linux/netfilter_ipv4.h @@ -57,10 +57,8 @@ enum nf_ip_hook_priorities { NF_IP_PRI_RAW = -300, NF_IP_PRI_SELINUX_FIRST = -225, NF_IP_PRI_CONNTRACK = -200, - NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD = -175, NF_IP_PRI_MANGLE = -150, NF_IP_PRI_NAT_DST = -100, - NF_IP_PRI_BRIDGE_SABOTAGE_LOCAL_OUT = -50, NF_IP_PRI_FILTER = 0, NF_IP_PRI_NAT_SRC = 100, NF_IP_PRI_SELINUX_LAST = 225, diff --git a/include/linux/netfilter_ipv6.h b/include/linux/netfilter_ipv6.h index ab81a6dc94ea..66ca8e3100dc 100644 --- a/include/linux/netfilter_ipv6.h +++ b/include/linux/netfilter_ipv6.h @@ -62,10 +62,8 @@ enum nf_ip6_hook_priorities { NF_IP6_PRI_CONNTRACK_DEFRAG = -400, NF_IP6_PRI_SELINUX_FIRST = -225, NF_IP6_PRI_CONNTRACK = -200, - NF_IP6_PRI_BRIDGE_SABOTAGE_FORWARD = -175, NF_IP6_PRI_MANGLE = -150, NF_IP6_PRI_NAT_DST = -100, - NF_IP6_PRI_BRIDGE_SABOTAGE_LOCAL_OUT = -50, NF_IP6_PRI_FILTER = 0, NF_IP6_PRI_NAT_SRC = 100, NF_IP6_PRI_SELINUX_LAST = 225, diff --git a/include/linux/nfsd/nfsd.h b/include/linux/nfsd/nfsd.h index edb54c3171b3..0727774772ba 100644 --- a/include/linux/nfsd/nfsd.h +++ b/include/linux/nfsd/nfsd.h @@ -275,12 +275,12 @@ static inline int is_fsid(struct svc_fh *fh, struct knfsd_fh *reffh) * we might process an operation with side effects, and be unable to * tell the client that the operation succeeded. * - * COMPOUND_SLACK_SPACE - this is the minimum amount of buffer space + * COMPOUND_SLACK_SPACE - this is the minimum bytes of buffer space * needed to encode an "ordinary" _successful_ operation. (GETATTR, * READ, READDIR, and READLINK have their own buffer checks.) if we * fall below this level, we fail the next operation with NFS4ERR_RESOURCE. * - * COMPOUND_ERR_SLACK_SPACE - this is the minimum amount of buffer space + * COMPOUND_ERR_SLACK_SPACE - this is the minimum bytes of buffer space * needed to encode an operation which has failed with NFS4ERR_RESOURCE. * care is taken to ensure that we never fall below this level for any * reason. diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h index c3673f487e84..ab5c236bd9a7 100644 --- a/include/linux/nfsd/state.h +++ b/include/linux/nfsd/state.h @@ -273,7 +273,6 @@ struct nfs4_stateid { ((err) != nfserr_stale_stateid) && \ ((err) != nfserr_bad_stateid)) -extern __be32 nfsd4_renew(clientid_t *clid); extern __be32 nfs4_preprocess_stateid_op(struct svc_fh *current_fh, stateid_t *stateid, int flags, struct file **filp); extern void nfs4_lock_state(void); diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h index 45ca01b5f844..09799bcee0ac 100644 --- a/include/linux/nfsd/xdr4.h +++ b/include/linux/nfsd/xdr4.h @@ -44,6 +44,12 @@ #define NFSD4_MAX_TAGLEN 128 #define XDR_LEN(n) (((n) + 3) & ~3) +struct nfsd4_compound_state { + struct svc_fh current_fh; + struct svc_fh save_fh; + struct nfs4_stateowner *replay_owner; +}; + struct nfsd4_change_info { u32 atomic; u32 before_ctime_sec; @@ -430,35 +436,39 @@ __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, __be32 *buffer, int *countp, u32 *bmval, struct svc_rqst *); extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp, + struct nfsd4_compound_state *, struct nfsd4_setclientid *setclid); extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp, + struct nfsd4_compound_state *, struct nfsd4_setclientid_confirm *setclientid_confirm); extern __be32 nfsd4_process_open1(struct nfsd4_open *open); extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open); extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp, - struct svc_fh *current_fh, struct nfsd4_open_confirm *oc, - struct nfs4_stateowner **); -extern __be32 nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, - struct nfsd4_close *close, - struct nfs4_stateowner **replay_owner); + struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc); +extern __be32 nfsd4_close(struct svc_rqst *rqstp, + struct nfsd4_compound_state *, + struct nfsd4_close *close); extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp, - struct svc_fh *current_fh, struct nfsd4_open_downgrade *od, - struct nfs4_stateowner **replay_owner); -extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, - struct nfsd4_lock *lock, - struct nfs4_stateowner **replay_owner); -extern __be32 nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, + struct nfsd4_compound_state *, + struct nfsd4_open_downgrade *od); +extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *, + struct nfsd4_lock *lock); +extern __be32 nfsd4_lockt(struct svc_rqst *rqstp, + struct nfsd4_compound_state *, struct nfsd4_lockt *lockt); -extern __be32 nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, - struct nfsd4_locku *locku, - struct nfs4_stateowner **replay_owner); +extern __be32 nfsd4_locku(struct svc_rqst *rqstp, + struct nfsd4_compound_state *, + struct nfsd4_locku *locku); extern __be32 nfsd4_release_lockowner(struct svc_rqst *rqstp, + struct nfsd4_compound_state *, struct nfsd4_release_lockowner *rlockowner); extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *); extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp, - struct svc_fh *current_fh, struct nfsd4_delegreturn *dr); + struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr); +extern __be32 nfsd4_renew(struct svc_rqst *rqstp, + struct nfsd4_compound_state *, clientid_t *clid); #endif /* diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h index fdfb0e44912f..0b9f0dc30d61 100644 --- a/include/linux/nsproxy.h +++ b/include/linux/nsproxy.h @@ -24,7 +24,6 @@ struct pid_namespace; struct nsproxy { atomic_t count; spinlock_t nslock; - unsigned long id; struct uts_namespace *uts_ns; struct ipc_namespace *ipc_ns; struct mnt_namespace *mnt_ns; diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 51180dba9a98..95c1e74afebc 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2067,6 +2067,10 @@ #define PCI_DEVICE_ID_JMICRON_JMB366 0x2366 #define PCI_DEVICE_ID_JMICRON_JMB368 0x2368 +#define PCI_VENDOR_ID_KORENIX 0x1982 +#define PCI_DEVICE_ID_KORENIX_JETCARDF0 0x1600 +#define PCI_DEVICE_ID_KORENIX_JETCARDF1 0x16ff + #define PCI_VENDOR_ID_TEKRAM 0x1de1 #define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h index ea4f7cd7bfd8..2e19478e9e84 100644 --- a/include/linux/pipe_fs_i.h +++ b/include/linux/pipe_fs_i.h @@ -12,7 +12,7 @@ struct pipe_buffer { struct page *page; unsigned int offset, len; - struct pipe_buf_operations *ops; + const struct pipe_buf_operations *ops; unsigned int flags; }; @@ -41,9 +41,7 @@ struct pipe_buf_operations { struct pipe_inode_info { wait_queue_head_t wait; unsigned int nrbufs, curbuf; - struct pipe_buffer bufs[PIPE_BUFFERS]; struct page *tmp_page; - unsigned int start; unsigned int readers; unsigned int writers; unsigned int waiting_writers; @@ -52,6 +50,7 @@ struct pipe_inode_info { struct fasync_struct *fasync_readers; struct fasync_struct *fasync_writers; struct inode *inode; + struct pipe_buffer bufs[PIPE_BUFFERS]; }; /* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 20f47b81d3fa..8bbd459eafdc 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -39,7 +39,7 @@ extern struct platform_device *platform_device_register_simple(char *, unsigned extern struct platform_device *platform_device_alloc(const char *name, unsigned int id); extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num); -extern int platform_device_add_data(struct platform_device *pdev, void *data, size_t size); +extern int platform_device_add_data(struct platform_device *pdev, const void *data, size_t size); extern int platform_device_add(struct platform_device *pdev); extern void platform_device_del(struct platform_device *pdev); extern void platform_device_put(struct platform_device *pdev); diff --git a/include/linux/reciprocal_div.h b/include/linux/reciprocal_div.h new file mode 100644 index 000000000000..f9c90b33285b --- /dev/null +++ b/include/linux/reciprocal_div.h @@ -0,0 +1,32 @@ +#ifndef _LINUX_RECIPROCAL_DIV_H +#define _LINUX_RECIPROCAL_DIV_H + +#include <linux/types.h> + +/* + * This file describes reciprocical division. + * + * This optimizes the (A/B) problem, when A and B are two u32 + * and B is a known value (but not known at compile time) + * + * The math principle used is : + * Let RECIPROCAL_VALUE(B) be (((1LL << 32) + (B - 1))/ B) + * Then A / B = (u32)(((u64)(A) * (R)) >> 32) + * + * This replaces a divide by a multiply (and a shift), and + * is generally less expensive in CPU cycles. + */ + +/* + * Computes the reciprocal value (R) for the value B of the divisor. + * Should not be called before each reciprocal_divide(), + * or else the performance is slower than a normal divide. + */ +extern u32 reciprocal_value(u32 B); + + +static inline u32 reciprocal_divide(u32 A, u32 R) +{ + return (u32)(((u64)A * R) >> 32); +} +#endif diff --git a/include/linux/sched.h b/include/linux/sched.h index ea92e5c89089..446373535190 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1144,7 +1144,6 @@ static inline void put_task_struct(struct task_struct *t) #define PF_MEMALLOC 0x00000800 /* Allocating memory */ #define PF_FLUSHER 0x00001000 /* responsible for disk writeback */ #define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */ -#define PF_FREEZE 0x00004000 /* this task is being frozen for suspend now */ #define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */ #define PF_FROZEN 0x00010000 /* frozen for system suspend */ #define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */ diff --git a/include/linux/slab.h b/include/linux/slab.h index 2271886744f8..1ef822e31c77 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -1,7 +1,9 @@ /* - * linux/include/linux/slab.h - * Written by Mark Hemment, 1996. - * (markhe@nextd.demon.co.uk) + * Written by Mark Hemment, 1996 (markhe@nextd.demon.co.uk). + * + * (C) SGI 2006, Christoph Lameter <clameter@sgi.com> + * Cleaned up and restructured to ease the addition of alternative + * implementations of SLAB allocators. */ #ifndef _LINUX_SLAB_H @@ -10,64 +12,95 @@ #ifdef __KERNEL__ #include <linux/gfp.h> -#include <linux/init.h> #include <linux/types.h> -#include <asm/page.h> /* kmalloc_sizes.h needs PAGE_SIZE */ -#include <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */ -#include <linux/compiler.h> -/* kmem_cache_t exists for legacy reasons and is not used by code in mm */ typedef struct kmem_cache kmem_cache_t __deprecated; -/* flags to pass to kmem_cache_create(). - * The first 3 are only valid when the allocator as been build - * SLAB_DEBUG_SUPPORT. +/* + * Flags to pass to kmem_cache_create(). + * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set. */ -#define SLAB_DEBUG_FREE 0x00000100UL /* Peform (expensive) checks on free */ -#define SLAB_DEBUG_INITIAL 0x00000200UL /* Call constructor (as verifier) */ -#define SLAB_RED_ZONE 0x00000400UL /* Red zone objs in a cache */ -#define SLAB_POISON 0x00000800UL /* Poison objects */ -#define SLAB_HWCACHE_ALIGN 0x00002000UL /* align objs on a h/w cache lines */ -#define SLAB_CACHE_DMA 0x00004000UL /* use GFP_DMA memory */ -#define SLAB_MUST_HWCACHE_ALIGN 0x00008000UL /* force alignment */ -#define SLAB_STORE_USER 0x00010000UL /* store the last owner for bug hunting */ -#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* track pages allocated to indicate - what is reclaimable later*/ -#define SLAB_PANIC 0x00040000UL /* panic if kmem_cache_create() fails */ -#define SLAB_DESTROY_BY_RCU 0x00080000UL /* defer freeing pages to RCU */ +#define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */ +#define SLAB_DEBUG_INITIAL 0x00000200UL /* DEBUG: Call constructor (as verifier) */ +#define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */ +#define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */ +#define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */ +#define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ +#define SLAB_MUST_HWCACHE_ALIGN 0x00008000UL /* Force alignment even if debuggin is active */ +#define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ +#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */ +#define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ +#define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */ #define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ -/* flags passed to a constructor func */ -#define SLAB_CTOR_CONSTRUCTOR 0x001UL /* if not set, then deconstructor */ -#define SLAB_CTOR_ATOMIC 0x002UL /* tell constructor it can't sleep */ -#define SLAB_CTOR_VERIFY 0x004UL /* tell constructor it's a verify call */ +/* Flags passed to a constructor functions */ +#define SLAB_CTOR_CONSTRUCTOR 0x001UL /* If not set, then deconstructor */ +#define SLAB_CTOR_ATOMIC 0x002UL /* Tell constructor it can't sleep */ +#define SLAB_CTOR_VERIFY 0x004UL /* Tell constructor it's a verify call */ -#ifndef CONFIG_SLOB - -/* prototypes */ -extern void __init kmem_cache_init(void); +/* + * struct kmem_cache related prototypes + */ +void __init kmem_cache_init(void); +extern int slab_is_available(void); -extern struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, +struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, unsigned long, void (*)(void *, struct kmem_cache *, unsigned long), void (*)(void *, struct kmem_cache *, unsigned long)); -extern void kmem_cache_destroy(struct kmem_cache *); -extern int kmem_cache_shrink(struct kmem_cache *); -extern void *kmem_cache_alloc(struct kmem_cache *, gfp_t); -extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); -extern void kmem_cache_free(struct kmem_cache *, void *); -extern unsigned int kmem_cache_size(struct kmem_cache *); -extern const char *kmem_cache_name(struct kmem_cache *); +void kmem_cache_destroy(struct kmem_cache *); +int kmem_cache_shrink(struct kmem_cache *); +void *kmem_cache_alloc(struct kmem_cache *, gfp_t); +void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); +void kmem_cache_free(struct kmem_cache *, void *); +unsigned int kmem_cache_size(struct kmem_cache *); +const char *kmem_cache_name(struct kmem_cache *); +int kmem_ptr_validate(struct kmem_cache *cachep, const void *ptr); + +#ifdef CONFIG_NUMA +extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); +#else +static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep, + gfp_t flags, int node) +{ + return kmem_cache_alloc(cachep, flags); +} +#endif + +/* + * Common kmalloc functions provided by all allocators + */ +void *__kmalloc(size_t, gfp_t); +void *__kzalloc(size_t, gfp_t); +void kfree(const void *); +unsigned int ksize(const void *); + +/** + * kcalloc - allocate memory for an array. The memory is set to zero. + * @n: number of elements. + * @size: element size. + * @flags: the type of memory to allocate. + */ +static inline void *kcalloc(size_t n, size_t size, gfp_t flags) +{ + if (n != 0 && size > ULONG_MAX / n) + return NULL; + return __kzalloc(n * size, flags); +} -/* Size description struct for general caches. */ -struct cache_sizes { - size_t cs_size; - struct kmem_cache *cs_cachep; - struct kmem_cache *cs_dmacachep; -}; -extern struct cache_sizes malloc_sizes[]; +/* + * Allocator specific definitions. These are mainly used to establish optimized + * ways to convert kmalloc() calls to kmem_cache_alloc() invocations by selecting + * the appropriate general cache at compile time. + */ -extern void *__kmalloc(size_t, gfp_t); +#ifdef CONFIG_SLAB +#include <linux/slab_def.h> +#else +/* + * Fallback definitions for an allocator not wanting to provide + * its own optimized kmalloc definitions (like SLOB). + */ /** * kmalloc - allocate memory @@ -116,46 +149,9 @@ extern void *__kmalloc(size_t, gfp_t); */ static inline void *kmalloc(size_t size, gfp_t flags) { - if (__builtin_constant_p(size)) { - int i = 0; -#define CACHE(x) \ - if (size <= x) \ - goto found; \ - else \ - i++; -#include "kmalloc_sizes.h" -#undef CACHE - { - extern void __you_cannot_kmalloc_that_much(void); - __you_cannot_kmalloc_that_much(); - } -found: - return kmem_cache_alloc((flags & GFP_DMA) ? - malloc_sizes[i].cs_dmacachep : - malloc_sizes[i].cs_cachep, flags); - } return __kmalloc(size, flags); } -/* - * kmalloc_track_caller is a special version of kmalloc that records the - * calling function of the routine calling it for slab leak tracking instead - * of just the calling function (confusing, eh?). - * It's useful when the call to kmalloc comes from a widely-used standard - * allocator where we care about the real place the memory allocation - * request comes from. - */ -#ifndef CONFIG_DEBUG_SLAB -#define kmalloc_track_caller(size, flags) \ - __kmalloc(size, flags) -#else -extern void *__kmalloc_track_caller(size_t, gfp_t, void*); -#define kmalloc_track_caller(size, flags) \ - __kmalloc_track_caller(size, flags, __builtin_return_address(0)) -#endif - -extern void *__kzalloc(size_t, gfp_t); - /** * kzalloc - allocate memory. The memory is set to zero. * @size: how many bytes of memory are required. @@ -163,72 +159,41 @@ extern void *__kzalloc(size_t, gfp_t); */ static inline void *kzalloc(size_t size, gfp_t flags) { - if (__builtin_constant_p(size)) { - int i = 0; -#define CACHE(x) \ - if (size <= x) \ - goto found; \ - else \ - i++; -#include "kmalloc_sizes.h" -#undef CACHE - { - extern void __you_cannot_kzalloc_that_much(void); - __you_cannot_kzalloc_that_much(); - } -found: - return kmem_cache_zalloc((flags & GFP_DMA) ? - malloc_sizes[i].cs_dmacachep : - malloc_sizes[i].cs_cachep, flags); - } return __kzalloc(size, flags); } +#endif -/** - * kcalloc - allocate memory for an array. The memory is set to zero. - * @n: number of elements. - * @size: element size. - * @flags: the type of memory to allocate. - */ -static inline void *kcalloc(size_t n, size_t size, gfp_t flags) +#ifndef CONFIG_NUMA +static inline void *kmalloc_node(size_t size, gfp_t flags, int node) { - if (n != 0 && size > ULONG_MAX / n) - return NULL; - return kzalloc(n * size, flags); + return kmalloc(size, flags); } -extern void kfree(const void *); -extern unsigned int ksize(const void *); -extern int slab_is_available(void); - -#ifdef CONFIG_NUMA -extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); -extern void *__kmalloc_node(size_t size, gfp_t flags, int node); - -static inline void *kmalloc_node(size_t size, gfp_t flags, int node) +static inline void *__kmalloc_node(size_t size, gfp_t flags, int node) { - if (__builtin_constant_p(size)) { - int i = 0; -#define CACHE(x) \ - if (size <= x) \ - goto found; \ - else \ - i++; -#include "kmalloc_sizes.h" -#undef CACHE - { - extern void __you_cannot_kmalloc_that_much(void); - __you_cannot_kmalloc_that_much(); - } -found: - return kmem_cache_alloc_node((flags & GFP_DMA) ? - malloc_sizes[i].cs_dmacachep : - malloc_sizes[i].cs_cachep, flags, node); - } - return __kmalloc_node(size, flags, node); + return __kmalloc(size, flags); } +#endif /* !CONFIG_NUMA */ /* + * kmalloc_track_caller is a special version of kmalloc that records the + * calling function of the routine calling it for slab leak tracking instead + * of just the calling function (confusing, eh?). + * It's useful when the call to kmalloc comes from a widely-used standard + * allocator where we care about the real place the memory allocation + * request comes from. + */ +#ifdef CONFIG_DEBUG_SLAB +extern void *__kmalloc_track_caller(size_t, gfp_t, void*); +#define kmalloc_track_caller(size, flags) \ + __kmalloc_track_caller(size, flags, __builtin_return_address(0)) +#else +#define kmalloc_track_caller(size, flags) \ + __kmalloc(size, flags) +#endif /* DEBUG_SLAB */ + +#ifdef CONFIG_NUMA +/* * kmalloc_node_track_caller is a special version of kmalloc_node that * records the calling function of the routine calling it for slab leak * tracking instead of just the calling function (confusing, eh?). @@ -236,70 +201,23 @@ found: * standard allocator where we care about the real place the memory * allocation request comes from. */ -#ifndef CONFIG_DEBUG_SLAB -#define kmalloc_node_track_caller(size, flags, node) \ - __kmalloc_node(size, flags, node) -#else +#ifdef CONFIG_DEBUG_SLAB extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *); #define kmalloc_node_track_caller(size, flags, node) \ __kmalloc_node_track_caller(size, flags, node, \ __builtin_return_address(0)) +#else +#define kmalloc_node_track_caller(size, flags, node) \ + __kmalloc_node(size, flags, node) #endif + #else /* CONFIG_NUMA */ -static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep, - gfp_t flags, int node) -{ - return kmem_cache_alloc(cachep, flags); -} -static inline void *kmalloc_node(size_t size, gfp_t flags, int node) -{ - return kmalloc(size, flags); -} #define kmalloc_node_track_caller(size, flags, node) \ kmalloc_track_caller(size, flags) -#endif -extern int FASTCALL(kmem_cache_reap(int)); -extern int FASTCALL(kmem_ptr_validate(struct kmem_cache *cachep, void *ptr)); - -#else /* CONFIG_SLOB */ - -/* SLOB allocator routines */ - -void kmem_cache_init(void); -struct kmem_cache *kmem_cache_create(const char *c, size_t, size_t, - unsigned long, - void (*)(void *, struct kmem_cache *, unsigned long), - void (*)(void *, struct kmem_cache *, unsigned long)); -void kmem_cache_destroy(struct kmem_cache *c); -void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags); -void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); -void kmem_cache_free(struct kmem_cache *c, void *b); -const char *kmem_cache_name(struct kmem_cache *); -void *kmalloc(size_t size, gfp_t flags); -void *__kzalloc(size_t size, gfp_t flags); -void kfree(const void *m); -unsigned int ksize(const void *m); -unsigned int kmem_cache_size(struct kmem_cache *c); - -static inline void *kcalloc(size_t n, size_t size, gfp_t flags) -{ - return __kzalloc(n * size, flags); -} - -#define kmem_cache_shrink(d) (0) -#define kmem_cache_reap(a) -#define kmem_ptr_validate(a, b) (0) -#define kmem_cache_alloc_node(c, f, n) kmem_cache_alloc(c, f) -#define kmalloc_node(s, f, n) kmalloc(s, f) -#define kzalloc(s, f) __kzalloc(s, f) -#define kmalloc_track_caller kmalloc - -#define kmalloc_node_track_caller kmalloc_node - -#endif /* CONFIG_SLOB */ +#endif /* DEBUG_SLAB */ #endif /* __KERNEL__ */ - #endif /* _LINUX_SLAB_H */ + diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h new file mode 100644 index 000000000000..4b463e66ddea --- /dev/null +++ b/include/linux/slab_def.h @@ -0,0 +1,100 @@ +#ifndef _LINUX_SLAB_DEF_H +#define _LINUX_SLAB_DEF_H + +/* + * Definitions unique to the original Linux SLAB allocator. + * + * What we provide here is a way to optimize the frequent kmalloc + * calls in the kernel by selecting the appropriate general cache + * if kmalloc was called with a size that can be established at + * compile time. + */ + +#include <linux/init.h> +#include <asm/page.h> /* kmalloc_sizes.h needs PAGE_SIZE */ +#include <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */ +#include <linux/compiler.h> + +/* Size description struct for general caches. */ +struct cache_sizes { + size_t cs_size; + struct kmem_cache *cs_cachep; + struct kmem_cache *cs_dmacachep; +}; +extern struct cache_sizes malloc_sizes[]; + +static inline void *kmalloc(size_t size, gfp_t flags) +{ + if (__builtin_constant_p(size)) { + int i = 0; +#define CACHE(x) \ + if (size <= x) \ + goto found; \ + else \ + i++; +#include "kmalloc_sizes.h" +#undef CACHE + { + extern void __you_cannot_kmalloc_that_much(void); + __you_cannot_kmalloc_that_much(); + } +found: + return kmem_cache_alloc((flags & GFP_DMA) ? + malloc_sizes[i].cs_dmacachep : + malloc_sizes[i].cs_cachep, flags); + } + return __kmalloc(size, flags); +} + +static inline void *kzalloc(size_t size, gfp_t flags) +{ + if (__builtin_constant_p(size)) { + int i = 0; +#define CACHE(x) \ + if (size <= x) \ + goto found; \ + else \ + i++; +#include "kmalloc_sizes.h" +#undef CACHE + { + extern void __you_cannot_kzalloc_that_much(void); + __you_cannot_kzalloc_that_much(); + } +found: + return kmem_cache_zalloc((flags & GFP_DMA) ? + malloc_sizes[i].cs_dmacachep : + malloc_sizes[i].cs_cachep, flags); + } + return __kzalloc(size, flags); +} + +#ifdef CONFIG_NUMA +extern void *__kmalloc_node(size_t size, gfp_t flags, int node); + +static inline void *kmalloc_node(size_t size, gfp_t flags, int node) +{ + if (__builtin_constant_p(size)) { + int i = 0; +#define CACHE(x) \ + if (size <= x) \ + goto found; \ + else \ + i++; +#include "kmalloc_sizes.h" +#undef CACHE + { + extern void __you_cannot_kmalloc_that_much(void); + __you_cannot_kmalloc_that_much(); + } +found: + return kmem_cache_alloc_node((flags & GFP_DMA) ? + malloc_sizes[i].cs_dmacachep : + malloc_sizes[i].cs_cachep, flags, node); + } + return __kmalloc_node(size, flags, node); +} + +#endif /* CONFIG_NUMA */ + +#endif /* _LINUX_SLAB_DEF_H */ diff --git a/include/linux/smb_fs_sb.h b/include/linux/smb_fs_sb.h index 5b4ae2cc445c..3aa97aa4277f 100644 --- a/include/linux/smb_fs_sb.h +++ b/include/linux/smb_fs_sb.h @@ -55,7 +55,7 @@ struct smb_sb_info { * generation is incremented. */ unsigned int generation; - pid_t conn_pid; + struct pid *conn_pid; struct smb_conn_opt opt; wait_queue_head_t conn_wq; int conn_complete; diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h index 9df8833670cb..98a1d8cfb73d 100644 --- a/include/linux/sysrq.h +++ b/include/linux/sysrq.h @@ -37,23 +37,37 @@ struct sysrq_key_op { #ifdef CONFIG_MAGIC_SYSRQ +extern int sysrq_on(void); + +/* + * Do not use this one directly: + */ +extern int __sysrq_enabled; + /* Generic SysRq interface -- you may call it from any device driver, supplying * ASCII code of the key, pointer to registers and kbd/tty structs (if they * are available -- else NULL's). */ -void handle_sysrq(int, struct tty_struct *); -void __handle_sysrq(int, struct tty_struct *, int check_mask); -int register_sysrq_key(int, struct sysrq_key_op *); -int unregister_sysrq_key(int, struct sysrq_key_op *); +void handle_sysrq(int key, struct tty_struct *tty); +void __handle_sysrq(int key, struct tty_struct *tty, int check_mask); +int register_sysrq_key(int key, struct sysrq_key_op *op); +int unregister_sysrq_key(int key, struct sysrq_key_op *op); struct sysrq_key_op *__sysrq_get_key_op(int key); #else +static inline int sysrq_on(void) +{ + return 0; +} static inline int __reterr(void) { return -EINVAL; } +static inline void handle_sysrq(int key, struct tty_struct *tty) +{ +} #define register_sysrq_key(ig,nore) __reterr() #define unregister_sysrq_key(ig,nore) __reterr() diff --git a/include/linux/unwind.h b/include/linux/unwind.h index 749928c161fb..7760860fa170 100644 --- a/include/linux/unwind.h +++ b/include/linux/unwind.h @@ -14,63 +14,6 @@ struct module; -#ifdef CONFIG_STACK_UNWIND - -#include <asm/unwind.h> - -#ifndef ARCH_UNWIND_SECTION_NAME -#define ARCH_UNWIND_SECTION_NAME ".eh_frame" -#endif - -/* - * Initialize unwind support. - */ -extern void unwind_init(void); -extern void unwind_setup(void); - -#ifdef CONFIG_MODULES - -extern void *unwind_add_table(struct module *, - const void *table_start, - unsigned long table_size); - -extern void unwind_remove_table(void *handle, int init_only); - -#endif - -extern int unwind_init_frame_info(struct unwind_frame_info *, - struct task_struct *, - /*const*/ struct pt_regs *); - -/* - * Prepare to unwind a blocked task. - */ -extern int unwind_init_blocked(struct unwind_frame_info *, - struct task_struct *); - -/* - * Prepare to unwind the currently running thread. - */ -extern int unwind_init_running(struct unwind_frame_info *, - asmlinkage int (*callback)(struct unwind_frame_info *, - void *arg), - void *arg); - -/* - * Unwind to previous to frame. Returns 0 if successful, negative - * number in case of an error. - */ -extern int unwind(struct unwind_frame_info *); - -/* - * Unwind until the return pointer is in user-land (or until an error - * occurs). Returns 0 if successful, negative number in case of - * error. - */ -extern int unwind_to_user(struct unwind_frame_info *); - -#else - struct unwind_frame_info {}; static inline void unwind_init(void) {} @@ -85,12 +28,12 @@ static inline void *unwind_add_table(struct module *mod, return NULL; } -#endif - static inline void unwind_remove_table(void *handle, int init_only) { } +#endif + static inline int unwind_init_frame_info(struct unwind_frame_info *info, struct task_struct *tsk, const struct pt_regs *regs) @@ -122,6 +65,4 @@ static inline int unwind_to_user(struct unwind_frame_info *info) return -ENOSYS; } -#endif - #endif /* _LINUX_UNWIND_H */ diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index edef8d50b26b..2a7b38d87018 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -8,16 +8,21 @@ #include <linux/timer.h> #include <linux/linkage.h> #include <linux/bitops.h> +#include <asm/atomic.h> struct workqueue_struct; struct work_struct; typedef void (*work_func_t)(struct work_struct *work); +/* + * The first word is the work queue pointer and the flags rolled into + * one + */ +#define work_data_bits(work) ((unsigned long *)(&(work)->data)) + struct work_struct { - /* the first word is the work queue pointer and the flags rolled into - * one */ - unsigned long management; + atomic_long_t data; #define WORK_STRUCT_PENDING 0 /* T if work item pending execution */ #define WORK_STRUCT_NOAUTOREL 1 /* F if work item automatically released on exec */ #define WORK_STRUCT_FLAG_MASK (3UL) @@ -26,6 +31,9 @@ struct work_struct { work_func_t func; }; +#define WORK_DATA_INIT(autorelease) \ + ATOMIC_LONG_INIT((autorelease) << WORK_STRUCT_NOAUTOREL) + struct delayed_work { struct work_struct work; struct timer_list timer; @@ -36,13 +44,13 @@ struct execute_work { }; #define __WORK_INITIALIZER(n, f) { \ - .management = 0, \ + .data = WORK_DATA_INIT(0), \ .entry = { &(n).entry, &(n).entry }, \ .func = (f), \ } #define __WORK_INITIALIZER_NAR(n, f) { \ - .management = (1 << WORK_STRUCT_NOAUTOREL), \ + .data = WORK_DATA_INIT(1), \ .entry = { &(n).entry, &(n).entry }, \ .func = (f), \ } @@ -82,17 +90,21 @@ struct execute_work { /* * initialize all of a work item in one go + * + * NOTE! No point in using "atomic_long_set()": useing a direct + * assignment of the work data initializer allows the compiler + * to generate better code. */ #define INIT_WORK(_work, _func) \ do { \ - (_work)->management = 0; \ + (_work)->data = (atomic_long_t) WORK_DATA_INIT(0); \ INIT_LIST_HEAD(&(_work)->entry); \ PREPARE_WORK((_work), (_func)); \ } while (0) #define INIT_WORK_NAR(_work, _func) \ do { \ - (_work)->management = (1 << WORK_STRUCT_NOAUTOREL); \ + (_work)->data = (atomic_long_t) WORK_DATA_INIT(1); \ INIT_LIST_HEAD(&(_work)->entry); \ PREPARE_WORK((_work), (_func)); \ } while (0) @@ -114,15 +126,15 @@ struct execute_work { * @work: The work item in question */ #define work_pending(work) \ - test_bit(WORK_STRUCT_PENDING, &(work)->management) + test_bit(WORK_STRUCT_PENDING, work_data_bits(work)) /** * delayed_work_pending - Find out whether a delayable work item is currently * pending * @work: The work item in question */ -#define delayed_work_pending(work) \ - test_bit(WORK_STRUCT_PENDING, &(work)->work.management) +#define delayed_work_pending(w) \ + work_pending(&(w)->work) /** * work_release - Release a work item under execution @@ -143,7 +155,7 @@ struct execute_work { * This should also be used to release a delayed work item. */ #define work_release(work) \ - clear_bit(WORK_STRUCT_PENDING, &(work)->management) + clear_bit(WORK_STRUCT_PENDING, work_data_bits(work)) extern struct workqueue_struct *__create_workqueue(const char *name, @@ -188,7 +200,7 @@ static inline int cancel_delayed_work(struct delayed_work *work) ret = del_timer_sync(&work->timer); if (ret) - clear_bit(WORK_STRUCT_PENDING, &work->work.management); + work_release(&work->work); return ret; } |