title: How to gracefully exit from a blocking kernel_recvmsg()?
body: <p>I have the following running in a kernel thread:</p>
  
  <pre><code>size = kernel_recvmsg(kthread-&gt;sock, &amp;msg, &amp;iov, 1, bufsize, MSG_DONTWAIT)
  </code></pre>
  
  <p>I receive UDP packets very frequently (every 10ms let's say). In order to process them as fast as possible I don't have any sleep in the loop where the kernel_recvmsg() is. Unfortunately I observe very big CPU consumption while the UDP packets are not coming.
  If I make the socket blocking (remove the MSG_DONTWAIT) is there some indirect way to unblock and exit from kernel_recvmsg()..?</p>
  
  <p>What would happen if I do unexpected sock_release()? Should kernel_recvmsg() unblock and return some error and I could handle it accordingly (exit from the loop and thread)?</p>