Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5bc1421e authored by Neil Horman's avatar Neil Horman Committed by David S. Miller
Browse files

net: add network priority cgroup infrastructure (v4)



This patch adds in the infrastructure code to create the network priority
cgroup.  The cgroup, in addition to the standard processes file creates two
control files:

1) prioidx - This is a read-only file that exports the index of this cgroup.
This is a value that is both arbitrary and unique to a cgroup in this subsystem,
and is used to index the per-device priority map

2) priomap - This is a writeable file.  On read it reports a table of 2-tuples
<name:priority> where name is the name of a network interface and priority is
indicates the priority assigned to frames egresessing on the named interface and
originating from a pid in this cgroup

This cgroup allows for skb priority to be set prior to a root qdisc getting
selected. This is benenficial for DCB enabled systems, in that it allows for any
application to use dcb configured priorities so without application modification

Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: default avatarJohn Fastabend <john.r.fastabend@intel.com>
CC: Robert Love <robert.w.love@intel.com>
CC: "David S. Miller" <davem@davemloft.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 202ff1c2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
#ifdef CONFIG_DCB
#include <net/dcbnl.h>
#endif
#include <net/netprio_cgroup.h>

#include <linux/netdev_features.h>

@@ -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;
+65 −0
Original line number Diff line number Diff line
/*
 * 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 −0
Original line number Diff line number Diff line
@@ -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;
+7 −0
Original line number Diff line number Diff line
@@ -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

Loading