lkml.org 
[lkml]   [2006]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] add execute_in_process_context() API
    Dave Jones <davej@redhat.com> wrote:
    >
    > On Tue, Feb 07, 2006 at 02:00:19PM -0600, James Bottomley wrote:
    > > +int execute_in_process_context(void (*fn)(void *data), void *data)
    > > +{
    > > + struct work_queue_work *wqw;
    > > +
    > > + if (!in_interrupt()) {
    > > + fn(data);
    > > + return 0;
    > > + }
    > > +
    > > + wqw = kmalloc(sizeof(struct work_queue_work), GFP_ATOMIC);
    > > +
    > > + if (unlikely(!wqw)) {
    > > + printk(KERN_ERR "Failed to allocate memory\n");
    > > + WARN_ON(1);
    > > + return -ENOMEM;
    > > + }
    > > +
    > > + INIT_WORK(&wqw->work, execute_in_process_context_work, wqw);
    > > + wqw->fn = fn;
    > > + wqw->data = data;
    > > + schedule_work(&wqw->work);
    > > +
    > > + return 1;
    > > +}
    >
    > After the workqueue has run, what free's wqw ?
    >

    The callback (execute_in_process_context_work())

    The trap with this patch is that the caller has to run
    flush_scheduled_work() at the right time. But hopefully anyone who's using
    it knows that by now.

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-02-07 21:38    [W:0.023 / U:0.220 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site