Re: [PATCH v1] [semaphore] Removed redundant code from semaphore's down family of function

From: Peter Zijlstra
Date: Fri Aug 30 2019 - 06:46:15 EST


On Fri, Aug 30, 2019 at 04:10:10PM +0530, Satendra Singh Thakur wrote:

> > +static inline long schedule_timeout(long timeout)
> > +{
> > + if (__builtin_constant_p(timeout) && timeout == MAX_SCHEDULE_TIMEOUT) {
> > + schedule();
> > + return timeout;
> > + }
> > +
> > + return __schedule_timeout(timeout);
> > +}

> > + if (timeout == MAX_SCHEDULE_TIMEOUT) {
> > schedule();
> > - goto out;
> Hi Mr Peter,
> I have a suggestion here:
> The condition timeout == MAX_SCHEDULE_TIMEOUT is already handled in
> schedule_timeout function

Only if it is a compile time constant; otherwise it will end up here.

> and same conditon is handled again in __schedule_timeout.
> Currently, no other function calls __schedule_timeout except schedule_timeout.
> Therefore, it seems this condition will never become true.

Please read more careful.