Quantcast
Viewing all articles
Browse latest Browse all 22018

How can I tell the compiler/CPU to execute instructions back to back in kernel space's code?

How can I tell the compiler not to optimize and not to add any other instructions in between, and force the CPU to execute them back to back?

For example I'd like the kernel module to execute write (or read or mixed) commands as fast as possible

writel(0, addr);
writel(1, addr);
writel(0, addr);

or

writel(0, addr1);
writel(1, addr2);
writel(0, addr3);

Edit:

  • I replaced iowrite32 with writel that has a definition with volatile void __iomem *addr

  • addr* can be allocated with dma_alloc_coherent() or simply ioremap().

  • My question isn't about order of execution (that is solved with memory barrier or volatile) but delay between them.

  • Might be possible by combining my commands in a single assembly asm volatile() but I'd rather use something safer.


Viewing all articles
Browse latest Browse all 22018

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>