Muli Ben-Yehuda's journal

September 6, 2003

packing up is hard to do

Filed under: Uncategorized — Muli Ben-Yehuda @ 5:55 PM

On Friday, we spent the morning packing up ladypine‘s apartment, and mostly rubbing against each other the wrong way. Not fun. We took a welcome break for lunch at Pasto with Gilad and Limor, who are getting married!. Lunch was loads of fun, and afterwards we went by the new apartment and threw away the furniture that needed throwing, including a huge bed. I thought I could get away from lugging heavy furniture, since we’re paying a professional moving company a sizable chunk of our hard earned money, but it was not meant to be. I made on the order of ten trips up and down three flights of stairs, carrying assorted furniture, some with ladypine‘s help and some alone. Eventually, we were all done and came back to my place and collapsed. In the evening we started packing up my place, and eventually Orna fell asleep and I studied a little and read a lot of Harry Potter. Finished it, too. Book review coming up eventually.

Today we took apart Orna’s bedroom and huge wall closet in the morning. Luckily her father helped us, and it only took three hours…

Now I’m taking a break from packing up my apartment. I have so many books, and so many cloths I never wear. I should be taking this opportunity to throw away anything I don’t need, but it’s easier to just dump it all into boxes and sort it out in the new place. “Remember, kids, after a while, the things you own end up owning you”

premature optimization is the root of all evil

Filed under: Uncategorized — Muli Ben-Yehuda @ 4:31 PM

I’m taking a short break from packing and alterntating between marvelling at some of the crap I’ve managed to accumulate and the lost treasures I’m rediscovering.

On Thursday night I came home from work and studied, goofed off on IRC, and read lkml and the fifth Potter book. Reading lkml, I saw Linus saying that mprotect is mixing up PROT_XXX and VM_XXX flags, and would someone please fix it? Jamie Lokier and me ended up each writing a patch to fix it. Jamie’s patch was cleaner, but contained this “gem”:

 +/* Optimisation macro. */ 
+#define _calc_vm_trans(x,bit1,bit2) \ 
+  ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \ 
+   : ((x) & (bit1)) / ((bit1) / (bit2))) 

In the likely case you’re now scratching your head, here’s my version:

 
+/* check if bit1 is on in 'in'. If it is, return bit2 
+ * this is used for transltating from one bit field domain to another, 
+ * e.g. PROT_XXX to VM_XXX + */ 
+static unsigned long trans_bit(unsigned long in, unsigned long bit1, 
+		             unsigned long bit2) 
+{ 
+        if (bit1 == bit2) 
+                return (in & bit1); 
+ 
+        return  (in & bit1) ? bit2 : 0; 
+} 

I flamed Jamie gently, asking if he really thought that shaving a couple of instructions is worth the many programmer cycles this “optimization” will cost. I guess he did, because he never replied. I also guess Linus agrees, because he commited it. Furrfu. I’ll send a patch to add a bit of documentation in a day or two, if no one will beat me to it.

Blog at WordPress.com.