On Mon, May 03, 2004 at 23:09:38 +0200, Jan Hudec wrote: > On Mon, May 03, 2004 at 22:16:21 +0900, Tetsuo Handa wrote: > > I don't know whether functions defined in fs/*.c is called > > by the players (1) and (2). > > But if these functions could be called by (1) and (2), > > I need to confirm whether I can refer to 'current' or not. > > Every function in fs/*.c has known calling rules that state, whether it > can be called in interrupt (either (1) or (2)) context or not. If it > can, it must never use current. > > > How can I determine the value of 'current' is valid or not > > (if these functions could be called by (1) and (2)) ? > > current must only be used in (3) and is *always* valid in that context. > In (1) and (2) it points to a randomly chosen task struct (the one > currently scheduled). > > > I want to know 'current' is valid or not > > even when interrupts or bottom halves are disabled > > outside of my patch functions, > > so it is not enough just checking "in_interrupt() returns 0". Well, I see I overcomplicated it a bit. So, short answer: You are asking wrong question. You should be asking: "can I rely on current being meaningful in function X (possibly when it gets argument Y)." It is almost surely always has, or never has and it's possible to tell from the source. > Having a function, that can be called from interrupt context and may not > and if it's not does something to current sounds like a broken semantics. > > Either the function should do something with current -- and must not be > called in interrupt context (which you may check, if you want to be sure > -- BUG_ON(in_interrupt())), or it does not do anything to current (nor > any other things forbidden in interrupt) and can be called there. > > (There are some functions -- eg. kmalloc -- that sometimes need current > -- but it's not based on context but on parameter passed to it). > > Generaly, you should think whether the function will be called "on > behalf of a process". If it does (eg. everything called from syscalls), > it will have valid "current", always. If it is, or may be, called by > other means that syscall, the current it gets does not need to make > sense (it may be valid (it always is), may be even useable (process > context), but may be the one of kswapd or something like that). ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@ucw.cz>
Attachment:
signature.asc
Description: Digital signature