From: David S. <ds...@al...> - 2002-09-13 18:28:30
|
Philippe Elie wrote: > > David Smith wrote: > > > > >It's essentialy the same patch as the last time but with locking both > >of the page table (mm->page_table_lock) during lookup, and of the > >individual pages. It also has all of the backtrace code in a new file > >op_backtrace.c. Backtrace samples are put in counter (ctr+1). > > > do we need really get_page(), mm->page_table_lock is not sufficient ? > Yes, mm->page_table_lock is only held during the actual page table lookup, but the page is accessed after that. I suppose the lock could instead be held the whole time during backtrace, but I wanted to release it quickly. But, to be honest, I think now that the whole locking stuff is just so much wasted effort. I believe it is possible to use get_user() instead, which would be both faster and simpler. The only thing to look out for is that a page fault in get_user() can't swap or call schedule. But if called from an interrupt handler, it wont do that. The page fault hanler checks in_interrupt() before trying to handle the fault, and the return code from the fault will not schedule when returning to kernel code. All that is needed is a patch to the nmi handler to make sure the page fault handler knows we're in an interrupt (see below). The patch I'm currently using has get_user() instead of locking, and so far there have been no problems (that is still all with RTC on a single pentium classic, though...). diff -u -r1.13 op_nmi.c --- module/x86/op_nmi.c 7 Sep 2002 18:19:39 -0000 1.13 +++ module/x86/op_nmi.c 12 Sep 2002 18:59:14 -0000 @@ -44,8 +44,14 @@ uint cpu = op_cpu_id(); int i; + /* Tell the world (or more specifically the page fault handler) we're + in interrupt context. The backtrace code needs this for get_user() */ + local_irq_count(cpu)++; + for (i = 0 ; i < op_nr_counters ; ++i) op_check_ctr(cpu, regs, i); + + local_irq_count(cpu)--; } /* ---------------- PMC setup ------------------ */ /David |