NavigationUser loginSpam?See spam posts on this site? If so, please don't reply to the spam! Instead, just report the URL to the webmaster. |
Logging messagesHello, I want to add code to a device driver which logs the timestamp every time a particular function is invoked. How do I do this? Thanks .. |
Logging messages
I think the kernel adds the timestamp. Try:
printk(KERN_INFO "A number: %d\n", some_integer_variable);
Be very careful; in device drivers it is very easy to spam the log and make your computer useless.
Kernel msgs
Well, how can I avoid teh spamming? Can I write to my own logfile? Is there any special way f doing it? Or should I just write to a file? I am afraid file i/o might slow down the driver, especially since this is the network driver that I plan on modifying. (Actually, all I need is the timestamp in the skb data structure)
Kernel msgs
I don't know what you're doing so I can't tell you how to avoid spamming. I don't even know why you want to print out timestamps in a network driver. The printk is output to file (or stdout if you use KERN_DEBUG in the statement); either way, if you're going to have high network traffic, unless the printk is in a "bottom half" tasklet, you're going to completely foul the entire system. Even if you didn't foul the OS itself, you will render the computer useless with 100% of CPU time spent on printing messages. You need to think very carefully about what you want to do and how it can be done, but you definitely should not print numerous messages from any driver.
If you're really desperate to show some values at much longer intervals (average, peak, etc), you can consider exporting module parameters as 'read only' and putting in debug code which collects the information you want and stores it in those module params.
Re: Kernel msgs
There are ways to reduce output of printk. here is a good overview
http://www.linuxchix.org/content/courses/kernel_hacking/lesson5
---
Contact Center Services
This Is A Test Comment
This is a TEST Comment
Salman Khan
Salman Khan
http://www.google.com/