tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Syscall kill(2) called for a zombie process should return 0



On Wed, 18 Jul 2012, Mouse wrote:

> Subject: Re: Syscall kill(2) called for a zombie process should return 0
> 
> > +                   if (p != NULL && P_ZOMBIE(p)) {
> > +                           mutex_exit(proc_lock);
> > +                           return 0;
> > +                   }
> >                     mutex_exit(proc_lock);
> >                     return ESRCH;
> 
> > This is a general question, not necessarily specific to the patch.
> > Which is more costly?  Two function calls as above, or storing the
> > return value in a variable to return with just one function call to
> > mutex_exit?
> 
> "It depends."  A good optimizer could turn either one into the other,
> so it may make no real difference.  If optimization is disabled or
> limited, the version quoted above will probably be marginally larger
> and, assuming "larger code" doesn't mean more cache line fills,
> marginally faster.  Which is `more costly' depends on what costs you
> care about and to what extent.

Not necessarily.  Don't forget about the extra instructions needed to 
store and reload the register contents from the variable in RAM (unless 
the optimizer is turned on and you have a machine with register windows).

OTOH, if you really care about this level of detail you should be writing 
hand optimized assembly.  If you use a compiler you should worry more 
about maintainability than micro-optimizations that can have all sorts of 
strange sideffects like moving a block of code over an instruction cache 
line.

Eduardo


Home | Main Index | Thread Index | Old Index