Re: [PATCH] -mm: i386 apm.c optimization

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

 



Andreas Mohr wrote:

Hello all,

- avoid expensive modulo (integer division) which happened
 since APM_MAX_EVENTS is 20 (non-power-of-2)
- kill compiler warnings by initializing two variables
- add __read_mostly to some important static variables that are read often
 (by idle loop etc.)
- constify several structures

Patch tested on 2.6.16-ck5, rediffed against 2.6.17-rc1-mm2. @@ -1104,7 +1105,8 @@

static apm_event_t get_queued_event(struct apm_user *as)
{
-	as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS;
+	if (++as->event_tail >= APM_MAX_EVENTS)
+		as->event_tail = 0;
	return as->events[as->event_tail];
}

Either event_tail can never be > APM_MAX_EVENTS (I believe that's true) and you should use ==, or you should do a proper mod function:
 ++as->event_tail;
 while (as->event_tail >= APM_MAX_EVENTS) as->event_tail -= APM_MAX_EVENTS;

In the unlikely even that the event_tail is already too large you want a proper mod, not to set it to zero.

--
bill davidsen <[email protected]>
 CTO TMR Associates, Inc
 Doing interesting things with small computers since 1979

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux