Does __free_page() will sleep?

mofaph mofaph at gmail.com
Mon Aug 11 04:21:36 EDT 2014


Hi, all.

I alloc a bio and add some pages into it, can I free bio and pages in
bi_end_io()?

For example, here is some code snipets:

================================================================================

/* This is in irq context, we can't sleep here. So, does __free_page()
will sleep? */
int my_end_io(struct bio *bio, int error)
{
    struct page *page = bio->bi_private;
    __free_page(page);
    bio_put(bio);
    return 0;
}

int some_function(int rw)
{
    bio = bio_alloc(GFP_KERNEL, 1);
    page = page_alloc();

    bio_add_page(bio, page, PAGE_SIZE, 0);
    bio->bi_end_io = my_end_io;
    bio->bi_private = page;

    submit_bio(rw, bio);
}

================================================================================

Thanks.

mofaph at gmail.com
2014/8/11



More information about the Kernelnewbies mailing list