Re: iova RB tree setup tweak.

From: Andrew Morton
Date: Mon Feb 11 2008 - 17:30:30 EST


On Mon, 11 Feb 2008 13:56:51 -0800
mark gross <mgross@xxxxxxxxxxxxxxx> wrote:

> The following patch merges two functions into one allowing for a 3%
> reduction in overhead in locating, allocating and inserting pages for
> use in IOMMU operations.
>
> Its a bit of a eye-crosser so I welcome any RB-tree / MM experts to take
> a look. It works by re-using some of the information gathered in the
> search for the pages to use in setting up the IOTLB's in the insertion
> of the iova structure into the RB tree.
>

I guess this is a PCI patch hence I'd be tagging is as
to-be-merged-via-greg's-pci-tree.

>
> Singed-off-by: <mgross@xxxxxxxxxxxxxxx>
>

ow, that musta hurt.

>
> Index: linux-2.6.24-mm1/drivers/pci/iova.c
> ===================================================================
> --- linux-2.6.24-mm1.orig/drivers/pci/iova.c 2008-02-07 11:05:44.000000000 -0800
> +++ linux-2.6.24-mm1/drivers/pci/iova.c 2008-02-07 13:05:03.000000000 -0800
> @@ -72,20 +72,25 @@
> return pad_size;
> }
>
> -static int __alloc_iova_range(struct iova_domain *iovad, unsigned long size,
> - unsigned long limit_pfn, struct iova *new, bool size_aligned)
> +static int __alloc_and_insert_iova_range(struct iova_domain *iovad,
> + unsigned long size, unsigned long limit_pfn,
> + struct iova *new, bool size_aligned)
> {
> - struct rb_node *curr = NULL;
> + struct rb_node *prev, *curr = NULL;
> unsigned long flags;
> unsigned long saved_pfn;
> unsigned int pad_size = 0;
>
> /* Walk the tree backwards */
> spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
> saved_pfn = limit_pfn;
> curr = __get_cached_rbnode(iovad, &limit_pfn);
> + prev = curr;
> while (curr) {
> struct iova *curr_iova = container_of(curr, struct iova, node);
> +
> if (limit_pfn < curr_iova->pfn_lo)
> goto move_left;
> else if (limit_pfn < curr_iova->pfn_hi)
> @@ -99,6 +104,7 @@

For some reason patch(1) claims that the patch is corrupted at this line.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/