public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: do_exit() and lock_kernel() semantics
@ 2002-03-25 20:13 Manfred Spraul
  2002-03-25 20:46 ` Kevin Pedretti
  0 siblings, 1 reply; 6+ messages in thread
From: Manfred Spraul @ 2002-03-25 20:13 UTC (permalink / raw)
  To: Kevin Pedretti; +Cc: linux-kernel

> Thus, for each receive we have to convert the virt address of the
> user-land receive buffer to a physical address (in the kernel region)
> before doing the memcpy (copy_to_user doesn't work from interrupt
> context).

Why do you want to do that at interrupt time?
I'd call map_user_kiobuf() when the user-land buffer is set up, and then
write directly (i.e. with kmap_atomic()) into the pages stored in
iobuf->maplist[]. It avoids the page table scan at interrupt time.

Which platform do you use? map_user_kiobuf() doesn't enforce cache
coherency internally, outside of i386 you might need additional
flush_cache_whatever (see Documentation/cachetlb.txt)

--
    Manfred


^ permalink raw reply	[flat|nested] 6+ messages in thread
* do_exit() and lock_kernel() semantics
@ 2002-03-25 19:25 Kevin Pedretti
  2002-03-25 20:17 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kevin Pedretti @ 2002-03-25 19:25 UTC (permalink / raw)
  To: kernelnewbies; +Cc: ktpedre, linux-kernel

Hello,
    do_exit() does a lock_kernel() before it destroys the dying 
processes mm context (sets task_struct->mm to NULL in 2.4 and &init_mm 
in 2.2).  Does lock_kernel() somehow disable interrupts?  It doesn't 
look like it does.  


Is there anyway from an interrupt context to check if a process is still 
alive (not exiting) and prevent it from exiting until the ISR is over? 
 I guess if lock_kernel disables interrupts globally and waits for 
inprogress interrupts to complete, then this isn't a problem.


More detail:
The reason I ask is that I'm working on/modifying a set of modules that 
accesses user space from interrupt context.  I know this is not a good 
thing to do generally, but for performance reasons the original author 
wanted to copy directly into a mlocked user space buffer from a network 
receive interrupt.  Since the buffer is mlocked, it is always guaranteed 
to be there and no page faults will happen (right??? I'm new at this). 
 Thus, for each receive we have to convert the virt address of the 
user-land receive buffer to a physical address (in the kernel region) 
before doing the memcpy (copy_to_user doesn't work from interrupt 
context).   This all seems to work fine in practice.  However, it seems 
to me that there is a race that can happen if a process is in the middle 
of dying and a receive interrupt happens.  task->mm can be set to 
NULL/init_mm out from under me while doing a receive (e.g. on another cpu).


Thanks for any help.

Kevin  


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-03-26 10:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-25 20:13 do_exit() and lock_kernel() semantics Manfred Spraul
2002-03-25 20:46 ` Kevin Pedretti
  -- strict thread matches above, loose matches on Subject: below --
2002-03-25 19:25 Kevin Pedretti
2002-03-25 20:17 ` Andrew Morton
2002-03-26  7:53 ` Ashok Raj
2002-03-26 10:11 ` Itai Nahshon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox