All of lore.kernel.org
 help / color / mirror / Atom feed
* Char device write repeating
       [not found]       ` <CAK7rcp9BGzQTM0y=kHhqiJru45g1tbusgtkBRaw9jLM=R4UdsQ@mail.gmail.com>
@ 2016-10-04 14:58         ` Kenneth Adam Miller
  2016-10-04 15:05           ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Kenneth Adam Miller @ 2016-10-04 14:58 UTC (permalink / raw)
  To: kernelnewbies

I have a character device that I am calling write on and which is
succeeding, but which is repeatedly executing. I have hard coded the return
value to one, so I don't think the userland standard library is retrying
but I could be wrong. Can anybody tell me why write would be re-executed by
the kernel and how to fix it? I dont actually copy_from_user, I just need
this in order to signal kernel land.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20161004/78e0e141/attachment.html 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Char device write repeating
  2016-10-04 14:58         ` Char device write repeating Kenneth Adam Miller
@ 2016-10-04 15:05           ` Greg KH
  2016-10-04 18:42             ` Daniel.
  2016-10-05  6:29             ` Martin Kletzander
  0 siblings, 2 replies; 6+ messages in thread
From: Greg KH @ 2016-10-04 15:05 UTC (permalink / raw)
  To: kernelnewbies

On Tue, Oct 04, 2016 at 10:58:16AM -0400, Kenneth Adam Miller wrote:
> I have a character device that I am calling write on and which is succeeding,
> but which is repeatedly executing. I have hard coded the return value to one,
> so I don't think the userland standard library is retrying but I could be
> wrong. Can anybody tell me why write would be re-executed by the kernel and how
> to fix it? I dont actually copy_from_user, I just need this in order to signal
> kernel land.

Do you have a pointer to your code somewhere?  This is a very common bug
that people have...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Char device write repeating
  2016-10-04 15:05           ` Greg KH
@ 2016-10-04 18:42             ` Daniel.
  2016-10-05 12:44               ` François
  2016-10-05  6:29             ` Martin Kletzander
  1 sibling, 1 reply; 6+ messages in thread
From: Daniel. @ 2016-10-04 18:42 UTC (permalink / raw)
  To: kernelnewbies

Because the libc is calling it again based on what has been passed as
argument and what was received as return value. Here is one example
https://gist.github.com/gkos/5479135. I don't really know if this code is
working since I made it a long time ago.

Regards,

2016-10-04 12:05 GMT-03:00 Greg KH <greg@kroah.com>:

> On Tue, Oct 04, 2016 at 10:58:16AM -0400, Kenneth Adam Miller wrote:
> > I have a character device that I am calling write on and which is
> succeeding,
> > but which is repeatedly executing. I have hard coded the return value to
> one,
> > so I don't think the userland standard library is retrying but I could be
> > wrong. Can anybody tell me why write would be re-executed by the kernel
> and how
> > to fix it? I dont actually copy_from_user, I just need this in order to
> signal
> > kernel land.
>
> Do you have a pointer to your code somewhere?  This is a very common bug
> that people have...
>
> thanks,
>
> greg k-h
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>



-- 
*"Do or do not. There is no try"*
  *Yoda Master*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20161004/40f3829d/attachment.html 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Char device write repeating
  2016-10-04 15:05           ` Greg KH
  2016-10-04 18:42             ` Daniel.
@ 2016-10-05  6:29             ` Martin Kletzander
  2016-10-05 11:30               ` Kenneth Adam Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Martin Kletzander @ 2016-10-05  6:29 UTC (permalink / raw)
  To: kernelnewbies

On Tue, Oct 04, 2016 at 05:05:57PM +0200, Greg KH wrote:
>On Tue, Oct 04, 2016 at 10:58:16AM -0400, Kenneth Adam Miller wrote:
>> I have a character device that I am calling write on and which is succeeding,
>> but which is repeatedly executing. I have hard coded the return value to one,

Correct me if I'm wrong, I'm just a self-thought newbie, but this ^^
sounds to me like the problem.  Because the write should return how many
bytes were written (or error), the function is being called until it's
been all written.  If you just want to be called once and you don't care
what the data are (which is the weird thing in the first place), I think
you should return the length you got as an argument.

>> so I don't think the userland standard library is retrying but I could be
>> wrong. Can anybody tell me why write would be re-executed by the kernel and how
>> to fix it? I dont actually copy_from_user, I just need this in order to signal
>> kernel land.
>
>Do you have a pointer to your code somewhere?  This is a very common bug
>that people have...
>
>thanks,
>
>greg k-h
>
>_______________________________________________
>Kernelnewbies mailing list
>Kernelnewbies at kernelnewbies.org
>https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: Digital signature
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20161005/f0fb88d5/attachment.bin 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Char device write repeating
  2016-10-05  6:29             ` Martin Kletzander
@ 2016-10-05 11:30               ` Kenneth Adam Miller
  0 siblings, 0 replies; 6+ messages in thread
From: Kenneth Adam Miller @ 2016-10-05 11:30 UTC (permalink / raw)
  To: kernelnewbies

I didn't know it, but I had my poll and write messages switched in userland
under await and send signal implementations of types. Sorry, it works now,
it wasn't the kernel land repeatedly executing it. I wasn't sure, so I was
still debugging. Anyway, thanks a lot though.

On Oct 5, 2016 2:29 AM, "Martin Kletzander" <mkletzan@redhat.com> wrote:

> On Tue, Oct 04, 2016 at 05:05:57PM +0200, Greg KH wrote:
>
>> On Tue, Oct 04, 2016 at 10:58:16AM -0400, Kenneth Adam Miller wrote:
>>
>>> I have a character device that I am calling write on and which is
>>> succeeding,
>>> but which is repeatedly executing. I have hard coded the return value to
>>> one,
>>>
>>
> Correct me if I'm wrong, I'm just a self-thought newbie, but this ^^
> sounds to me like the problem.  Because the write should return how many
> bytes were written (or error), the function is being called until it's
> been all written.  If you just want to be called once and you don't care
> what the data are (which is the weird thing in the first place), I think
> you should return the length you got as an argument.
>
> so I don't think the userland standard library is retrying but I could be
>>> wrong. Can anybody tell me why write would be re-executed by the kernel
>>> and how
>>> to fix it? I dont actually copy_from_user, I just need this in order to
>>> signal
>>> kernel land.
>>>
>>
>> Do you have a pointer to your code somewhere?  This is a very common bug
>> that people have...
>>
>> thanks,
>>
>> greg k-h
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20161005/5464d2bb/attachment.html 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Char device write repeating
  2016-10-04 18:42             ` Daniel.
@ 2016-10-05 12:44               ` François
  0 siblings, 0 replies; 6+ messages in thread
From: François @ 2016-10-05 12:44 UTC (permalink / raw)
  To: kernelnewbies

On Tue, Oct 04, 2016 at 03:42:52PM -0300, Daniel. wrote:
> Because the libc is calling it again based on what has been passed as
> argument and what was received as return value. Here is one example
> https://gist.github.com/gkos/5479135. I don't really know if this code is
> working since I made it a long time ago.

Your test to check wether the device is already open looks weak to me.
You should rather use atomic operations such as described in [1] or
mutex like in [2].

[1] http://www.oreilly.com/openbook/linuxdrive3/book/ch06.pdf p 40
[2] http://pete.akeo.ie/2011/08/writing-linux-device-driver-for-kernels.html

-- 
Fran?ois

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-10-05 12:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAK7rcp8HTmpVDZHDMw75Oep1eGS+efs5EUUh26mFvWmXaFVGCg@mail.gmail.com>
     [not found] ` <CAK7rcp9akHJ4E1Ms9HwsNWTpnDjPyGcf8OE+an2bRDCbVLAO7g@mail.gmail.com>
     [not found]   ` <CAK7rcp-1GfT3M9bNA-STDhgXjO9WX+SCZoAGZgYo_uZZjA-TAA@mail.gmail.com>
     [not found]     ` <CAK7rcp9yVW2m9pRCB=dTFrN6Pey+_1FukP2xfizaKY5_T5RP6Q@mail.gmail.com>
     [not found]       ` <CAK7rcp9BGzQTM0y=kHhqiJru45g1tbusgtkBRaw9jLM=R4UdsQ@mail.gmail.com>
2016-10-04 14:58         ` Char device write repeating Kenneth Adam Miller
2016-10-04 15:05           ` Greg KH
2016-10-04 18:42             ` Daniel.
2016-10-05 12:44               ` François
2016-10-05  6:29             ` Martin Kletzander
2016-10-05 11:30               ` Kenneth Adam Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.