Conversation
Signed-off-by: Dmitriy Ganshin <d.hanshyn@gmail.com>
DevyatovAndrey
left a comment
There was a problem hiding this comment.
Please provide PR description and changes.
| if (delay) | ||
| mod_timer(&timer, jiffies + msecs_to_jiffies(delay * HZ)); | ||
| else | ||
| del_timer(&timer); |
There was a problem hiding this comment.
Once deleted how would it be inited back?
What if user consequently adjust spam times to 10 sec, 0, 5 sec?
There was a problem hiding this comment.
If the delay is less than 1 then the timer will be stopped.
The timer will be turned on again after the delay is set to be greater than or equal to 1.
99 if (tmp) {
100 pr_info("delay: %ld\n", delay);
101 timer_update();
The spam period of the message can only be set to an integer value, because the delay is an integer value. 0.5 s can not be installed, you can from 1c
| class_remove_file(attr_class, &class_attr_previous_ads); | ||
| class_destroy(attr_class); | ||
|
|
||
| del_timer(&timer); |
There was a problem hiding this comment.
del_timer(&timer);
What if timer is already deleted by timer_update ?
There was a problem hiding this comment.
Will delete the already deleted timerю
I can add the timer_pedding () function to check if the timer is running.
There was a problem hiding this comment.
Cool!
Could you please provide the log of such behavior?
- Start timer with some interval
- Adjust interval to zero
- rmmod the driver
There was a problem hiding this comment.
insmod module_time.ko
echo "1" > /sys/class/time_module/spam
echo "0" > /sys/class/time_module/spam
rmmod module_time.ko
dmesg
[ 3090.780090] mymodule: module loaded
[ 3090.780090] Create:
[ 3090.780090] /sys/class/time_module/
[ 3096.150538] delay setting:
[ 3096.150922] delay: 1
[ 3097.184634] uptime module 6 s.
[ 3098.208571] uptime module 7 s.
[ 3099.232588] uptime module 8 s.
[ 3100.256579] uptime module 9 s.
[ 3101.280518] uptime module 10 s.
[ 3102.304590] uptime module 11 s.
[ 3103.328536] uptime module 12 s.
[ 3104.352584] uptime module 13 s.
[ 3105.376513] uptime module 14 s.
[ 3106.400605] uptime module 15 s.
[ 3106.729052] delay setting:
[ 3106.729264] delay: 0
[ 3112.811275] mymodule: module exited
[ 3112.811275] Remove:
[ 3112.811275] /sys/class/time_module/
|
Please add PR description |
|
Implemented a kernel module with an API in sysfs.
The module creates the time_module class in / sys / class /. The module provides 3 attributes:
previous(ro) - returns the relative time (in seconds) elapsed from the previous reading
revious_abs(ro) - returns the absolute time of the previous reading;
spam(rw) - periodically printed message how much time has elapsed since the module was started, period can be customized.