Re: [PATCH v4] mm: cma: support sysfs

Minchan Kim
2021-03-19T19:04:29Z

On Fri, Mar 19, 2021 at 09:48:11PM +0300, Dmitry Osipenko wrote:
> 19.03.2021 21:21, Minchan Kim пишет:
> > On Fri, Mar 19, 2021 at 08:56:06PM +0300, Dmitry Osipenko wrote:
> >> 19.03.2021 19:30, Minchan Kim пишет:
> >>> +static void cma_kobj_release(struct kobject *kobj)
> >>> +{
> >>> + struct cma_kobject *cma_kobj = container_of(kobj, struct cma_kobject, kobj);
> >>> +
> >>> + kfree(cma_kobj);
> >>> +}
> >>
> >> Oh, wait.. I think this kfree wrong since cma_kobj belongs to the array.
> >
> > Oh, good spot. Let me use kzalloc.
> >
>
> Thinking a bit more about this.. it looks like actually it should be
> better to get back to the older variant of cma_stat, but allocate at the
> time of CMA initialization, rather than at the time of sysfs
> initialization. Then the cma_stat will be decoupled from the cma struct

IIRC, the problem was slab was not initiaized at CMA init point.
That's why I liked your suggestion.

> and cma_stat will be a self-contained object.

Yeah, self-contained is better but it's already weird to
have differnt lifetime for one object since CMA object
never die, technically.