title: Polling control register of a device in user space to check errors
body: <p>I am writing code to log errors in user space occurring on a PCI device(Kernel already logs them in kernel ring buffer). Currently, I have two approaches in front of me,</p>
  
  <ol>
  <li><p>Modify kernel device driver to send an interrupt to my user space process (using eventfd) and then upon receiving this interrupt (using select() or poll()) I can fetch the detailed error information using ioctl (will require a change in device driver). This requires changes in the kernel code which I would like to avoid.</p></li>
  <li><p>My process runs as a root, so, I can read/write error status registers of the device using sysfs. For this, I will have to constantly poll the registers and once the error happens I can read the status register, decode it, get the detailed error information and then clear the registers.</p></li>
  </ol>
  
  <p>I am more inclined towards the second approach as it requires changes only in the the user space. </p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Does the second approach even make sense?</li>
  <li>If it does then what are the pros and cons of both the approaches?</li>
  <li>Polling in second approach will result in wastage of CPU cycles. Does use of select() or poll() in first approach also results in the wastage of CPU cycles in similar proportions.</li>
  </ol>
  
  <p>Helpful response will be greatly appreciated! :)</p>