On Mon, Oct 4, 2010 at 11:28 AM, Vimal <j.vimal@xxxxxxxxx> wrote: > Hi, > > I am trying to setup a workqueue to defer computation intensive work > in a performance critical path. I read about the workqueue mechanism > in the LDD3 book; however, the API seems to be different now. > > Specifically: the LDD3 book says that we can create a work_struct and > initialise it as follows: > > INIT_WORK(struct work_struct *work, void (*fn)(void *), void *data); > > However, in 2.6.35, I am unable to see the "data" argument to the > INIT_WORK macro. Also, the "fn" pointer definition has changed to: > void (*fn)(struct work_struct *). > > I could get away with initialising the work_struct myself, by looking > at the fields and setting "data" accordingly (work->data is of type > atomic_long_t), but I think they are supposed to be opaque. Could > someone clarify how I should go about doing this? You have to use container_of() here. For example struct cpufreq_policy { ...... .... struct work_struct update; ........ }; static void handle_update(struct work_struct *work) { struct cpufreq_policy *policy = container_of(work, struct cpufreq_policy, update); ............. ............. } module_init() { struct cpufreq_policy policy; ........ ........ INIT_WORK(&policy, handle_update); .......... } Hope this helps. Arun > > Or, is there a different way of implementing the requirement? (defer > computation intensive work in a performance critical path.) > > Thanks, > -- > Vimal > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx > Please read the FAQ at http://kernelnewbies.org/FAQ > > -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ