From: Jamie Lokier <jamie@shareable.org>
To: Muli Ben-Yehuda <mulix@mulix.org>
Cc: Linus Torvalds <torvalds@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Stop mprotect() changing MAP_SHARED and other cleanup
Date: Thu, 4 Sep 2003 23:04:35 +0100 [thread overview]
Message-ID: <20030904220435.GI31590@mail.jlokier.co.uk> (raw)
In-Reply-To: <20030904201851.GK13947@actcom.co.il>
Muli Ben-Yehuda wrote:
> > +/* Optimisation macro. */
> > +#define _calc_vm_trans(x,bit1,bit2) \
> > + ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \
> > + : ((x) & (bit1)) / ((bit1) / (bit2))
>
> Why is this necessary? the original version of the macro was much
> simpler. If this isn't just for shaving a couple of optimization,
> please document it. If it is, I urge you to reconsider ;-)
When the bits don't match, mine reduces to a mask-and-shift. The
original reduces to a mask-and-conditional, which is usually slower.
Hopefully GCC optimises the latter to the former these days, but there
is no harm in helping.
I vaguely recall GCC being able to optimise (x&mask1) | (x&mask2) to
x&(mask1|mask2), not 100% sure though. If so, the PROT_ bits
translation will reduce to prot & 7.
-- Jamie
next prev parent reply other threads:[~2003-09-04 22:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-04 19:34 Jamie Lokier
2003-09-04 20:18 ` Muli Ben-Yehuda
2003-09-04 22:04 ` Jamie Lokier [this message]
2003-09-05 6:34 ` Muli Ben-Yehuda
2003-09-04 23:46 ` Jamie Lokier
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=20030904220435.GI31590@mail.jlokier.co.uk \
--to=jamie@shareable.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mulix@mulix.org \
--cc=torvalds@osdl.org \
/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
all inboxes | Powered by JetHome®