Re: [PATCH 3/3] Revert "f2fs: use kvmalloc, if kmalloc is failed"

From: Eric Biggers
Date: Mon Nov 04 2019 - 21:38:40 EST


On Tue, Nov 05, 2019 at 10:17:41AM +0800, Chao Yu wrote:
> On 2019/11/5 8:02, Jaegeuk Kim wrote:
> > On 11/01, Chao Yu wrote:
> >> This reverts commit 5222595d093ebe80329d38d255d14316257afb3e.
> >>
> >> As discussed with Eric, as kvmalloc() will try kmalloc() first, so
> >> when we need allocate large size memory, it'd better to use
> >> f2fs_kvmalloc() directly rather than adding additional fallback
> >> logic to call kvmalloc() after we failed in f2fs_kmalloc().
> >>
> >> In order to avoid allocation failure described in original commit,
> >> I change to use f2fs_kvmalloc() for .free_nid_bitmap bitmap memory.
> >
> > Is there any problem in the previous flow?
>
> No existing problem, however, it's redundant to introduce fallback flow in
> f2fs_kmalloc() like vmalloc() did, since we can call f2fs_vmalloc() directly in
> places where we need large memory.
>
> Thanks,
>

f2fs_kmalloc() also violated the naming convention used everywhere else in the
kernel since it could return both kmalloc and vmalloc memory, not just kmalloc
memory. That's really error-prone since people would naturally assume it's safe
to free the *_kmalloc()-ed memory with kfree().

- Eric