2019-06-04 08:11:33 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2008-11-20 12:10:00 +00:00
|
|
|
/*
|
|
|
|
* net/sched/sch_drr.c Deficit Round Robin scheduler
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2008-11-20 12:10:00 +00:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/pkt_sched.h>
|
|
|
|
#include <net/sch_generic.h>
|
|
|
|
#include <net/pkt_sched.h>
|
|
|
|
#include <net/pkt_cls.h>
|
|
|
|
|
|
|
|
struct drr_class {
|
|
|
|
struct Qdisc_class_common common;
|
|
|
|
unsigned int filter_cnt;
|
|
|
|
|
2021-10-16 08:49:09 +00:00
|
|
|
struct gnet_stats_basic_sync bstats;
|
2008-11-20 12:10:00 +00:00
|
|
|
struct gnet_stats_queue qstats;
|
2016-12-04 17:48:16 +00:00
|
|
|
struct net_rate_estimator __rcu *rate_est;
|
2008-11-20 12:10:00 +00:00
|
|
|
struct list_head alist;
|
|
|
|
struct Qdisc *qdisc;
|
|
|
|
|
|
|
|
u32 quantum;
|
|
|
|
u32 deficit;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drr_sched {
|
|
|
|
struct list_head active;
|
2014-09-13 03:05:27 +00:00
|
|
|
struct tcf_proto __rcu *filter_list;
|
2017-05-17 09:07:55 +00:00
|
|
|
struct tcf_block *block;
|
2008-11-20 12:10:00 +00:00
|
|
|
struct Qdisc_class_hash clhash;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct drr_class *drr_find_class(struct Qdisc *sch, u32 classid)
|
|
|
|
{
|
|
|
|
struct drr_sched *q = qdisc_priv(sch);
|
|
|
|
struct Qdisc_class_common *clc;
|
|
|
|
|
|
|
|
clc = qdisc_class_find(&q->clhash, classid);
|
|
|
|
if (clc == NULL)
|
|
|
|
return NULL;
|
|
|
|
return container_of(clc, struct drr_class, common);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct nla_policy drr_policy[TCA_DRR_MAX + 1] = {
|
|
|
|
[TCA_DRR_QUANTUM] = { .type = NLA_U32 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static int drr_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
|
2017-12-20 17:35:15 +00:00
|
|
|
struct nlattr **tca, unsigned long *arg,
|
|
|
|
struct netlink_ext_ack *extack)
|
2008-11-20 12:10:00 +00:00
|
|
|
{
|
|
|
|
struct drr_sched *q = qdisc_priv(sch);
|
|
|
|
struct drr_class *cl = (struct drr_class *)*arg;
|
2009-02-27 10:42:38 +00:00
|
|
|
struct nlattr *opt = tca[TCA_OPTIONS];
|
2008-11-20 12:10:00 +00:00
|
|
|
struct nlattr *tb[TCA_DRR_MAX + 1];
|
|
|
|
u32 quantum;
|
|
|
|
int err;
|
|
|
|
|
2017-12-20 17:35:24 +00:00
|
|
|
if (!opt) {
|
|
|
|
NL_SET_ERR_MSG(extack, "DRR options are required for this operation");
|
2009-02-27 10:42:38 +00:00
|
|
|
return -EINVAL;
|
2017-12-20 17:35:24 +00:00
|
|
|
}
|
2009-02-27 10:42:38 +00:00
|
|
|
|
netlink: make validation more configurable for future strictness
We currently have two levels of strict validation:
1) liberal (default)
- undefined (type >= max) & NLA_UNSPEC attributes accepted
- attribute length >= expected accepted
- garbage at end of message accepted
2) strict (opt-in)
- NLA_UNSPEC attributes accepted
- attribute length >= expected accepted
Split out parsing strictness into four different options:
* TRAILING - check that there's no trailing data after parsing
attributes (in message or nested)
* MAXTYPE - reject attrs > max known type
* UNSPEC - reject attributes with NLA_UNSPEC policy entries
* STRICT_ATTRS - strictly validate attribute size
The default for future things should be *everything*.
The current *_strict() is a combination of TRAILING and MAXTYPE,
and is renamed to _deprecated_strict().
The current regular parsing has none of this, and is renamed to
*_parse_deprecated().
Additionally it allows us to selectively set one of the new flags
even on old policies. Notably, the UNSPEC flag could be useful in
this case, since it can be arranged (by filling in the policy) to
not be an incompatible userspace ABI change, but would then going
forward prevent forgetting attribute entries. Similar can apply
to the POLICY flag.
We end up with the following renames:
* nla_parse -> nla_parse_deprecated
* nla_parse_strict -> nla_parse_deprecated_strict
* nlmsg_parse -> nlmsg_parse_deprecated
* nlmsg_parse_strict -> nlmsg_parse_deprecated_strict
* nla_parse_nested -> nla_parse_nested_deprecated
* nla_validate_nested -> nla_validate_nested_deprecated
Using spatch, of course:
@@
expression TB, MAX, HEAD, LEN, POL, EXT;
@@
-nla_parse(TB, MAX, HEAD, LEN, POL, EXT)
+nla_parse_deprecated(TB, MAX, HEAD, LEN, POL, EXT)
@@
expression NLH, HDRLEN, TB, MAX, POL, EXT;
@@
-nlmsg_parse(NLH, HDRLEN, TB, MAX, POL, EXT)
+nlmsg_parse_deprecated(NLH, HDRLEN, TB, MAX, POL, EXT)
@@
expression NLH, HDRLEN, TB, MAX, POL, EXT;
@@
-nlmsg_parse_strict(NLH, HDRLEN, TB, MAX, POL, EXT)
+nlmsg_parse_deprecated_strict(NLH, HDRLEN, TB, MAX, POL, EXT)
@@
expression TB, MAX, NLA, POL, EXT;
@@
-nla_parse_nested(TB, MAX, NLA, POL, EXT)
+nla_parse_nested_deprecated(TB, MAX, NLA, POL, EXT)
@@
expression START, MAX, POL, EXT;
@@
-nla_validate_nested(START, MAX, POL, EXT)
+nla_validate_nested_deprecated(START, MAX, POL, EXT)
@@
expression NLH, HDRLEN, MAX, POL, EXT;
@@
-nlmsg_validate(NLH, HDRLEN, MAX, POL, EXT)
+nlmsg_validate_deprecated(NLH, HDRLEN, MAX, POL, EXT)
For this patch, don't actually add the strict, non-renamed versions
yet so that it breaks compile if I get it wrong.
Also, while at it, make nla_validate and nla_parse go down to a
common __nla_validate_parse() function to avoid code duplication.
Ultimately, this allows us to have very strict validation for every
new caller of nla_parse()/nlmsg_parse() etc as re-introduced in the
next patch, while existing things will continue to work as is.
In effect then, this adds fully strict validation for any new command.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 12:07:28 +00:00
|
|
|
err = nla_parse_nested_deprecated(tb, TCA_DRR_MAX, opt, drr_policy,
|
|
|
|
extack);
|
2008-11-20 12:10:00 +00:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (tb[TCA_DRR_QUANTUM]) {
|
|
|
|
quantum = nla_get_u32(tb[TCA_DRR_QUANTUM]);
|
2017-12-20 17:35:24 +00:00
|
|
|
if (quantum == 0) {
|
|
|
|
NL_SET_ERR_MSG(extack, "Specified DRR quantum cannot be zero");
|
2008-11-20 12:10:00 +00:00
|
|
|
return -EINVAL;
|
2017-12-20 17:35:24 +00:00
|
|
|
}
|
2008-11-20 12:10:00 +00:00
|
|
|
} else
|
|
|
|
quantum = psched_mtu(qdisc_dev(sch));
|
|
|
|
|
|
|
|
if (cl != NULL) {
|
2008-11-26 05:13:31 +00:00
|
|
|
if (tca[TCA_RATE]) {
|
2014-09-28 18:52:56 +00:00
|
|
|
err = gen_replace_estimator(&cl->bstats, NULL,
|
|
|
|
&cl->rate_est,
|
2016-06-06 16:37:16 +00:00
|
|
|
NULL,
|
|
|
|
qdisc_root_sleeping_running(sch),
|
2008-11-26 05:13:31 +00:00
|
|
|
tca[TCA_RATE]);
|
2017-12-20 17:35:24 +00:00
|
|
|
if (err) {
|
|
|
|
NL_SET_ERR_MSG(extack, "Failed to replace estimator");
|
2008-11-26 05:13:31 +00:00
|
|
|
return err;
|
2017-12-20 17:35:24 +00:00
|
|
|
}
|
2008-11-26 05:13:31 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 12:10:00 +00:00
|
|
|
sch_tree_lock(sch);
|
|
|
|
if (tb[TCA_DRR_QUANTUM])
|
|
|
|
cl->quantum = quantum;
|
|
|
|
sch_tree_unlock(sch);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl = kzalloc(sizeof(struct drr_class), GFP_KERNEL);
|
|
|
|
if (cl == NULL)
|
|
|
|
return -ENOBUFS;
|
|
|
|
|
2021-10-16 08:49:09 +00:00
|
|
|
gnet_stats_basic_sync_init(&cl->bstats);
|
2008-11-20 12:10:00 +00:00
|
|
|
cl->common.classid = classid;
|
|
|
|
cl->quantum = quantum;
|
2010-10-16 13:04:08 +00:00
|
|
|
cl->qdisc = qdisc_create_dflt(sch->dev_queue,
|
2017-12-20 17:35:21 +00:00
|
|
|
&pfifo_qdisc_ops, classid,
|
|
|
|
NULL);
|
2008-11-20 12:10:00 +00:00
|
|
|
if (cl->qdisc == NULL)
|
|
|
|
cl->qdisc = &noop_qdisc;
|
2017-03-08 15:03:32 +00:00
|
|
|
else
|
|
|
|
qdisc_hash_add(cl->qdisc, true);
|
2008-11-20 12:10:00 +00:00
|
|
|
|
2008-11-26 05:13:31 +00:00
|
|
|
if (tca[TCA_RATE]) {
|
2014-09-28 18:52:56 +00:00
|
|
|
err = gen_replace_estimator(&cl->bstats, NULL, &cl->rate_est,
|
2016-06-06 16:37:16 +00:00
|
|
|
NULL,
|
|
|
|
qdisc_root_sleeping_running(sch),
|
2008-11-26 05:13:31 +00:00
|
|
|
tca[TCA_RATE]);
|
|
|
|
if (err) {
|
2017-12-20 17:35:24 +00:00
|
|
|
NL_SET_ERR_MSG(extack, "Failed to replace estimator");
|
2018-09-24 16:22:50 +00:00
|
|
|
qdisc_put(cl->qdisc);
|
2008-11-26 05:13:31 +00:00
|
|
|
kfree(cl);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
2008-11-20 12:10:00 +00:00
|
|
|
|
|
|
|
sch_tree_lock(sch);
|
|
|
|
qdisc_class_hash_insert(&q->clhash, &cl->common);
|
|
|
|
sch_tree_unlock(sch);
|
|
|
|
|
|
|
|
qdisc_class_hash_grow(sch, &q->clhash);
|
|
|
|
|
|
|
|
*arg = (unsigned long)cl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drr_destroy_class(struct Qdisc *sch, struct drr_class *cl)
|
|
|
|
{
|
2016-12-04 17:48:16 +00:00
|
|
|
gen_kill_estimator(&cl->rate_est);
|
2018-09-24 16:22:50 +00:00
|
|
|
qdisc_put(cl->qdisc);
|
2008-11-20 12:10:00 +00:00
|
|
|
kfree(cl);
|
|
|
|
}
|
|
|
|
|
2021-01-19 12:08:12 +00:00
|
|
|
static int drr_delete_class(struct Qdisc *sch, unsigned long arg,
|
|
|
|
struct netlink_ext_ack *extack)
|
2008-11-20 12:10:00 +00:00
|
|
|
{
|
|
|
|
struct drr_sched *q = qdisc_priv(sch);
|
|
|
|
struct drr_class *cl = (struct drr_class *)arg;
|
|
|
|
|
|
|
|
if (cl->filter_cnt > 0)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
sch_tree_lock(sch);
|
|
|
|
|
2019-03-28 15:53:13 +00:00
|
|
|
qdisc_purge_queue(cl->qdisc);
|
2008-11-20 12:10:00 +00:00
|
|
|
qdisc_class_hash_remove(&q->clhash, &cl->common);
|
|
|
|
|
|
|
|
sch_tree_unlock(sch);
|
|
|
|
|
net_sched: remove tc class reference counting
For TC classes, their ->get() and ->put() are always paired, and the
reference counting is completely useless, because:
1) For class modification and dumping paths, we already hold RTNL lock,
so all of these ->get(),->change(),->put() are atomic.
2) For filter bindiing/unbinding, we use other reference counter than
this one, and they should have RTNL lock too.
3) For ->qlen_notify(), it is special because it is called on ->enqueue()
path, but we already hold qdisc tree lock there, and we hold this
tree lock when graft or delete the class too, so it should not be gone
or changed until we release the tree lock.
Therefore, this patch removes ->get() and ->put(), but:
1) Adds a new ->find() to find the pointer to a class by classid, no
refcnt.
2) Move the original class destroy upon the last refcnt into ->delete(),
right after releasing tree lock. This is fine because the class is
already removed from hash when holding the lock.
For those who also use ->put() as ->unbind(), just rename them to reflect
this change.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-08-24 23:51:29 +00:00
|
|
|
drr_destroy_class(sch, cl);
|
|
|
|
return 0;
|
2008-11-20 12:10:00 +00:00
|
|
|
}
|
|
|
|
|
net_sched: remove tc class reference counting
For TC classes, their ->get() and ->put() are always paired, and the
reference counting is completely useless, because:
1) For class modification and dumping paths, we already hold RTNL lock,
so all of these ->get(),->change(),->put() are atomic.
2) For filter bindiing/unbinding, we use other reference counter than
this one, and they should have RTNL lock too.
3) For ->qlen_notify(), it is special because it is called on ->enqueue()
path, but we already hold qdisc tree lock there, and we hold this
tree lock when graft or delete the class too, so it should not be gone
or changed until we release the tree lock.
Therefore, this patch removes ->get() and ->put(), but:
1) Adds a new ->find() to find the pointer to a class by classid, no
refcnt.
2) Move the original class destroy upon the last refcnt into ->delete(),
right after releasing tree lock. This is fine because the class is
already removed from hash when holding the lock.
For those who also use ->put() as ->unbind(), just rename them to reflect
this change.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-08-24 23:51:29 +00:00
|
|
|
static unsigned long drr_search_class(struct Qdisc *sch, u32 classid)
|
2008-11-20 12:10:00 +00:00
|
|
|
{
|
net_sched: remove tc class reference counting
For TC classes, their ->get() and ->put() are always paired, and the
reference counting is completely useless, because:
1) For class modification and dumping paths, we already hold RTNL lock,
so all of these ->get(),->change(),->put() are atomic.
2) For filter bindiing/unbinding, we use other reference counter than
this one, and they should have RTNL lock too.
3) For ->qlen_notify(), it is special because it is called on ->enqueue()
path, but we already hold qdisc tree lock there, and we hold this
tree lock when graft or delete the class too, so it should not be gone
or changed until we release the tree lock.
Therefore, this patch removes ->get() and ->put(), but:
1) Adds a new ->find() to find the pointer to a class by classid, no
refcnt.
2) Move the original class destroy upon the last refcnt into ->delete(),
right after releasing tree lock. This is fine because the class is
already removed from hash when holding the lock.
For those who also use ->put() as ->unbind(), just rename them to reflect
this change.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-08-24 23:51:29 +00:00
|
|
|
return (unsigned long)drr_find_class(sch, classid);
|
2008-11-20 12:10:00 +00:00
|
|
|
}
|
|
|
|
|
2017-12-20 17:35:16 +00:00
|
|
|
static struct tcf_block *drr_tcf_block(struct Qdisc *sch, unsigned long cl,
|
|
|
|
struct netlink_ext_ack *extack)
|
2008-11-20 12:10:00 +00:00
|
|
|
{
|
|
|
|
struct drr_sched *q = qdisc_priv(sch);
|
|
|
|
|
2017-12-20 17:35:24 +00:00
|
|
|
if (cl) {
|
|
|
|
NL_SET_ERR_MSG(extack, "DRR classid must be zero");
|
2008-11-20 12:10:00 +00:00
|
|
|
return NULL;
|
2017-12-20 17:35:24 +00:00
|
|
|
}
|
2008-11-20 12:10:00 +00:00
|
|
|
|
2017-05-17 09:07:55 +00:00
|
|
|
return q->block;
|
2008-11-20 12:10:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long drr_bind_tcf(struct Qdisc *sch, unsigned long parent,
|
|
|
|
u32 classid)
|
|
|
|
{
|
|
|
|
struct drr_class *cl = drr_find_class(sch, classid);
|
|
|
|
|
|
|
|
if (cl != NULL)
|
|
|
|
cl->filter_cnt++;
|
|
|
|
|
|
|
|
return (unsigned long)cl;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drr_unbind_tcf(struct Qdisc *sch, unsigned long arg)
|
|
|
|
{
|
|
|
|
struct drr_class *cl = (struct drr_class *)arg;
|
|
|
|
|
|
|
|
cl->filter_cnt--;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int drr_graft_class(struct Qdisc *sch, unsigned long arg,
|
2017-12-20 17:35:17 +00:00
|
|
|
struct Qdisc *new, struct Qdisc **old,
|
|
|
|
struct netlink_ext_ack *extack)
|
2008-11-20 12:10:00 +00:00
|
|
|
{
|
|
|
|
struct drr_class *cl = (struct drr_class *)arg;
|
|
|
|
|
|
|
|
if (new == NULL) {
|
2017-12-20 17:35:21 +00:00
|
|
|
new = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops,
|
|
|
|
cl->common.classid, NULL);
|
2008-11-20 12:10:00 +00:00
|
|
|
if (new == NULL)
|
|
|
|
new = &noop_qdisc;
|
|
|
|
}
|
|
|
|
|
2016-02-25 22:55:00 +00:00
|
|
|
*old = qdisc_replace(sch, new, &cl->qdisc);
|
2008-11-20 12:10:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct Qdisc *drr_class_leaf(struct Qdisc *sch, unsigned long arg)
|
|
|
|
{
|
|
|
|
struct drr_class *cl = (struct drr_class *)arg;
|
|
|
|
|
|
|
|
return cl->qdisc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drr_qlen_notify(struct Qdisc *csh, unsigned long arg)
|
|
|
|
{
|
|
|
|
struct drr_class *cl = (struct drr_class *)arg;
|
|
|
|
|
2017-08-15 13:39:59 +00:00
|
|
|
list_del(&cl->alist);
|
2008-11-20 12:10:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int drr_dump_class(struct Qdisc *sch, unsigned long arg,
|
|
|
|
struct sk_buff *skb, struct tcmsg *tcm)
|
|
|
|
{
|
|
|
|
struct drr_class *cl = (struct drr_class *)arg;
|
|
|
|
struct nlattr *nest;
|
|
|
|
|
|
|
|
tcm->tcm_parent = TC_H_ROOT;
|
|
|
|
tcm->tcm_handle = cl->common.classid;
|
|
|
|
tcm->tcm_info = cl->qdisc->handle;
|
|
|
|
|
2019-04-26 09:13:06 +00:00
|
|
|
nest = nla_nest_start_noflag(skb, TCA_OPTIONS);
|
2008-11-20 12:10:00 +00:00
|
|
|
if (nest == NULL)
|
|
|
|
goto nla_put_failure;
|
2012-03-29 09:11:39 +00:00
|
|
|
if (nla_put_u32(skb, TCA_DRR_QUANTUM, cl->quantum))
|
|
|
|
goto nla_put_failure;
|
2008-11-20 12:10:00 +00:00
|
|
|
return nla_nest_end(skb, nest);
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
nla_nest_cancel(skb, nest);
|
|
|
|
return -EMSGSIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int drr_dump_class_stats(struct Qdisc *sch, unsigned long arg,
|
|
|
|
struct gnet_dump *d)
|
|
|
|
{
|
|
|
|
struct drr_class *cl = (struct drr_class *)arg;
|
2019-03-28 15:53:12 +00:00
|
|
|
__u32 qlen = qdisc_qlen_sum(cl->qdisc);
|
|
|
|
struct Qdisc *cl_q = cl->qdisc;
|
2008-11-20 12:10:00 +00:00
|
|
|
struct tc_drr_stats xstats;
|
|
|
|
|
|
|
|
memset(&xstats, 0, sizeof(xstats));
|
2014-09-28 18:53:57 +00:00
|
|
|
if (qlen)
|
2008-11-20 12:10:00 +00:00
|
|
|
xstats.deficit = cl->deficit;
|
|
|
|
|
2016-06-06 16:37:16 +00:00
|
|
|
if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch),
|
|
|
|
d, NULL, &cl->bstats) < 0 ||
|
2016-12-04 17:48:16 +00:00
|
|
|
gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 ||
|
2019-03-28 15:53:12 +00:00
|
|
|
gnet_stats_copy_queue(d, cl_q->cpu_qstats, &cl_q->qstats, qlen) < 0)
|
2008-11-20 12:10:00 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
return gnet_stats_copy_app(d, &xstats, sizeof(xstats));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drr_walk(struct Qdisc *sch, struct qdisc_walker *arg)
|
|
|
|
{
|
|
|
|
struct drr_sched *q = qdisc_priv(sch);
|
|
|
|
struct drr_class *cl;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (arg->stop)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < q->clhash.hashsize; i++) {
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 01:06:00 +00:00
|
|
|
hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) {
|
2008-11-20 12:10:00 +00:00
|
|
|
if (arg->count < arg->skip) {
|
|
|
|
arg->count++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (arg->fn(sch, (unsigned long)cl, arg) < 0) {
|
|
|
|
arg->stop = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
arg->count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct drr_class *drr_classify(struct sk_buff *skb, struct Qdisc *sch,
|
|
|
|
int *qerr)
|
|
|
|
{
|
|
|
|
struct drr_sched *q = qdisc_priv(sch);
|
|
|
|
struct drr_class *cl;
|
|
|
|
struct tcf_result res;
|
2014-09-13 03:05:27 +00:00
|
|
|
struct tcf_proto *fl;
|
2008-11-20 12:10:00 +00:00
|
|
|
int result;
|
|
|
|
|
|
|
|
if (TC_H_MAJ(skb->priority ^ sch->handle) == 0) {
|
|
|
|
cl = drr_find_class(sch, skb->priority);
|
|
|
|
if (cl != NULL)
|
|
|
|
return cl;
|
|
|
|
}
|
|
|
|
|
|
|
|
*qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
|
2014-09-13 03:05:27 +00:00
|
|
|
fl = rcu_dereference_bh(q->filter_list);
|
2021-07-28 18:08:00 +00:00
|
|
|
result = tcf_classify(skb, NULL, fl, &res, false);
|
2008-11-20 12:10:00 +00:00
|
|
|
if (result >= 0) {
|
|
|
|
#ifdef CONFIG_NET_CLS_ACT
|
|
|
|
switch (result) {
|
|
|
|
case TC_ACT_QUEUED:
|
|
|
|
case TC_ACT_STOLEN:
|
2017-06-06 12:12:02 +00:00
|
|
|
case TC_ACT_TRAP:
|
2008-11-20 12:10:00 +00:00
|
|
|
*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
|
2020-07-07 17:21:38 +00:00
|
|
|
fallthrough;
|
2008-11-20 12:10:00 +00:00
|
|
|
case TC_ACT_SHOT:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
cl = (struct drr_class *)res.class;
|
|
|
|
if (cl == NULL)
|
|
|
|
cl = drr_find_class(sch, res.classid);
|
|
|
|
return cl;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-07-14 17:03:08 +00:00
|
|
|
static int drr_enqueue(struct sk_buff *skb, struct Qdisc *sch,
|
2016-06-22 06:16:49 +00:00
|
|
|
struct sk_buff **to_free)
|
2008-11-20 12:10:00 +00:00
|
|
|
{
|
2019-01-09 16:09:42 +00:00
|
|
|
unsigned int len = qdisc_pkt_len(skb);
|
2008-11-20 12:10:00 +00:00
|
|
|
struct drr_sched *q = qdisc_priv(sch);
|
|
|
|
struct drr_class *cl;
|
2012-09-27 22:35:47 +00:00
|
|
|
int err = 0;
|
2019-01-09 16:09:43 +00:00
|
|
|
bool first;
|
2008-11-20 12:10:00 +00:00
|
|
|
|
|
|
|
cl = drr_classify(skb, sch, &err);
|
|
|
|
if (cl == NULL) {
|
|
|
|
if (err & __NET_XMIT_BYPASS)
|
2014-09-28 18:53:29 +00:00
|
|
|
qdisc_qstats_drop(sch);
|
2016-06-22 06:16:49 +00:00
|
|
|
__qdisc_drop(skb, to_free);
|
2008-11-20 12:10:00 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2019-01-09 16:09:43 +00:00
|
|
|
first = !cl->qdisc->q.qlen;
|
2020-07-14 17:03:08 +00:00
|
|
|
err = qdisc_enqueue(skb, cl->qdisc, to_free);
|
2008-11-20 12:10:00 +00:00
|
|
|
if (unlikely(err != NET_XMIT_SUCCESS)) {
|
|
|
|
if (net_xmit_drop_count(err)) {
|
|
|
|
cl->qstats.drops++;
|
2014-09-28 18:53:29 +00:00
|
|
|
qdisc_qstats_drop(sch);
|
2008-11-20 12:10:00 +00:00
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2019-01-09 16:09:43 +00:00
|
|
|
if (first) {
|
2008-11-20 12:10:00 +00:00
|
|
|
list_add_tail(&cl->alist, &q->active);
|
|
|
|
cl->deficit = cl->quantum;
|
|
|
|
}
|
|
|
|
|
2019-01-09 16:09:42 +00:00
|
|
|
sch->qstats.backlog += len;
|
2008-11-20 12:10:00 +00:00
|
|
|
sch->q.qlen++;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct sk_buff *drr_dequeue(struct Qdisc *sch)
|
|
|
|
{
|
|
|
|
struct drr_sched *q = qdisc_priv(sch);
|
|
|
|
struct drr_class *cl;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
unsigned int len;
|
|
|
|
|
2008-11-24 23:46:08 +00:00
|
|
|
if (list_empty(&q->active))
|
|
|
|
goto out;
|
|
|
|
while (1) {
|
2008-11-20 12:10:00 +00:00
|
|
|
cl = list_first_entry(&q->active, struct drr_class, alist);
|
|
|
|
skb = cl->qdisc->ops->peek(cl->qdisc);
|
2014-06-11 18:35:18 +00:00
|
|
|
if (skb == NULL) {
|
|
|
|
qdisc_warn_nonwc(__func__, cl->qdisc);
|
2008-11-24 23:46:08 +00:00
|
|
|
goto out;
|
2014-06-11 18:35:18 +00:00
|
|
|
}
|
2008-11-20 12:10:00 +00:00
|
|
|
|
|
|
|
len = qdisc_pkt_len(skb);
|
|
|
|
if (len <= cl->deficit) {
|
|
|
|
cl->deficit -= len;
|
|
|
|
skb = qdisc_dequeue_peeked(cl->qdisc);
|
2016-01-28 03:30:51 +00:00
|
|
|
if (unlikely(skb == NULL))
|
|
|
|
goto out;
|
2008-11-20 12:10:00 +00:00
|
|
|
if (cl->qdisc->q.qlen == 0)
|
|
|
|
list_del(&cl->alist);
|
2012-05-10 05:36:34 +00:00
|
|
|
|
|
|
|
bstats_update(&cl->bstats, skb);
|
2011-01-21 07:31:33 +00:00
|
|
|
qdisc_bstats_update(sch, skb);
|
2016-06-01 23:15:17 +00:00
|
|
|
qdisc_qstats_backlog_dec(sch, skb);
|
2008-11-20 12:10:00 +00:00
|
|
|
sch->q.qlen--;
|
|
|
|
return skb;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl->deficit += cl->quantum;
|
|
|
|
list_move_tail(&cl->alist, &q->active);
|
|
|
|
}
|
2008-11-24 23:46:08 +00:00
|
|
|
out:
|
2008-11-20 12:10:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-20 17:35:13 +00:00
|
|
|
static int drr_init_qdisc(struct Qdisc *sch, struct nlattr *opt,
|
|
|
|
struct netlink_ext_ack *extack)
|
2008-11-20 12:10:00 +00:00
|
|
|
{
|
|
|
|
struct drr_sched *q = qdisc_priv(sch);
|
|
|
|
int err;
|
|
|
|
|
2017-12-20 17:35:19 +00:00
|
|
|
err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
|
2017-05-17 09:07:55 +00:00
|
|
|
if (err)
|
|
|
|
return err;
|
2008-11-20 12:10:00 +00:00
|
|
|
err = qdisc_class_hash_init(&q->clhash);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
INIT_LIST_HEAD(&q->active);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drr_reset_qdisc(struct Qdisc *sch)
|
|
|
|
{
|
|
|
|
struct drr_sched *q = qdisc_priv(sch);
|
|
|
|
struct drr_class *cl;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < q->clhash.hashsize; i++) {
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 01:06:00 +00:00
|
|
|
hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) {
|
2008-11-20 12:10:00 +00:00
|
|
|
if (cl->qdisc->q.qlen)
|
|
|
|
list_del(&cl->alist);
|
|
|
|
qdisc_reset(cl->qdisc);
|
|
|
|
}
|
|
|
|
}
|
2016-06-01 23:15:17 +00:00
|
|
|
sch->qstats.backlog = 0;
|
2008-11-20 12:10:00 +00:00
|
|
|
sch->q.qlen = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drr_destroy_qdisc(struct Qdisc *sch)
|
|
|
|
{
|
|
|
|
struct drr_sched *q = qdisc_priv(sch);
|
|
|
|
struct drr_class *cl;
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 01:06:00 +00:00
|
|
|
struct hlist_node *next;
|
2008-11-20 12:10:00 +00:00
|
|
|
unsigned int i;
|
|
|
|
|
2017-05-17 09:07:55 +00:00
|
|
|
tcf_block_put(q->block);
|
2008-11-20 12:10:00 +00:00
|
|
|
|
|
|
|
for (i = 0; i < q->clhash.hashsize; i++) {
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 01:06:00 +00:00
|
|
|
hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i],
|
2008-11-20 12:10:00 +00:00
|
|
|
common.hnode)
|
|
|
|
drr_destroy_class(sch, cl);
|
|
|
|
}
|
|
|
|
qdisc_class_hash_destroy(&q->clhash);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct Qdisc_class_ops drr_class_ops = {
|
|
|
|
.change = drr_change_class,
|
|
|
|
.delete = drr_delete_class,
|
net_sched: remove tc class reference counting
For TC classes, their ->get() and ->put() are always paired, and the
reference counting is completely useless, because:
1) For class modification and dumping paths, we already hold RTNL lock,
so all of these ->get(),->change(),->put() are atomic.
2) For filter bindiing/unbinding, we use other reference counter than
this one, and they should have RTNL lock too.
3) For ->qlen_notify(), it is special because it is called on ->enqueue()
path, but we already hold qdisc tree lock there, and we hold this
tree lock when graft or delete the class too, so it should not be gone
or changed until we release the tree lock.
Therefore, this patch removes ->get() and ->put(), but:
1) Adds a new ->find() to find the pointer to a class by classid, no
refcnt.
2) Move the original class destroy upon the last refcnt into ->delete(),
right after releasing tree lock. This is fine because the class is
already removed from hash when holding the lock.
For those who also use ->put() as ->unbind(), just rename them to reflect
this change.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-08-24 23:51:29 +00:00
|
|
|
.find = drr_search_class,
|
2017-05-17 09:07:55 +00:00
|
|
|
.tcf_block = drr_tcf_block,
|
2008-11-20 12:10:00 +00:00
|
|
|
.bind_tcf = drr_bind_tcf,
|
|
|
|
.unbind_tcf = drr_unbind_tcf,
|
|
|
|
.graft = drr_graft_class,
|
|
|
|
.leaf = drr_class_leaf,
|
|
|
|
.qlen_notify = drr_qlen_notify,
|
|
|
|
.dump = drr_dump_class,
|
|
|
|
.dump_stats = drr_dump_class_stats,
|
|
|
|
.walk = drr_walk,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct Qdisc_ops drr_qdisc_ops __read_mostly = {
|
|
|
|
.cl_ops = &drr_class_ops,
|
|
|
|
.id = "drr",
|
|
|
|
.priv_size = sizeof(struct drr_sched),
|
|
|
|
.enqueue = drr_enqueue,
|
|
|
|
.dequeue = drr_dequeue,
|
|
|
|
.peek = qdisc_peek_dequeued,
|
|
|
|
.init = drr_init_qdisc,
|
|
|
|
.reset = drr_reset_qdisc,
|
|
|
|
.destroy = drr_destroy_qdisc,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init drr_init(void)
|
|
|
|
{
|
|
|
|
return register_qdisc(&drr_qdisc_ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit drr_exit(void)
|
|
|
|
{
|
|
|
|
unregister_qdisc(&drr_qdisc_ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(drr_init);
|
|
|
|
module_exit(drr_exit);
|
|
|
|
MODULE_LICENSE("GPL");
|