Skip to contentSkip to conversation

linux-next: build failure after merge of the xarray tree

PATCH Stephen Rothwell 3 participants 7 messages Feb 12, 2019 – Feb 21, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

After merging the xarray tree, today's linux-next build (powerpc ppc64_defconfig) failed like this:

In file included from include/linux/list.h:9,
from include/linux/module.h:9,
from drivers/infiniband/core/device.c:34:
drivers/infiniband/core/device.c: In function 'assign_name':
include/linux/kernel.h:22:18: warning: passing argument 3 of 'xa_alloc' makes pointer from integer without a cast [-Wint-conversion]

 #define INT_MAX  ((int)(~0U>>1))
                  ^~~~~~~~~~~~~~~
drivers/infiniband/core/device.c:591:43: note: in expansion of macro 'INT_MAX'
  ret = xa_alloc(&devices, &device->index, INT_MAX, device, GFP_KERNEL);
                                           ^~~~~~~

In file included from include/linux/radix-tree.h:31,
from include/linux/idr.h:15,
from include/linux/kernfs.h:14,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/module.h:17,
from drivers/infiniband/core/device.c:34:
include/linux/xarray.h:796:9: note: expected 'void *' but argument is of type 'int'
void *entry, struct xa_limit limit, gfp_t gfp)
~~~~~~^~~~~
drivers/infiniband/core/device.c:591:52: error: incompatible type for argument 4 of 'xa_alloc'

  ret = xa_alloc(&devices, &device->index, INT_MAX, device, GFP_KERNEL);
                                                    ^~~~~~

In file included from include/linux/radix-tree.h:31,
from include/linux/idr.h:15,
from include/linux/kernfs.h:14,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/module.h:17,
from drivers/infiniband/core/device.c:34:
include/linux/xarray.h:796:32: note: expected 'struct xa_limit' but argument is of type 'struct ib_device *'
void *entry, struct xa_limit limit, gfp_t gfp)

                ~~~~~~~~~~~~~~~~^~~~~

In file included from include/linux/list.h:9,
from include/linux/module.h:9,
from drivers/infiniband/core/device.c:34:
include/linux/kernel.h:22:18: warning: passing argument 3 of 'xa_alloc' makes pointer from integer without a cast [-Wint-conversion]

 #define INT_MAX  ((int)(~0U>>1))
                  ^~~~~~~~~~~~~~~
drivers/infiniband/core/device.c:594:44: note: in expansion of macro 'INT_MAX'
   ret = xa_alloc(&devices, &device->index, INT_MAX, device,
                                            ^~~~~~~

In file included from include/linux/radix-tree.h:31,
from include/linux/idr.h:15,
from include/linux/kernfs.h:14,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/module.h:17,
from drivers/infiniband/core/device.c:34:
include/linux/xarray.h:796:9: note: expected 'void *' but argument is of type 'int'
void *entry, struct xa_limit limit, gfp_t gfp)
~~~~~~^~~~~
drivers/infiniband/core/device.c:594:53: error: incompatible type for argument 4 of 'xa_alloc'
ret = xa_alloc(&devices, &device->index, INT_MAX, device,

                                                     ^~~~~~

In file included from include/linux/radix-tree.h:31,
from include/linux/idr.h:15,
from include/linux/kernfs.h:14,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/module.h:17,
from drivers/infiniband/core/device.c:34:
include/linux/xarray.h:796:32: note: expected 'struct xa_limit' but argument is of type 'struct ib_device *'
void *entry, struct xa_limit limit, gfp_t gfp)

                ~~~~~~~~~~~~~~~~^~~~~

In file included from include/linux/list.h:9,
from include/linux/module.h:9,
from drivers/infiniband/core/device.c:34:
drivers/infiniband/core/device.c: In function 'assign_client_id':
include/linux/kernel.h:22:18: warning: passing argument 3 of 'xa_alloc' makes pointer from integer without a cast [-Wint-conversion]

 #define INT_MAX  ((int)(~0U>>1))
                  ^~~~~~~~~~~~~~~
drivers/infiniband/core/device.c:826:47: note: in expansion of macro 'INT_MAX'
  ret = xa_alloc(&clients, &client->client_id, INT_MAX, client,
                                               ^~~~~~~

In file included from include/linux/radix-tree.h:31,
from include/linux/idr.h:15,
from include/linux/kernfs.h:14,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/module.h:17,
from drivers/infiniband/core/device.c:34:
include/linux/xarray.h:796:9: note: expected 'void *' but argument is of type 'int'
void *entry, struct xa_limit limit, gfp_t gfp)
~~~~~~^~~~~
drivers/infiniband/core/device.c:826:56: error: incompatible type for argument 4 of 'xa_alloc'
ret = xa_alloc(&clients, &client->client_id, INT_MAX, client,

                                                        ^~~~~~

In file included from include/linux/radix-tree.h:31,
from include/linux/idr.h:15,
from include/linux/kernfs.h:14,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/module.h:17,
from drivers/infiniband/core/device.c:34:
include/linux/xarray.h:796:32: note: expected 'struct xa_limit' but argument is of type 'struct ib_client *'
void *entry, struct xa_limit limit, gfp_t gfp)

                ~~~~~~~~~~~~~~~~^~~~~

Caused by commit

a3e4d3f97ec8 ("XArray: Redesign xa_alloc API")

interacting with commits

e59178d895af ("RDMA/devices: Use xarray to store the clients") 0df91bb67334 ("RDMA/devices: Use xarray to store the client_data")

from the rdma tree.

Its a bit of a pain modifying a published API like this :-(

I have added the following merge fixup patch for today (I assume some of the assignments are also now redundant).

From: Stephen Rothwell <[email protected]>
Date: Tue, 12 Feb 2019 16:09:58 +1100
Subject: [PATCH] RDMA/devices: fix up for xa_alloc API change

---
 drivers/infiniband/core/device.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/infiniband/core/device.c +6 -5
index 3325be4f91a5..283ecc2aee89 100644
@@ -588,11 +588,12 @@ static int assign_name(struct ib_device *device, const char *name)
 
 	/* Cyclically allocate a user visible ID for the device */
 	device->index = last_id;
-	ret = xa_alloc(&devices, &device->index, INT_MAX, device, GFP_KERNEL);
+	ret = xa_alloc(&devices, &device->index, device,
+		       XA_LIMIT(last_id, INT_MAX), GFP_KERNEL);
 	if (ret == -ENOSPC) {
 		device->index = 0;
-		ret = xa_alloc(&devices, &device->index, INT_MAX, device,
-			       GFP_KERNEL);
+		ret = xa_alloc(&devices, &device->index, device,
+			       XA_LIMIT(0, INT_MAX), GFP_KERNEL);
 	}
 	if (ret)
 		goto out;
@@ -823,8 +824,8 @@ static int assign_client_id(struct ib_client *client)
 		client->client_id =
 			list_last_entry(&client_list, struct ib_client, list)
 				->client_id;
-	ret = xa_alloc(&clients, &client->client_id, INT_MAX, client,
-		       GFP_KERNEL);
+	ret = xa_alloc(&clients, &client->client_id, client,
+		       XA_LIMIT(client->client_id, INT_MAX), GFP_KERNEL);
 	if (ret)
 		goto out;
 
Signature · 5 lines
2.20.1

-- 
Cheers,
Stephen Rothwell
#1 lore raw
Quoted 4 lines · Stephen Rothwell

Caused by commit

a3e4d3f97ec8 ("XArray: Redesign xa_alloc API")

Quoted 8 lines

interacting with commits

e59178d895af ("RDMA/devices: Use xarray to store the clients") 0df91bb67334 ("RDMA/devices: Use xarray to store the client_data")

from the rdma tree.

Its a bit of a pain modifying a published API like this :-(

Yes, it is. I wasn't expecting people to actually start using it ;-)

Seriously, there are several defects in the published API which do warrant a change. The most severe one is that it's really easy to forget to initialise the start index. And while I'm making that change, I should fix smaller things like the errno at the same time.

Quoted 2 lines

I have added the following merge fixup patch for today (I assume some of the assignments are also now redundant).

I think the first of these should be using the alloc_cyclic API, like this:

drivers/infiniband/core/device.c +3 -15
index 283ecc2aee89..d0b56c70a553 100644
@@ -586,20 +586,8 @@ static int assign_name(struct ib_device *device, const char *name)
 	}
 	strlcpy(device->name, dev_name(&device->dev), IB_DEVICE_NAME_MAX);
 
-	/* Cyclically allocate a user visible ID for the device */
-	device->index = last_id;
-	ret = xa_alloc(&devices, &device->index, device,
-		       XA_LIMIT(last_id, INT_MAX), GFP_KERNEL);
-	if (ret == -ENOSPC) {
-		device->index = 0;
-		ret = xa_alloc(&devices, &device->index, device,
-			       XA_LIMIT(0, INT_MAX), GFP_KERNEL);
-	}
-	if (ret)
-		goto out;
-	last_id = device->index + 1;
-
-	ret = 0;
+	ret = xa_alloc_cyclic(&devices, &device->index, device, xa_limit_31b,
+			&last_id, GFP_KERNEL);
 
 out:
 	up_write(&devices_rwsem);
@@ -750,7 +738,7 @@ int ib_register_device(struct ib_device *device, const char *name)
 	int ret;
 
 	ret = assign_name(device, name);
-	if (ret)
+	if (ret < 0)
 		return ret;
 
 	ret = setup_device(device);
#2 lore raw
Quoted 12 lines · Matthew Wilcox
Quoted 11 lines · Stephen Rothwell

Caused by commit

a3e4d3f97ec8 ("XArray: Redesign xa_alloc API")

interacting with commits

e59178d895af ("RDMA/devices: Use xarray to store the clients") 0df91bb67334 ("RDMA/devices: Use xarray to store the client_data")

from the rdma tree.

Quoted 8 lines
Quoted 1 line

Its a bit of a pain modifying a published API like this :-(

Yes, it is. I wasn't expecting people to actually start using it ;-)

Seriously, there are several defects in the published API which do warrant a change. The most severe one is that it's really easy to forget to initialise the start index. And while I'm making that change, I should fix smaller things like the errno at the same time.

I hope you will send your tree in the 2nd week of the merge window with all these merge fixes in it..

I think Linus will not like it if he has to fix this when merging rdma.

Quoted 4 lines
Quoted 2 lines

I have added the following merge fixup patch for today (I assume some of the assignments are also now redundant).

I think the first of these should be using the alloc_cyclic API, like this:

Yes, it is waiting for you :)

Quoted 27 lines
drivers/infiniband/core/device.c +3 -14
index 283ecc2aee89..d0b56c70a553 100644
+++ b/drivers/infiniband/core/device.c
@@ -586,20 +586,8 @@ static int assign_name(struct ib_device *device, const char *name)
 	}
 	strlcpy(device->name, dev_name(&device->dev), IB_DEVICE_NAME_MAX);
 
-	/* Cyclically allocate a user visible ID for the device */
-	device->index = last_id;
-	ret = xa_alloc(&devices, &device->index, device,
-		       XA_LIMIT(last_id, INT_MAX), GFP_KERNEL);
-	if (ret == -ENOSPC) {
-		device->index = 0;
-		ret = xa_alloc(&devices, &device->index, device,
-			       XA_LIMIT(0, INT_MAX), GFP_KERNEL);
-	}
-	if (ret)
-		goto out;
-	last_id = device->index + 1;
-
-	ret = 0;
+	ret = xa_alloc_cyclic(&devices, &device->index, device, xa_limit_31b,
+			&last_id, GFP_KERNEL);
 
 out:
 	up_write(&devices_rwsem);

drivers/infiniband/core/device.c int ib_register_device(struct ib_device *device, const char *name) · line 742

Quoted 6 lines
drivers/infiniband/core/device.c +1 -1
@@ -750,7 +738,7 @@ int ib_register_device(struct ib_device *device, const char *name)
 	int ret;
 
 	ret = assign_name(device, name);
-	if (ret)
+	if (ret < 0)
 		return ret;

This <0 should be near the xa_alloc_cyclic, I don't want the unusual '1' to propogate.. Far too likely that someone will forget about the special case.

Jason

#3 lore raw
Quoted 11 lines · Jason Gunthorpe
Quoted 4 lines · Matthew Wilcox

Seriously, there are several defects in the published API which do warrant a change. The most severe one is that it's really easy to forget to initialise the start index. And while I'm making that change, I should fix smaller things like the errno at the same time.

I hope you will send your tree in the 2nd week of the merge window with all these merge fixes in it..

I think Linus will not like it if he has to fix this when merging rdma.

Ahhahhahhah. No. Burned once. Not doing that again.

https://lore.kernel.org/lkml/CA+55aFxFjAmrFpwQmEHCthHOzgidCKnod+cNDEE+3Spu9o1s3w@mail.gmail.com/

Quoted 11 lines

drivers/infiniband/core/device.c int ib_register_device(struct ib_device *device, const char *name) · line 742

Quoted 7 lines
drivers/infiniband/core/device.c +1 -1
@@ -750,7 +738,7 @@ int ib_register_device(struct ib_device *device, const char *name)
 	int ret;
 
 	ret = assign_name(device, name);
-	if (ret)
+	if (ret < 0)
 		return ret;

This <0 should be near the xa_alloc_cyclic, I don't want the unusual '1' to propogate.. Far too likely that someone will forget about the special case.

Feel free to propose an alternate fix for sfr to put in his tree and we can both include it as a proposed patch in our respective pull requests.

#4 lore raw
Quoted 7 lines · Matthew Wilcox
Quoted 6 lines · Jason Gunthorpe
Quoted 4 lines · Matthew Wilcox

Seriously, there are several defects in the published API which do warrant a change. The most severe one is that it's really easy to forget to initialise the start index. And while I'm making that change, I should fix smaller things like the errno at the same time.

Quoted 7 lines
Quoted 5 lines

I hope you will send your tree in the 2nd week of the merge window with all these merge fixes in it..

I think Linus will not like it if he has to fix this when merging rdma.

Ahhahhahhah. No. Burned once. Not doing that again.

I'm not suggesting you should do that - basing on the nvdimm tree to avoid conflicts was a terrible idea.

There are two sane approaches you can do here:

1) Base on -rcX and Merge to Linus's tree and resolve all conflicts before sending the PR. The PR should ideally go in the second week as it is a tree wide API change.

You can read Linus's comments on handling complex merge resolutions in PRs here:
https://lore.kernel.org/lkml/CA+55aFzcp=a2sNOVR7DTEY9dehYamXaJ1bpSfF0FZir_9MhsVg@mail.gmail.com/

2) Rebase on top of Linus's actual tree in the *second* week of the merge window and resolve all conflicts in your rebase, then send the PR.

In both cases coordinate with conflicting trees to have their PR's sent in the first week so Linus sees no conflicts.

This is basically the same advise Linus gave you:

https://lore.kernel.org/lkml/CA+55aFw+dwofadgvzrM-UCMSih+f1choCwW+xFFM3aPjoRQX_g@mail.gmail.com/

Linus talks here about the trade off for #1 and #2, with a preference to #1.

#2 is good for "you just want your series to make more sense on its own" - which I think is where tree-wide changes tend to end up.

I personally think it is not good to put major logic changes in merge commits, so I would prefer the #2 approach for this case.

Also, the general philosophy that the person doing the tree-wide change should do the work :)

Quoted 12 lines
Quoted 11 lines

drivers/infiniband/core/device.c int ib_register_device(struct ib_device *device, const char *name) · line 742

Quoted 7 lines
drivers/infiniband/core/device.c +1 -1
@@ -750,7 +738,7 @@ int ib_register_device(struct ib_device *device, const char *name)
 	int ret;
 
 	ret = assign_name(device, name);
-	if (ret)
+	if (ret < 0)
 		return ret;

This <0 should be near the xa_alloc_cyclic, I don't want the unusual '1' to propogate.. Far too likely that someone will forget about the special case.

Quoted 2 lines

Feel free to propose an alternate fix for sfr to put in his tree and we can both include it as a proposed patch in our respective pull requests.

SFR's tree is just a reference. Who ever takes care to resolve these conflicts has to manually do the fixing up. If you do send your tree early I will fix it up as part of prepping the RDMA tree PR. Otherwise you will have to fix it.

What I don't want to see is we send both trees at the same time and neither gives merge guidance to Linus.

Also, FWIW, there are two more series in the RDMA patchworks adding an xa_array call.

Regards,
Jason

#5 lore raw

Hi Jason,

Quoted 3 lines · On Wed, 13 Feb 2019 22:09:36 +0000 Jason Gunthorpe <[email protected]> wrote:

I personally think it is not good to put major logic changes in merge commits, so I would prefer the #2 approach for this case.

These are not difficult merge fixes or logic changes.

Quoted 2 lines

Also, the general philosophy that the person doing the tree-wide change should do the work :)

In fact, I have done the work :-) All you guys have to do is inform Linus and give him my resolutions. The change to xa_alloc_cyclic could just be a followup patch once the air clears.

Quoted 4 lines

SFR's tree is just a reference. Who ever takes care to resolve these conflicts has to manually do the fixing up. If you do send your tree early I will fix it up as part of prepping the RDMA tree PR. Otherwise you will have to fix it.

Neither of you need to fix it ...

Quoted 2 lines

What I don't want to see is we send both trees at the same time and neither gives merge guidance to Linus.

Well, I have now reminded you both, so hopefully you will both tell Linus.

Signature · 2 lines
Cheers,
Stephen Rothwell
#6 lore raw
Quoted 8 lines · Stephen Rothwell

Hi Jason,

Quoted 3 lines · On Wed, 13 Feb 2019 22:09:36 +0000 Jason Gunthorpe <[email protected]> wrote:

I personally think it is not good to put major logic changes in merge commits, so I would prefer the #2 approach for this case.

These are not difficult merge fixes or logic changes.

That comment was directed at Matt's correct suggestion to use alloc_cyclic, this same suggestion applies to this conflict as well.

The mechanical change of the args is not so bad for a merge commit.

Quoted 6 lines
Quoted 4 lines

SFR's tree is just a reference. Who ever takes care to resolve these conflicts has to manually do the fixing up. If you do send your tree early I will fix it up as part of prepping the RDMA tree PR. Otherwise you will have to fix it.

Neither of you need to fix it ...

Not quite, I always re-do and verify all your merge resolutions and send them to Linus as both a raw diff and as an actual merge commit for him to reference. This way these things are checked in multiple ways.

It is difficult to run this flow if we don't have an agreed order of trees, as producing the resolutions for an unmerged tree is not so straight forward.

Jason