[..] > >> > >> - p->zeromap = bitmap_zalloc(maxpages, GFP_KERNEL); > >> + p->zeromap = kvzalloc(DIV_ROUND_UP(maxpages, 8), GFP_KERNEL); > > No, 8 is not right for 32-bit kernels. I think you want > > p->zeromap = kvzalloc(BITS_TO_LONGS(maxpages), GFP_KERNEL); > > but please check it carefully, I'm easily confused by such conversions. > > > > Hugh > > Ah yes, didnt take into account 32-bit kernel. I think its supposed to be > > p->zeromap = kvzalloc(BITS_TO_LONGS(maxpages) * sizeof(unsigned long), > GFP_KERNEL); You can do something similar to bitmap_zalloc() and use: kvmalloc_array(BITS_TO_LONGS(nbits), sizeof(unsigned long), GFP_KERNEL | __GFP_ZERO) I don't see a kvzalloc_array() variant to use directly, but it should be trivial to add it. I can see other users of kvmalloc_array() that pass in __GFP_ZERO (e.g. fs/ntfs3/bitmap.c). , or you could take it a step further and add bitmap_kvzalloc(), assuming the maintainers are open to that. The main reason I want to avoid doing the multiplication inline is because kvmalloc_array() has a check_mul_overflow() check, and I assume it must have been added for a reason.