Re: [PATCH v5 6/6] zsmalloc: Implement writeback mechanism for zsmalloc
From: Minchan Kim
Date: Fri Nov 18 2022 - 17:38:49 EST
On Fri, Nov 18, 2022 at 02:08:08PM -0800, Nhat Pham wrote:
> Thanks a lot for the suggestions so far and for the review, Minchan!
> Quick question about your last comment:
>
> >> +#ifdef CONFIG_ZPOOL
> >
> > Let's remove the ifdef machinery here.
> >
> >> + /* Free all deferred handles from zs_free */
> >> + free_handles(pool, zspage);
> >> +#endif
>
> free_handles() here is for the deferred handle freeing, which is also
> under CONFIG_ZPOOL now, so I don't think we should remove the #ifdef
> CONFIG_ZPOOL here, no? Let me know if I'm misunderstanding your
> suggestion, or if you have any further comments regarding this patch.
What I meant is
#ifdef CONFIG_ZPOOL
/*
* Free all the deferred handles whose objects are freed in zs_free.
*/
static void free_handles(struct zs_pool *pool, struct zspage *zspage)
{
unsigned long handle = (unsigned long)zspage->deferred_handles;
while (handle) {
unsigned long nxt_handle = handle_to_obj(handle);
cache_free_handle(pool, handle);
handle = nxt_handle;
}
}
#else
static inline void free_handles(struct zs_pool *pool, struct zspage *zspage) {}
#endif
And then we could do
__free_zspage
free_handles(pool, zspage);
So without CONFIG_ZPOOL, the free_nandles function will be void.