Re: [PATCH v36 2/5] virtio_balloon: replace oom notifier with shrinker

From: Wei Wang
Date: Mon Jul 23 2018 - 21:45:09 EST


On 07/23/2018 10:13 PM, Michael S. Tsirkin wrote:
vb->vb_dev_info.inode->i_mapping->a_ops = &balloon_aops;
#endif
+ err = virtio_balloon_register_shrinker(vb);
+ if (err)
+ goto out_del_vqs;
So we can get scans before device is ready. Leak will fail
then. Why not register later after device is ready?
Probably no.

- it would be better not to set device ready when register_shrinker failed.
That's very rare so I won't be too worried.

Just a little confused with the point here. "very rare" means it still could happen (even it's a corner case), and if that happens, we got something wrong functionally. So it will be a bug if we change like that, right?

Still couldn't understand the reason of changing shrinker_register after device_ready (the original oom notifier was registered before setting device ready too)?
(I think the driver won't get shrinker_scan called if device isn't ready because of the reasons below)

- When the device isn't ready, ballooning won't happen, that is,
vb->num_pages will be 0, which results in shrinker_count=0 and shrinker_scan
won't be called.

Best,
Wei