* [PATCH net-next 02/11] net: Introduce new api for walking upper and lower devices
From: David Ahern @ 2016-10-18 2:15 UTC (permalink / raw)
To: jiri, netdev, davem
Cc: dledford, sean.hefty, hal.rosenstock, linux-rdma, j.vosburgh,
vfalico, andy, jeffrey.t.kirsher, intel-wired-lan, David Ahern
In-Reply-To: <1476756953-30923-1-git-send-email-dsa@cumulusnetworks.com>
This patch introduces netdev_walk_all_upper_dev_rcu,
netdev_walk_all_lower_dev and netdev_walk_all_lower_dev_rcu. These
functions recursively walk the adj_list of devices to determine all upper
and lower devices.
The functions take a callback function that is invoked for each device
in the list. If the callback returns non-0, the walk is terminated and
the functions return that code back to callers.
v3
- simplified netdev_has_upper_dev_all_rcu and __netdev_has_upper_dev and
removed typecast as suggested by Stephen
v2
- fixed definition of netdev_next_lower_dev_rcu to mirror the upper_dev
version.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
include/linux/netdevice.h | 17 +++++
net/core/dev.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 172 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index bf341b65ca5e..a5902d995907 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3778,6 +3778,14 @@ struct net_device *netdev_all_upper_get_next_dev_rcu(struct net_device *dev,
updev; \
updev = netdev_all_upper_get_next_dev_rcu(dev, &(iter)))
+int netdev_walk_all_upper_dev_rcu(struct net_device *dev,
+ int (*fn)(struct net_device *upper_dev,
+ void *data),
+ void *data);
+
+bool netdev_has_upper_dev_all_rcu(struct net_device *dev,
+ struct net_device *upper_dev);
+
void *netdev_lower_get_next_private(struct net_device *dev,
struct list_head **iter);
void *netdev_lower_get_next_private_rcu(struct net_device *dev,
@@ -3821,6 +3829,15 @@ struct net_device *netdev_all_lower_get_next_rcu(struct net_device *dev,
ldev; \
ldev = netdev_all_lower_get_next_rcu(dev, &(iter)))
+int netdev_walk_all_lower_dev(struct net_device *dev,
+ int (*fn)(struct net_device *lower_dev,
+ void *data),
+ void *data);
+int netdev_walk_all_lower_dev_rcu(struct net_device *dev,
+ int (*fn)(struct net_device *lower_dev,
+ void *data),
+ void *data);
+
void *netdev_adjacent_get_private(struct list_head *adj_list);
void *netdev_lower_get_first_private_rcu(struct net_device *dev);
struct net_device *netdev_master_upper_dev_get(struct net_device *dev);
diff --git a/net/core/dev.c b/net/core/dev.c
index f67fd16615bb..fc48337cfab8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5156,6 +5156,31 @@ bool netdev_has_upper_dev(struct net_device *dev,
EXPORT_SYMBOL(netdev_has_upper_dev);
/**
+ * netdev_has_upper_dev_all - Check if device is linked to an upper device
+ * @dev: device
+ * @upper_dev: upper device to check
+ *
+ * Find out if a device is linked to specified upper device and return true
+ * in case it is. Note that this checks the entire upper device chain.
+ * The caller must hold rcu lock.
+ */
+
+static int __netdev_has_upper_dev(struct net_device *upper_dev, void *data)
+{
+ struct net_device *dev = data;
+
+ return upper_dev == dev;
+}
+
+bool netdev_has_upper_dev_all_rcu(struct net_device *dev,
+ struct net_device *upper_dev)
+{
+ return !!netdev_walk_all_upper_dev_rcu(dev, __netdev_has_upper_dev,
+ upper_dev);
+}
+EXPORT_SYMBOL(netdev_has_upper_dev_all_rcu);
+
+/**
* netdev_has_any_upper_dev - Check if device is linked to some device
* @dev: device
*
@@ -5255,6 +5280,51 @@ struct net_device *netdev_all_upper_get_next_dev_rcu(struct net_device *dev,
}
EXPORT_SYMBOL(netdev_all_upper_get_next_dev_rcu);
+static struct net_device *netdev_next_upper_dev_rcu(struct net_device *dev,
+ struct list_head **iter)
+{
+ struct netdev_adjacent *upper;
+
+ WARN_ON_ONCE(!rcu_read_lock_held() && !lockdep_rtnl_is_held());
+
+ upper = list_entry_rcu((*iter)->next, struct netdev_adjacent, list);
+
+ if (&upper->list == &dev->adj_list.upper)
+ return NULL;
+
+ *iter = &upper->list;
+
+ return upper->dev;
+}
+
+int netdev_walk_all_upper_dev_rcu(struct net_device *dev,
+ int (*fn)(struct net_device *dev,
+ void *data),
+ void *data)
+{
+ struct net_device *udev;
+ struct list_head *iter;
+ int ret;
+
+ for (iter = &dev->adj_list.upper,
+ udev = netdev_next_upper_dev_rcu(dev, &iter);
+ udev;
+ udev = netdev_next_upper_dev_rcu(dev, &iter)) {
+ /* first is the upper device itself */
+ ret = fn(udev, data);
+ if (ret)
+ return ret;
+
+ /* then look at all of its upper devices */
+ ret = netdev_walk_all_upper_dev_rcu(udev, fn, data);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(netdev_walk_all_upper_dev_rcu);
+
/**
* netdev_lower_get_next_private - Get the next ->private from the
* lower neighbour list
@@ -5361,6 +5431,49 @@ struct net_device *netdev_all_lower_get_next(struct net_device *dev, struct list
}
EXPORT_SYMBOL(netdev_all_lower_get_next);
+static struct net_device *netdev_next_lower_dev(struct net_device *dev,
+ struct list_head **iter)
+{
+ struct netdev_adjacent *lower;
+
+ lower = list_entry(*iter, struct netdev_adjacent, list);
+
+ if (&lower->list == &dev->adj_list.lower)
+ return NULL;
+
+ *iter = lower->list.next;
+
+ return lower->dev;
+}
+
+int netdev_walk_all_lower_dev(struct net_device *dev,
+ int (*fn)(struct net_device *dev,
+ void *data),
+ void *data)
+{
+ struct net_device *ldev;
+ struct list_head *iter;
+ int ret;
+
+ for (iter = &dev->adj_list.lower,
+ ldev = netdev_next_lower_dev(dev, &iter);
+ ldev;
+ ldev = netdev_next_lower_dev(dev, &iter)) {
+ /* first is the lower device itself */
+ ret = fn(ldev, data);
+ if (ret)
+ return ret;
+
+ /* then look at all of its lower devices */
+ ret = netdev_walk_all_lower_dev(ldev, fn, data);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(netdev_walk_all_lower_dev);
+
/**
* netdev_all_lower_get_next_rcu - Get the next device from all
* lower neighbour list, RCU variant
@@ -5382,6 +5495,48 @@ struct net_device *netdev_all_lower_get_next_rcu(struct net_device *dev,
}
EXPORT_SYMBOL(netdev_all_lower_get_next_rcu);
+static struct net_device *netdev_next_lower_dev_rcu(struct net_device *dev,
+ struct list_head **iter)
+{
+ struct netdev_adjacent *lower;
+
+ lower = list_entry_rcu((*iter)->next, struct netdev_adjacent, list);
+ if (&lower->list == &dev->adj_list.lower)
+ return NULL;
+
+ *iter = &lower->list;
+
+ return lower->dev;
+}
+
+int netdev_walk_all_lower_dev_rcu(struct net_device *dev,
+ int (*fn)(struct net_device *dev,
+ void *data),
+ void *data)
+{
+ struct net_device *ldev;
+ struct list_head *iter;
+ int ret;
+
+ for (iter = &dev->adj_list.lower,
+ ldev = netdev_next_lower_dev_rcu(dev, &iter);
+ ldev;
+ ldev = netdev_next_lower_dev_rcu(dev, &iter)) {
+ /* first is the lower device itself */
+ ret = fn(ldev, data);
+ if (ret)
+ return ret;
+
+ /* then look at all of its lower devices */
+ ret = netdev_walk_all_lower_dev_rcu(ldev, fn, data);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(netdev_walk_all_lower_dev_rcu);
+
/**
* netdev_lower_get_first_private_rcu - Get the first ->private from the
* lower neighbour list, RCU
--
2.1.4
^ permalink raw reply related
* [PATCH net-next 01/11] net: Remove refnr arg when inserting link adjacencies
From: David Ahern @ 2016-10-18 2:15 UTC (permalink / raw)
To: jiri-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA,
davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA,
sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
j.vosburgh-Re5JQEeQqe8AvxtiuMwx3w, vfalico-Re5JQEeQqe8AvxtiuMwx3w,
andy-QlMahl40kYEqcZcGjlUOXw,
jeffrey.t.kirsher-ral2JQCrhuEAvxtiuMwx3w,
intel-wired-lan-qjLDD68F18P21nG7glBr7A, David Ahern
In-Reply-To: <1476756953-30923-1-git-send-email-dsa-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
Commit 93409033ae65 ("net: Add netdev all_adj_list refcnt propagation to
fix panic") propagated the refnr to insert and remove functions tracking
the netdev adjacency graph. However, for the insert path the refnr can
only be 1. Accordingly, remove the refnr argument to make that clear.
ie., the refnr arg in 93409033ae65 was only needed for the remove path.
Signed-off-by: David Ahern <dsa-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
---
net/core/dev.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 352e98129601..f67fd16615bb 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5453,7 +5453,6 @@ static inline bool netdev_adjacent_is_neigh_list(struct net_device *dev,
static int __netdev_adjacent_dev_insert(struct net_device *dev,
struct net_device *adj_dev,
- u16 ref_nr,
struct list_head *dev_list,
void *private, bool master)
{
@@ -5463,7 +5462,7 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
adj = __netdev_find_adj(adj_dev, dev_list);
if (adj) {
- adj->ref_nr += ref_nr;
+ adj->ref_nr += 1;
return 0;
}
@@ -5473,7 +5472,7 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
adj->dev = adj_dev;
adj->master = master;
- adj->ref_nr = ref_nr;
+ adj->ref_nr = 1;
adj->private = private;
dev_hold(adj_dev);
@@ -5547,22 +5546,21 @@ static void __netdev_adjacent_dev_remove(struct net_device *dev,
static int __netdev_adjacent_dev_link_lists(struct net_device *dev,
struct net_device *upper_dev,
- u16 ref_nr,
struct list_head *up_list,
struct list_head *down_list,
void *private, bool master)
{
int ret;
- ret = __netdev_adjacent_dev_insert(dev, upper_dev, ref_nr, up_list,
+ ret = __netdev_adjacent_dev_insert(dev, upper_dev, up_list,
private, master);
if (ret)
return ret;
- ret = __netdev_adjacent_dev_insert(upper_dev, dev, ref_nr, down_list,
+ ret = __netdev_adjacent_dev_insert(upper_dev, dev, down_list,
private, false);
if (ret) {
- __netdev_adjacent_dev_remove(dev, upper_dev, ref_nr, up_list);
+ __netdev_adjacent_dev_remove(dev, upper_dev, 1, up_list);
return ret;
}
@@ -5570,10 +5568,9 @@ static int __netdev_adjacent_dev_link_lists(struct net_device *dev,
}
static int __netdev_adjacent_dev_link(struct net_device *dev,
- struct net_device *upper_dev,
- u16 ref_nr)
+ struct net_device *upper_dev)
{
- return __netdev_adjacent_dev_link_lists(dev, upper_dev, ref_nr,
+ return __netdev_adjacent_dev_link_lists(dev, upper_dev,
&dev->all_adj_list.upper,
&upper_dev->all_adj_list.lower,
NULL, false);
@@ -5602,12 +5599,12 @@ static int __netdev_adjacent_dev_link_neighbour(struct net_device *dev,
struct net_device *upper_dev,
void *private, bool master)
{
- int ret = __netdev_adjacent_dev_link(dev, upper_dev, 1);
+ int ret = __netdev_adjacent_dev_link(dev, upper_dev);
if (ret)
return ret;
- ret = __netdev_adjacent_dev_link_lists(dev, upper_dev, 1,
+ ret = __netdev_adjacent_dev_link_lists(dev, upper_dev,
&dev->adj_list.upper,
&upper_dev->adj_list.lower,
private, master);
@@ -5676,7 +5673,7 @@ static int __netdev_upper_dev_link(struct net_device *dev,
list_for_each_entry(j, &upper_dev->all_adj_list.upper, list) {
pr_debug("Interlinking %s with %s, non-neighbour\n",
i->dev->name, j->dev->name);
- ret = __netdev_adjacent_dev_link(i->dev, j->dev, i->ref_nr);
+ ret = __netdev_adjacent_dev_link(i->dev, j->dev);
if (ret)
goto rollback_mesh;
}
@@ -5686,7 +5683,7 @@ static int __netdev_upper_dev_link(struct net_device *dev,
list_for_each_entry(i, &upper_dev->all_adj_list.upper, list) {
pr_debug("linking %s's upper device %s with %s\n",
upper_dev->name, i->dev->name, dev->name);
- ret = __netdev_adjacent_dev_link(dev, i->dev, i->ref_nr);
+ ret = __netdev_adjacent_dev_link(dev, i->dev);
if (ret)
goto rollback_upper_mesh;
}
@@ -5695,7 +5692,7 @@ static int __netdev_upper_dev_link(struct net_device *dev,
list_for_each_entry(i, &dev->all_adj_list.lower, list) {
pr_debug("linking %s's lower device %s with %s\n", dev->name,
i->dev->name, upper_dev->name);
- ret = __netdev_adjacent_dev_link(i->dev, upper_dev, i->ref_nr);
+ ret = __netdev_adjacent_dev_link(i->dev, upper_dev);
if (ret)
goto rollback_lower_mesh;
}
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v3 net-next 00/11] net: Fix netdev adjacency tracking
From: David Ahern @ 2016-10-18 2:15 UTC (permalink / raw)
To: jiri, netdev, davem
Cc: dledford, sean.hefty, hal.rosenstock, linux-rdma, j.vosburgh,
vfalico, andy, jeffrey.t.kirsher, intel-wired-lan, David Ahern
The netdev adjacency tracking is failing to create proper dependencies
for some topologies. For example this topology
+--------+
| myvrf |
+--------+
| |
| +---------+
| | macvlan |
| +---------+
| |
+----------+
| bridge |
+----------+
|
+--------+
| bond1 |
+--------+
|
+--------+
| eth3 |
+--------+
hits 1 of 2 problems depending on the order of enslavement. The base set of
commands for both cases:
ip link add bond1 type bond
ip link set bond1 up
ip link set eth3 down
ip link set eth3 master bond1
ip link set eth3 up
ip link add bridge type bridge
ip link set bridge up
ip link add macvlan link bridge type macvlan
ip link set macvlan up
ip link add myvrf type vrf table 1234
ip link set myvrf up
ip link set bridge master myvrf
Case 1 enslave macvlan to the vrf before enslaving the bond to the bridge:
ip link set macvlan master myvrf
ip link set bond1 master bridge
Attempts to delete the VRF:
ip link delete myvrf
trigger the BUG in __netdev_adjacent_dev_remove:
[ 587.405260] tried to remove device eth3 from myvrf
[ 587.407269] ------------[ cut here ]------------
[ 587.408918] kernel BUG at /home/dsa/kernel.git/net/core/dev.c:5661!
[ 587.411113] invalid opcode: 0000 [#1] SMP
[ 587.412454] Modules linked in: macvlan bridge stp llc bonding vrf
[ 587.414765] CPU: 0 PID: 726 Comm: ip Not tainted 4.8.0+ #109
[ 587.416766] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
[ 587.420241] task: ffff88013ab6eec0 task.stack: ffffc90000628000
[ 587.422163] RIP: 0010:[<ffffffff813cef03>] [<ffffffff813cef03>] __netdev_adjacent_dev_remove+0x40/0x12c
...
[ 587.446053] Call Trace:
[ 587.446424] [<ffffffff813d1542>] __netdev_adjacent_dev_unlink+0x20/0x3c
[ 587.447390] [<ffffffff813d16a3>] netdev_upper_dev_unlink+0xfa/0x15e
[ 587.448297] [<ffffffffa00003a3>] vrf_del_slave+0x13/0x2a [vrf]
[ 587.449153] [<ffffffffa00004a4>] vrf_dev_uninit+0xea/0x114 [vrf]
[ 587.450036] [<ffffffff813d19b0>] rollback_registered_many+0x22b/0x2da
[ 587.450974] [<ffffffff813d1aac>] unregister_netdevice_many+0x17/0x48
[ 587.451903] [<ffffffff813de444>] rtnl_delete_link+0x3c/0x43
[ 587.452719] [<ffffffff813dedcd>] rtnl_dellink+0x180/0x194
When the BUG is converted to a WARN_ON it shows 4 missing adjacencies:
eth3 - myvrf, mvrf - eth3, bond1 - myvrf and myvrf - bond1
All of those are because the __netdev_upper_dev_link function does not
properly link macvlan lower devices to myvrf when it is enslaved.
The second case just flips the ordering of the enslavements:
ip link set bond1 master bridge
ip link set macvlan master myvrf
Then run:
ip link delete bond1
ip link delete myvrf
The vrf delete command hangs because myvrf has a reference that has not
been released. In this case the removal code does not account for 2 paths
between eth3 and myvrf - one from bridge to vrf and the other through the
macvlan.
Rather than try to maintain a linked list of all upper and lower devices
per netdevice, only track the direct neighbors. The remaining stack can
be determined by recursively walking the neighbors.
The existing netdev_for_each_all_upper_dev_rcu,
netdev_for_each_all_lower_dev and netdev_for_each_all_lower_dev_rcu macros
are replaced with APIs that walk the upper and lower device lists. The
new APIs take a callback function and a data arg that is passed to the
callback for each device in the list. Drivers using the old macros are
converted in separate patches to make it easier on reviewers. It is an
API conversion only; no functional change is intended.
v3
- address Stephen's comment to simplify logic and remove typecasts
v2
- fixed bond0 references in cover-letter
- fixed definition of netdev_next_lower_dev_rcu to mirror the upper_dev
version.
David Ahern (11):
net: Remove refnr arg when inserting link adjacencies
net: Introduce new api for walking upper and lower devices
net: bonding: Flip to the new dev walk API
IB/core: Flip to the new dev walk API
IB/ipoib: Flip to new dev walk API
ixgbe: Flip to the new dev walk API
mlxsw: Flip to the new dev walk API
rocker: Flip to the new dev walk API
net: Remove all_adj_list and its references
net: Add warning if any lower device is still in adjacency list
net: dev: Improve debug statements for adjacency tracking
drivers/infiniband/core/core_priv.h | 9 +-
drivers/infiniband/core/roce_gid_mgmt.c | 42 +--
drivers/infiniband/ulp/ipoib/ipoib_main.c | 37 ++-
drivers/net/bonding/bond_alb.c | 82 +++---
drivers/net/bonding/bond_main.c | 17 +-
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 132 ++++++----
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 37 ++-
drivers/net/ethernet/rocker/rocker_main.c | 31 ++-
include/linux/netdevice.h | 38 ++-
net/core/dev.c | 350 ++++++++++++-------------
10 files changed, 423 insertions(+), 352 deletions(-)
--
2.1.4
^ permalink raw reply
* Re: [PATCH net-next 02/11] net: Introduce new api for walking upper and lower devices
From: David Ahern @ 2016-10-18 0:42 UTC (permalink / raw)
To: Stephen Hemminger
Cc: jiri-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA,
davem-fT/PcQaiUtIeIZ0/mPfg9Q, dledford-H+wXaHxf7aLQT0dZR+AlfA,
sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
j.vosburgh-Re5JQEeQqe8AvxtiuMwx3w, vfalico-Re5JQEeQqe8AvxtiuMwx3w,
andy-QlMahl40kYEqcZcGjlUOXw,
jeffrey.t.kirsher-ral2JQCrhuEAvxtiuMwx3w,
intel-wired-lan-qjLDD68F18P21nG7glBr7A
In-Reply-To: <20161017052121.2322279d@xeon-e3>
On 10/17/16 6:21 AM, Stephen Hemminger wrote:
>
> No if/else needed. No cast of void * ptr need. Use const if possible?
>
so much of the stack does not use const and trying to add it for this API does not work -- the upper or lower device is passed to the callbacks and those callbacks invoke other apis. e.g., the bond patch calls vlan_get_encap_level, bond_verify_device_path and bond_confirm_addr and none of those accept a const dev.
v3 coming up with the more succinct versions, but const is not possible.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* RE: building rdma-core from travis
From: Hefty, Sean @ 2016-10-18 0:06 UTC (permalink / raw)
To: Hefty, Sean,
linux-rdma (linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org)
In-Reply-To: <1828884A29C6694DAF28B7E6B8A82373AB096A7B-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
> CMake Error at CMakeLists.txt:23 (cmake_minimum_required):
>
> CMake 2.8.11 or higher is required. You are running version 2.8.7
>
>
> I can see that travis runs successfully against rdma-core. Was there a
> magic setting used to work-around the travis version?
It looks like rdma-core requires the 'trusty' build on travis...
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* building rdma-core from travis
From: Hefty, Sean @ 2016-10-17 23:53 UTC (permalink / raw)
To: linux-rdma (linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org)
I'm trying to build the wonderful new build system that has infested rdma-core from another travis project. I hit this error attempting to run build.sh from a travis.yml script.
CMake Error at CMakeLists.txt:23 (cmake_minimum_required):
CMake 2.8.11 or higher is required. You are running version 2.8.7
I can see that travis runs successfully against rdma-core. Was there a magic setting used to work-around the travis version?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH 03/28] [v2] infiniband: shut up a maybe-uninitialized warning
From: Arnd Bergmann @ 2016-10-17 22:05 UTC (permalink / raw)
To: Doug Ledford
Cc: Linus Torvalds, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
Arnd Bergmann, Sean Hefty, Hal Rosenstock, Matan Barak,
Haggai Eran, Leon Romanovsky, Sagi Grimberg, Bart Van Assche,
Alex Vesker, Guy Shapiro, linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20161017220342.1627073-1-arnd-r2nGTMty4D4@public.gmane.org>
Some configurations produce this harmless warning when built with
gcc -Wmaybe-uninitialized:
infiniband/core/cma.c: In function 'cma_get_net_dev':
infiniband/core/cma.c:1242:12: warning: 'src_addr_storage.sin_addr.s_addr' may be used uninitialized in this function [-Wmaybe-uninitialized]
I previously reported this for the powerpc64 defconfig, but have now
reproduced the same thing for x86 as well, using gcc-5 or higher.
The code looks correct to me, and this change just rearranges it
by making sure we alway initialize the entire address structure
to make the warning disappear. My first approach added an
initialization at the time of the declaration, which Doug commented
may be too costly, so I hope this version doesn't add overhead.
Link: http://arm-soc.lixom.net/buildlogs/mainline/v4.7-rc6/buildall.powerpc.ppc64_defconfig.log.passed
Link: https://patchwork.kernel.org/patch/9212825/
Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
---
drivers/infiniband/core/cma.c | 56 ++++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 27 deletions(-)
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 36bf50e..24e0ea6 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1094,47 +1094,47 @@ static void cma_save_ib_info(struct sockaddr *src_addr,
}
}
-static void cma_save_ip4_info(struct sockaddr *src_addr,
- struct sockaddr *dst_addr,
+static void cma_save_ip4_info(struct sockaddr_in *src_addr,
+ struct sockaddr_in *dst_addr,
struct cma_hdr *hdr,
__be16 local_port)
{
- struct sockaddr_in *ip4;
-
if (src_addr) {
- ip4 = (struct sockaddr_in *)src_addr;
- ip4->sin_family = AF_INET;
- ip4->sin_addr.s_addr = hdr->dst_addr.ip4.addr;
- ip4->sin_port = local_port;
+ *src_addr = (struct sockaddr_in) {
+ .sin_family = AF_INET,
+ .sin_addr.s_addr = hdr->dst_addr.ip4.addr,
+ .sin_port = local_port,
+ };
}
if (dst_addr) {
- ip4 = (struct sockaddr_in *)dst_addr;
- ip4->sin_family = AF_INET;
- ip4->sin_addr.s_addr = hdr->src_addr.ip4.addr;
- ip4->sin_port = hdr->port;
+ *dst_addr = (struct sockaddr_in) {
+ .sin_family = AF_INET,
+ .sin_addr.s_addr = hdr->src_addr.ip4.addr,
+ .sin_port = hdr->port,
+ };
}
}
-static void cma_save_ip6_info(struct sockaddr *src_addr,
- struct sockaddr *dst_addr,
+static void cma_save_ip6_info(struct sockaddr_in6 *src_addr,
+ struct sockaddr_in6 *dst_addr,
struct cma_hdr *hdr,
__be16 local_port)
{
- struct sockaddr_in6 *ip6;
-
if (src_addr) {
- ip6 = (struct sockaddr_in6 *)src_addr;
- ip6->sin6_family = AF_INET6;
- ip6->sin6_addr = hdr->dst_addr.ip6;
- ip6->sin6_port = local_port;
+ *src_addr = (struct sockaddr_in6) {
+ .sin6_family = AF_INET6,
+ .sin6_addr = hdr->dst_addr.ip6,
+ .sin6_port = local_port,
+ };
}
if (dst_addr) {
- ip6 = (struct sockaddr_in6 *)dst_addr;
- ip6->sin6_family = AF_INET6;
- ip6->sin6_addr = hdr->src_addr.ip6;
- ip6->sin6_port = hdr->port;
+ *dst_addr = (struct sockaddr_in6) {
+ .sin6_family = AF_INET6,
+ .sin6_addr = hdr->src_addr.ip6,
+ .sin6_port = hdr->port,
+ };
}
}
@@ -1159,10 +1159,12 @@ static int cma_save_ip_info(struct sockaddr *src_addr,
switch (cma_get_ip_ver(hdr)) {
case 4:
- cma_save_ip4_info(src_addr, dst_addr, hdr, port);
+ cma_save_ip4_info((struct sockaddr_in *)src_addr,
+ (struct sockaddr_in *)dst_addr, hdr, port);
break;
case 6:
- cma_save_ip6_info(src_addr, dst_addr, hdr, port);
+ cma_save_ip6_info((struct sockaddr_in6 *)src_addr,
+ (struct sockaddr_in6 *)dst_addr, hdr, port);
break;
default:
return -EAFNOSUPPORT;
@@ -1309,7 +1311,7 @@ static bool validate_net_dev(struct net_device *net_dev,
static struct net_device *cma_get_net_dev(struct ib_cm_event *ib_event,
const struct cma_req_info *req)
{
- struct sockaddr_storage listen_addr_storage, src_addr_storage;
+ struct sockaddr_storage listen_addr_storage = {}, src_addr_storage = {};
struct sockaddr *listen_addr = (struct sockaddr *)&listen_addr_storage,
*src_addr = (struct sockaddr *)&src_addr_storage;
struct net_device *net_dev;
--
2.9.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* Re: [PATCH 0/8] infiniband: Remove semaphores
From: Arnd Bergmann @ 2016-10-17 20:37 UTC (permalink / raw)
To: Bart Van Assche
Cc: Binoy Jayan, Doug Ledford, Sean Hefty, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <8c560960-5498-57b5-6da6-218b71d9eef9-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
On Monday, October 17, 2016 1:28:01 PM CEST Bart Van Assche wrote:
> On 10/17/2016 01:06 PM, Arnd Bergmann wrote:
> > Using an open-coded semaphore as a replacement is probably just
> > the last resort that we can consider once we are down to the
> > last handful of users. I haven't looked at drivers/infiniband/
> > yet for this, but I believe that drivers/acpi/ is a case for
> > which I see no better alternative (the AML bytecode requires
> > counting semaphore semantics).
>
> Hello Arnd,
>
> Thanks for the detailed reply. However, I doubt that removing and
> open-coding counting semaphores is the best alternative. Counting
> semaphores are a useful abstraction. I think open-coding counting
> semaphores everywhere counting semaphores are used would be a step back
> instead of a step forward.
Absolutely agreed, that's why I said 'last resort' above. I don't
think that we need to go there for infiniband. See my reply
for patch 6 for one idea on how to handle hns and mthca. There
might be better ways.
These fall into the general category of using the counting semaphore
to count something that we already know in the code that uses
the semaphore, so we can remove the count and just need some other
waiting primitive.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 7/8] IB/mthca: Replace counting semaphore event_sem with wait condition
From: Arnd Bergmann @ 2016-10-17 20:32 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Binoy Jayan, Doug Ledford, Sean Hefty, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20161017163954.GB7207-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
On Monday, October 17, 2016 9:39:54 AM CEST Christoph Hellwig wrote:
> Same NAK as for the last patch.
Right, whatever we decide to do for patch 6 is what should be
done here too, as the hns code was clearly copied unchanged.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 6/8] IB/hns: Replace counting semaphore event_sem with wait condition
From: Arnd Bergmann @ 2016-10-17 20:29 UTC (permalink / raw)
To: Binoy Jayan
Cc: Doug Ledford, Sean Hefty, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476721862-7070-7-git-send-email-binoy.jayan-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
On Monday, October 17, 2016 10:01:00 PM CEST Binoy Jayan wrote:
> --- a/drivers/infiniband/hw/hns/hns_roce_cmd.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c
> @@ -248,10 +248,14 @@ static int hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param,
> {
> int ret = 0;
>
> - down(&hr_dev->cmd.event_sem);
> + wait_event(hr_dev->cmd.event_sem.wq,
> + atomic_add_unless(&hr_dev->cmd.event_sem.count, -1, 0));
> +
> ret = __hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param,
> in_modifier, op_modifier, op, timeout);
> - up(&hr_dev->cmd.event_sem);
> +
> + if (atomic_inc_return(&hr_dev->cmd.event_sem.count) == 1)
> + wake_up(&hr_dev->cmd.event_sem.wq);
>
> return ret;
> }
This is the only interesting use of the event_sem that cares about
the counting and it protects the __hns_roce_cmd_mbox_wait() from being
entered too often. The count here is the number of size of the
hr_dev->cmd.context[] array.
However, that function already use a spinlock to protect that array
and pick the correct context. I think changing the inner function
to handle the case of 'no context available' by using a waitqueue
without counting anything would be a reasonable transformation
away from the semaphore.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 0/8] infiniband: Remove semaphores
From: Bart Van Assche @ 2016-10-17 20:28 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Binoy Jayan, Doug Ledford, Sean Hefty, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <6244597.a6XMUIxjP0@wuerfel>
On 10/17/2016 01:06 PM, Arnd Bergmann wrote:
> Using an open-coded semaphore as a replacement is probably just
> the last resort that we can consider once we are down to the
> last handful of users. I haven't looked at drivers/infiniband/
> yet for this, but I believe that drivers/acpi/ is a case for
> which I see no better alternative (the AML bytecode requires
> counting semaphore semantics).
Hello Arnd,
Thanks for the detailed reply. However, I doubt that removing and
open-coding counting semaphores is the best alternative. Counting
semaphores are a useful abstraction. I think open-coding counting
semaphores everywhere counting semaphores are used would be a step back
instead of a step forward.
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* RE: ibacm cleanups
From: Hefty, Sean @ 2016-10-17 20:27 UTC (permalink / raw)
To: Christoph Hellwig,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
> This series fixed various sparse issues in ibacm, makes it use
> the common list helpers and removes various cruft.
Thanks - series looks good to me.
Acked-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH rdma-core 2/4] glue/redhat: add udev/systemd/etc infrastructure bits
From: Jason Gunthorpe @ 2016-10-17 20:13 UTC (permalink / raw)
To: Weiny, Ira
Cc: Jarod Wilson, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Doug Ledford, Hefty, Sean
In-Reply-To: <2807E5FD2F6FDA4886F6618EAC48510E24F0A408-8k97q/ur5Z2krb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
On Mon, Oct 17, 2016 at 07:10:46PM +0000, Weiny, Ira wrote:
> What I have been worried about is conflicts between infiniband-diags
> and the new rdma-core. RH made a separate package out of rdma-ndd
> so that would be easy but I don't think other distros have.
> So how do you obsolete "part" of a package?
The distros know how to do this, they just conflict with the old
version of infiniband-diags.
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 0/8] infiniband: Remove semaphores
From: Arnd Bergmann @ 2016-10-17 20:06 UTC (permalink / raw)
To: Bart Van Assche
Cc: Binoy Jayan, Doug Ledford, Sean Hefty, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <216461f1-3070-c93a-a560-7560a727cb8d-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
On Monday, October 17, 2016 9:57:34 AM CEST Bart Van Assche wrote:
> On 10/17/2016 09:30 AM, Binoy Jayan wrote:
> > These are a set of patches which removes semaphores from infiniband.
> > These are part of a bigger effort to eliminate all semaphores from the
> > linux kernel.
>
> Hello Binoy,
>
> Why do you think it would be a good idea to eliminate all semaphores
> from the Linux kernel? I don't know anyone who doesn't consider
> semaphores a useful abstraction.
There are a several reasons why the semaphores as defined in the
kernel are bad and we should get rid of them:
- semaphores cannot be analysed using lockdep, since they don't
always fit in the simpler 'mutex' semantics
- those that are basically mutexes should be converted to mutexes
for efficiency and consistency anyway
- the semaphores that are not just used as mutexes are typically
used as completions and should just be converted to completions
for simplicity
- when running a preempt-rt kernel, semaphores suffer from priority
inversion problems, while mutexes use use priority inheritance
as a countermeasure
There are very few remaining semaphores in the kernel and generally
speaking we'd be better off removing them all so no new users
show up in the future. Most of them are trivial to replace with
mutexes or completions. For the ones that are not trivially replaced,
we have to look at each one and decide what to do about them,
there usually is some solution that actually improves the code.
Using an open-coded semaphore as a replacement is probably just
the last resort that we can consider once we are down to the
last handful of users. I haven't looked at drivers/infiniband/
yet for this, but I believe that drivers/acpi/ is a case for
which I see no better alternative (the AML bytecode requires
counting semaphore semantics).
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH rdma-core 2/4] glue/redhat: add udev/systemd/etc infrastructure bits
From: Jason Gunthorpe @ 2016-10-17 19:14 UTC (permalink / raw)
To: Doug Ledford; +Cc: Jarod Wilson, linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <a6c8091e-fe83-8413-77d7-4aac053b8e62-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
On Mon, Oct 17, 2016 at 02:56:37PM -0400, Doug Ledford wrote:
> Since it got snipped, I'm pretty sure it just lists opensm in the Wants=
> tag. With systemd, that's a soft dependency. Only if opensm is
> installed and configured to start anyway does systemd then order this
> item after opensm. Since you need opensm for links to come up anyway,
> it makes sense for the order of startup for RDMA related items to be:
Daemons should not require opensm to be started to operate
correctly.
If they do we surely have a boot race bug that should be fixed,
because we cannot rely on a remote SM to have configured the port the
time window betweeen rdma.service completion and dependent service
start.
So I view every use of a opensm dependent in a unit file as either
unnecessary or working around a bug.. Lets ID the bugs so we at least
know where we stand..
Plus, there are more SM's than opensm, so we really should not
hardwire a single SM in the service files upstream, but try and work
with all the SMs...
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: iscsi_trx going into D state
From: Robert LeBlanc @ 2016-10-17 19:11 UTC (permalink / raw)
To: Zhu Lingshan
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <CAANLjFobXiBO2tXxTBB-8BQjM8FC0wmxdxQvEd6Rp=1LZkrvpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Sorry hit send too soon.
In addition, on the client we see:
# ps -aux | grep D | grep kworker
root 5583 0.0 0.0 0 0 ? D 11:55 0:03 [kworker/11:0]
root 7721 0.1 0.0 0 0 ? D 12:00 0:04 [kworker/4:25]
root 10877 0.0 0.0 0 0 ? D 09:27 0:00 [kworker/22:1]
root 11246 0.0 0.0 0 0 ? D 10:28 0:00 [kworker/30:2]
root 14034 0.0 0.0 0 0 ? D 12:20 0:02 [kworker/19:15]
root 14048 0.0 0.0 0 0 ? D 12:20 0:00 [kworker/16:0]
root 15871 0.0 0.0 0 0 ? D 12:25 0:00 [kworker/13:0]
root 17442 0.0 0.0 0 0 ? D 12:28 0:00 [kworker/9:1]
root 17816 0.0 0.0 0 0 ? D 12:30 0:00 [kworker/11:1]
root 18744 0.0 0.0 0 0 ? D 12:32 0:00 [kworker/10:2]
root 19060 0.0 0.0 0 0 ? D 12:32 0:00 [kworker/29:0]
root 21748 0.0 0.0 0 0 ? D 12:40 0:00 [kworker/21:0]
root 21967 0.0 0.0 0 0 ? D 12:40 0:00 [kworker/22:0]
root 21978 0.0 0.0 0 0 ? D 12:40 0:00 [kworker/22:2]
root 22024 0.0 0.0 0 0 ? D 12:40 0:00 [kworker/22:4]
root 22035 0.0 0.0 0 0 ? D 12:40 0:00 [kworker/22:5]
root 22060 0.0 0.0 0 0 ? D 12:40 0:00 [kworker/16:1]
root 22282 0.0 0.0 0 0 ? D 12:41 0:00 [kworker/26:0]
root 22362 0.0 0.0 0 0 ? D 12:42 0:00 [kworker/18:9]
root 22426 0.0 0.0 0 0 ? D 12:42 0:00 [kworker/16:3]
root 23298 0.0 0.0 0 0 ? D 12:43 0:00 [kworker/12:1]
root 23302 0.0 0.0 0 0 ? D 12:43 0:00 [kworker/12:5]
root 24264 0.0 0.0 0 0 ? D 12:46 0:00 [kworker/30:1]
root 24271 0.0 0.0 0 0 ? D 12:46 0:00 [kworker/14:8]
root 24441 0.0 0.0 0 0 ? D 12:47 0:00 [kworker/9:7]
root 24443 0.0 0.0 0 0 ? D 12:47 0:00 [kworker/9:9]
root 25005 0.0 0.0 0 0 ? D 12:48 0:00 [kworker/30:3]
root 25158 0.0 0.0 0 0 ? D 12:49 0:00 [kworker/9:12]
root 26382 0.0 0.0 0 0 ? D 12:52 0:00 [kworker/13:2]
root 26453 0.0 0.0 0 0 ? D 12:52 0:00 [kworker/21:2]
root 26724 0.0 0.0 0 0 ? D 12:53 0:00 [kworker/19:1]
root 28400 0.0 0.0 0 0 ? D 05:20 0:00 [kworker/25:1]
root 29552 0.0 0.0 0 0 ? D 11:40 0:00 [kworker/17:1]
root 29811 0.0 0.0 0 0 ? D 11:40 0:00 [kworker/7:10]
root 31903 0.0 0.0 0 0 ? D 11:43 0:00 [kworker/26:1]
And all of the processes have this stack:
[<ffffffffa0727ed5>] iser_release_work+0x25/0x60 [ib_iser]
[<ffffffff8109633f>] process_one_work+0x14f/0x400
[<ffffffff81096bb4>] worker_thread+0x114/0x470
[<ffffffff8109c6f8>] kthread+0xd8/0xf0
[<ffffffff8172004f>] ret_from_fork+0x3f/0x70
[<ffffffffffffffff>] 0xffffffffffffffff
We are not able to log out of the sessions in all cases. And have to
restart the box.
iscsiadm -m session will show messages like:
iscsiadm: could not read session targetname: 5
iscsiadm: could not find session info for session100
iscsiadm: could not read session targetname: 5
iscsiadm: could not find session info for session101
iscsiadm: could not read session targetname: 5
iscsiadm: could not find session info for session103
...
I can't find any way to force iscsiadm to clean up these sessions
possibly due to tasks in D state.
----------------
Robert LeBlanc
PGP Fingerprint 79A2 9CA4 6CC4 45DD A904 C70E E654 3BB2 FA62 B9F1
On Mon, Oct 17, 2016 at 10:32 AM, Robert LeBlanc <robert-4JaGZRWAfWbajFs6igw21g@public.gmane.org> wrote:
> Some more info as we hit this this morning. We have volumes mirrored
> between two targets and we had one target on the kernel with the three
> patches mentioned in this thread [0][1][2] and the other was on a
> kernel without the patches. We decided that after a week and a half we
> wanted to get both targets on the same kernel so we rebooted the
> non-patched target. Within an hour we saw iSCSI in D state with the
> same stack trace so it seems that we are not hitting any of the
> WARN_ON lines. We are getting both iscsi_trx and iscsi_np both in D
> state, this time we have two iscsi_trx processes in D state. I don't
> know if stale sessions on the clients could be contributing to this
> issue (the target trying to close non-existent sessions??). This is on
> 4.4.23. Any more debug info we can throw at this problem to help?
>
> Thank you,
> Robert LeBlanc
>
> # ps aux | grep D | grep iscsi
> root 16525 0.0 0.0 0 0 ? D 08:50 0:00 [iscsi_np]
> root 16614 0.0 0.0 0 0 ? D 08:50 0:00 [iscsi_trx]
> root 16674 0.0 0.0 0 0 ? D 08:50 0:00 [iscsi_trx]
>
> # for i in 16525 16614 16674; do echo $i; cat /proc/$i/stack; done
> 16525
> [<ffffffff814f0d5f>] iscsit_stop_session+0x19f/0x1d0
> [<ffffffff814e2516>] iscsi_check_for_session_reinstatement+0x1e6/0x270
> [<ffffffff814e4ed0>] iscsi_target_check_for_existing_instances+0x30/0x40
> [<ffffffff814e5020>] iscsi_target_do_login+0x140/0x640
> [<ffffffff814e63bc>] iscsi_target_start_negotiation+0x1c/0xb0
> [<ffffffff814e410b>] iscsi_target_login_thread+0xa9b/0xfc0
> [<ffffffff8109c748>] kthread+0xd8/0xf0
> [<ffffffff8172018f>] ret_from_fork+0x3f/0x70
> [<ffffffffffffffff>] 0xffffffffffffffff
> 16614
> [<ffffffff814cca79>] target_wait_for_sess_cmds+0x49/0x1a0
> [<ffffffffa064692b>] isert_wait_conn+0x1ab/0x2f0 [ib_isert]
> [<ffffffff814f0ef2>] iscsit_close_connection+0x162/0x870
> [<ffffffff814df9bf>] iscsit_take_action_for_connection_exit+0x7f/0x100
> [<ffffffff814f00a0>] iscsi_target_rx_thread+0x5a0/0xe80
> [<ffffffff8109c748>] kthread+0xd8/0xf0
> [<ffffffff8172018f>] ret_from_fork+0x3f/0x70
> [<ffffffffffffffff>] 0xffffffffffffffff
> 16674
> [<ffffffff814cca79>] target_wait_for_sess_cmds+0x49/0x1a0
> [<ffffffffa064692b>] isert_wait_conn+0x1ab/0x2f0 [ib_isert]
> [<ffffffff814f0ef2>] iscsit_close_connection+0x162/0x870
> [<ffffffff814df9bf>] iscsit_take_action_for_connection_exit+0x7f/0x100
> [<ffffffff814f00a0>] iscsi_target_rx_thread+0x5a0/0xe80
> [<ffffffff8109c748>] kthread+0xd8/0xf0
> [<ffffffff8172018f>] ret_from_fork+0x3f/0x70
> [<ffffffffffffffff>] 0xffffffffffffffff
>
>
> [0] https://www.spinics.net/lists/target-devel/msg13463.html
> [1] http://marc.info/?l=linux-scsi&m=147282568910535&w=2
> [2] http://www.spinics.net/lists/linux-scsi/msg100221.html
> ----------------
> Robert LeBlanc
> PGP Fingerprint 79A2 9CA4 6CC4 45DD A904 C70E E654 3BB2 FA62 B9F1
>
>
> On Fri, Oct 7, 2016 at 8:59 PM, Zhu Lingshan <lszhu-IBi9RG/b67k@public.gmane.org> wrote:
>> Hi Robert,
>>
>> I also see this issue, but this is not the only code path can trigger this
>> problem, I think you may also see iscsi_np in D status. I fixed one code
>> path whitch still not merged to mainline. I will forward you my patch later.
>> Note: my patch only fixed one code path, you may see other call statck with
>> D status.
>>
>> Thanks,
>> BR
>> Zhu Lingshan
>>
>>
>> 在 2016/10/1 1:14, Robert LeBlanc 写道:
>>>
>>> We are having a reoccurring problem where iscsi_trx is going into D
>>> state. It seems like it is waiting for a session tear down to happen
>>> or something, but keeps waiting. We have to reboot these targets on
>>> occasion. This is running the 4.4.12 kernel and we have seen it on
>>> several previous 4.4.x and 4.2.x kernels. There is no message in dmesg
>>> or /var/log/messages. This seems to happen with increased frequency
>>> when we have a disruption in our Infiniband fabric, but can happen
>>> without any changes to the fabric (other than hosts rebooting).
>>>
>>> # ps aux | grep iscsi | grep D
>>> root 4185 0.0 0.0 0 0 ? D Sep29 0:00
>>> [iscsi_trx]
>>> root 18505 0.0 0.0 0 0 ? D Sep29 0:00
>>> [iscsi_np]
>>>
>>> # cat /proc/4185/stack
>>> [<ffffffff814cc999>] target_wait_for_sess_cmds+0x49/0x1a0
>>> [<ffffffffa087292b>] isert_wait_conn+0x1ab/0x2f0 [ib_isert]
>>> [<ffffffff814f0de2>] iscsit_close_connection+0x162/0x840
>>> [<ffffffff814df8df>] iscsit_take_action_for_connection_exit+0x7f/0x100
>>> [<ffffffff814effc0>] iscsi_target_rx_thread+0x5a0/0xe80
>>> [<ffffffff8109c6f8>] kthread+0xd8/0xf0
>>> [<ffffffff8172004f>] ret_from_fork+0x3f/0x70
>>> [<ffffffffffffffff>] 0xffffffffffffffff
>>>
>>> # cat /proc/18505/stack
>>> [<ffffffff814f0c71>] iscsit_stop_session+0x1b1/0x1c0
>>> [<ffffffff814e2436>] iscsi_check_for_session_reinstatement+0x1e6/0x270
>>> [<ffffffff814e4df0>] iscsi_target_check_for_existing_instances+0x30/0x40
>>> [<ffffffff814e4f40>] iscsi_target_do_login+0x140/0x640
>>> [<ffffffff814e62dc>] iscsi_target_start_negotiation+0x1c/0xb0
>>> [<ffffffff814e402b>] iscsi_target_login_thread+0xa9b/0xfc0
>>> [<ffffffff8109c6f8>] kthread+0xd8/0xf0
>>> [<ffffffff8172004f>] ret_from_fork+0x3f/0x70
>>> [<ffffffffffffffff>] 0xffffffffffffffff
>>>
>>> What can we do to help get this resolved?
>>>
>>> Thanks,
>>>
>>> ----------------
>>> Robert LeBlanc
>>> PGP Fingerprint 79A2 9CA4 6CC4 45DD A904 C70E E654 3BB2 FA62 B9F1
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH 13/13] ibacm: mark large integer constant as unsigned long long
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
ibacm/src/acm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index b7f1dc0..2d0d1d4 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -2772,7 +2772,7 @@ static void acmc_recv_mad(struct acmc_port *port)
pthread_mutex_lock(&port->lock);
list_for_each(&port->sa_pending, req, entry) {
/* The lower 32-bit of the tid is used for agentid in umad */
- if (req->mad.sa_mad.mad_hdr.tid == (hdr->tid & 0xFFFFFFFF00000000)) {
+ if (req->mad.sa_mad.mad_hdr.tid == (hdr->tid & 0xFFFFFFFF00000000ULL)) {
found = 1;
list_del(&req->entry);
port->sa_credits++;
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 12/13] ibacm: mark symbols static where possible
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
ibacm/prov/acmp/src/acmp.c | 2 +-
ibacm/src/acm.c | 2 +-
ibacm/src/acme.c | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 1e37ee4..2ca0bf5 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -259,7 +259,7 @@ static atomic_t wait_cnt;
static pthread_t retry_thread_id;
static int retry_thread_started = 0;
-__thread char log_data[ACM_MAX_ADDRESS];
+static __thread char log_data[ACM_MAX_ADDRESS];
/*
* Service options - may be set through ibacm_opts.cfg file.
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 0571363..b7f1dc0 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -186,7 +186,7 @@ static struct acmc_client client_array[FD_SETSIZE - 1];
static FILE *flog;
static pthread_mutex_t log_lock;
-__thread char log_data[ACM_MAX_ADDRESS];
+static __thread char log_data[ACM_MAX_ADDRESS];
static atomic_t counter[ACM_MAX_COUNTER];
static struct acmc_device *
diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c
index 5a571cf..36221f4 100644
--- a/ibacm/src/acme.c
+++ b/ibacm/src/acme.c
@@ -69,10 +69,10 @@ enum perf_query_output {
PERF_QUERY_EP_ADDR
};
static enum perf_query_output perf_query;
-int verbose;
+static int verbose;
-struct ibv_context **verbs;
-int dev_cnt;
+static struct ibv_context **verbs;
+static int dev_cnt;
#define VPRINT(format, ...) do { if (verbose) printf(format, ## __VA_ARGS__ ); } while (0)
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 11/13] ibacm: use ccan/list.h
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
Trivial conversion, aided by the additional type safety and helpers.
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
ibacm/linux/dlist.h | 80 ------------------
ibacm/prov/acmp/src/acmp.c | 141 +++++++++++--------------------
ibacm/src/acm.c | 206 ++++++++++++++-------------------------------
3 files changed, 112 insertions(+), 315 deletions(-)
delete mode 100644 ibacm/linux/dlist.h
diff --git a/ibacm/linux/dlist.h b/ibacm/linux/dlist.h
deleted file mode 100644
index 89f5af3..0000000
--- a/ibacm/linux/dlist.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2009 Intel Corporation. All rights reserved.
- *
- * This software is available to you under the OpenIB.org BSD license
- * below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef _DLIST_H_
-#define _DLIST_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct _DLIST_ENTRY {
- struct _DLIST_ENTRY *Next;
- struct _DLIST_ENTRY *Prev;
-
-} DLIST_ENTRY;
-
-static void DListInit(DLIST_ENTRY *pHead)
-{
- pHead->Next = pHead;
- pHead->Prev = pHead;
-}
-
-static int DListEmpty(DLIST_ENTRY *pHead)
-{
- return pHead->Next == pHead;
-}
-
-static void DListInsertAfter(DLIST_ENTRY *pNew, DLIST_ENTRY *pHead)
-{
- pNew->Next = pHead->Next;
- pNew->Prev = pHead;
- pHead->Next->Prev = pNew;
- pHead->Next = pNew;
-}
-
-static void DListInsertBefore(DLIST_ENTRY *pNew, DLIST_ENTRY *pHead)
-{
- DListInsertAfter(pNew, pHead->Prev);
-}
-
-#define DListInsertHead DListInsertAfter
-#define DListInsertTail DListInsertBefore
-
-static void DListRemove(DLIST_ENTRY *pEntry)
-{
- pEntry->Prev->Next = pEntry->Next;
- pEntry->Next->Prev = pEntry->Prev;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _DLIST_H_
diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 1cb14e1..1e37ee4 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -45,7 +45,6 @@
#include <infiniband/umad.h>
#include <infiniband/verbs.h>
#include <ifaddrs.h>
-#include <dlist.h>
#include <dlfcn.h>
#include <search.h>
#include <netdb.h>
@@ -56,6 +55,7 @@
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <inttypes.h>
+#include <ccan/list.h>
#include "acm_util.h"
#include "acm_mad.h"
@@ -113,7 +113,7 @@ struct acmp_dest {
struct ibv_path_record path;
union ibv_gid mgid;
uint64_t req_id;
- DLIST_ENTRY req_queue;
+ struct list_head req_queue;
uint32_t remote_qpn;
pthread_mutex_t lock;
enum acmp_state state;
@@ -129,7 +129,7 @@ struct acmp_device;
struct acmp_port {
struct acmp_device *dev;
const struct acm_port *port;
- DLIST_ENTRY ep_list;
+ struct list_head ep_list;
pthread_mutex_t lock;
struct acmp_dest sa_dest;
enum ibv_port_state state;
@@ -148,7 +148,7 @@ struct acmp_device {
struct ibv_comp_channel *channel;
struct ibv_pd *pd;
uint64_t guid;
- DLIST_ENTRY entry;
+ struct list_node entry;
pthread_t comp_thread_id;
int port_cnt;
struct acmp_port port[0];
@@ -157,7 +157,7 @@ struct acmp_device {
/* Maintain separate virtual send queues to avoid deadlock */
struct acmp_send_queue {
int credits;
- DLIST_ENTRY pending;
+ struct list_head pending;
};
struct acmp_addr {
@@ -173,7 +173,7 @@ struct acmp_ep {
struct ibv_qp *qp;
struct ibv_mr *mr;
uint8_t *recv_bufs;
- DLIST_ENTRY entry;
+ struct list_node entry;
char id_string[ACM_MAX_ADDRESS];
void *dest_map[ACM_ADDRESS_RESERVED - 1];
struct acmp_dest mc_dest[MAX_EP_MC];
@@ -184,15 +184,15 @@ struct acmp_ep {
pthread_mutex_t lock;
struct acmp_send_queue resolve_queue;
struct acmp_send_queue resp_queue;
- DLIST_ENTRY active_queue;
- DLIST_ENTRY wait_queue;
+ struct list_head active_queue;
+ struct list_head wait_queue;
enum acmp_state state;
struct acmp_addr addr_info[MAX_EP_ADDR];
atomic_t counters[ACM_MAX_COUNTER];
};
struct acmp_send_msg {
- DLIST_ENTRY entry;
+ struct list_node entry;
struct acmp_ep *ep;
struct acmp_dest *dest;
struct ibv_ah *ah;
@@ -210,7 +210,7 @@ struct acmp_send_msg {
struct acmp_request {
uint64_t id;
- DLIST_ENTRY entry;
+ struct list_node entry;
struct acm_msg msg;
struct acmp_ep *ep;
};
@@ -249,11 +249,11 @@ static struct acm_provider def_prov = {
.query_perf = acmp_query_perf,
};
-static DLIST_ENTRY acmp_dev_list;
+static LIST_HEAD(acmp_dev_list);
static pthread_mutex_t acmp_dev_lock;
static atomic_t g_tid;
-static DLIST_ENTRY timeout_list;
+static LIST_HEAD(timeout_list);
static event_t timeout_event;
static atomic_t wait_cnt;
static pthread_t retry_thread_id;
@@ -301,7 +301,7 @@ static void
acmp_init_dest(struct acmp_dest *dest, uint8_t addr_type,
const uint8_t *addr, size_t size)
{
- DListInit(&dest->req_queue);
+ list_head_init(&dest->req_queue);
atomic_init(&dest->refcnt);
atomic_set(&dest->refcnt, 1);
pthread_mutex_init(&dest->lock, NULL);
@@ -508,11 +508,11 @@ static void acmp_post_send(struct acmp_send_queue *queue, struct acmp_send_msg *
if (queue->credits) {
acm_log(2, "posting send to QP\n");
queue->credits--;
- DListInsertTail(&msg->entry, &ep->active_queue);
+ list_add_tail(&ep->active_queue, &msg->entry);
ibv_post_send(ep->qp, &msg->wr, &bad_wr);
} else {
acm_log(2, "no sends available, queuing message\n");
- DListInsertTail(&msg->entry, &queue->pending);
+ list_add_tail(&queue->pending, &msg->entry);
}
pthread_mutex_unlock(&ep->lock);
}
@@ -539,17 +539,14 @@ static void acmp_send_available(struct acmp_ep *ep, struct acmp_send_queue *queu
{
struct acmp_send_msg *msg;
struct ibv_send_wr *bad_wr;
- DLIST_ENTRY *entry;
- if (DListEmpty(&queue->pending)) {
- queue->credits++;
- } else {
+ msg = list_pop(&queue->pending, struct acmp_send_msg, entry);
+ if (msg) {
acm_log(2, "posting queued send message\n");
- entry = queue->pending.Next;
- DListRemove(entry);
- msg = container_of(entry, struct acmp_send_msg, entry);
- DListInsertTail(&msg->entry, &ep->active_queue);
+ list_add_tail(&ep->active_queue, &msg->entry);
ibv_post_send(ep->qp, &msg->wr, &bad_wr);
+ } else {
+ queue->credits++;
}
}
@@ -558,11 +555,11 @@ static void acmp_complete_send(struct acmp_send_msg *msg)
struct acmp_ep *ep = msg->ep;
pthread_mutex_lock(&ep->lock);
- DListRemove(&msg->entry);
+ list_del(&msg->entry);
if (msg->tries) {
acm_log(2, "waiting for response\n");
msg->expires = time_stamp_ms() + ep->port->subnet_timeout + timeout;
- DListInsertTail(&msg->entry, &ep->wait_queue);
+ list_add_tail(&ep->wait_queue, &msg->entry);
if (atomic_inc(&wait_cnt) == 1)
event_signal(&timeout_event);
} else {
@@ -575,20 +572,17 @@ static void acmp_complete_send(struct acmp_send_msg *msg)
static struct acmp_send_msg *acmp_get_request(struct acmp_ep *ep, uint64_t tid, int *free)
{
- struct acmp_send_msg *msg, *req = NULL;
+ struct acmp_send_msg *msg, *next, *req = NULL;
struct acm_mad *mad;
- DLIST_ENTRY *entry, *next;
acm_log(2, "\n");
pthread_mutex_lock(&ep->lock);
- for (entry = ep->wait_queue.Next; entry != &ep->wait_queue; entry = next) {
- next = entry->Next;
- msg = container_of(entry, struct acmp_send_msg, entry);
+ list_for_each_safe(&ep->wait_queue, msg, next, entry) {
mad = (struct acm_mad *) msg->data;
if (mad->tid == tid) {
acm_log(2, "match found in wait queue\n");
req = msg;
- DListRemove(entry);
+ list_del(&msg->entry);
(void) atomic_dec(&wait_cnt);
acmp_send_available(ep, msg->req_queue);
*free = 1;
@@ -596,8 +590,7 @@ static struct acmp_send_msg *acmp_get_request(struct acmp_ep *ep, uint64_t tid,
}
}
- for (entry = ep->active_queue.Next; entry != &ep->active_queue; entry = entry->Next) {
- msg = container_of(entry, struct acmp_send_msg, entry);
+ list_for_each(&ep->active_queue, msg, entry) {
mad = (struct acm_mad *) msg->data;
if (mad->tid == tid && msg->tries) {
acm_log(2, "match found in active queue\n");
@@ -972,14 +965,10 @@ static void
acmp_complete_queued_req(struct acmp_dest *dest, uint8_t status)
{
struct acmp_request *req;
- DLIST_ENTRY *entry;
acm_log(2, "status %d\n", status);
pthread_mutex_lock(&dest->lock);
- while (!DListEmpty(&dest->req_queue)) {
- entry = dest->req_queue.Next;
- DListRemove(entry);
- req = container_of(entry, struct acmp_request, entry);
+ while ((req = list_pop(&dest->req_queue, struct acmp_request, entry))) {
pthread_mutex_unlock(&dest->lock);
acm_log(2, "completing request, client %" PRIu64 "\n", req->id);
@@ -1113,7 +1102,7 @@ acmp_process_addr_req(struct acmp_ep *ep, struct ibv_wc *wc, struct acm_mad *mad
status = acmp_record_acm_route(ep, dest);
break;
}
- if (addr || !DListEmpty(&dest->req_queue)) {
+ if (addr || !list_empty(&dest->req_queue)) {
status = acmp_resolve_path_sa(ep, dest, acmp_resolve_sa_resp);
if (status)
break;
@@ -1458,15 +1447,12 @@ static void acmp_ep_join(struct acmp_ep *ep)
static int acmp_port_join(void *port_context)
{
struct acmp_ep *ep;
- DLIST_ENTRY *ep_entry;
struct acmp_port *port = port_context;
acm_log(1, "device %s port %d\n", port->dev->verbs->device->name,
port->port_num);
- for (ep_entry = port->ep_list.Next; ep_entry != &port->ep_list;
- ep_entry = ep_entry->Next) {
- ep = container_of(ep_entry, struct acmp_ep, entry);
+ list_for_each(&port->ep_list, ep, entry) {
if (!ep->endpoint) {
/* Stale endpoint */
continue;
@@ -1497,16 +1483,11 @@ static int acmp_handle_event(void *port_context, enum ibv_event_type type)
static void acmp_process_timeouts(void)
{
- DLIST_ENTRY *entry;
struct acmp_send_msg *msg;
struct acm_resolve_rec *rec;
struct acm_mad *mad;
-
- while (!DListEmpty(&timeout_list)) {
- entry = timeout_list.Next;
- DListRemove(entry);
- msg = container_of(entry, struct acmp_send_msg, entry);
+ while ((msg = list_pop(&timeout_list, struct acmp_send_msg, entry))) {
mad = (struct acm_mad *) &msg->data[0];
rec = (struct acm_resolve_rec *) mad->data;
@@ -1521,24 +1502,21 @@ static void acmp_process_timeouts(void)
static void acmp_process_wait_queue(struct acmp_ep *ep, uint64_t *next_expire)
{
- struct acmp_send_msg *msg;
- DLIST_ENTRY *entry, *next;
+ struct acmp_send_msg *msg, *next;
struct ibv_send_wr *bad_wr;
- for (entry = ep->wait_queue.Next; entry != &ep->wait_queue; entry = next) {
- next = entry->Next;
- msg = container_of(entry, struct acmp_send_msg, entry);
+ list_for_each_safe(&ep->wait_queue, msg, next, entry) {
if (msg->expires < time_stamp_ms()) {
- DListRemove(entry);
+ list_del(&msg->entry);
(void) atomic_dec(&wait_cnt);
if (--msg->tries) {
acm_log(1, "notice - retrying request\n");
- DListInsertTail(&msg->entry, &ep->active_queue);
+ list_add_tail(&ep->active_queue, &msg->entry);
ibv_post_send(ep->qp, &msg->wr, &bad_wr);
} else {
acm_log(0, "notice - failing request\n");
acmp_send_available(ep, msg->req_queue);
- DListInsertTail(&msg->entry, &timeout_list);
+ list_add_tail(&timeout_list, &msg->entry);
}
} else {
*next_expire = min(*next_expire, msg->expires);
@@ -1556,7 +1534,6 @@ static void *acmp_retry_handler(void *context)
struct acmp_device *dev;
struct acmp_port *port;
struct acmp_ep *ep;
- DLIST_ENTRY *dev_entry, *ep_entry;
uint64_t next_expire;
int i, wait;
@@ -1579,24 +1556,17 @@ static void *acmp_retry_handler(void *context)
next_expire = -1;
pthread_mutex_lock(&acmp_dev_lock);
- for (dev_entry = acmp_dev_list.Next; dev_entry != &acmp_dev_list;
- dev_entry = dev_entry->Next) {
-
- dev = container_of(dev_entry, struct acmp_device, entry);
+ list_for_each(&acmp_dev_list, dev, entry) {
pthread_mutex_unlock(&acmp_dev_lock);
for (i = 0; i < dev->port_cnt; i++) {
port = &dev->port[i];
pthread_mutex_lock(&port->lock);
- for (ep_entry = port->ep_list.Next;
- ep_entry != &port->ep_list;
- ep_entry = ep_entry->Next) {
-
- ep = container_of(ep_entry, struct acmp_ep, entry);
+ list_for_each(&port->ep_list, ep, entry) {
pthread_mutex_unlock(&port->lock);
pthread_mutex_lock(&ep->lock);
- if (!DListEmpty(&ep->wait_queue))
+ if (!list_empty(&ep->wait_queue))
acmp_process_wait_queue(ep, &next_expire);
pthread_mutex_unlock(&ep->lock);
pthread_mutex_lock(&port->lock);
@@ -1735,7 +1705,7 @@ static uint8_t acmp_queue_req(struct acmp_dest *dest, uint64_t id, struct acm_ms
}
req->ep = dest->ep;
- DListInsertTail(&req->entry, &dest->req_queue);
+ list_add_tail(&dest->req_queue, &req->entry);
return ACM_STATUS_SUCCESS;
}
@@ -2446,15 +2416,12 @@ static void acmp_remove_addr(void *addr_context)
static struct acmp_port *acmp_get_port(struct acm_endpoint *endpoint)
{
struct acmp_device *dev;
- DLIST_ENTRY *dev_entry;
acm_log(1, "dev 0x%" PRIx64 " port %d pkey 0x%x\n",
endpoint->port->dev->dev_guid, endpoint->port->port_num,
endpoint->pkey);
- for (dev_entry = acmp_dev_list.Next; dev_entry != &acmp_dev_list;
- dev_entry = dev_entry->Next) {
- dev = container_of(dev_entry, struct acmp_device, entry);
+ list_for_each(&acmp_dev_list, dev, entry) {
if (dev->guid == endpoint->port->dev->dev_guid)
return &dev->port[endpoint->port->port_num - 1];
}
@@ -2466,13 +2433,11 @@ static struct acmp_ep *
acmp_get_ep(struct acmp_port *port, struct acm_endpoint *endpoint)
{
struct acmp_ep *ep;
- DLIST_ENTRY *entry;
acm_log(1, "dev 0x%" PRIx64 " port %d pkey 0x%x\n",
endpoint->port->dev->dev_guid, endpoint->port->port_num, endpoint->pkey);
- for (entry = port->ep_list.Next; entry != &port->ep_list;
- entry = entry->Next) {
- ep = container_of(entry, struct acmp_ep, entry);
+
+ list_for_each(&port->ep_list, ep, entry) {
if (ep->pkey == endpoint->pkey)
return ep;
}
@@ -2526,10 +2491,10 @@ acmp_alloc_ep(struct acmp_port *port, struct acm_endpoint *endpoint)
ep->pkey = endpoint->pkey;
ep->resolve_queue.credits = resolve_depth;
ep->resp_queue.credits = send_depth;
- DListInit(&ep->resolve_queue.pending);
- DListInit(&ep->resp_queue.pending);
- DListInit(&ep->active_queue);
- DListInit(&ep->wait_queue);
+ list_head_init(&ep->resolve_queue.pending);
+ list_head_init(&ep->resp_queue.pending);
+ list_head_init(&ep->active_queue);
+ list_head_init(&ep->wait_queue);
pthread_mutex_init(&ep->lock, NULL);
sprintf(ep->id_string, "%s-%d-0x%x", port->dev->verbs->device->name,
port->port_num, endpoint->pkey);
@@ -2628,7 +2593,7 @@ static int acmp_open_endpoint(const struct acm_endpoint *endpoint,
goto err2;
pthread_mutex_lock(&port->lock);
- DListInsertHead(&ep->entry, &port->ep_list);
+ list_add(&port->ep_list, &ep->entry);
pthread_mutex_unlock(&port->lock);
acmp_ep_preload(ep);
acmp_ep_join(ep);
@@ -2757,7 +2722,7 @@ static void acmp_init_port(struct acmp_port *port, struct acmp_device *dev,
port->dev = dev;
port->port_num = port_num;
pthread_mutex_init(&port->lock, NULL);
- DListInit(&port->ep_list);
+ list_head_init(&port->ep_list);
acmp_init_dest(&port->sa_dest, ACM_ADDRESS_LID, NULL, 0);
port->state = IBV_PORT_DOWN;
}
@@ -2768,16 +2733,12 @@ static int acmp_open_dev(const struct acm_device *device, void **dev_context)
size_t size;
struct ibv_device_attr attr;
int i, ret;
- DLIST_ENTRY *dev_entry;
struct ibv_context *verbs;
acm_log(1, "dev_guid 0x%" PRIx64 " %s\n", device->dev_guid,
device->verbs->device->name);
- for (dev_entry = acmp_dev_list.Next; dev_entry != &acmp_dev_list;
- dev_entry = dev_entry->Next) {
- dev = container_of(dev_entry, struct acmp_device, entry);
-
+ list_for_each(&acmp_dev_list, dev, entry) {
if (dev->guid == device->dev_guid) {
acm_log(2, "dev_guid 0x%" PRIx64 " already exits\n",
device->dev_guid);
@@ -2839,7 +2800,7 @@ static int acmp_open_dev(const struct acm_device *device, void **dev_context)
}
pthread_mutex_lock(&acmp_dev_lock);
- DListInsertHead(&dev->entry, &acmp_dev_list);
+ list_add(&acmp_dev_list, &dev->entry);
pthread_mutex_unlock(&acmp_dev_lock);
dev->guid = device->dev_guid;
*dev_context = dev;
@@ -2947,9 +2908,7 @@ static void __attribute__((constructor)) acmp_init(void)
atomic_init(&g_tid);
atomic_init(&wait_cnt);
- DListInit(&acmp_dev_list);
pthread_mutex_init(&acmp_dev_lock, NULL);
- DListInit(&timeout_list);
event_init(&timeout_event);
umad_init();
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 37bbbe7..0571363 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -46,7 +46,6 @@
#include <infiniband/verbs.h>
#include <infiniband/umad_types.h>
#include <infiniband/umad_sa.h>
-#include <dlist.h>
#include <dlfcn.h>
#include <search.h>
#include <net/if.h>
@@ -59,6 +58,7 @@
#include <rdma/ib_user_sa.h>
#include <poll.h>
#include <inttypes.h>
+#include <ccan/list.h>
#include "acm_mad.h"
#include "acm_util.h"
#if !defined(RDMA_NL_LS_F_ERR)
@@ -75,19 +75,19 @@
#define NL_CLIENT_INDEX 0
struct acmc_subnet {
- DLIST_ENTRY entry;
+ struct list_node entry;
uint64_t subnet_prefix;
};
struct acmc_prov {
struct acm_provider *prov;
void *handle;
- DLIST_ENTRY entry;
- DLIST_ENTRY subnet_list;
+ struct list_node entry;
+ struct list_head subnet_list;
};
struct acmc_prov_context {
- DLIST_ENTRY entry;
+ struct list_node entry;
atomic_t refcnt;
struct acm_provider *prov;
void *context;
@@ -103,11 +103,11 @@ struct acmc_port {
int mad_portid;
int mad_agentid;
struct ib_mad_addr sa_addr;
- DLIST_ENTRY sa_pending;
- DLIST_ENTRY sa_wait;
+ struct list_head sa_pending;
+ struct list_head sa_wait;
int sa_credits;
pthread_mutex_t lock;
- DLIST_ENTRY ep_list;
+ struct list_head ep_list;
enum ibv_port_state state;
int gid_cnt;
union ibv_gid *gid_tbl;
@@ -119,8 +119,8 @@ struct acmc_port {
struct acmc_device {
struct acm_device device;
- DLIST_ENTRY entry;
- DLIST_ENTRY prov_dev_context_list;
+ struct list_node entry;
+ struct list_head prov_dev_context_list;
int port_cnt;
struct acmc_port port[0];
};
@@ -136,7 +136,7 @@ struct acmc_ep {
struct acm_endpoint endpoint;
void *prov_ep_context;
struct acmc_addr addr_info[MAX_EP_ADDR];
- DLIST_ENTRY entry;
+ struct list_node entry;
};
struct acmc_client {
@@ -153,7 +153,7 @@ union socket_addr {
};
struct acmc_sa_req {
- DLIST_ENTRY entry;
+ struct list_node entry;
struct acmc_ep *ep;
void (*resp_handler)(struct acm_sa_mad *);
struct acm_sa_mad mad;
@@ -175,10 +175,10 @@ struct acm_nl_msg {
};
static char def_prov_name[ACM_PROV_NAME_SIZE] = "ibacmp";
-static DLIST_ENTRY provider_list;
+static LIST_HEAD(provider_list);
static struct acmc_prov *def_provider = NULL;
-static DLIST_ENTRY dev_list;
+static LIST_HEAD(dev_list);
static int listen_socket;
static int ip_mon_socket;
@@ -308,13 +308,11 @@ acm_alloc_prov_context(struct acm_provider *prov)
}
static struct acmc_prov_context *
-acm_get_prov_context(DLIST_ENTRY *list, struct acm_provider *prov)
+acm_get_prov_context(struct list_head *list, struct acm_provider *prov)
{
- DLIST_ENTRY *entry;
struct acmc_prov_context *ctx;
- for (entry = list->Next; entry != list; entry = entry->Next) {
- ctx = container_of(entry, struct acmc_prov_context, entry);
+ list_for_each(list, ctx, entry) {
if (ctx->prov == prov) {
return ctx;
}
@@ -324,7 +322,7 @@ acm_get_prov_context(DLIST_ENTRY *list, struct acm_provider *prov)
}
static struct acmc_prov_context *
-acm_acquire_prov_context(DLIST_ENTRY *list, struct acm_provider *prov)
+acm_acquire_prov_context(struct list_head *list, struct acm_provider *prov)
{
struct acmc_prov_context *ctx;
@@ -335,7 +333,7 @@ acm_acquire_prov_context(DLIST_ENTRY *list, struct acm_provider *prov)
acm_log(0, "Error -- failed to allocate provider context\n");
return NULL;
}
- DListInsertTail(&ctx->entry, list);
+ list_add_tail(list, &ctx->entry);
} else {
atomic_inc(&ctx->refcnt);
}
@@ -347,7 +345,7 @@ static void
acm_release_prov_context(struct acmc_prov_context *ctx)
{
if (atomic_dec(&ctx->refcnt) <= 0) {
- DListRemove(&ctx->entry);
+ list_del(&ctx->entry);
free(ctx);
}
}
@@ -679,7 +677,6 @@ acm_get_port_ep_address(struct acmc_port *port, struct acm_ep_addr_data *data)
{
struct acmc_ep *ep;
struct acm_address *addr;
- DLIST_ENTRY *ep_entry;
int i;
if (port->state != IBV_PORT_ACTIVE)
@@ -689,10 +686,7 @@ acm_get_port_ep_address(struct acmc_port *port, struct acm_ep_addr_data *data)
!acm_is_path_from_port(port, &data->info.path))
return NULL;
- for (ep_entry = port->ep_list.Next; ep_entry != &port->ep_list;
- ep_entry = ep_entry->Next) {
-
- ep = container_of(ep_entry, struct acmc_ep, entry);
+ list_for_each(&port->ep_list, ep, entry) {
if ((data->type == ACM_EP_INFO_PATH) &&
(!data->info.path.pkey ||
(ntohs(data->info.path.pkey) == ep->endpoint.pkey))) {
@@ -715,16 +709,12 @@ static struct acmc_addr *acm_get_ep_address(struct acm_ep_addr_data *data)
{
struct acmc_device *dev;
struct acmc_addr *addr;
- DLIST_ENTRY *dev_entry;
int i;
acm_format_name(2, log_data, sizeof log_data,
data->type, data->info.addr, sizeof data->info.addr);
acm_log(2, "%s\n", log_data);
- for (dev_entry = dev_list.Next; dev_entry != &dev_list;
- dev_entry = dev_entry->Next) {
-
- dev = container_of(dev_entry, struct acmc_device, entry);
+ list_for_each(&dev_list, dev, entry) {
for (i = 0; i < dev->port_cnt; i++) {
addr = acm_get_port_ep_address(&dev->port[i], data);
if (addr)
@@ -741,27 +731,17 @@ static struct acmc_addr *acm_get_ep_address(struct acm_ep_addr_data *data)
static struct acmc_ep *acm_get_ep(int index)
{
struct acmc_device *dev;
- DLIST_ENTRY *dev_entry;
struct acmc_ep *ep;
- DLIST_ENTRY *ep_entry;
int i, inx = 0;
acm_log(2, "ep index %d\n", index);
- for (dev_entry = dev_list.Next; dev_entry != &dev_list;
- dev_entry = dev_entry->Next) {
- dev = container_of(dev_entry, struct acmc_device, entry);
+ list_for_each(&dev_list, dev, entry) {
for (i = 0; i < dev->port_cnt; i++) {
if (dev->port[i].state != IBV_PORT_ACTIVE)
continue;
- for (ep_entry = dev->port[i].ep_list.Next;
- ep_entry != &dev->port[i].ep_list;
- ep_entry = ep_entry->Next, inx++) {
- if (index == inx) {
- ep = container_of(ep_entry,
- struct acmc_ep,
- entry);
+ list_for_each(&dev->port[i].ep_list, ep, entry) {
+ if (index == inx)
return ep;
- }
}
}
}
@@ -1271,27 +1251,19 @@ static void acm_ip_iter_cb(char *ifname, union ibv_gid *gid, uint16_t pkey,
*/
static int resync_system_ips(void)
{
- DLIST_ENTRY *dev_entry;
struct acmc_device *dev;
struct acmc_port *port;
struct acmc_ep *ep;
- DLIST_ENTRY *entry;
int i, cnt;
acm_log(0, "Resyncing all IP's\n");
/* mark all IP's invalid */
- for (dev_entry = dev_list.Next; dev_entry != &dev_list;
- dev_entry = dev_entry->Next) {
- dev = container_of(dev_entry, struct acmc_device, entry);
-
+ list_for_each(&dev_list, dev, entry) {
for (cnt = 0; cnt < dev->port_cnt; cnt++) {
port = &dev->port[cnt];
- for (entry = port->ep_list.Next; entry != &port->ep_list;
- entry = entry->Next) {
- ep = container_of(entry, struct acmc_ep, entry);
-
+ list_for_each(&port->ep_list, ep, entry) {
for (i = 0; i < MAX_EP_ADDR; i++) {
if (ep->addr_info[i].addr.type == ACM_ADDRESS_IP ||
ep->addr_info[i].addr.type == ACM_ADDRESS_IP6)
@@ -1703,7 +1675,6 @@ static void acm_server(void)
fd_set readfds;
int i, n, ret;
struct acmc_device *dev;
- DLIST_ENTRY *dev_entry;
acm_log(0, "started\n");
acm_init_server();
@@ -1731,9 +1702,7 @@ static void acm_server(void)
}
}
- for (dev_entry = dev_list.Next; dev_entry != &dev_list;
- dev_entry = dev_entry->Next) {
- dev = container_of(dev_entry, struct acmc_device, entry);
+ list_for_each(&dev_list, dev, entry) {
FD_SET(dev->device.verbs->async_fd, &readfds);
n = max(n, (int) dev->device.verbs->async_fd);
}
@@ -1761,9 +1730,7 @@ static void acm_server(void)
}
}
- for (dev_entry = dev_list.Next; dev_entry != &dev_list;
- dev_entry = dev_entry->Next) {
- dev = container_of(dev_entry, struct acmc_device, entry);
+ list_for_each(&dev_list, dev, entry) {
if (FD_ISSET(dev->device.verbs->async_fd, &readfds)) {
acm_log(2, "handling event from %s\n",
dev->device.verbs->device->name);
@@ -1907,15 +1874,10 @@ out:
static struct acmc_device *
acm_get_device_from_gid(union ibv_gid *sgid, uint8_t *port)
{
- DLIST_ENTRY *dev_entry;
struct acmc_device *dev;
int i;
- for (dev_entry = dev_list.Next; dev_entry != &dev_list;
- dev_entry = dev_entry->Next) {
-
- dev = container_of(dev_entry, struct acmc_device, entry);
-
+ list_for_each(&dev_list, dev, entry) {
for (*port = 1; *port <= dev->port_cnt; (*port)++) {
for (i = 0; i < dev->port[*port - 1].gid_cnt; i++) {
@@ -2032,12 +1994,10 @@ out:
static struct acmc_ep *acm_find_ep(struct acmc_port *port, uint16_t pkey)
{
struct acmc_ep *ep, *res = NULL;
- DLIST_ENTRY *entry;
acm_log(2, "pkey 0x%x\n", pkey);
- for (entry = port->ep_list.Next; entry != &port->ep_list; entry = entry->Next) {
- ep = container_of(entry, struct acmc_ep, entry);
+ list_for_each(&port->ep_list, ep, entry) {
if (ep->endpoint.pkey == pkey) {
res = ep;
break;
@@ -2111,7 +2071,7 @@ static void acm_ep_up(struct acmc_port *port, uint16_t pkey)
goto ep_close;
}
- DListInsertHead(&ep->entry, &port->ep_list);
+ list_add(&port->ep_list, &ep->entry);
return;
ep_close:
@@ -2123,22 +2083,13 @@ ep_close:
static void acm_assign_provider(struct acmc_port *port)
{
- DLIST_ENTRY *entry;
struct acmc_prov *prov;
- DLIST_ENTRY *sub_entry;
struct acmc_subnet *subnet;
acm_log(2, "port %s/%d\n", port->port.dev->verbs->device->name,
port->port.port_num);
- for (entry = provider_list.Next; entry != &provider_list;
- entry = entry->Next) {
- prov = container_of(entry, struct acmc_prov, entry);
-
- for (sub_entry = prov->subnet_list.Next;
- sub_entry != &prov->subnet_list;
- sub_entry = sub_entry->Next) {
- subnet = container_of(sub_entry, struct acmc_subnet,
- entry);
+ list_for_each(&provider_list, prov, entry) {
+ list_for_each(&prov->subnet_list, subnet, entry) {
if (subnet->subnet_prefix ==
port->gid_tbl[0].global.subnet_prefix) {
acm_log(2, "Found provider %s for port %s/%d\n",
@@ -2291,16 +2242,11 @@ err1:
static void acm_shutdown_port(struct acmc_port *port)
{
- DLIST_ENTRY *entry;
struct acmc_ep *ep;
struct acmc_prov_context *dev_ctx;
- while (!DListEmpty(&port->ep_list)) {
- entry = port->ep_list.Next;
- DListRemove(entry);
- ep = container_of(entry, struct acmc_ep, entry);
+ while ((ep = list_pop(&port->ep_list, struct acmc_ep, entry)))
acm_ep_down(ep);
- }
if (port->prov_port_context) {
port->prov->close_port(port->prov_port_context);
@@ -2404,14 +2350,10 @@ static void acm_event_handler(struct acmc_device *dev)
static void acm_activate_devices(void)
{
struct acmc_device *dev;
- DLIST_ENTRY *dev_entry;
int i;
acm_log(1, "\n");
- for (dev_entry = dev_list.Next; dev_entry != &dev_list;
- dev_entry = dev_entry->Next) {
-
- dev = container_of(dev_entry, struct acmc_device, entry);
+ list_for_each(&dev_list, dev, entry) {
for (i = 0; i < dev->port_cnt; i++) {
acm_port_up(&dev->port[i]);
}
@@ -2426,9 +2368,9 @@ acm_open_port(struct acmc_port *port, struct acmc_device *dev, uint8_t port_num)
port->port.dev = &dev->device;
port->port.port_num = port_num;
pthread_mutex_init(&port->lock, NULL);
- DListInit(&port->ep_list);
- DListInit(&port->sa_pending);
- DListInit(&port->sa_wait);
+ list_head_init(&port->ep_list);
+ list_head_init(&port->sa_pending);
+ list_head_init(&port->sa_wait);
port->sa_credits = sa.depth;
port->sa_addr.qpn = htonl(1);
port->sa_addr.qkey = htonl(ACM_QKEY);
@@ -2475,13 +2417,13 @@ static void acm_open_dev(struct ibv_device *ibdev)
dev->device.verbs = verbs;
dev->device.dev_guid = ibv_get_device_guid(ibdev);
dev->port_cnt = attr.phys_port_cnt;
- DListInit(&dev->prov_dev_context_list);
+ list_head_init(&dev->prov_dev_context_list);
for (i = 0; i < dev->port_cnt; i++) {
acm_open_port(&dev->port[i], dev, i + 1);
}
- DListInsertHead(&dev->entry, &dev_list);
+ list_add(&dev_list, &dev->entry);
acm_log(1, "%s opened\n", ibdev->name);
return;
@@ -2507,7 +2449,7 @@ static int acm_open_devices(void)
acm_open_dev(ibdev[i]);
ibv_free_device_list(ibdev);
- if (DListEmpty(&dev_list)) {
+ if (list_empty(&dev_list)) {
acm_log(0, "ERROR - no devices\n");
return -1;
}
@@ -2523,7 +2465,6 @@ static void acm_load_prov_config(void)
char prov_name[ACM_PROV_NAME_SIZE];
uint64_t prefix;
struct acmc_prov *prov;
- DLIST_ENTRY *entry;
struct acmc_subnet *subnet;
if (!(fd = fopen(opts_file, "r")))
@@ -2562,9 +2503,7 @@ static void acm_load_prov_config(void)
/* Convert it into network byte order */
prefix = htonll(prefix);
- for (entry = provider_list.Next; entry != &provider_list;
- entry = entry->Next) {
- prov = container_of(entry, struct acmc_prov, entry);
+ list_for_each(&provider_list, prov, entry) {
if (!strcasecmp(prov->prov->name, prov_name)) {
subnet = calloc(1, sizeof (*subnet));
if (!subnet) {
@@ -2572,17 +2511,15 @@ static void acm_load_prov_config(void)
return;
}
subnet->subnet_prefix = prefix;
- DListInsertTail(&subnet->entry,
- &prov->subnet_list);
+ list_add_after(&provider_list, &prov->entry,
+ &subnet->entry);
}
}
}
fclose(fd);
- for (entry = provider_list.Next; entry != &provider_list;
- entry = entry->Next) {
- prov = container_of(entry, struct acmc_prov, entry);
+ list_for_each(&provider_list, prov, entry) {
if (!strcasecmp(prov->prov->name, def_prov_name)) {
def_provider = prov;
break;
@@ -2665,8 +2602,8 @@ static int acm_open_providers(void)
prov->prov = provider;
prov->handle = handle;
- DListInit(&prov->subnet_list);
- DListInsertTail(&prov->entry, &provider_list);
+ list_head_init(&prov->subnet_list);
+ list_add_tail(&provider_list, &prov->entry);
if (!strcasecmp(provider->name, def_prov_name))
def_provider = prov;
}
@@ -2679,23 +2616,15 @@ static int acm_open_providers(void)
static void acm_close_providers(void)
{
struct acmc_prov *prov;
- DLIST_ENTRY *entry;
- DLIST_ENTRY *sub_entry;
struct acmc_subnet *subnet;
acm_log(1, "\n");
def_provider = NULL;
- while (!DListEmpty(&provider_list)) {
- entry = provider_list.Next;
- DListRemove(entry);
- prov = container_of(entry, struct acmc_prov, entry);
- while (!DListEmpty(&prov->subnet_list)) {
- sub_entry = prov->subnet_list.Next;
- DListRemove(sub_entry);
- subnet = container_of(sub_entry, struct acmc_subnet,
- entry);
+
+ while ((prov = list_pop(&provider_list, struct acmc_prov, entry))) {
+ while ((subnet = list_pop(&prov->subnet_list,
+ struct acmc_subnet, entry)))
free(subnet);
- }
dlclose(prov->handle);
free(prov);
}
@@ -2704,23 +2633,17 @@ static void acm_close_providers(void)
static int acmc_init_sa_fds(void)
{
struct acmc_device *dev;
- DLIST_ENTRY *dev_entry;
int ret, p, i = 0;
- for (dev_entry = dev_list.Next; dev_entry != &dev_list;
- dev_entry = dev_entry->Next) {
- dev = container_of(dev_entry, struct acmc_device, entry);
+ list_for_each(&dev_list, dev, entry)
sa.nfds += dev->port_cnt;
- }
sa.fds = calloc(sa.nfds, sizeof(*sa.fds));
sa.ports = calloc(sa.nfds, sizeof(*sa.ports));
if (!sa.fds || !sa.ports)
return -ENOMEM;
- for (dev_entry = dev_list.Next; dev_entry != &dev_list;
- dev_entry = dev_entry->Next) {
- dev = container_of(dev_entry, struct acmc_device, entry);
+ list_for_each(&dev_list, dev, entry) {
for (p = 0; p < dev->port_cnt; p++) {
sa.fds[i].fd = umad_get_fd(dev->port[p].mad_portid);
sa.fds[i].events = POLLIN;
@@ -2784,16 +2707,16 @@ int acm_send_sa_mad(struct acm_sa_mad *mad)
mad->umad.addr.pkey_index = req->ep->port->sa_pkey_index;
pthread_mutex_lock(&port->lock);
- if (port->sa_credits && DListEmpty(&port->sa_wait)) {
+ if (port->sa_credits && list_empty(&port->sa_wait)) {
ret = umad_send(port->mad_portid, port->mad_agentid, &mad->umad,
sizeof mad->sa_mad, sa.timeout, sa.retries);
if (!ret) {
port->sa_credits--;
- DListInsertTail(&req->entry, &port->sa_pending);
+ list_add_tail(&port->sa_pending, &req->entry);
}
} else {
ret = 0;
- DListInsertTail(&req->entry, &port->sa_wait);
+ list_add_tail(&port->sa_wait, &req->entry);
}
pthread_mutex_unlock(&port->lock);
return ret;
@@ -2805,18 +2728,18 @@ static void acmc_send_queued_req(struct acmc_port *port)
int ret;
pthread_mutex_lock(&port->lock);
- if (DListEmpty(&port->sa_wait) || !port->sa_credits) {
+ if (list_empty(&port->sa_wait) || !port->sa_credits) {
pthread_mutex_unlock(&port->lock);
return;
}
- req = container_of(port->sa_wait.Next, struct acmc_sa_req, entry);
- DListRemove(&req->entry);
+ req = list_pop(&port->sa_wait, struct acmc_sa_req, entry);
+
ret = umad_send(port->mad_portid, port->mad_agentid, &req->mad.umad,
sizeof req->mad.sa_mad, sa.timeout, sa.retries);
if (!ret) {
port->sa_credits--;
- DListInsertTail(&req->entry, &port->sa_pending);
+ list_add_tail(&port->sa_pending, &req->entry);
}
pthread_mutex_unlock(&port->lock);
@@ -2830,7 +2753,6 @@ static void acmc_recv_mad(struct acmc_port *port)
{
struct acmc_sa_req *req;
struct acm_sa_mad resp;
- DLIST_ENTRY *entry;
int ret, len, found;
struct umad_hdr *hdr;
@@ -2848,13 +2770,11 @@ static void acmc_recv_mad(struct acmc_port *port)
hdr->method, hdr->status, hdr->tid, hdr->attr_id, hdr->attr_mod);
found = 0;
pthread_mutex_lock(&port->lock);
- for (entry = port->sa_pending.Next; entry != &port->sa_pending;
- entry = entry->Next) {
- req = container_of(entry, struct acmc_sa_req, entry);
+ list_for_each(&port->sa_pending, req, entry) {
/* The lower 32-bit of the tid is used for agentid in umad */
if (req->mad.sa_mad.mad_hdr.tid == (hdr->tid & 0xFFFFFFFF00000000)) {
found = 1;
- DListRemove(entry);
+ list_del(&req->entry);
port->sa_credits++;
break;
}
@@ -3086,8 +3006,6 @@ int main(int argc, char **argv)
acm_log(0, "Assistant to the InfiniBand Communication Manager\n");
acm_log_options();
- DListInit(&provider_list);
- DListInit(&dev_list);
for (i = 0; i < ACM_MAX_COUNTER; i++)
atomic_init(&counter[i]);
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 10/13] ibacm: cleanup "lock"
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
Make it static to libacm.c, give it a more reasonable name and initialize
it at compile time.
Note tha the critical sections for this lock could be reduced easily, but
that's a different project if someone cares enough..
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
ibacm/CMakeLists.txt | 1 -
ibacm/linux/libacm_linux.c | 37 -------------------------------------
ibacm/src/libacm.c | 22 +++++++++++-----------
3 files changed, 11 insertions(+), 49 deletions(-)
delete mode 100644 ibacm/linux/libacm_linux.c
diff --git a/ibacm/CMakeLists.txt b/ibacm/CMakeLists.txt
index 7ed8fd5..505fba3 100644
--- a/ibacm/CMakeLists.txt
+++ b/ibacm/CMakeLists.txt
@@ -38,7 +38,6 @@ set_target_properties(ibacmp PROPERTIES
install(TARGETS ibacmp DESTINATION "${ACM_PROVIDER_DIR}")
rdma_executable(ib_acme
- linux/libacm_linux.c
src/acme.c
src/libacm.c
src/parse.c
diff --git a/ibacm/linux/libacm_linux.c b/ibacm/linux/libacm_linux.c
deleted file mode 100644
index 2b8a910..0000000
--- a/ibacm/linux/libacm_linux.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2009 Intel Corporation. All rights reserved.
- *
- * This software is available to you under the OpenIB.org BSD license
- * below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <osd.h>
-
-pthread_mutex_t lock;
-
-static void __attribute__((constructor)) lib_init(void)
-{
- pthread_mutex_init(&lock, NULL);
-}
diff --git a/ibacm/src/libacm.c b/ibacm/src/libacm.c
index 4273dfe..1980919 100644
--- a/ibacm/src/libacm.c
+++ b/ibacm/src/libacm.c
@@ -38,7 +38,7 @@
#include <netdb.h>
#include <arpa/inet.h>
-extern pthread_mutex_t lock;
+static pthread_mutex_t acm_lock = PTHREAD_MUTEX_INITIALIZER;
static int sock = -1;
static short server_port = 6125;
@@ -212,7 +212,7 @@ static int acm_resolve(uint8_t *src, uint8_t *dest, uint8_t type,
struct acm_msg msg;
int ret, cnt = 0;
- pthread_mutex_lock(&lock);
+ pthread_mutex_lock(&acm_lock);
memset(&msg, 0, sizeof msg);
msg.hdr.version = ACM_VERSION;
msg.hdr.opcode = ACM_OP_RESOLVE;
@@ -246,7 +246,7 @@ static int acm_resolve(uint8_t *src, uint8_t *dest, uint8_t type,
ret = acm_format_resp(&msg, paths, count, print);
out:
- pthread_mutex_unlock(&lock);
+ pthread_mutex_unlock(&acm_lock);
return ret;
}
@@ -275,7 +275,7 @@ int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags)
struct acm_ep_addr_data *data;
int ret;
- pthread_mutex_lock(&lock);
+ pthread_mutex_lock(&acm_lock);
memset(&msg, 0, sizeof msg);
msg.hdr.version = ACM_VERSION;
msg.hdr.opcode = ACM_OP_RESOLVE;
@@ -299,7 +299,7 @@ int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags)
*path = data->info.path;
out:
- pthread_mutex_unlock(&lock);
+ pthread_mutex_unlock(&acm_lock);
return ret;
}
@@ -308,7 +308,7 @@ int ib_acm_query_perf(int index, uint64_t **counters, int *count)
struct acm_msg msg;
int ret, i;
- pthread_mutex_lock(&lock);
+ pthread_mutex_lock(&acm_lock);
memset(&msg, 0, sizeof msg);
msg.hdr.version = ACM_VERSION;
msg.hdr.opcode = ACM_OP_PERF_QUERY;
@@ -341,7 +341,7 @@ int ib_acm_query_perf(int index, uint64_t **counters, int *count)
(*counters)[i] = ntohll(msg.perf_data[i]);
ret = 0;
out:
- pthread_mutex_unlock(&lock);
+ pthread_mutex_unlock(&acm_lock);
return ret;
}
@@ -353,7 +353,7 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data)
int cnt;
struct acm_ep_config_data *edata;
- pthread_mutex_lock(&lock);
+ pthread_mutex_lock(&acm_lock);
memset(&msg, 0, sizeof msg);
msg.hdr.version = ACM_VERSION;
msg.hdr.opcode = ACM_OP_EP_QUERY;
@@ -391,7 +391,7 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data)
*data = edata;
ret = 0;
out:
- pthread_mutex_unlock(&lock);
+ pthread_mutex_unlock(&acm_lock);
return ret;
}
@@ -404,7 +404,7 @@ int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type,
if (!src)
return -1;
- pthread_mutex_lock(&lock);
+ pthread_mutex_lock(&acm_lock);
memset(&msg, 0, sizeof msg);
msg.hdr.version = ACM_VERSION;
msg.hdr.opcode = ACM_OP_PERF_QUERY;
@@ -444,7 +444,7 @@ int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type,
ret = 0;
out:
- pthread_mutex_unlock(&lock);
+ pthread_mutex_unlock(&acm_lock);
return ret;
}
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 09/13] ibacm: remove e stricmp and strnicmp
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
ibacm/linux/osd.h | 3 ---
ibacm/prov/acmp/src/acmp.c | 50 +++++++++++++++++++++++-----------------------
ibacm/src/acm.c | 30 ++++++++++++++--------------
ibacm/src/acme.c | 4 ++--
4 files changed, 42 insertions(+), 45 deletions(-)
diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index ee582bb..6e408f7 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -87,9 +87,6 @@ typedef struct { volatile int val; } atomic_t;
#define atomic_get(v) ((v)->val)
#define atomic_set(v, s) ((v)->val = s)
-#define stricmp strcasecmp
-#define strnicmp strncasecmp
-
typedef struct { pthread_cond_t cond; pthread_mutex_t mutex; } event_t;
static inline void event_init(event_t *e)
{
diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 4cda359..1cb14e1 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -1057,7 +1057,7 @@ acmp_addr_lookup(struct acmp_ep *ep, uint8_t *addr, uint16_t type)
continue;
if ((type == ACM_ADDRESS_NAME &&
- !strnicmp((char *) ep->addr_info[i].info.name,
+ !strncasecmp((char *) ep->addr_info[i].info.name,
(char *) addr, ACM_MAX_ADDRESS)) ||
!memcmp(ep->addr_info[i].info.addr, addr,
ACM_MAX_ADDRESS)) {
@@ -1993,7 +1993,7 @@ static void acmp_query_perf(void *ep_context, uint64_t *values, uint8_t *cnt)
static enum acmp_addr_prot acmp_convert_addr_prot(char *param)
{
- if (!stricmp("acm", param))
+ if (!strcasecmp("acm", param))
return ACMP_ADDR_PROT_ACM;
return addr_prot;
@@ -2001,9 +2001,9 @@ static enum acmp_addr_prot acmp_convert_addr_prot(char *param)
static enum acmp_route_prot acmp_convert_route_prot(char *param)
{
- if (!stricmp("acm", param))
+ if (!strcasecmp("acm", param))
return ACMP_ROUTE_PROT_ACM;
- else if (!stricmp("sa", param))
+ else if (!strcasecmp("sa", param))
return ACMP_ROUTE_PROT_SA;
return route_prot;
@@ -2011,9 +2011,9 @@ static enum acmp_route_prot acmp_convert_route_prot(char *param)
static enum acmp_loopback_prot acmp_convert_loopback_prot(char *param)
{
- if (!stricmp("none", param))
+ if (!strcasecmp("none", param))
return ACMP_LOOPBACK_PROT_NONE;
- else if (!stricmp("local", param))
+ else if (!strcasecmp("local", param))
return ACMP_LOOPBACK_PROT_LOCAL;
return loopback_prot;
@@ -2021,9 +2021,9 @@ static enum acmp_loopback_prot acmp_convert_loopback_prot(char *param)
static enum acmp_route_preload acmp_convert_route_preload(char *param)
{
- if (!stricmp("none", param) || !stricmp("no", param))
+ if (!strcasecmp("none", param) || !strcasecmp("no", param))
return ACMP_ROUTE_PRELOAD_NONE;
- else if (!stricmp("opensm_full_v1", param))
+ else if (!strcasecmp("opensm_full_v1", param))
return ACMP_ROUTE_PRELOAD_OSM_FULL_V1;
return route_preload;
@@ -2031,9 +2031,9 @@ static enum acmp_route_preload acmp_convert_route_preload(char *param)
static enum acmp_addr_preload acmp_convert_addr_preload(char *param)
{
- if (!stricmp("none", param) || !stricmp("no", param))
+ if (!strcasecmp("none", param) || !strcasecmp("no", param))
return ACMP_ADDR_PRELOAD_NONE;
- else if (!stricmp("acm_hosts", param))
+ else if (!strcasecmp("acm_hosts", param))
return ACMP_ADDR_PRELOAD_HOSTS;
return addr_preload;
@@ -2882,37 +2882,37 @@ static void acmp_set_options(void)
if (sscanf(s, "%31s%255s", opt, value) != 2)
continue;
- if (!stricmp("addr_prot", opt))
+ if (!strcasecmp("addr_prot", opt))
addr_prot = acmp_convert_addr_prot(value);
- else if (!stricmp("addr_timeout", opt))
+ else if (!strcasecmp("addr_timeout", opt))
addr_timeout = atoi(value);
- else if (!stricmp("route_prot", opt))
+ else if (!strcasecmp("route_prot", opt))
route_prot = acmp_convert_route_prot(value);
else if (!strcmp("route_timeout", opt))
route_timeout = atoi(value);
- else if (!stricmp("loopback_prot", opt))
+ else if (!strcasecmp("loopback_prot", opt))
loopback_prot = acmp_convert_loopback_prot(value);
- else if (!stricmp("timeout", opt))
+ else if (!strcasecmp("timeout", opt))
timeout = atoi(value);
- else if (!stricmp("retries", opt))
+ else if (!strcasecmp("retries", opt))
retries = atoi(value);
- else if (!stricmp("resolve_depth", opt))
+ else if (!strcasecmp("resolve_depth", opt))
resolve_depth = atoi(value);
- else if (!stricmp("send_depth", opt))
+ else if (!strcasecmp("send_depth", opt))
send_depth = atoi(value);
- else if (!stricmp("recv_depth", opt))
+ else if (!strcasecmp("recv_depth", opt))
recv_depth = atoi(value);
- else if (!stricmp("min_mtu", opt))
+ else if (!strcasecmp("min_mtu", opt))
min_mtu = acm_convert_mtu(atoi(value));
- else if (!stricmp("min_rate", opt))
+ else if (!strcasecmp("min_rate", opt))
min_rate = acm_convert_rate(atoi(value));
- else if (!stricmp("route_preload", opt))
+ else if (!strcasecmp("route_preload", opt))
route_preload = acmp_convert_route_preload(value);
- else if (!stricmp("route_data_file", opt))
+ else if (!strcasecmp("route_data_file", opt))
strcpy(route_data_file, value);
- else if (!stricmp("addr_preload", opt))
+ else if (!strcasecmp("addr_preload", opt))
addr_preload = acmp_convert_addr_preload(value);
- else if (!stricmp("addr_data_file", opt))
+ else if (!strcasecmp("addr_data_file", opt))
strcpy(addr_data_file, value);
}
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 912d563..37bbbe7 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -388,7 +388,7 @@ static void acm_mark_addr_invalid(struct acmc_ep *ep,
continue;
if ((data->type == ACM_ADDRESS_NAME &&
- !strnicmp((char *) ep->addr_info[i].addr.info.name,
+ !strncasecmp((char *) ep->addr_info[i].addr.info.name,
(char *) data->info.addr, ACM_MAX_ADDRESS)) ||
!memcmp(ep->addr_info[i].addr.info.addr, data->info.addr,
ACM_MAX_ADDRESS)) {
@@ -410,7 +410,7 @@ acm_addr_lookup(const struct acm_endpoint *endpoint, uint8_t *addr, uint8_t addr
continue;
if ((addr_type == ACM_ADDRESS_NAME &&
- !strnicmp((char *) ep->addr_info[i].addr.info.name,
+ !strncasecmp((char *) ep->addr_info[i].addr.info.name,
(char *) addr, ACM_MAX_ADDRESS)) ||
!memcmp(ep->addr_info[i].addr.info.addr, addr, ACM_MAX_ADDRESS))
return &ep->addr_info[i].addr;
@@ -2004,7 +2004,7 @@ static int acm_assign_ep_names(struct acmc_ep *ep)
memcpy(addr, name, addr_len);
}
- if (stricmp(pkey_str, "default")) {
+ if (strcasecmp(pkey_str, "default")) {
if (sscanf(pkey_str, "%hx", &pkey) != 1) {
acm_log(0, "ERROR - bad pkey format %s\n", pkey_str);
continue;
@@ -2013,7 +2013,7 @@ static int acm_assign_ep_names(struct acmc_ep *ep)
pkey = ep->port->def_acm_pkey;
}
- if (!stricmp(dev_name, dev) &&
+ if (!strcasecmp(dev_name, dev) &&
(ep->port->port.port_num == (uint8_t) port) &&
(ep->endpoint.pkey == pkey)) {
acm_log(1, "assigning %s\n", name);
@@ -2939,23 +2939,23 @@ static void acm_set_options(void)
if (sscanf(s, "%32s%256s", opt, value) != 2)
continue;
- if (!stricmp("log_file", opt))
+ if (!strcasecmp("log_file", opt))
strcpy(log_file, value);
- else if (!stricmp("log_level", opt))
+ else if (!strcasecmp("log_level", opt))
log_level = atoi(value);
- else if (!stricmp("lock_file", opt))
+ else if (!strcasecmp("lock_file", opt))
strcpy(lock_file, value);
- else if (!stricmp("server_port", opt))
+ else if (!strcasecmp("server_port", opt))
server_port = (short) atoi(value);
- else if (!stricmp("provider_lib_path", opt))
+ else if (!strcasecmp("provider_lib_path", opt))
strcpy(prov_lib_path, value);
- else if (!stricmp("support_ips_in_addr_cfg", opt))
+ else if (!strcasecmp("support_ips_in_addr_cfg", opt))
support_ips_in_addr_cfg = atoi(value);
- else if (!stricmp("timeout", opt))
+ else if (!strcasecmp("timeout", opt))
sa.timeout = atoi(value);
- else if (!stricmp("retries", opt))
+ else if (!strcasecmp("retries", opt))
sa.retries = atoi(value);
- else if (!stricmp("sa_depth", opt))
+ else if (!strcasecmp("sa_depth", opt))
sa.depth = atoi(value);
}
@@ -2981,10 +2981,10 @@ static FILE *acm_open_log(void)
{
FILE *f;
- if (!stricmp(log_file, "stdout"))
+ if (!strcasecmp(log_file, "stdout"))
return stdout;
- if (!stricmp(log_file, "stderr"))
+ if (!strcasecmp(log_file, "stderr"))
return stderr;
if (!(f = fopen(log_file, "w")))
diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c
index f2c9348..5a571cf 100644
--- a/ibacm/src/acme.c
+++ b/ibacm/src/acme.c
@@ -968,9 +968,9 @@ static char *opt_arg(int argc, char **argv)
static void parse_perf_arg(char *arg)
{
- if (!strnicmp("col", arg, 3)) {
+ if (!strncasecmp("col", arg, 3)) {
perf_query = PERF_QUERY_COL;
- } else if (!strnicmp("all", arg, 3)) {
+ } else if (!strncasecmp("all", arg, 3)) {
perf_query = PERF_QUERY_EP_ALL;
} else if (!strcmp("s", arg)) {
perf_query = PERF_QUERY_EP_ADDR;
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 08/13] ibacm: remove no-op osd_init/osd_close macros
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
ibacm/linux/osd.h | 3 ---
ibacm/prov/acmp/src/acmp.c | 3 ---
ibacm/src/acm.c | 3 ---
ibacm/src/acme.c | 8 +-------
4 files changed, 1 insertion(+), 16 deletions(-)
diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 12877f4..ee582bb 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -112,9 +112,6 @@ static inline int event_wait(event_t *e, int timeout)
return ret;
}
-#define osd_init() 0
-#define osd_close()
-
static inline uint64_t time_stamp_us(void)
{
struct timeval curtime;
diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 1f3aeef..4cda359 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -2941,9 +2941,6 @@ static void acmp_log_options(void)
static void __attribute__((constructor)) acmp_init(void)
{
- if (osd_init())
- return;
-
acmp_set_options();
acmp_log_options();
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 056824d..912d563 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -3076,9 +3076,6 @@ int main(int argc, char **argv)
if (daemon)
daemonize();
- if (osd_init())
- return -1;
-
acm_set_options();
if (acm_open_lock_file())
return -1;
diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c
index c5be0a3..f2c9348 100644
--- a/ibacm/src/acme.c
+++ b/ibacm/src/acme.c
@@ -985,14 +985,10 @@ static void parse_perf_arg(char *arg)
int main(int argc, char **argv)
{
- int op, ret;
+ int op, ret = 0;
int make_addr = 0;
int make_opts = 0;
- ret = osd_init();
- if (ret)
- goto out;
-
while ((op = getopt(argc, argv, "e::f:s:d:vcA::O::D:P::S:C:V")) != -1) {
switch (op) {
case 'e':
@@ -1068,8 +1064,6 @@ int main(int argc, char **argv)
if (!ret && make_opts)
ret = gen_opts();
- osd_close();
-out:
if (verbose || !(make_addr || make_opts) || ret)
printf("return status 0x%x\n", ret);
return ret;
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 07/13] ibacm: remove CDECL_FUNC
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
ibacm/linux/osd.h | 2 --
ibacm/src/acm.c | 2 +-
ibacm/src/acme.c | 2 +-
3 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 5fafd4d..12877f4 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -53,8 +53,6 @@
#define ACM_ADDR_FILE "ibacm_addr.cfg"
#define ACM_OPTS_FILE "ibacm_opts.cfg"
-#define CDECL_FUNC
-
#if DEFINE_ATOMICS
typedef struct { pthread_mutex_t mut; int val; } atomic_t;
static inline int atomic_inc(atomic_t *atomic)
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 508148a..056824d 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -3049,7 +3049,7 @@ static void show_usage(char *program)
printf(" (default %s/%s)\n", ACM_CONF_DIR, ACM_OPTS_FILE);
}
-int CDECL_FUNC main(int argc, char **argv)
+int main(int argc, char **argv)
{
int i, op, daemon = 1;
diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c
index a924dad..c5be0a3 100644
--- a/ibacm/src/acme.c
+++ b/ibacm/src/acme.c
@@ -983,7 +983,7 @@ static void parse_perf_arg(char *arg)
}
}
-int CDECL_FUNC main(int argc, char **argv)
+int main(int argc, char **argv)
{
int op, ret;
int make_addr = 0;
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 06/13] ibacm: remove unused LIB_DESTRUCTOR define
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
ibacm/linux/osd.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 00a5084..5fafd4d 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -53,7 +53,6 @@
#define ACM_ADDR_FILE "ibacm_addr.cfg"
#define ACM_OPTS_FILE "ibacm_opts.cfg"
-#define LIB_DESTRUCTOR __attribute__((destructor))
#define CDECL_FUNC
#if DEFINE_ATOMICS
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 05/13] ibacm: remove unused helper beginthread
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
ibacm/linux/osd.h | 6 ------
1 file changed, 6 deletions(-)
diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 7ce52e6..00a5084 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -130,10 +130,4 @@ static inline uint64_t time_stamp_us(void)
#define time_stamp_sec() (time_stamp_ms() / (uint64_t) 1000)
#define time_stamp_min() (time_stamp_sec() / (uint64_t) 60)
-static inline int beginthread(void (*func)(void *), void *arg)
-{
- pthread_t thread;
- return pthread_create(&thread, NULL, (void *(*)(void*)) func, arg);
-}
-
#endif /* OSD_H */
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox