Messages in this thread | | | Date | Thu, 4 Sep 2003 23:04:35 +0100 | From | Jamie Lokier <> | Subject | Re: [PATCH] Stop mprotect() changing MAP_SHARED and other cleanup |
| |
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 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |