Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277918
b: refs/heads/master
c: 5bc1421
h: refs/heads/master
v: v3
  • Loading branch information
Neil Horman authored and David S. Miller committed Nov 22, 2011
1 parent bddc5bc commit 7f7bf62
Show file tree
Hide file tree
Showing 11 changed files with 470 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 202ff1c26c768efeead20b388556eda265dc8352
refs/heads/master: 5bc1421e34ecfe0bd4b26dc3232b7d5e25179144
8 changes: 8 additions & 0 deletions trunk/include/linux/cgroup_subsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,16 @@ SUBSYS(net_cls)
SUBSYS(blkio)
#endif

/* */

#ifdef CONFIG_CGROUP_PERF
SUBSYS(perf)
#endif

/* */

#ifdef CONFIG_NETPRIO_CGROUP
SUBSYS(net_prio)
#endif

/* */
4 changes: 4 additions & 0 deletions trunk/include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#ifdef CONFIG_DCB
#include <net/dcbnl.h>
#endif
#include <net/netprio_cgroup.h>

#include <linux/netdev_features.h>

Expand Down Expand Up @@ -1244,6 +1245,9 @@ struct net_device {
#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
/* max exchange id for FCoE LRO by ddp */
unsigned int fcoe_ddp_xid;
#endif
#if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
struct netprio_map __rcu *priomap;
#endif
/* phy device may attach itself for hardware timestamping */
struct phy_device *phydev;
Expand Down
65 changes: 65 additions & 0 deletions trunk/include/net/netprio_cgroup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* netprio_cgroup.h Control Group Priority set
*
*
* Authors: Neil Horman <nhorman@tuxdriver.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*/

#ifndef _NETPRIO_CGROUP_H
#define _NETPRIO_CGROUP_H
#include <linux/module.h>
#include <linux/cgroup.h>
#include <linux/hardirq.h>
#include <linux/rcupdate.h>

struct cgroup_netprio_state
{
struct cgroup_subsys_state css;
u32 prioidx;
};

struct netprio_map {
struct rcu_head rcu;
u32 priomap_len;
u32 priomap[];
};

#ifdef CONFIG_CGROUPS

#ifndef CONFIG_NETPRIO_CGROUP
extern int net_prio_subsys_id;
#endif

extern void sock_update_netprioidx(struct sock *sk);

static inline struct cgroup_netprio_state
*task_netprio_state(struct task_struct *p)
{
#if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
return container_of(task_subsys_state(p, net_prio_subsys_id),
struct cgroup_netprio_state, css);
#else
return NULL;
#endif
}

#else

#define sock_update_netprioidx(sk)
#define skb_update_prio(skb)

static inline struct cgroup_netprio_state
*task_netprio_state(struct task_struct *p)
{
return NULL;
}

#endif

#endif /* _NET_CLS_CGROUP_H */
3 changes: 3 additions & 0 deletions trunk/include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ struct sock {
unsigned short sk_ack_backlog;
unsigned short sk_max_ack_backlog;
__u32 sk_priority;
#ifdef CONFIG_CGROUPS
__u32 sk_cgrp_prioidx;
#endif
struct pid *sk_peer_pid;
const struct cred *sk_peer_cred;
long sk_rcvtimeo;
Expand Down
7 changes: 7 additions & 0 deletions trunk/net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ config XPS
depends on SMP && SYSFS && USE_GENERIC_SMP_HELPERS
default y

config NETPRIO_CGROUP
tristate "Network priority cgroup"
depends on CGROUPS
---help---
Cgroup subsystem for use in assigning processes to network priorities on
a per-interface basis

config HAVE_BPF_JIT
bool

Expand Down
1 change: 1 addition & 0 deletions trunk/net/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ obj-$(CONFIG_FIB_RULES) += fib_rules.o
obj-$(CONFIG_TRACEPOINTS) += net-traces.o
obj-$(CONFIG_NET_DROP_MONITOR) += drop_monitor.o
obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += timestamping.o
obj-$(CONFIG_NETPRIO_CGROUP) += netprio_cgroup.o
14 changes: 14 additions & 0 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,18 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
return rc;
}

#if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
static void skb_update_prio(struct sk_buff *skb)
{
struct netprio_map *map = rcu_dereference(skb->dev->priomap);

if ((!skb->priority) && (skb->sk) && map)
skb->priority = map->priomap[skb->sk->sk_cgrp_prioidx];
}
#else
#define skb_update_prio(skb)
#endif

static DEFINE_PER_CPU(int, xmit_recursion);
#define RECURSION_LIMIT 10

Expand Down Expand Up @@ -2489,6 +2501,8 @@ int dev_queue_xmit(struct sk_buff *skb)
*/
rcu_read_lock_bh();

skb_update_prio(skb);

txq = dev_pick_tx(dev, skb);
q = rcu_dereference_bh(txq->qdisc);

Expand Down
Loading

0 comments on commit 7f7bf62

Please sign in to comment.