[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <09e60732-6a46-dd00-f9d5-4ef17ee685c8@nvidia.com>
Date: Tue, 9 Feb 2021 12:11:20 -0800
From: John Hubbard <jhubbard@...dia.com>
To: Greg KH <gregkh@...uxfoundation.org>,
Minchan Kim <minchan@...nel.org>
CC: Andrew Morton <akpm@...ux-foundation.org>,
linux-mm <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>, <surenb@...gle.com>,
<joaodias@...gle.com>, <willy@...radead.org>
Subject: Re: [PATCH v2] mm: cma: support sysfs
On 2/9/21 9:49 AM, Greg KH wrote:
>>> That's fine if you want to add it to the parent. If so, then the
>>> kobject controls the lifetime of the structure, nothing else can.
>>
>> The problem was parent object(i.e., struct cma cma_areas) is
>> static arrary so kobj->release function will be NULL or just
>> dummy. Is it okay? I thought it was one of the what you wanted
>> to avoid it.
>
> No, that is not ok.
>
>>> Either is fine with me, what is "forbidden" is having a kobject and
>>> somehow thinking that it does not control the lifetime of the structure.
>>
>> Since parent object is static arrary, there is no need to control the
>> lifetime so I am curious if parent object approach is okay from kobject
>> handling point of view.
>
> So the array is _NEVER_ freed? If not, fine, don't provide a release
> function for the kobject, but ick, just make a dynamic kobject I don't
> see the problem for something so tiny and not very many...
>
Yeah, I wasn't trying to generate so much discussion, I initially thought it
would be a minor comment: "just use an embedded struct and avoid some extra
code", at first.
> I worry that any static kobject might be copied/pasted as someone might
> think this is an ok thing to do. And it's not an ok thing to do.
>
Overall, then, we're seeing that there is a small design hole: in order
to use sysfs most naturally, you either much provide a dynamically allocated
item for it, or you must use the static kobject, and the second one sets a
bad example.
I think we should just use a static kobject, with a cautionary comment to
would-be copy-pasters, that explains the design constraints above. That way,
we still get a nice, less-code implementation, a safe design, and it only
really costs us a single carefully written comment.
thanks,
--
John Hubbard
NVIDIA
Powered by blists - more mailing lists