Hi Peter, Matthias et al,
Sorry for the delay. Thanks for all your feedback so far !
I'll try to give a better description of the problem and what I think
I've learnt so far :
First, my small test module code has always used del_timer_sync() on
exit. The SAM9260 platform is a single CPU however, thus CONFIG_SMP is
not defined. As far as I can tell from kernel source, on a non-SMP
system del_timer_sync() is equated to del_timer() anyway.
Because I'm not used yet to set up a module through makefile (wrt
pulling in all the autoconfig defines etc) I'm manually including this.
I should note that it's possible the Kernel config is not set right for
my target, since the (factory default) examples show the build of a
executable, but that wouldn't work until I rebuilt the kernel with
CONFIG_EABI defined....
Here's the gist of my test code :
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<all my defines here, see below>
<all my includes here>
static int timer_tick = 1;
static void timer_fire(unsigned long);
static DEFINE_TIMER(timer_ticktock, 0, 0, 0);
module_param(timer_tick, int, 0);
MODULE_PARM_DESC(timer_tick, "Timer delay");
static void timer_fire(unsigned long data)
{
mod_timer(&timer_ticktock, jiffies + (timer_tick*HZ));
printk ("Timer fired at %lu jiffies [%lX]\n", jiffies, data);
}
static int __init timer_init(void)
{
timer_ticktock.data = (unsigned long) current;
unsigned long expire = (timer_tick*HZ) + jiffies;
init_timer(&timer_ticktock);
timer_ticktock.expires = expire;
timer_ticktock.data = (unsigned long) current;
timer_ticktock.function = timer_fire;
add_timer(&timer_ticktock);
// mod_timer(&timer_ticktock, jiffies + (timer_tick*HZ));
printk("start PID = %u\n",timer_ticktock.start_pid);
return 0;
}
static void __exit timer_exit(void)
{
del_timer_sync(&timer_ticktock);
}
// Module Entry and Exit
//======================
static int __init hello_init(void)
{
printk("The process is \"%s\" (pid %i)\n",
current->comm, current->pid);
timer_init();
return 0;
}
static void __exit hello_exit(void)
{
timer_exit();
printk("Timer module Exited\n");
}
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Skeleton timer callbacks");
MODULE_AUTHOR("Kris De Vos");
MODULE_INFO(vermagic, VERMAGIC_STRING);
module_init (hello_init);
module_exit (hello_exit);
struct module __this_module
__attribute__((section(".gnu.linkonce.this_module"))) = {
.name = "hello_timer",
.init = hello_init,
#ifdef CONFIG_MODULE_UNLOAD
.exit = hello_exit,
#endif
.arch = MODULE_ARCH_INIT,
};
static const char __module_depends[]
__used
__attribute__((section(".modinfo"))) =
"depends=";
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Note that I tried TWO variations for the timer init :
First I had this =>
static DEFINE_TIMER(timer_ticktock, timer_fire, 0, 0);
and in timer_init :
static int __init timer_init(void)
{
mod_timer(&timer_ticktock, jiffies + (timer_tick*HZ));
return 0;
}
The code for my test module shown above shows the way I thought maybe
dynamic timers are supposed to be initialised. (ie. using init_timer(),
add_timer() etc ). Is there a difference ?
Both ways seem to yield the same hick ups.
My defines are :
#define __LINUX_ARM_ARCH__ 5
#define LINUX_ARM_ARCH
#define __KERNEL__
#define MODULE
#define CONFIG_MODULES
#define CONFIG_MODULE_UNLOAD
#define CONFIG_RWSEM_GENERIC_SPINLOCK
#define CONFIG_SCHED_DEBUG
#define CONFIG_DEBUG_PREEMPT
#define CONFIG_LOCK_KERNEL
#define CONFIG_DEBUG_KERNEL
#define CONFIG_PREEMPT
#define CONFIG_HZ 100
#define CONFIG_AEABI
#define CONFIG_ARCH_AT91
#define CONFIG_ARCH_AT91SAM9260
#define CONFIG_AT91_PMC_UNIT
#define CONFIG_MACH_SAM9_L9260
#define CONFIG_PRINTK
#define CONFIG_TIMER_STATS
#define CONFIG_BROKEN_ON_SMP
#define CONFIG_BUG
#define CONFIG_DEBUG_BUGVERBOSE
(I added in TIMER_STATS afterwards in the kernel for debug)
Note that CONFIG_BROKEN_ON_SMP is defined in the default target setup,
but CONFIG_SMP isn't ???? (is that right ???)
The sort of occasional errors/warnings are get are eg. :
sam9-l9260:/mnt/kris/olimex# insmod hello_timer
Timer fired at 4114 jiffies [C3C4D9C0]
rmmod hello_timer
Timer module Exited
traps_kernel BUG at kernel/module.c:473!
Trying to vfree() bad address (636b5f5f)
------------[ cut here ]------------
WARNING: at mm/vmalloc.c:385 __vunmap+0x64/0xec()
Modules linked in: [last unloaded: hello_timer]
[<c0029244>] (dump_stack+0x0/0x14) from [<c003cca8>] (warn_on_slowpath
+0x4c/0x68)
[<c003cc5c>] (warn_on_slowpath+0x0/0x68) from [<c0084b50>] (__vunmap
+0x64/0xec)
r6:c0349812 r5:636b5f5f r4:00000f5f
[<c0084aec>] (__vunmap+0x0/0xec) from [<c0084cd0>] (vfree+0x40/0x48)
r7:00000880 r6:c0349812 r5:000001d9 r4:c034ee50
[<c0084c90>] (vfree+0x0/0x48) from [<c002991c>] (module_free+0x14/0x18)
[<c0029908>] (module_free+0x0/0x18) from [<c005ffbc>] (free_module
+0xd4/0xe0)
[<c005fee8>] (free_module+0x0/0xe0) from [<c00618d0>] (sys_delete_module
+0x1e4/0x20c)
r5:c344e000 r4:bf0006c0
[<c00616ec>] (sys_delete_module+0x0/0x20c) from [<c0024b00>]
(ret_fast_syscall+0x0/0x2c)
r7:00000081 r6:be7ff570 r5:be7ff558 r4:be801d70
---[ end trace d30994dbcef2d362 ]---
ERROR: Removing 'hello_timer': Function not implemented
sam9-l9260:/mnt/kris/olimex#
IMPORTANT (I think) :
=====================
the traps.c BUG call to __bug() is from this line in module.c (473) :
static inline void percpu_modfree(void *pcpuptr)
{
BUG();
}
If CONFIG_SMP is not defined, why then do I get a BUG() call from
function percpu_modfree() ?????
I'm wondering if there's something screwy in the way the kernel has been
compiled.
Also, when I get a segmentation fault, it seems to be caused by a
deliberate call from a NULL pointer dereference (ie. a BUG check in the
kernel).
When I get such a fault, lsmod and the likes doesn't work anymore, the
target hangs and I have to reboot it.
If anybody can shed some light on this, I would be very grateful.
Best Regards,
Kris
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ