RE: create a kernel socket from interrupt context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Title: RE: create a kernel socket from interrupt context

Hi Mark,

Use Workqueues as a deferred procedure call and not the tasklet or softIRQ. SoftIRQs and tasklets cannot sleep.
Thumb rule is if the deferred work needs to sleep, worq queues are used.

--
Regards,
Gaurav Aggarwal

-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx
[mailto:kernelnewbies-bounce@xxxxxxxxxxxx]On Behalf Of Mark Ryden
Sent: Friday, February 23, 2007 1:58 PM
To: kernelnewbies@xxxxxxxxxxxx
Subject: Re: create a kernel socket from interrupt context


Hi,

Thanks, Topi.

 I tried two things:
  First , create a work queue and calling it from the interrupt.
  what happens is that  queue_work() fails. (The return value from
queue_work()  is NOT 1 ).

So I looked into it and found that the problem is that I am in fact in
software interrupt context, not in hw interrupt context.
After looking for solutions and reading about this,I found out that
what I should use for software interrupts is a  tasklet.
So I inserted taskets and the tasklet function is indeed called from
the software interrupt context.
The problem is that when I try to send a packet from a tasklet I have the same
error; "sleeping function called from invalid context".
Is there some way out of this ? I mean, to send packets from software
interrupt context ?

Regards,
Mark




On 2/22/07, Mark Ryden <markryde@xxxxxxxxx> wrote:
> Hello,
>
> Is it possible somehow to create a TCP socket from kernel and to send
> a message when you are in interrupt context ?
> I made a test : I created a kernel socket with
> sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock)
> and then connected it with:
> sock->ops->connect(sock,
>                                                                          (struct sockaddr*)&addr,
>                                                                          sizeof(struct sockaddr), 0)
>
> When working NOT in interrupt context,it works OK;  I called :
> kernel_sendmsg(sock, &msg, &iov, 1, length);
> and a TCP packet WAS sent (I verified it with a sniffer)
>
> BUT, in interrupt context, I called :
> kernel_sendmsg(sock, &msg, &iov, 1, length);
>
> I got:
> Feb 22 12:02:54 markhost kernel: BUG: sleeping function called from
> invalid context
> Feb 22 12:02:54 markhost: in_atomic():1, irqs_disabled():0
>
> Why is it so ? is there another way create a kernel TCP socket
> and to send a packet?
>
> Regards,
> Mark
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


The information contained in this electronic mail transmission may be privileged and confidential, and therefore, protected from disclosure. If you have received this communication in error, please notify us immediately by replying to this message and deleting it from your computer without copying or disclosing it.

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux