lkml.org 
[lkml]   [2021]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v12 15/17] counter: Implement events_queue_size sysfs attribute
From
Date
On 7/10/21 11:08 AM, David Lechner wrote:
> On 7/10/21 10:43 AM, David Lechner wrote:
>> On 7/10/21 5:25 AM, William Breathitt Gray wrote:
>>>> and after that
>>>>
>>>> [   16.564403] ================================================
>>>> [   16.570725] WARNING: lock held when returning to user space!
>>>> [   16.577044] 5.13.0-next-20210706+ #4 Not tainted
>>>> [   16.582198] ------------------------------------------------
>>>> [   16.588507] cat/331 is leaving the kernel with locks still held!
>>>> [   16.595214] 1 lock held by cat/331:
>>>> [   16.599103]  #0: ffff888102bb3630
>>>> (&counter->chrdev_lock){+.+.}-{3:3}, at: counter_chrdev_open+0x21/0x60
>>>> [counter]
>>>>
>>>> Jarkko
>>> I'm not sure how to resolve this warning. The purpose of this lock is to
>>> limit chrdev to a single open at a time. To accomplish this I grab this
>>> lock in counter_chrdev_open() and hold it until counter_chrdev_release()
>>> is called. Is there a better way to accomplish this?
>>
>> How about using an atomic flag, e.g test_and_set_bit()?
>
> Another option could be to rethink it at a higher level and avoid the
> need for a lock (and sysfs attribute) altogether. For example, would it
> work to (re)allocate the kfifo buffer in the COUNTER_ENABLE_EVENTS_IOCTL
> callback and add a parameter to that ioctl to specify the buffer size
> (with units of events rather than bytes)?
>

Thinking about it a bit more, this probably isn't a good suggestion.
It would create issues with being able to start reading from the chrdev
before enabling events.

\
 
 \ /
  Last update: 2021-07-10 19:54    [W:1.837 / U:0.620 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site