aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/cio
diff options
context:
space:
mode:
authorPeter Oberparleiter <oberpar@linux.vnet.ibm.com>2013-11-26 08:59:21 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2013-12-16 08:37:42 -0500
commit47d30674d6c79197fa7bfb0d09d5857f61e0277b (patch)
tree97e100ae386becbf98bdf892ca1cc137ea90f634 /drivers/s390/cio
parent175746eb06a8925274558793814d8c802dc48276 (diff)
s390/css: Prevent unnecessary allocation in subchannel loop
Subchannel looping function for_each_subchannel_staged() allocates a subchannel-ID-bitmap to efficiently iterate over the list of known and unknown subchannels. Since this function is also used to iterate over known-subchannels only, optimize that case by not requiring the ID-bitmap allocation and falling back to simple bus_for_each_dev() looping. Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com> Reviewed-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/cio')
-rw-r--r--drivers/s390/cio/css.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 604333ebf01e..0268e5fd59b5 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -69,7 +69,8 @@ static int call_fn_known_sch(struct device *dev, void *data)
69 struct cb_data *cb = data; 69 struct cb_data *cb = data;
70 int rc = 0; 70 int rc = 0;
71 71
72 idset_sch_del(cb->set, sch->schid); 72 if (cb->set)
73 idset_sch_del(cb->set, sch->schid);
73 if (cb->fn_known_sch) 74 if (cb->fn_known_sch)
74 rc = cb->fn_known_sch(sch, cb->data); 75 rc = cb->fn_known_sch(sch, cb->data);
75 return rc; 76 return rc;
@@ -115,6 +116,13 @@ int for_each_subchannel_staged(int (*fn_known)(struct subchannel *, void *),
115 cb.fn_known_sch = fn_known; 116 cb.fn_known_sch = fn_known;
116 cb.fn_unknown_sch = fn_unknown; 117 cb.fn_unknown_sch = fn_unknown;
117 118
119 if (fn_known && !fn_unknown) {
120 /* Skip idset allocation in case of known-only loop. */
121 cb.set = NULL;
122 return bus_for_each_dev(&css_bus_type, NULL, &cb,
123 call_fn_known_sch);
124 }
125
118 cb.set = idset_sch_new(); 126 cb.set = idset_sch_new();
119 if (!cb.set) 127 if (!cb.set)
120 /* fall back to brute force scanning in case of oom */ 128 /* fall back to brute force scanning in case of oom */