From: Bill Davidsen <davidsen@tmr.com>
To: Andreas Mohr <andi@rhlx01.fht-esslingen.de>
Cc: Andrew Morton <akpm@osdl.org>,
sfr@canb.auug.org.au, linux-laptop@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] -mm: i386 apm.c optimization
Date: Fri, 05 May 2006 09:55:13 -0400 [thread overview]
Message-ID: <445B5941.3020606@tmr.com> (raw)
In-Reply-To: <20060416220552.GA22998@rhlx01.fht-esslingen.de>
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 <davidsen@tmr.com>
CTO TMR Associates, Inc
Doing interesting things with small computers since 1979
prev parent reply other threads:[~2006-05-05 13:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-16 22:05 [PATCH] -mm: i386 apm.c optimization Andreas Mohr
2006-05-05 13:55 ` Bill Davidsen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=445B5941.3020606@tmr.com \
--to=davidsen@tmr.com \
--cc=akpm@osdl.org \
--cc=andi@rhlx01.fht-esslingen.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-laptop@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).