Le 20/03/2012 21:48, Jeffrey Squyres a écrit :
> On Mar 20, 2012, at 3:45 PM, Brice Goglin wrote:
>
>> That looks good to me, as long as starting port numbers to 1 for
>> non-IB/OFED is OK.
>
> Hmm. Not sure about that. I always thought it was strange that IB devices
> started with port 1.
>
> Are *we* (hwloc) supplying the port number, or are you getting it from /sys
> somewhere?
>
> (/me reads the patch and ibdev2netdev...)
>
> Ah, I see -- we're effectively doing the same thing as the ibdev2netdev
> script:
>
> -----
> port=$(cat /sys/class/net/$eth/dev_id)
> port=$(printf "%d" $port)
> port=$(( port + 1 ))
> -----
>
> Hrm. I don't know if the +1 is a good assumption to make in general.
Yeah the kernel code tells me that this +1 is really IB specific. dev_id
was initially added for shared NIC, each client gets a different dev_id
(starting at 0). It was later used by IB guys to identify ports 1 and 2
(each port gets a netdevice and they all share the same hardware device,
so they used dev_id as well).
New patch attached, it doesn't add port numbers for non-IB devices.
Brice
Index: src/topology-libpci.c
===================================================================
--- src/topology-libpci.c (révision 4414)
+++ src/topology-libpci.c (copie de travail)
@@ -25,6 +25,7 @@
#include <hwloc/linux.h>
#include <dirent.h>
#include <sys/types.h>
+#include <sys/stat.h>
#endif
#define CONFIG_SPACE_CACHESIZE 256
@@ -123,6 +124,7 @@
hwloc_linux_net_class_fillinfos(struct hwloc_topology *topology __hwloc_attribute_unused, struct hwloc_obj *obj, const char *osdevpath)
{
FILE *fd;
+ struct stat st;
char path[256];
snprintf(path, sizeof(path), "%s/address", osdevpath);
fd = fopen(path, "r");
@@ -136,6 +138,25 @@
}
fclose(fd);
}
+ snprintf(path, sizeof(path), "%s/device/infiniband", osdevpath);
+ if (!stat(path, &st)) {
+ snprintf(path, sizeof(path), "%s/dev_id", osdevpath);
+ fd = fopen(path, "r");
+ if (fd) {
+ char hexid[16];
+ if (fgets(hexid, sizeof(hexid), fd)) {
+ char *eoid;
+ unsigned long port;
+ port = strtoul(hexid, &eoid, 0);
+ if (eoid != hexid) {
+ char portstr[16];
+ snprintf(portstr, sizeof(portstr), "%ld", port+1);
+ hwloc_obj_add_info(obj, "Port", portstr);
+ }
+ }
+ fclose(fd);
+ }
+ }
}
static void
hwloc_linux_lookup_net_class(struct hwloc_topology *topology, struct hwloc_obj *pcidev, const char *pcidevpath)