Skip to content

Commit

Permalink
s390/css: Prevent unnecessary allocation in subchannel loop
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Oberparleiter authored and Martin Schwidefsky committed Dec 16, 2013
1 parent 175746e commit 47d3067
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/s390/cio/css.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ static int call_fn_known_sch(struct device *dev, void *data)
struct cb_data *cb = data;
int rc = 0;

idset_sch_del(cb->set, sch->schid);
if (cb->set)
idset_sch_del(cb->set, sch->schid);
if (cb->fn_known_sch)
rc = cb->fn_known_sch(sch, cb->data);
return rc;
Expand Down Expand Up @@ -115,6 +116,13 @@ int for_each_subchannel_staged(int (*fn_known)(struct subchannel *, void *),
cb.fn_known_sch = fn_known;
cb.fn_unknown_sch = fn_unknown;

if (fn_known && !fn_unknown) {
/* Skip idset allocation in case of known-only loop. */
cb.set = NULL;
return bus_for_each_dev(&css_bus_type, NULL, &cb,
call_fn_known_sch);
}

cb.set = idset_sch_new();
if (!cb.set)
/* fall back to brute force scanning in case of oom */
Expand Down

0 comments on commit 47d3067

Please sign in to comment.