Reputation: 4517
From http://www.makelinux.net/ldd3/chp-7-sect-1.shtml
Needless to say, both
jiffies
andjiffies_64
must be considered read-only
I wrote a program to verify and it successfully updates the jiffies
value.
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/jiffies.h>
static int __init test_hello_init(void)
{
jiffies = 0;
pr_info("jiffies:%lu\n", jiffies);
return 0;
}
static void __exit test_hello_exit(void)
{
}
MODULE_LICENSE("GPL");
module_init(test_hello_init);
module_exit(test_hello_exit);
This module successfully sets the jiffies
to zero. Am I missing something?
Upvotes: 0
Views: 565
Reputation: 69286
What you are reading is merely a warning. It is an unwritten contract between you (kernel module developer) and the kernel. You shouldn't modify the value of jiffies
since it is not up to you to do so, and is updated by the kernel according to a set of complicated rules that you should not worry about. The jiffies
value is used internally by the scheduler, so bad things can happen modifying it. Chances are that the variable you see in your module is only a thread-local copy of the real one, so modifying could have no effect. In any case, you shouldn't do it. It is only provided to you as additional information that your module might need to know to implement some logic.
Of course, since you are working in C, there is no concept of "permissions" for variables. Anything that is mapped in a readable and writable region of memory can be modified, you could even modify data in read-only memory by changing the permissions first. You can do all sorts of bad stuff if you want. There are a lot of things you're not supposed to alter, even if you have the ability to do so.
Upvotes: 2