Re: Problem with module spanning from multiple files
Hi aleksey, On Wed, Jul 18, 2012 at 9:34 AM, aleksey l...@cfotr.com wrote: test.c: #include linux/kernel.h #include linux/module.h int my_module_init(void) { pr_emerg(Hello, world - this is the kernel speaking\n ) ; return 0; } MODULE_DESCRIPTION(test driver ) ; MODULE_LICENSE(GPL v2 ) ; MODULE_VERSION(0.1 ) ; module_init(my_module_init) ; module_exit(my_module_exit) ; this should not compile. How does the compiler know the symbol my_module_exit? Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Problem with module spanning from multiple files
On Wed, Jul 18, 2012 at 10:40 AM, aleksey l...@cfotr.com wrote: obj-m = test.o test-objs = test_sub.o all: $(MAKE) -C $(KDIR) M=$(shell pwd) modules But the problem is stay. i don't receive any message on module load. Apparently, the problem is the name of your obj-m target and the name of the other object which should be build. This worked for me: obj-m += mytest.o mytest-objs += test.o test_sub.o Your kernel module will then be called mytest.ko and consists of test.o and test_sub.o Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Regarding usage of perf tools
Hi Sandeep, On Wed, Jul 11, 2012 at 7:46 AM, sandeep kumar coolsandyfor...@gmail.com wrote: Dear Phillip, Can you suggest me where do i get the userspace tool code for only perf-tools? Any any good link that explains the dependencies of perf tools? i know the kernel related code is present in /tools/perf folder/ I'm sorry if my previous post confused you. What i meant was that the userspace perf code is in tools/perf and the necessary kernel code to use perf on a system can be enabled using CONFIG_PERF_EVENTS and there may be some more config switches for a finer-grained activation of perf events. There are some dependency hints in the tools/perf/Makefile, but in the end I used trial and error to get all dependencies installed. Hope that helps! Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Not getting login prompt after CPU entered into cpu_idle() state
On Mon, Jul 9, 2012 at 3:36 PM, Srinidhi M srinidhi@gmail.com wrote: So, we have built busybox with the same tool chain version that we used to build the 2.6.32 kernel image. Even though, we are seeing the same error messages i.e. we are seeing 5 to 6 /sbin/modprobe calls after calling the /sbin/init. After that, we did not see any messages at all. We are getting the SAME log messages that we got earlier when we use this busybox file system which was build with same tool chain. My next guess would be that some tty device nodes changed and your init configuration at /etc/inittab points to wrong console devices. At least that was the case when I had a similar error. Init starts and puts the login prompt on the wrong console device so you don't see it. Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Mapping of Device Physical Address to Kernel Virtual address
Hi Prabhu, On Tue, Jul 10, 2012 at 6:56 AM, Prabhu nath gprabhun...@gmail.com wrote: For E.g. I have a device whose physical address range is 0x80008000 to 0x80008FFF. Is it possible to map this device physical address to a known virtual address range 0xF0008000 to 0xF0008FFF. I don't think this is possible, because these virtual address ranges are handled by the kernel VMA system and are allocated dynamically, so that is not just a bitmask or something to change. My hardware configuration has 128 MB of system RAM which will have been MAPPED to the Kernel virtual address from 0xC000 to 0xC7FF Also is it possible to configure the vmalloc kernel virtual address region to a fixed range of 128 MB from 0xC800 to 0xCFFF You could change PAGE_OFFSET. From [1]: PHYS_OFFSET Physical start address of the first bank of RAM. PAGE_OFFSET Virtual start address of the first bank of RAM. During the kernel boot phase, virtual address PAGE_OFFSET will be mapped to physical address PHYS_OFFSET, along with any other mappings you supply. This should be the same value as TASK_SIZE. But I'm curious: Why do you want to change it? Greetings, Philipp [1]: http://www.kernelport.org/defines.html ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Not getting login prompt after CPU entered into cpu_idle() state
On Fri, Jul 6, 2012 at 10:39 AM, Srinidhi M srinidhi@gmail.com wrote: On Fri, Jul 6, 2012 at 1:10 AM, sk.syed2 sk.sy...@gmail.com wrote: Here are the final debug statements which we are seeing in the hyper terminal. Can you post the full logs WITHOUT your debug prints. What is the toolchain you are using? Please find the attached FULL log file without our own messages. If the init process cannot be started, the kernel should at least panic. Try passing init=/foo to the kernel boot to force the panic. If that does not lead to the panic, then yuo can be sure that it is a kernel problem. Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: interface for a hardware trigger driver
(resend, forgot CC) Hi Andre! On Thu, May 10, 2012 at 11:09:07AM +0200, Andre Haupt wrote: Hi folks, Its been a while since i last did some kernel related stuff, so please bear with me if this sounds strange to your ears. What i want to achieve: I want to implement a hardware trigger that a user space process can react on. I need a driver that blocks a process/thread until a sepcific hardware interrupt occurs. The process should call a kernel interface and then should get blocked until another process/thread calls another kernel interface to stop waiting for the irq or an interrupt actually occurs. What i have: Back in the days i wrote a little character driver which implemented 2 ioctl commands. One command (IOCTL_TRIGGER_WAIT_IRQ) put the calling process to sleep using wait_evemt_interruptible() and the other command (IOCTL_TRIGGER_STOP_WAIT_IRQ) woke a processes again by calling wake_up_interruptible(). Now ioctls are frowned upon and i do not want to mess with majors and minors anymore either. Do you have any hints to the right approach for such a driver? Should i use some sysfs interface? If yes, which? Or does such a driver already exist? Can it be one completely in user space? Why don't you use open(), write(), read() etc. to do the job? Tasks which should block can then do echo wait /dev/yourdevname and another process can cancel the waiting by doing echo cancel /dev/yourdevname Greeting, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: interface for a hardware trigger driver
Hi Andre, On Thu, May 10, 2012 at 03:18:49PM +0200, Andre Haupt wrote: Or better, reading the device file blocks and returns the trigger status (none, triggered, aborted) and writing to the device file wakes up the sleeping processes. So cat /dev/mydevice would block until an interrupt occurs or someone does an echo foo /dev/mydevice. this is even better, yes. I vagely remember having done that in the first place. I cant remember why i went with the ioctl stuff back then, though. It's always good to drop ioctl code ;) Using the semantics you mentionend above for read() and write(), the code gets simpler and easier to follow IMHO. Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: side effects of calling interruptible_sleep_on_timeout()
Hi Devendra, On Tue, Apr 24, 2012 at 03:24:23PM +0530, devendra rawat wrote: Hi, A switch driver is causing soft lockup on Montavista Linux Kernel 2.6.10 system. While browsing through the code of the driver. I came across a snippet where after disabling the interrupts a call is made to interruptible_sleep_on_timeout(). The code snippet is like cli(); init_waitqueue_head(queue); interruptible_sleep_on_timeout(queue, USEC_TO_JIFFIES(usec)); thread_check_signals(); sti(); I need to know the side effect of this sort of code, can it be responsible for the softlockup of the system ? Its a PowerPC based system. you cannot call sleep functions after disabling interrupts, because no interrupt will arrive for the scheduler to see the timeout and resume your task. Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Node creation For real time devices
Hi Manty! On Fri, Apr 20, 2012 at 3:29 PM, manty kuma mantyk...@gmail.com wrote: Hi, I want to know how a node is created when a hardware is connected to the system. Information that I know : When a hardware is connected to the system, the device name is compared with the driver name, if it matches, then probe is called. Info i wish to know: At which point is the node created and who is creating it(In other words, i want to know where is mknod happening)? This one thing is bugging my mind from so many months. Please tell me programatically where is this happening. I will be very thankful. Please correct me if I'm wrong, my understanding is this: The hardware is connected and the corresponding subsystem or bus will be notified (i.e. by interrupt of the device). The kernel then creates an uevent and notifies the userspace part of udev (udevd) through a netlink socket. The uevent is received by udevd and now udev can check for rules to add the device node to /dev. That's when the creation and naming of the device node happens. Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Include guard macro query
On Thu, Apr 19, 2012 at 12:24:42PM +0530, Pritam Bankar wrote: Hi, In Linux code we add a guard macro to avoid multiple declarations of identifiers. But I see some macros defined with trailing underscores. e.g. In arch/x86/include/asm/ Normally it is defined like, #ifndef _ASM_X86_ALTERNATIVE_H #define _ASM_X86_ALTERNATIVE_H But in some files I see trailing underscore after H , e.g. arch/x86/include/asm/intel_scu_ipc.h #ifndef _ASM_X86_INTEL_SCU_IPC_H_ #define _ASM_X86_INTEL_SCU_IPC_H_ There are others files also arch/x86/include/asm/irqflags.h http://lxr.linux.no/#linux+v3.3.2/arch/x86/include/asm/probe_roms.h DOES THIS TRAILING UNDERSCORE HAS SPECIAL MEANING ??? My guess: No. Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Hung Task Timeout
On Wed, Apr 18, 2012 at 01:01:45PM +0530, mani wrote: I think in my case both the tasks wait in the wait_queue and never come to the TASK_RUNNING state. In case of the TASK_INTERRUPTIBLE, it will get scheduled (or put to run queue) in two cases only:- 1. If it receive any signal not before that (we are not sending any signal to the task so it will remain in the wait_queue) 2. we call a wake_up () call. otherwise there is no point in putting the task in run queue which has nothing to do. Yes, correct. You should use TASK_INTERRUPTIBLE here, otherwise your kernel thread cannot receive signals and you are not able to kill(1) your thread from userspace or use kthread_stop() in the kernel. Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: How does the driver initialize corresponding with several same devices ?
On Wed, Apr 18, 2012 at 05:16:01PM +0800, Li Haifeng wrote: I make a driver module and built in the kernel. There are three devices use the same driver on the hardware platform. To use each device, the probe function of the driver module should be probed. So, the driver module is registered in the kernel. My question is, how times should the probe function of the driver be called and create nodes in devfs to corresponding with the three devices? It depends on what your architecture supports. If you have support for device tree, your entry in the device tree will make the subsystem call your probe function for each device it finds. You can then check the `compatible` entry of the device node and your driver is then able to register itself to the kernel subsystem. Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: How does the driver initialize corresponding with several same devices ?
On Wed, Apr 18, 2012 at 04:32:12PM +0530, anish singh wrote: On Wed, Apr 18, 2012 at 4:18 PM, Philipp Ittershagen p.ittersha...@googlemail.com wrote: On Wed, Apr 18, 2012 at 05:16:01PM +0800, Li Haifeng wrote: I make a driver module and built in the kernel. There are three devices use the same driver on the hardware platform. To use each device, the probe function of the driver module should be probed. So, the driver module is registered in the kernel. My question is, how times should the probe function of the driver be called and create nodes in devfs to corresponding with the three devices? It depends on what your architecture supports. If you have support for device tree, your entry in the device tree will make the subsystem call your probe function for each device it finds. You can then check the `compatible` entry of the device node and your driver is then able to register itself to the kernel subsystem. Without device tree what would be your answer as i guess device tree has come recently in picture but not sure. Let me rephrase your question and see if I understand it correctly. You have a probe function which already gets called for each device in your platform and you want to know how to make each device accessible in userspace (using i.e. devfs nodes) ? Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Hung Task Timeout
Mani, On Tue, Apr 17, 2012 at 1:35 PM, mani manish...@gmail.com wrote: Thanks Philipp for the explanation and the link. But i Still have the same question:- Do scheduler schedule the tasks with TASK_INTERRUPTIBLE state ? As i know TASK_UNINTERRUPTIBLE TASK_INTERRUPTIBLE both are not in the run queue and so both type of tasks should not being scheduled by the scheduler. If YES, then why it is needed to schedule task in TASK_INTERRUPTIBLE state ? think of a signal as a software interrupt. If your thread is in the TASK_INTERRUPTIBLE state, it can be woken up by such software interrupt handlers in order to deliver the signal to your thread. Your thread will then be put into the runqueue ( and state will be TASK_RUNNING) and your wait_event_interruptible() call will return with the value -ERESTARTSYS. This is for you to be able to react to the delivered signal (you can read the active signals using signal_pending(current)). So, to answer your question: Yes, your thread will be put back into the runqueue, if you mark it as TASK_INTERRUPTIBLE and a signal is delivered to your thread. Your thread will _not_ be interrupted by software interrupts/signals when you mark it as TASK_UNINTERRUPTIBLE. What is the significance of the task-switch_count in the scheduler ? surely it got updated for the TASK_INTERRUPTIBLE task. [kernel/hung_task.c]check_hung_task() You can see in the same source file that check_hung_task() is called by check_hung_uninterruptible_tasks(). But the function check_hung_task() is only called for tasks which are in the state TASK_UNINTERRUPTIBLE: if (t-state == TASK_UNINTERRUPTIBLE) check_hung_task(t, timeout); The t-last_switch_count counts the number of switches since the last call to check_hung_task() (the value is only updated there). I hope this answers your questions. Greetings, Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: /proc question
Hello Surenkumar, On Wed, Feb 8, 2012 at 8:54 AM, Surenkumar Nihalani su...@gatech.edu wrote: Hello All, I am writing a kernel module and I wanted to know which data structure backs up the /proc/self or how do I get the process id of my call and number of it's threads from within the kernel? You can get the process id of the current context using the directive current-pid. The macro current refers to the current task struct, so it should also be possible to get the number of threads. Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: parent inode from the current struct inode
Hi Jack, On Wed, Feb 8, 2012 at 8:48 AM, Jack David jd6...@gmail.com wrote: Hi All, Is possible to get parent directory's inode structure from the current inode? If so, how can I do that? It should be possible to use the container_of macro to get the parent dentry struct. Then, you can get the parent dentry d_parent and access its inode. (Please correct me, if I'm wrong. I didn't test it). Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: 答复: parent inode from the current struct inode
Hi Jack, On Wed, Feb 8, 2012 at 2:00 PM, Jack David jd6...@gmail.com wrote: Okay, I tried container_of, but it did not work. So I tried d_obtain_alias() which worked. But I am not sure if I have to make a call to dput() as well in order to free the dentry obtained. Anyone can confirm this? since d_obtain_alias() calls dput when something goes wrong after allocating the dentry, I'm assuming that you also have to call dput to free the dentry. Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Tool for automatic style of coding guidelines
Hi Prajosh, On Fri, Jan 27, 2012 at 1:20 PM, Prajosh Premdas premdas.praj...@gmail.com wrote: Hi I have developed some kernel drivers and would like to send the patches for review. But i find that I have not followed the coding guideline for tabs and spaces properly, which can be easily corrected by using some tools like astyle. Can any body please help me with the proper commands string for the astyle tool? Or could any body please suggest me with any new tool like indent etc which you are using there is a script called checkpatch.pl in the srcipts/ subdirectory. It will show you the problems with your code style among other things. The kernel maintainers strongly suggest to use the script before posting any patches so that any major (style) flaws like indent etc. can be fixed before posting the patch to the mailing list. Hope this helps! Philipp O ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: schedule history between 2 interrupts
Hi Amit, you can use ftrace to trace function calls using the funcction_graph tracer. Greetings, Philipp On Tue, Oct 4, 2011 at 8:24 AM, Amit Nagal helloin.a...@gmail.com wrote: Hi , i have a gap of 2-3 ms between 2 usb interrupts callback . i want to know which kernel/user threads execute in the gap of 2-3 ms . basically i want to log schedule history between 2 usb interrupts callback . which data structures / functions can i use to furnish schedule logging history for this case ? Regards Amit Nagal ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: interview question how does application connects to device
On 07/05/2011 06:15 AM, Bond wrote: But he was expecting some thing more complex. Well, to be honest, I also was expecting something more complex when I first looked at kernel programming and creating character devices ;) But the file_operations interface is really straight-forward and simple, very nice. Philipp ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies