From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755181AbXHAXqr (ORCPT ); Wed, 1 Aug 2007 19:46:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752753AbXHAXqi (ORCPT ); Wed, 1 Aug 2007 19:46:38 -0400 Received: from smtp2.linux-foundation.org ([207.189.120.14]:57171 "EHLO smtp2.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751596AbXHAXqi (ORCPT ); Wed, 1 Aug 2007 19:46:38 -0400 Date: Wed, 1 Aug 2007 16:45:54 -0700 From: Andrew Morton To: "Keshavamurthy, Anil S" Cc: Linux Kernel , Greg KH , Andi K , arjan , Ashok Raj , Suresh B Subject: Re: [patch -mm][Intel-IOMMU] Optimize sg map/unmap calls Message-Id: <20070801164554.5d2d157a.akpm@linux-foundation.org> In-Reply-To: <20070801200623.GA20780@linux-os.sc.intel.com> References: <20070801200623.GA20780@linux-os.sc.intel.com> X-Mailer: Sylpheed version 2.2.7 (GTK+ 2.8.6; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 Aug 2007 13:06:23 -0700 "Keshavamurthy, Anil S" wrote: > +/* Computes the padding size required, to make the > + * the start address naturally aligned on its size > + */ > +static int > +iova_get_pad_size(int size, unsigned int limit_pfn) > +{ > + unsigned int pad_size = 0; > + unsigned int order = ilog2(size); > + > + if (order) > + pad_size = (limit_pfn + 1) % (1 << order); > + > + return pad_size; > +} This isn't obviously doing the right thing for non-power-of-2 inputs. ilog2() rounds down... Please check that this, and all the other ilog2()s which have been added are doing the right thing if they can be presented with non-power-of-2 inputs?