[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6bc141d2-ca07-7f03-c306-683f0f630605@gmail.com>
Date: Fri, 19 Mar 2021 21:59:08 +0300
From: Dmitry Osipenko <digetx@...il.com>
To: Minchan Kim <minchan@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-mm <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>, joaodias@...gle.com,
willy@...radead.org, david@...hat.com, surenb@...gle.com,
John Hubbard <jhubbard@...dia.com>,
Nicolas Chauvet <kwizart@...il.com>,
"linux-tegra@...r.kernel.org" <linux-tegra@...r.kernel.org>
Subject: Re: [PATCH v4] mm: cma: support sysfs
19.03.2021 21:18, Minchan Kim пишет:
>>> + if (ZERO_OR_NULL_PTR(cma_kobjs))
>>> + goto out;
>>> +
>>> + do {
>>> + cma = &cma_areas[i];
>>> + cma->kobj = &cma_kobjs[i];
>> Does cma really need are pointer to cma_kobj?
> Do you mean something like this?
>
> struct cma {
> ..
> ..
> struct kobject *kobj;
> };
>
> Then, how could we we make kobject dynamic model?
>
> We need to get struct cma from kboj like below.
>
> static ssize_t alloc_pages_success_show(struct kobject *kobj,
> struct kobj_attribute *attr, char *buf)
> {
> struct cma_kobject *cma_kobj = container_of(kobj,
> struct cma_kobject, kobj);
> struct cma *cma = cma_kobj->cma;
>
> return sysfs_emit(buf, "%llu\n",
> atomic64_read(&cma->nr_pages_succeeded));
> }
>
> So kobj should be not a pointer in the container struct.
> Am I missing your point? Otherwise, it would be great if you suggest
> better idea.
I meant that cma_kobj->cma is okay, but cma->kobj wasn't really used
anywhere since struct cma can't be released. I.e. we could write
kobject_put(&cma->kobj->kobj) as kobject_put(&cma_kobjs[i].kobj);
But since we won't use the array anymore and maybe will get back to use
the cma_stat, then it will be fine to add the pointer.
Powered by blists - more mailing lists