Re: [Qemu-devel] Detecting context switch in QEMU
Hi Xin Tong.. On Mon, Sep 3, 2012 at 4:48 AM, Xin Tong wrote: > BTW, if a thread makes a system call, when the kernel is servicing the > syscall. is it still accessing the thread's memory using the threads > page table (i.e. the kernel is using virtual address ?). how about AIO > kernel threads ? accessing thread user space memory? hmquite likely... let's say in a case of read() or write() AIO kernel thread... not sure, I guess eventually kernel AIO thread will wake up the user space side and do some data transfer from kernel to user space (or maybe also the other way around). The word "async" here stress the meaning that the kernel side of I/O operation doesn't operate in the context of the reading/writing process. CMIIW -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
Re: [Qemu-devel] Detecting context switch in QEMU
On Sun, Sep 2, 2012 at 8:52 AM, Xin Tong wrote: > On Sat, Sep 1, 2012 at 10:52 PM, Mulyadi Santosa > wrote: >> On Sun, Sep 2, 2012 at 2:33 AM, Xin Tong wrote: >>> I want to detect context switches in QEMU x86_64-softmmu. one of the >>> ideas i have is to track the write to CR3. is this valid on QEMU ( >>> i.e. are their any cases in which the assumption could break). >> >> >> CMIIW, if context switch happen from a parent process to its NPTL >> based thread, or to kernel thread, then CR3 won't be updated since >> they are using the same address space in Linux kernel, right? >> BTW, if a thread makes a system call, when the kernel is servicing the syscall. is it still accessing the thread's memory using the threads page table (i.e. the kernel is using virtual address ?). how about AIO kernel threads ? Xin >> And that includes no TLB flush AFAIK. >> > Ok, i do not know this. but it seems tracking CR3 is no good. any ideas ? > > Xin > >> >> -- >> regards, >> >> Mulyadi Santosa >> Freelance Linux trainer and consultant >> >> blog: the-hydra.blogspot.com >> training: mulyaditraining.blogspot.com
Re: [Qemu-devel] Detecting context switch in QEMU
Hi.. On Sun, Sep 2, 2012 at 10:52 PM, Xin Tong wrote: > Ok, i do not know this. but it seems tracking CR3 is no good. any ideas ? from the Linux kernel source: http://lxr.free-electrons.com/source/kernel/sched/core.c#L3456: /* 2042 * context_switch - switch to the new MM and the new 2043 * thread's register state. 2044 */ 2045 static inline void 2046 context_switch(struct rq *rq, struct task_struct *prev, 2047struct task_struct *next) i am not so good on arch detail...perhaps you have ideas what "thread's register state" is? -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
Re: [Qemu-devel] Detecting context switch in QEMU
On Sat, Sep 1, 2012 at 10:52 PM, Mulyadi Santosa wrote: > On Sun, Sep 2, 2012 at 2:33 AM, Xin Tong wrote: >> I want to detect context switches in QEMU x86_64-softmmu. one of the >> ideas i have is to track the write to CR3. is this valid on QEMU ( >> i.e. are their any cases in which the assumption could break). > > > CMIIW, if context switch happen from a parent process to its NPTL > based thread, or to kernel thread, then CR3 won't be updated since > they are using the same address space in Linux kernel, right? > > And that includes no TLB flush AFAIK. > Ok, i do not know this. but it seems tracking CR3 is no good. any ideas ? Xin > > -- > regards, > > Mulyadi Santosa > Freelance Linux trainer and consultant > > blog: the-hydra.blogspot.com > training: mulyaditraining.blogspot.com
Re: [Qemu-devel] Detecting context switch in QEMU
On Sun, Sep 2, 2012 at 2:33 AM, Xin Tong wrote: > I want to detect context switches in QEMU x86_64-softmmu. one of the > ideas i have is to track the write to CR3. is this valid on QEMU ( > i.e. are their any cases in which the assumption could break). CMIIW, if context switch happen from a parent process to its NPTL based thread, or to kernel thread, then CR3 won't be updated since they are using the same address space in Linux kernel, right? And that includes no TLB flush AFAIK. -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
[Qemu-devel] Detecting context switch in QEMU
I want to detect context switches in QEMU x86_64-softmmu. one of the ideas i have is to track the write to CR3. is this valid on QEMU ( i.e. are their any cases in which the assumption could break). Xin