Re: [PATCH 02/10] IB/uverbs: Build the specs into a radix tree at runtime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 03, 2018 at 01:31:35PM -0600, Jason Gunthorpe wrote:
> From: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
>
> This radix tree datastructure is intended to replace the 'hash' structure
> used today for parsing ioctl methods during system calls. This first
> commit introduces the structure and builds it from the existing .rodata
> descriptions.
>
> The so-called hash arrangement is actually a 5 level open coded radix tree.
> This new version uses a 3 level radix tree built using the radix tree
> library.
>
> Overall this is much less code and much easier to build as the radix tree
> API allows for dynamic modification during the building. There is a small
> memory penalty to pay for this, but since the radix tree is allocated on
> a per device basis, a few kb of RAM seems immaterial considering the
> gained simplicity.
>
> The radix tree is similar to the existing tree, but also has a 'attr_bkey'
> concept, which is a small value'd index for each method attribute. This is
> used to simplify and improve performance of everything in the next
> patches.
>
> Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
> ---
>  drivers/infiniband/core/Makefile      |   3 +-
>  drivers/infiniband/core/rdma_core.h   |  50 ++++
>  drivers/infiniband/core/uverbs.h      |   1 +
>  drivers/infiniband/core/uverbs_main.c |  14 +-
>  drivers/infiniband/core/uverbs_uapi.c | 350 ++++++++++++++++++++++++++
>  include/rdma/uverbs_ioctl.h           | 137 ++++++++++
>  6 files changed, 552 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/infiniband/core/uverbs_uapi.c

<...>

> +struct uverbs_api *uverbs_alloc_api(
> +	const struct uverbs_object_tree_def *const *driver_specs,
> +	enum rdma_driver_id driver_id)
> +{
> +	struct uverbs_api *uapi;
> +	int rc;
> +
> +	uapi = kzalloc(sizeof(*uapi), GFP_KERNEL);
> +	if (!uapi)
> +		return ERR_PTR(-ENOMEM);
> +
> +	INIT_RADIX_TREE(&uapi->radix, GFP_KERNEL);
> +	uapi->driver_id = driver_id;
> +
> +	rc = uapi_merge_tree(uapi, uverbs_default_get_objects(), false);
> +	if (rc)
> +		goto err;
> +
> +	for (; *driver_specs; driver_specs++) {
> +		rc = uapi_merge_tree(uapi, *driver_specs, true);
> +		if (rc)
> +			goto err;
> +	}

For driver without "driver_specs", the code bellow should be

diff --git a/drivers/infiniband/core/uverbs_uapi.c b/drivers/infiniband/core/uverbs_uapi.c
index 0b778289799f..db6518efe0d9 100644
--- a/drivers/infiniband/core/uverbs_uapi.c
+++ b/drivers/infiniband/core/uverbs_uapi.c
@@ -269,7 +269,7 @@ struct uverbs_api *uverbs_alloc_api(
 	if (rc)
 		goto err;

-	for (; *driver_specs; driver_specs++) {
+	for (; driver_specs && *driver_specs; driver_specs++) {
 		rc = uapi_merge_tree(uapi, *driver_specs, true);
 		if (rc)
 			goto err;

Thanks

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux