[linux-mm-cc] [PATCH 3/4] compcache: send callback when swap slot is freed

Nitin Gupta ngupta at vflare.org
Mon Aug 24 02:40:20 EDT 2009


On Mon, Aug 24, 2009 at 10:07 AM, Nitin Gupta<ngupta at vflare.org> wrote:

<snip>

> +/*
> + * Sets callback for event when swap_map[offset] == 0
> + * i.e. page at this swap offset is no longer used.
> + */
> +void set_swap_free_notify(struct block_device *bdev,
> +                       swap_free_notify_fn *notify_fn)
> +{
> +       unsigned int i;
> +       struct swap_info_struct *sis;
> +
> +       spin_lock(&swap_lock);
> +       for (i = 0; i <= nr_swapfiles; i++) {
> +               sis = &swap_info[i];
> +               if (!(sis->flags & SWP_USED))
> +                       continue;
> +               if (sis->bdev == bdev)
> +                       break;
> +       }
> +

> +       /* swap device not found */
> +       if (i > nr_swapfiles)
> +               return;

How could I miss this! We need to unlock before this return. I will
send revised diffs once I get additional reviews.


> +
> +       BUG_ON(!sis || sis->swap_free_notify_fn);
> +       sis->swap_free_notify_fn = notify_fn;
> +       spin_unlock(&swap_lock);
> +
> +       return;
> +}
> +EXPORT_SYMBOL_GPL(set_swap_free_notify);
> +


Nitin


More information about the linux-mm-cc mailing list