From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965396AbXCFRn0 (ORCPT ); Tue, 6 Mar 2007 12:43:26 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S965397AbXCFRn0 (ORCPT ); Tue, 6 Mar 2007 12:43:26 -0500 Received: from mx1.redhat.com ([66.187.233.31]:48176 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965396AbXCFRnZ (ORCPT ); Tue, 6 Mar 2007 12:43:25 -0500 From: David Howells In-Reply-To: References: <1173200555.9349.2.camel@localhost.localdomain> To: Linus Torvalds Cc: Benjamin Herrenschmidt , Linux Kernel Mailing List , Andrew Morton Subject: Re: get_order() broken ! X-Mailer: MH-E 8.0; nmh 1.1; GNU Emacs 22.0.50 Date: Tue, 06 Mar 2007 17:43:16 +0000 Message-ID: <2793.1173202996@redhat.com> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Linus Torvalds wrote: > Yeah, I think the recent get_order() changes to change it to use ilog2() > are just crap. I actually looked at it when it went in, but I assumed that > it had been tested. I don't think it has. It had, it's just that the testing totally failed to show up the problem; that and I think my userspace testing went wrong because I made the wrong assumptions about what the answer should be. However, having discussed it with Ben, HPA and David Woodhouse and others I've come up with a patch (sent separately) that should fix it by using: ilog2((n) - 1) + 1 as the basis for the calculation as this should round up the result. I've encapsulated this as a function called ilog2_up() and fixed the docs to make it cleared how ilog2() and co actually work. David