All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH block/for-next 1/4] blkcg: move block/blk-cgroup.h to include/linux/blk-cgroup.h
@ 2014-11-17 21:13 Tejun Heo
  2014-11-17 21:13 ` [PATCH block/for-next 2/4] blkcg: add blkcg_root_css Tejun Heo
  2014-11-20 20:10 ` [PATCH block/for-next 1/4] blkcg: move block/blk-cgroup.h to include/linux/blk-cgroup.h Vivek Goyal
  0 siblings, 2 replies; 10+ messages in thread
From: Tejun Heo @ 2014-11-17 21:13 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, Vivek Goyal

cgroup aware writeback support will require exposing some of blkcg
details.  In preprataion, move block/blk-cgroup.h to
include/linux/blk-cgroup.h.  This patch is pure file move.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
---
Hello, Jens.

These four are misc prep patches on blkcg for cgroup writeback
support.

Thanks.

 block/blk-cgroup.c         |    2 
 block/blk-cgroup.h         |  603 ---------------------------------------------
 block/blk-core.c           |    2 
 block/blk-sysfs.c          |    2 
 block/blk-throttle.c       |    2 
 block/cfq-iosched.c        |    2 
 block/elevator.c           |    2 
 include/linux/blk-cgroup.h |  603 +++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 609 insertions(+), 609 deletions(-)

--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -19,7 +19,7 @@
 #include <linux/genhd.h>
 #include <linux/delay.h>
 #include <linux/atomic.h>
-#include "blk-cgroup.h"
+#include <linux/blk-cgroup.h>
 #include "blk.h"
 
 #define MAX_KEY_LEN 100
--- a/block/blk-cgroup.h
+++ /dev/null
@@ -1,603 +0,0 @@
-#ifndef _BLK_CGROUP_H
-#define _BLK_CGROUP_H
-/*
- * Common Block IO controller cgroup interface
- *
- * Based on ideas and code from CFQ, CFS and BFQ:
- * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
- *
- * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
- *		      Paolo Valente <paolo.valente@unimore.it>
- *
- * Copyright (C) 2009 Vivek Goyal <vgoyal@redhat.com>
- * 	              Nauman Rafique <nauman@google.com>
- */
-
-#include <linux/cgroup.h>
-#include <linux/u64_stats_sync.h>
-#include <linux/seq_file.h>
-#include <linux/radix-tree.h>
-#include <linux/blkdev.h>
-#include <linux/atomic.h>
-
-/* Max limits for throttle policy */
-#define THROTL_IOPS_MAX		UINT_MAX
-
-/* CFQ specific, out here for blkcg->cfq_weight */
-#define CFQ_WEIGHT_MIN		10
-#define CFQ_WEIGHT_MAX		1000
-#define CFQ_WEIGHT_DEFAULT	500
-
-#ifdef CONFIG_BLK_CGROUP
-
-enum blkg_rwstat_type {
-	BLKG_RWSTAT_READ,
-	BLKG_RWSTAT_WRITE,
-	BLKG_RWSTAT_SYNC,
-	BLKG_RWSTAT_ASYNC,
-
-	BLKG_RWSTAT_NR,
-	BLKG_RWSTAT_TOTAL = BLKG_RWSTAT_NR,
-};
-
-struct blkcg_gq;
-
-struct blkcg {
-	struct cgroup_subsys_state	css;
-	spinlock_t			lock;
-
-	struct radix_tree_root		blkg_tree;
-	struct blkcg_gq			*blkg_hint;
-	struct hlist_head		blkg_list;
-
-	/* TODO: per-policy storage in blkcg */
-	unsigned int			cfq_weight;	/* belongs to cfq */
-	unsigned int			cfq_leaf_weight;
-};
-
-struct blkg_stat {
-	struct u64_stats_sync		syncp;
-	uint64_t			cnt;
-};
-
-struct blkg_rwstat {
-	struct u64_stats_sync		syncp;
-	uint64_t			cnt[BLKG_RWSTAT_NR];
-};
-
-/*
- * A blkcg_gq (blkg) is association between a block cgroup (blkcg) and a
- * request_queue (q).  This is used by blkcg policies which need to track
- * information per blkcg - q pair.
- *
- * There can be multiple active blkcg policies and each has its private
- * data on each blkg, the size of which is determined by
- * blkcg_policy->pd_size.  blkcg core allocates and frees such areas
- * together with blkg and invokes pd_init/exit_fn() methods.
- *
- * Such private data must embed struct blkg_policy_data (pd) at the
- * beginning and pd_size can't be smaller than pd.
- */
-struct blkg_policy_data {
-	/* the blkg and policy id this per-policy data belongs to */
-	struct blkcg_gq			*blkg;
-	int				plid;
-
-	/* used during policy activation */
-	struct list_head		alloc_node;
-};
-
-/* association between a blk cgroup and a request queue */
-struct blkcg_gq {
-	/* Pointer to the associated request_queue */
-	struct request_queue		*q;
-	struct list_head		q_node;
-	struct hlist_node		blkcg_node;
-	struct blkcg			*blkcg;
-
-	/* all non-root blkcg_gq's are guaranteed to have access to parent */
-	struct blkcg_gq			*parent;
-
-	/* request allocation list for this blkcg-q pair */
-	struct request_list		rl;
-
-	/* reference count */
-	atomic_t			refcnt;
-
-	/* is this blkg online? protected by both blkcg and q locks */
-	bool				online;
-
-	struct blkg_policy_data		*pd[BLKCG_MAX_POLS];
-
-	struct rcu_head			rcu_head;
-};
-
-typedef void (blkcg_pol_init_pd_fn)(struct blkcg_gq *blkg);
-typedef void (blkcg_pol_online_pd_fn)(struct blkcg_gq *blkg);
-typedef void (blkcg_pol_offline_pd_fn)(struct blkcg_gq *blkg);
-typedef void (blkcg_pol_exit_pd_fn)(struct blkcg_gq *blkg);
-typedef void (blkcg_pol_reset_pd_stats_fn)(struct blkcg_gq *blkg);
-
-struct blkcg_policy {
-	int				plid;
-	/* policy specific private data size */
-	size_t				pd_size;
-	/* cgroup files for the policy */
-	struct cftype			*cftypes;
-
-	/* operations */
-	blkcg_pol_init_pd_fn		*pd_init_fn;
-	blkcg_pol_online_pd_fn		*pd_online_fn;
-	blkcg_pol_offline_pd_fn		*pd_offline_fn;
-	blkcg_pol_exit_pd_fn		*pd_exit_fn;
-	blkcg_pol_reset_pd_stats_fn	*pd_reset_stats_fn;
-};
-
-extern struct blkcg blkcg_root;
-
-struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, struct request_queue *q);
-struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,
-				    struct request_queue *q);
-int blkcg_init_queue(struct request_queue *q);
-void blkcg_drain_queue(struct request_queue *q);
-void blkcg_exit_queue(struct request_queue *q);
-
-/* Blkio controller policy registration */
-int blkcg_policy_register(struct blkcg_policy *pol);
-void blkcg_policy_unregister(struct blkcg_policy *pol);
-int blkcg_activate_policy(struct request_queue *q,
-			  const struct blkcg_policy *pol);
-void blkcg_deactivate_policy(struct request_queue *q,
-			     const struct blkcg_policy *pol);
-
-void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,
-		       u64 (*prfill)(struct seq_file *,
-				     struct blkg_policy_data *, int),
-		       const struct blkcg_policy *pol, int data,
-		       bool show_total);
-u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v);
-u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
-			 const struct blkg_rwstat *rwstat);
-u64 blkg_prfill_stat(struct seq_file *sf, struct blkg_policy_data *pd, int off);
-u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
-		       int off);
-
-u64 blkg_stat_recursive_sum(struct blkg_policy_data *pd, int off);
-struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkg_policy_data *pd,
-					     int off);
-
-struct blkg_conf_ctx {
-	struct gendisk			*disk;
-	struct blkcg_gq			*blkg;
-	u64				v;
-};
-
-int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
-		   const char *input, struct blkg_conf_ctx *ctx);
-void blkg_conf_finish(struct blkg_conf_ctx *ctx);
-
-
-static inline struct blkcg *css_to_blkcg(struct cgroup_subsys_state *css)
-{
-	return css ? container_of(css, struct blkcg, css) : NULL;
-}
-
-static inline struct blkcg *task_blkcg(struct task_struct *tsk)
-{
-	return css_to_blkcg(task_css(tsk, blkio_cgrp_id));
-}
-
-static inline struct blkcg *bio_blkcg(struct bio *bio)
-{
-	if (bio && bio->bi_css)
-		return css_to_blkcg(bio->bi_css);
-	return task_blkcg(current);
-}
-
-/**
- * blkcg_parent - get the parent of a blkcg
- * @blkcg: blkcg of interest
- *
- * Return the parent blkcg of @blkcg.  Can be called anytime.
- */
-static inline struct blkcg *blkcg_parent(struct blkcg *blkcg)
-{
-	return css_to_blkcg(blkcg->css.parent);
-}
-
-/**
- * blkg_to_pdata - get policy private data
- * @blkg: blkg of interest
- * @pol: policy of interest
- *
- * Return pointer to private data associated with the @blkg-@pol pair.
- */
-static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
-						  struct blkcg_policy *pol)
-{
-	return blkg ? blkg->pd[pol->plid] : NULL;
-}
-
-/**
- * pdata_to_blkg - get blkg associated with policy private data
- * @pd: policy private data of interest
- *
- * @pd is policy private data.  Determine the blkg it's associated with.
- */
-static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd)
-{
-	return pd ? pd->blkg : NULL;
-}
-
-/**
- * blkg_path - format cgroup path of blkg
- * @blkg: blkg of interest
- * @buf: target buffer
- * @buflen: target buffer length
- *
- * Format the path of the cgroup of @blkg into @buf.
- */
-static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen)
-{
-	char *p;
-
-	p = cgroup_path(blkg->blkcg->css.cgroup, buf, buflen);
-	if (!p) {
-		strncpy(buf, "<unavailable>", buflen);
-		return -ENAMETOOLONG;
-	}
-
-	memmove(buf, p, buf + buflen - p);
-	return 0;
-}
-
-/**
- * blkg_get - get a blkg reference
- * @blkg: blkg to get
- *
- * The caller should be holding an existing reference.
- */
-static inline void blkg_get(struct blkcg_gq *blkg)
-{
-	WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
-	atomic_inc(&blkg->refcnt);
-}
-
-void __blkg_release_rcu(struct rcu_head *rcu);
-
-/**
- * blkg_put - put a blkg reference
- * @blkg: blkg to put
- */
-static inline void blkg_put(struct blkcg_gq *blkg)
-{
-	WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
-	if (atomic_dec_and_test(&blkg->refcnt))
-		call_rcu(&blkg->rcu_head, __blkg_release_rcu);
-}
-
-struct blkcg_gq *__blkg_lookup(struct blkcg *blkcg, struct request_queue *q,
-			       bool update_hint);
-
-/**
- * blkg_for_each_descendant_pre - pre-order walk of a blkg's descendants
- * @d_blkg: loop cursor pointing to the current descendant
- * @pos_css: used for iteration
- * @p_blkg: target blkg to walk descendants of
- *
- * Walk @c_blkg through the descendants of @p_blkg.  Must be used with RCU
- * read locked.  If called under either blkcg or queue lock, the iteration
- * is guaranteed to include all and only online blkgs.  The caller may
- * update @pos_css by calling css_rightmost_descendant() to skip subtree.
- * @p_blkg is included in the iteration and the first node to be visited.
- */
-#define blkg_for_each_descendant_pre(d_blkg, pos_css, p_blkg)		\
-	css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css)	\
-		if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css),	\
-					      (p_blkg)->q, false)))
-
-/**
- * blkg_for_each_descendant_post - post-order walk of a blkg's descendants
- * @d_blkg: loop cursor pointing to the current descendant
- * @pos_css: used for iteration
- * @p_blkg: target blkg to walk descendants of
- *
- * Similar to blkg_for_each_descendant_pre() but performs post-order
- * traversal instead.  Synchronization rules are the same.  @p_blkg is
- * included in the iteration and the last node to be visited.
- */
-#define blkg_for_each_descendant_post(d_blkg, pos_css, p_blkg)		\
-	css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css)	\
-		if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css),	\
-					      (p_blkg)->q, false)))
-
-/**
- * blk_get_rl - get request_list to use
- * @q: request_queue of interest
- * @bio: bio which will be attached to the allocated request (may be %NULL)
- *
- * The caller wants to allocate a request from @q to use for @bio.  Find
- * the request_list to use and obtain a reference on it.  Should be called
- * under queue_lock.  This function is guaranteed to return non-%NULL
- * request_list.
- */
-static inline struct request_list *blk_get_rl(struct request_queue *q,
-					      struct bio *bio)
-{
-	struct blkcg *blkcg;
-	struct blkcg_gq *blkg;
-
-	rcu_read_lock();
-
-	blkcg = bio_blkcg(bio);
-
-	/* bypass blkg lookup and use @q->root_rl directly for root */
-	if (blkcg == &blkcg_root)
-		goto root_rl;
-
-	/*
-	 * Try to use blkg->rl.  blkg lookup may fail under memory pressure
-	 * or if either the blkcg or queue is going away.  Fall back to
-	 * root_rl in such cases.
-	 */
-	blkg = blkg_lookup_create(blkcg, q);
-	if (unlikely(IS_ERR(blkg)))
-		goto root_rl;
-
-	blkg_get(blkg);
-	rcu_read_unlock();
-	return &blkg->rl;
-root_rl:
-	rcu_read_unlock();
-	return &q->root_rl;
-}
-
-/**
- * blk_put_rl - put request_list
- * @rl: request_list to put
- *
- * Put the reference acquired by blk_get_rl().  Should be called under
- * queue_lock.
- */
-static inline void blk_put_rl(struct request_list *rl)
-{
-	/* root_rl may not have blkg set */
-	if (rl->blkg && rl->blkg->blkcg != &blkcg_root)
-		blkg_put(rl->blkg);
-}
-
-/**
- * blk_rq_set_rl - associate a request with a request_list
- * @rq: request of interest
- * @rl: target request_list
- *
- * Associate @rq with @rl so that accounting and freeing can know the
- * request_list @rq came from.
- */
-static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl)
-{
-	rq->rl = rl;
-}
-
-/**
- * blk_rq_rl - return the request_list a request came from
- * @rq: request of interest
- *
- * Return the request_list @rq is allocated from.
- */
-static inline struct request_list *blk_rq_rl(struct request *rq)
-{
-	return rq->rl;
-}
-
-struct request_list *__blk_queue_next_rl(struct request_list *rl,
-					 struct request_queue *q);
-/**
- * blk_queue_for_each_rl - iterate through all request_lists of a request_queue
- *
- * Should be used under queue_lock.
- */
-#define blk_queue_for_each_rl(rl, q)	\
-	for ((rl) = &(q)->root_rl; (rl); (rl) = __blk_queue_next_rl((rl), (q)))
-
-static inline void blkg_stat_init(struct blkg_stat *stat)
-{
-	u64_stats_init(&stat->syncp);
-}
-
-/**
- * blkg_stat_add - add a value to a blkg_stat
- * @stat: target blkg_stat
- * @val: value to add
- *
- * Add @val to @stat.  The caller is responsible for synchronizing calls to
- * this function.
- */
-static inline void blkg_stat_add(struct blkg_stat *stat, uint64_t val)
-{
-	u64_stats_update_begin(&stat->syncp);
-	stat->cnt += val;
-	u64_stats_update_end(&stat->syncp);
-}
-
-/**
- * blkg_stat_read - read the current value of a blkg_stat
- * @stat: blkg_stat to read
- *
- * Read the current value of @stat.  This function can be called without
- * synchroniztion and takes care of u64 atomicity.
- */
-static inline uint64_t blkg_stat_read(struct blkg_stat *stat)
-{
-	unsigned int start;
-	uint64_t v;
-
-	do {
-		start = u64_stats_fetch_begin_irq(&stat->syncp);
-		v = stat->cnt;
-	} while (u64_stats_fetch_retry_irq(&stat->syncp, start));
-
-	return v;
-}
-
-/**
- * blkg_stat_reset - reset a blkg_stat
- * @stat: blkg_stat to reset
- */
-static inline void blkg_stat_reset(struct blkg_stat *stat)
-{
-	stat->cnt = 0;
-}
-
-/**
- * blkg_stat_merge - merge a blkg_stat into another
- * @to: the destination blkg_stat
- * @from: the source
- *
- * Add @from's count to @to.
- */
-static inline void blkg_stat_merge(struct blkg_stat *to, struct blkg_stat *from)
-{
-	blkg_stat_add(to, blkg_stat_read(from));
-}
-
-static inline void blkg_rwstat_init(struct blkg_rwstat *rwstat)
-{
-	u64_stats_init(&rwstat->syncp);
-}
-
-/**
- * blkg_rwstat_add - add a value to a blkg_rwstat
- * @rwstat: target blkg_rwstat
- * @rw: mask of REQ_{WRITE|SYNC}
- * @val: value to add
- *
- * Add @val to @rwstat.  The counters are chosen according to @rw.  The
- * caller is responsible for synchronizing calls to this function.
- */
-static inline void blkg_rwstat_add(struct blkg_rwstat *rwstat,
-				   int rw, uint64_t val)
-{
-	u64_stats_update_begin(&rwstat->syncp);
-
-	if (rw & REQ_WRITE)
-		rwstat->cnt[BLKG_RWSTAT_WRITE] += val;
-	else
-		rwstat->cnt[BLKG_RWSTAT_READ] += val;
-	if (rw & REQ_SYNC)
-		rwstat->cnt[BLKG_RWSTAT_SYNC] += val;
-	else
-		rwstat->cnt[BLKG_RWSTAT_ASYNC] += val;
-
-	u64_stats_update_end(&rwstat->syncp);
-}
-
-/**
- * blkg_rwstat_read - read the current values of a blkg_rwstat
- * @rwstat: blkg_rwstat to read
- *
- * Read the current snapshot of @rwstat and return it as the return value.
- * This function can be called without synchronization and takes care of
- * u64 atomicity.
- */
-static inline struct blkg_rwstat blkg_rwstat_read(struct blkg_rwstat *rwstat)
-{
-	unsigned int start;
-	struct blkg_rwstat tmp;
-
-	do {
-		start = u64_stats_fetch_begin_irq(&rwstat->syncp);
-		tmp = *rwstat;
-	} while (u64_stats_fetch_retry_irq(&rwstat->syncp, start));
-
-	return tmp;
-}
-
-/**
- * blkg_rwstat_total - read the total count of a blkg_rwstat
- * @rwstat: blkg_rwstat to read
- *
- * Return the total count of @rwstat regardless of the IO direction.  This
- * function can be called without synchronization and takes care of u64
- * atomicity.
- */
-static inline uint64_t blkg_rwstat_total(struct blkg_rwstat *rwstat)
-{
-	struct blkg_rwstat tmp = blkg_rwstat_read(rwstat);
-
-	return tmp.cnt[BLKG_RWSTAT_READ] + tmp.cnt[BLKG_RWSTAT_WRITE];
-}
-
-/**
- * blkg_rwstat_reset - reset a blkg_rwstat
- * @rwstat: blkg_rwstat to reset
- */
-static inline void blkg_rwstat_reset(struct blkg_rwstat *rwstat)
-{
-	memset(rwstat->cnt, 0, sizeof(rwstat->cnt));
-}
-
-/**
- * blkg_rwstat_merge - merge a blkg_rwstat into another
- * @to: the destination blkg_rwstat
- * @from: the source
- *
- * Add @from's counts to @to.
- */
-static inline void blkg_rwstat_merge(struct blkg_rwstat *to,
-				     struct blkg_rwstat *from)
-{
-	struct blkg_rwstat v = blkg_rwstat_read(from);
-	int i;
-
-	u64_stats_update_begin(&to->syncp);
-	for (i = 0; i < BLKG_RWSTAT_NR; i++)
-		to->cnt[i] += v.cnt[i];
-	u64_stats_update_end(&to->syncp);
-}
-
-#else	/* CONFIG_BLK_CGROUP */
-
-struct cgroup;
-struct blkcg;
-
-struct blkg_policy_data {
-};
-
-struct blkcg_gq {
-};
-
-struct blkcg_policy {
-};
-
-static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, void *key) { return NULL; }
-static inline int blkcg_init_queue(struct request_queue *q) { return 0; }
-static inline void blkcg_drain_queue(struct request_queue *q) { }
-static inline void blkcg_exit_queue(struct request_queue *q) { }
-static inline int blkcg_policy_register(struct blkcg_policy *pol) { return 0; }
-static inline void blkcg_policy_unregister(struct blkcg_policy *pol) { }
-static inline int blkcg_activate_policy(struct request_queue *q,
-					const struct blkcg_policy *pol) { return 0; }
-static inline void blkcg_deactivate_policy(struct request_queue *q,
-					   const struct blkcg_policy *pol) { }
-
-static inline struct blkcg *bio_blkcg(struct bio *bio) { return NULL; }
-
-static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
-						  struct blkcg_policy *pol) { return NULL; }
-static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd) { return NULL; }
-static inline char *blkg_path(struct blkcg_gq *blkg) { return NULL; }
-static inline void blkg_get(struct blkcg_gq *blkg) { }
-static inline void blkg_put(struct blkcg_gq *blkg) { }
-
-static inline struct request_list *blk_get_rl(struct request_queue *q,
-					      struct bio *bio) { return &q->root_rl; }
-static inline void blk_put_rl(struct request_list *rl) { }
-static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl) { }
-static inline struct request_list *blk_rq_rl(struct request *rq) { return &rq->q->root_rl; }
-
-#define blk_queue_for_each_rl(rl, q)	\
-	for ((rl) = &(q)->root_rl; (rl); (rl) = NULL)
-
-#endif	/* CONFIG_BLK_CGROUP */
-#endif	/* _BLK_CGROUP_H */
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -32,12 +32,12 @@
 #include <linux/delay.h>
 #include <linux/ratelimit.h>
 #include <linux/pm_runtime.h>
+#include <linux/blk-cgroup.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/block.h>
 
 #include "blk.h"
-#include "blk-cgroup.h"
 #include "blk-mq.h"
 
 EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_remap);
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -8,9 +8,9 @@
 #include <linux/blkdev.h>
 #include <linux/blktrace_api.h>
 #include <linux/blk-mq.h>
+#include <linux/blk-cgroup.h>
 
 #include "blk.h"
-#include "blk-cgroup.h"
 #include "blk-mq.h"
 
 struct queue_sysfs_entry {
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -9,7 +9,7 @@
 #include <linux/blkdev.h>
 #include <linux/bio.h>
 #include <linux/blktrace_api.h>
-#include "blk-cgroup.h"
+#include <linux/blk-cgroup.h>
 #include "blk.h"
 
 /* Max dispatch from a group in 1 round */
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -14,8 +14,8 @@
 #include <linux/rbtree.h>
 #include <linux/ioprio.h>
 #include <linux/blktrace_api.h>
+#include <linux/blk-cgroup.h>
 #include "blk.h"
-#include "blk-cgroup.h"
 
 /*
  * tunables
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -35,11 +35,11 @@
 #include <linux/hash.h>
 #include <linux/uaccess.h>
 #include <linux/pm_runtime.h>
+#include <linux/blk-cgroup.h>
 
 #include <trace/events/block.h>
 
 #include "blk.h"
-#include "blk-cgroup.h"
 
 static DEFINE_SPINLOCK(elv_list_lock);
 static LIST_HEAD(elv_list);
--- /dev/null
+++ b/include/linux/blk-cgroup.h
@@ -0,0 +1,603 @@
+#ifndef _BLK_CGROUP_H
+#define _BLK_CGROUP_H
+/*
+ * Common Block IO controller cgroup interface
+ *
+ * Based on ideas and code from CFQ, CFS and BFQ:
+ * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
+ *
+ * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
+ *		      Paolo Valente <paolo.valente@unimore.it>
+ *
+ * Copyright (C) 2009 Vivek Goyal <vgoyal@redhat.com>
+ * 	              Nauman Rafique <nauman@google.com>
+ */
+
+#include <linux/cgroup.h>
+#include <linux/u64_stats_sync.h>
+#include <linux/seq_file.h>
+#include <linux/radix-tree.h>
+#include <linux/blkdev.h>
+#include <linux/atomic.h>
+
+/* Max limits for throttle policy */
+#define THROTL_IOPS_MAX		UINT_MAX
+
+/* CFQ specific, out here for blkcg->cfq_weight */
+#define CFQ_WEIGHT_MIN		10
+#define CFQ_WEIGHT_MAX		1000
+#define CFQ_WEIGHT_DEFAULT	500
+
+#ifdef CONFIG_BLK_CGROUP
+
+enum blkg_rwstat_type {
+	BLKG_RWSTAT_READ,
+	BLKG_RWSTAT_WRITE,
+	BLKG_RWSTAT_SYNC,
+	BLKG_RWSTAT_ASYNC,
+
+	BLKG_RWSTAT_NR,
+	BLKG_RWSTAT_TOTAL = BLKG_RWSTAT_NR,
+};
+
+struct blkcg_gq;
+
+struct blkcg {
+	struct cgroup_subsys_state	css;
+	spinlock_t			lock;
+
+	struct radix_tree_root		blkg_tree;
+	struct blkcg_gq			*blkg_hint;
+	struct hlist_head		blkg_list;
+
+	/* TODO: per-policy storage in blkcg */
+	unsigned int			cfq_weight;	/* belongs to cfq */
+	unsigned int			cfq_leaf_weight;
+};
+
+struct blkg_stat {
+	struct u64_stats_sync		syncp;
+	uint64_t			cnt;
+};
+
+struct blkg_rwstat {
+	struct u64_stats_sync		syncp;
+	uint64_t			cnt[BLKG_RWSTAT_NR];
+};
+
+/*
+ * A blkcg_gq (blkg) is association between a block cgroup (blkcg) and a
+ * request_queue (q).  This is used by blkcg policies which need to track
+ * information per blkcg - q pair.
+ *
+ * There can be multiple active blkcg policies and each has its private
+ * data on each blkg, the size of which is determined by
+ * blkcg_policy->pd_size.  blkcg core allocates and frees such areas
+ * together with blkg and invokes pd_init/exit_fn() methods.
+ *
+ * Such private data must embed struct blkg_policy_data (pd) at the
+ * beginning and pd_size can't be smaller than pd.
+ */
+struct blkg_policy_data {
+	/* the blkg and policy id this per-policy data belongs to */
+	struct blkcg_gq			*blkg;
+	int				plid;
+
+	/* used during policy activation */
+	struct list_head		alloc_node;
+};
+
+/* association between a blk cgroup and a request queue */
+struct blkcg_gq {
+	/* Pointer to the associated request_queue */
+	struct request_queue		*q;
+	struct list_head		q_node;
+	struct hlist_node		blkcg_node;
+	struct blkcg			*blkcg;
+
+	/* all non-root blkcg_gq's are guaranteed to have access to parent */
+	struct blkcg_gq			*parent;
+
+	/* request allocation list for this blkcg-q pair */
+	struct request_list		rl;
+
+	/* reference count */
+	atomic_t			refcnt;
+
+	/* is this blkg online? protected by both blkcg and q locks */
+	bool				online;
+
+	struct blkg_policy_data		*pd[BLKCG_MAX_POLS];
+
+	struct rcu_head			rcu_head;
+};
+
+typedef void (blkcg_pol_init_pd_fn)(struct blkcg_gq *blkg);
+typedef void (blkcg_pol_online_pd_fn)(struct blkcg_gq *blkg);
+typedef void (blkcg_pol_offline_pd_fn)(struct blkcg_gq *blkg);
+typedef void (blkcg_pol_exit_pd_fn)(struct blkcg_gq *blkg);
+typedef void (blkcg_pol_reset_pd_stats_fn)(struct blkcg_gq *blkg);
+
+struct blkcg_policy {
+	int				plid;
+	/* policy specific private data size */
+	size_t				pd_size;
+	/* cgroup files for the policy */
+	struct cftype			*cftypes;
+
+	/* operations */
+	blkcg_pol_init_pd_fn		*pd_init_fn;
+	blkcg_pol_online_pd_fn		*pd_online_fn;
+	blkcg_pol_offline_pd_fn		*pd_offline_fn;
+	blkcg_pol_exit_pd_fn		*pd_exit_fn;
+	blkcg_pol_reset_pd_stats_fn	*pd_reset_stats_fn;
+};
+
+extern struct blkcg blkcg_root;
+
+struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, struct request_queue *q);
+struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,
+				    struct request_queue *q);
+int blkcg_init_queue(struct request_queue *q);
+void blkcg_drain_queue(struct request_queue *q);
+void blkcg_exit_queue(struct request_queue *q);
+
+/* Blkio controller policy registration */
+int blkcg_policy_register(struct blkcg_policy *pol);
+void blkcg_policy_unregister(struct blkcg_policy *pol);
+int blkcg_activate_policy(struct request_queue *q,
+			  const struct blkcg_policy *pol);
+void blkcg_deactivate_policy(struct request_queue *q,
+			     const struct blkcg_policy *pol);
+
+void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,
+		       u64 (*prfill)(struct seq_file *,
+				     struct blkg_policy_data *, int),
+		       const struct blkcg_policy *pol, int data,
+		       bool show_total);
+u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v);
+u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
+			 const struct blkg_rwstat *rwstat);
+u64 blkg_prfill_stat(struct seq_file *sf, struct blkg_policy_data *pd, int off);
+u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
+		       int off);
+
+u64 blkg_stat_recursive_sum(struct blkg_policy_data *pd, int off);
+struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkg_policy_data *pd,
+					     int off);
+
+struct blkg_conf_ctx {
+	struct gendisk			*disk;
+	struct blkcg_gq			*blkg;
+	u64				v;
+};
+
+int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
+		   const char *input, struct blkg_conf_ctx *ctx);
+void blkg_conf_finish(struct blkg_conf_ctx *ctx);
+
+
+static inline struct blkcg *css_to_blkcg(struct cgroup_subsys_state *css)
+{
+	return css ? container_of(css, struct blkcg, css) : NULL;
+}
+
+static inline struct blkcg *task_blkcg(struct task_struct *tsk)
+{
+	return css_to_blkcg(task_css(tsk, blkio_cgrp_id));
+}
+
+static inline struct blkcg *bio_blkcg(struct bio *bio)
+{
+	if (bio && bio->bi_css)
+		return css_to_blkcg(bio->bi_css);
+	return task_blkcg(current);
+}
+
+/**
+ * blkcg_parent - get the parent of a blkcg
+ * @blkcg: blkcg of interest
+ *
+ * Return the parent blkcg of @blkcg.  Can be called anytime.
+ */
+static inline struct blkcg *blkcg_parent(struct blkcg *blkcg)
+{
+	return css_to_blkcg(blkcg->css.parent);
+}
+
+/**
+ * blkg_to_pdata - get policy private data
+ * @blkg: blkg of interest
+ * @pol: policy of interest
+ *
+ * Return pointer to private data associated with the @blkg-@pol pair.
+ */
+static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
+						  struct blkcg_policy *pol)
+{
+	return blkg ? blkg->pd[pol->plid] : NULL;
+}
+
+/**
+ * pdata_to_blkg - get blkg associated with policy private data
+ * @pd: policy private data of interest
+ *
+ * @pd is policy private data.  Determine the blkg it's associated with.
+ */
+static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd)
+{
+	return pd ? pd->blkg : NULL;
+}
+
+/**
+ * blkg_path - format cgroup path of blkg
+ * @blkg: blkg of interest
+ * @buf: target buffer
+ * @buflen: target buffer length
+ *
+ * Format the path of the cgroup of @blkg into @buf.
+ */
+static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen)
+{
+	char *p;
+
+	p = cgroup_path(blkg->blkcg->css.cgroup, buf, buflen);
+	if (!p) {
+		strncpy(buf, "<unavailable>", buflen);
+		return -ENAMETOOLONG;
+	}
+
+	memmove(buf, p, buf + buflen - p);
+	return 0;
+}
+
+/**
+ * blkg_get - get a blkg reference
+ * @blkg: blkg to get
+ *
+ * The caller should be holding an existing reference.
+ */
+static inline void blkg_get(struct blkcg_gq *blkg)
+{
+	WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
+	atomic_inc(&blkg->refcnt);
+}
+
+void __blkg_release_rcu(struct rcu_head *rcu);
+
+/**
+ * blkg_put - put a blkg reference
+ * @blkg: blkg to put
+ */
+static inline void blkg_put(struct blkcg_gq *blkg)
+{
+	WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
+	if (atomic_dec_and_test(&blkg->refcnt))
+		call_rcu(&blkg->rcu_head, __blkg_release_rcu);
+}
+
+struct blkcg_gq *__blkg_lookup(struct blkcg *blkcg, struct request_queue *q,
+			       bool update_hint);
+
+/**
+ * blkg_for_each_descendant_pre - pre-order walk of a blkg's descendants
+ * @d_blkg: loop cursor pointing to the current descendant
+ * @pos_css: used for iteration
+ * @p_blkg: target blkg to walk descendants of
+ *
+ * Walk @c_blkg through the descendants of @p_blkg.  Must be used with RCU
+ * read locked.  If called under either blkcg or queue lock, the iteration
+ * is guaranteed to include all and only online blkgs.  The caller may
+ * update @pos_css by calling css_rightmost_descendant() to skip subtree.
+ * @p_blkg is included in the iteration and the first node to be visited.
+ */
+#define blkg_for_each_descendant_pre(d_blkg, pos_css, p_blkg)		\
+	css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css)	\
+		if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css),	\
+					      (p_blkg)->q, false)))
+
+/**
+ * blkg_for_each_descendant_post - post-order walk of a blkg's descendants
+ * @d_blkg: loop cursor pointing to the current descendant
+ * @pos_css: used for iteration
+ * @p_blkg: target blkg to walk descendants of
+ *
+ * Similar to blkg_for_each_descendant_pre() but performs post-order
+ * traversal instead.  Synchronization rules are the same.  @p_blkg is
+ * included in the iteration and the last node to be visited.
+ */
+#define blkg_for_each_descendant_post(d_blkg, pos_css, p_blkg)		\
+	css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css)	\
+		if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css),	\
+					      (p_blkg)->q, false)))
+
+/**
+ * blk_get_rl - get request_list to use
+ * @q: request_queue of interest
+ * @bio: bio which will be attached to the allocated request (may be %NULL)
+ *
+ * The caller wants to allocate a request from @q to use for @bio.  Find
+ * the request_list to use and obtain a reference on it.  Should be called
+ * under queue_lock.  This function is guaranteed to return non-%NULL
+ * request_list.
+ */
+static inline struct request_list *blk_get_rl(struct request_queue *q,
+					      struct bio *bio)
+{
+	struct blkcg *blkcg;
+	struct blkcg_gq *blkg;
+
+	rcu_read_lock();
+
+	blkcg = bio_blkcg(bio);
+
+	/* bypass blkg lookup and use @q->root_rl directly for root */
+	if (blkcg == &blkcg_root)
+		goto root_rl;
+
+	/*
+	 * Try to use blkg->rl.  blkg lookup may fail under memory pressure
+	 * or if either the blkcg or queue is going away.  Fall back to
+	 * root_rl in such cases.
+	 */
+	blkg = blkg_lookup_create(blkcg, q);
+	if (unlikely(IS_ERR(blkg)))
+		goto root_rl;
+
+	blkg_get(blkg);
+	rcu_read_unlock();
+	return &blkg->rl;
+root_rl:
+	rcu_read_unlock();
+	return &q->root_rl;
+}
+
+/**
+ * blk_put_rl - put request_list
+ * @rl: request_list to put
+ *
+ * Put the reference acquired by blk_get_rl().  Should be called under
+ * queue_lock.
+ */
+static inline void blk_put_rl(struct request_list *rl)
+{
+	/* root_rl may not have blkg set */
+	if (rl->blkg && rl->blkg->blkcg != &blkcg_root)
+		blkg_put(rl->blkg);
+}
+
+/**
+ * blk_rq_set_rl - associate a request with a request_list
+ * @rq: request of interest
+ * @rl: target request_list
+ *
+ * Associate @rq with @rl so that accounting and freeing can know the
+ * request_list @rq came from.
+ */
+static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl)
+{
+	rq->rl = rl;
+}
+
+/**
+ * blk_rq_rl - return the request_list a request came from
+ * @rq: request of interest
+ *
+ * Return the request_list @rq is allocated from.
+ */
+static inline struct request_list *blk_rq_rl(struct request *rq)
+{
+	return rq->rl;
+}
+
+struct request_list *__blk_queue_next_rl(struct request_list *rl,
+					 struct request_queue *q);
+/**
+ * blk_queue_for_each_rl - iterate through all request_lists of a request_queue
+ *
+ * Should be used under queue_lock.
+ */
+#define blk_queue_for_each_rl(rl, q)	\
+	for ((rl) = &(q)->root_rl; (rl); (rl) = __blk_queue_next_rl((rl), (q)))
+
+static inline void blkg_stat_init(struct blkg_stat *stat)
+{
+	u64_stats_init(&stat->syncp);
+}
+
+/**
+ * blkg_stat_add - add a value to a blkg_stat
+ * @stat: target blkg_stat
+ * @val: value to add
+ *
+ * Add @val to @stat.  The caller is responsible for synchronizing calls to
+ * this function.
+ */
+static inline void blkg_stat_add(struct blkg_stat *stat, uint64_t val)
+{
+	u64_stats_update_begin(&stat->syncp);
+	stat->cnt += val;
+	u64_stats_update_end(&stat->syncp);
+}
+
+/**
+ * blkg_stat_read - read the current value of a blkg_stat
+ * @stat: blkg_stat to read
+ *
+ * Read the current value of @stat.  This function can be called without
+ * synchroniztion and takes care of u64 atomicity.
+ */
+static inline uint64_t blkg_stat_read(struct blkg_stat *stat)
+{
+	unsigned int start;
+	uint64_t v;
+
+	do {
+		start = u64_stats_fetch_begin_irq(&stat->syncp);
+		v = stat->cnt;
+	} while (u64_stats_fetch_retry_irq(&stat->syncp, start));
+
+	return v;
+}
+
+/**
+ * blkg_stat_reset - reset a blkg_stat
+ * @stat: blkg_stat to reset
+ */
+static inline void blkg_stat_reset(struct blkg_stat *stat)
+{
+	stat->cnt = 0;
+}
+
+/**
+ * blkg_stat_merge - merge a blkg_stat into another
+ * @to: the destination blkg_stat
+ * @from: the source
+ *
+ * Add @from's count to @to.
+ */
+static inline void blkg_stat_merge(struct blkg_stat *to, struct blkg_stat *from)
+{
+	blkg_stat_add(to, blkg_stat_read(from));
+}
+
+static inline void blkg_rwstat_init(struct blkg_rwstat *rwstat)
+{
+	u64_stats_init(&rwstat->syncp);
+}
+
+/**
+ * blkg_rwstat_add - add a value to a blkg_rwstat
+ * @rwstat: target blkg_rwstat
+ * @rw: mask of REQ_{WRITE|SYNC}
+ * @val: value to add
+ *
+ * Add @val to @rwstat.  The counters are chosen according to @rw.  The
+ * caller is responsible for synchronizing calls to this function.
+ */
+static inline void blkg_rwstat_add(struct blkg_rwstat *rwstat,
+				   int rw, uint64_t val)
+{
+	u64_stats_update_begin(&rwstat->syncp);
+
+	if (rw & REQ_WRITE)
+		rwstat->cnt[BLKG_RWSTAT_WRITE] += val;
+	else
+		rwstat->cnt[BLKG_RWSTAT_READ] += val;
+	if (rw & REQ_SYNC)
+		rwstat->cnt[BLKG_RWSTAT_SYNC] += val;
+	else
+		rwstat->cnt[BLKG_RWSTAT_ASYNC] += val;
+
+	u64_stats_update_end(&rwstat->syncp);
+}
+
+/**
+ * blkg_rwstat_read - read the current values of a blkg_rwstat
+ * @rwstat: blkg_rwstat to read
+ *
+ * Read the current snapshot of @rwstat and return it as the return value.
+ * This function can be called without synchronization and takes care of
+ * u64 atomicity.
+ */
+static inline struct blkg_rwstat blkg_rwstat_read(struct blkg_rwstat *rwstat)
+{
+	unsigned int start;
+	struct blkg_rwstat tmp;
+
+	do {
+		start = u64_stats_fetch_begin_irq(&rwstat->syncp);
+		tmp = *rwstat;
+	} while (u64_stats_fetch_retry_irq(&rwstat->syncp, start));
+
+	return tmp;
+}
+
+/**
+ * blkg_rwstat_total - read the total count of a blkg_rwstat
+ * @rwstat: blkg_rwstat to read
+ *
+ * Return the total count of @rwstat regardless of the IO direction.  This
+ * function can be called without synchronization and takes care of u64
+ * atomicity.
+ */
+static inline uint64_t blkg_rwstat_total(struct blkg_rwstat *rwstat)
+{
+	struct blkg_rwstat tmp = blkg_rwstat_read(rwstat);
+
+	return tmp.cnt[BLKG_RWSTAT_READ] + tmp.cnt[BLKG_RWSTAT_WRITE];
+}
+
+/**
+ * blkg_rwstat_reset - reset a blkg_rwstat
+ * @rwstat: blkg_rwstat to reset
+ */
+static inline void blkg_rwstat_reset(struct blkg_rwstat *rwstat)
+{
+	memset(rwstat->cnt, 0, sizeof(rwstat->cnt));
+}
+
+/**
+ * blkg_rwstat_merge - merge a blkg_rwstat into another
+ * @to: the destination blkg_rwstat
+ * @from: the source
+ *
+ * Add @from's counts to @to.
+ */
+static inline void blkg_rwstat_merge(struct blkg_rwstat *to,
+				     struct blkg_rwstat *from)
+{
+	struct blkg_rwstat v = blkg_rwstat_read(from);
+	int i;
+
+	u64_stats_update_begin(&to->syncp);
+	for (i = 0; i < BLKG_RWSTAT_NR; i++)
+		to->cnt[i] += v.cnt[i];
+	u64_stats_update_end(&to->syncp);
+}
+
+#else	/* CONFIG_BLK_CGROUP */
+
+struct cgroup;
+struct blkcg;
+
+struct blkg_policy_data {
+};
+
+struct blkcg_gq {
+};
+
+struct blkcg_policy {
+};
+
+static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, void *key) { return NULL; }
+static inline int blkcg_init_queue(struct request_queue *q) { return 0; }
+static inline void blkcg_drain_queue(struct request_queue *q) { }
+static inline void blkcg_exit_queue(struct request_queue *q) { }
+static inline int blkcg_policy_register(struct blkcg_policy *pol) { return 0; }
+static inline void blkcg_policy_unregister(struct blkcg_policy *pol) { }
+static inline int blkcg_activate_policy(struct request_queue *q,
+					const struct blkcg_policy *pol) { return 0; }
+static inline void blkcg_deactivate_policy(struct request_queue *q,
+					   const struct blkcg_policy *pol) { }
+
+static inline struct blkcg *bio_blkcg(struct bio *bio) { return NULL; }
+
+static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
+						  struct blkcg_policy *pol) { return NULL; }
+static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd) { return NULL; }
+static inline char *blkg_path(struct blkcg_gq *blkg) { return NULL; }
+static inline void blkg_get(struct blkcg_gq *blkg) { }
+static inline void blkg_put(struct blkcg_gq *blkg) { }
+
+static inline struct request_list *blk_get_rl(struct request_queue *q,
+					      struct bio *bio) { return &q->root_rl; }
+static inline void blk_put_rl(struct request_list *rl) { }
+static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl) { }
+static inline struct request_list *blk_rq_rl(struct request *rq) { return &rq->q->root_rl; }
+
+#define blk_queue_for_each_rl(rl, q)	\
+	for ((rl) = &(q)->root_rl; (rl); (rl) = NULL)
+
+#endif	/* CONFIG_BLK_CGROUP */
+#endif	/* _BLK_CGROUP_H */

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH block/for-next 2/4] blkcg: add blkcg_root_css
  2014-11-17 21:13 [PATCH block/for-next 1/4] blkcg: move block/blk-cgroup.h to include/linux/blk-cgroup.h Tejun Heo
@ 2014-11-17 21:13 ` Tejun Heo
  2014-11-17 21:15   ` [PATCH block/for-next 3/4] cgroup, block: implement task_get_css() and use it in bio_associate_current() Tejun Heo
  2014-11-20 20:16   ` [PATCH block/for-next 2/4] blkcg: add blkcg_root_css Vivek Goyal
  2014-11-20 20:10 ` [PATCH block/for-next 1/4] blkcg: move block/blk-cgroup.h to include/linux/blk-cgroup.h Vivek Goyal
  1 sibling, 2 replies; 10+ messages in thread
From: Tejun Heo @ 2014-11-17 21:13 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, Vivek Goyal

cgroup writeback support would need to tell whether a given blkcg
cgroup_subsys_state is the root one or not.  Add global constant
blkcg_root_css which points to &blkcg_root.css.  If blkcg is disabled,
it's defined as ERR_PTR(-EINVAL).

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
---
 block/blk-cgroup.c     |    2 ++
 include/linux/blkdev.h |    6 ++++++
 2 files changed, 8 insertions(+)

--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -30,6 +30,8 @@ struct blkcg blkcg_root = { .cfq_weight
 			    .cfq_leaf_weight = 2 * CFQ_WEIGHT_DEFAULT, };
 EXPORT_SYMBOL_GPL(blkcg_root);
 
+struct cgroup_subsys_state * const blkcg_root_css = &blkcg_root.css;
+
 static struct blkcg_policy *blkcg_policy[BLKCG_MAX_POLS];
 
 static bool blkcg_policy_enabled(struct request_queue *q,
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1408,6 +1408,9 @@ int kblockd_schedule_delayed_work(struct
 int kblockd_schedule_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay);
 
 #ifdef CONFIG_BLK_CGROUP
+
+extern struct cgroup_subsys_state * const blkcg_root_css;
+
 /*
  * This should not be using sched_clock(). A real patch is in progress
  * to fix this up, until that is in place we need to disable preemption
@@ -1437,6 +1440,9 @@ static inline uint64_t rq_io_start_time_
         return req->io_start_time_ns;
 }
 #else
+
+#define blkcg_root_css	((struct cgroup_subsys_state *)ERR_PTR(-EINVAL))
+
 static inline void set_start_time_ns(struct request *req) {}
 static inline void set_io_start_time_ns(struct request *req) {}
 static inline uint64_t rq_start_time_ns(struct request *req)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH block/for-next 3/4] cgroup, block: implement task_get_css() and use it in bio_associate_current()
  2014-11-17 21:13 ` [PATCH block/for-next 2/4] blkcg: add blkcg_root_css Tejun Heo
@ 2014-11-17 21:15   ` Tejun Heo
  2014-11-17 21:16     ` [PATCH block/for-next 4/4] block: implement bio_associate_blkcg() Tejun Heo
  2014-11-20 20:27     ` [PATCH block/for-next 3/4] cgroup, block: implement task_get_css() and use it in bio_associate_current() Vivek Goyal
  2014-11-20 20:16   ` [PATCH block/for-next 2/4] blkcg: add blkcg_root_css Vivek Goyal
  1 sibling, 2 replies; 10+ messages in thread
From: Tejun Heo @ 2014-11-17 21:15 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, Vivek Goyal, Li Zefan

bio_associate_current() currently open codes task_css() and
css_tryget_online() to find and pin $current's blkcg css.  Abstract it
into task_get_css() which is implemented from cgroup side.  As a task
is always associated with an online css for every subsystem except
while the css_set update is propagating, task_get_css() retries till
css_tryget_online() succeeds.

This is a cleanup and shouldn't lead to noticeable behavior changes.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Vivek Goyal <vgoyal@redhat.com>
---
Hello,

This one can be routed through either cgroup or block tree but I think
it'd be easier to route this through block as there will be more block
changes in the area.

Thanks.

 block/bio.c            |   11 +----------
 include/linux/cgroup.h |   25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 10 deletions(-)

--- a/block/bio.c
+++ b/block/bio.c
@@ -1997,7 +1997,6 @@ EXPORT_SYMBOL(bioset_create_nobvec);
 int bio_associate_current(struct bio *bio)
 {
 	struct io_context *ioc;
-	struct cgroup_subsys_state *css;
 
 	if (bio->bi_ioc)
 		return -EBUSY;
@@ -2006,17 +2005,9 @@ int bio_associate_current(struct bio *bi
 	if (!ioc)
 		return -ENOENT;
 
-	/* acquire active ref on @ioc and associate */
 	get_io_context_active(ioc);
 	bio->bi_ioc = ioc;
-
-	/* associate blkcg if exists */
-	rcu_read_lock();
-	css = task_css(current, blkio_cgrp_id);
-	if (css && css_tryget_online(css))
-		bio->bi_css = css;
-	rcu_read_unlock();
-
+	bio->bi_css = task_get_css(current, blkio_cgrp_id);
 	return 0;
 }
 
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -748,6 +748,31 @@ static inline struct cgroup_subsys_state
 }
 
 /**
+ * task_get_css - find and get the css for (task, subsys)
+ * @task: the target task
+ * @subsys_id: the target subsystem ID
+ *
+ * Find the css for the (@task, @subsys_id) combination, increment a
+ * reference on and return it.  This function is guaranteed to return a
+ * valid css.
+ */
+static inline struct cgroup_subsys_state *
+task_get_css(struct task_struct *task, int subsys_id)
+{
+	struct cgroup_subsys_state *css;
+
+	rcu_read_lock();
+	while (true) {
+		css = task_css(task, subsys_id);
+		if (likely(css_tryget_online(css)))
+			break;
+		cpu_relax();
+	}
+	rcu_read_unlock();
+	return css;
+}
+
+/**
  * task_css_is_root - test whether a task belongs to the root css
  * @task: the target task
  * @subsys_id: the target subsystem ID

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH block/for-next 4/4] block: implement bio_associate_blkcg()
  2014-11-17 21:15   ` [PATCH block/for-next 3/4] cgroup, block: implement task_get_css() and use it in bio_associate_current() Tejun Heo
@ 2014-11-17 21:16     ` Tejun Heo
  2014-11-20 21:15       ` Vivek Goyal
  2014-11-20 20:27     ` [PATCH block/for-next 3/4] cgroup, block: implement task_get_css() and use it in bio_associate_current() Vivek Goyal
  1 sibling, 1 reply; 10+ messages in thread
From: Tejun Heo @ 2014-11-17 21:16 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, Vivek Goyal

Currently, a bio can only be associated with the io_context and blkcg
of %current using bio_associate_current().  This is too restrictive
for cgroup writeback support.  Implement bio_associate_blkcg() which
associates a bio with the specified blkcg.

bio_associate_blkcg() leaves the io_context unassociated.
bio_associate_current() is updated so that it considers a bio as
already associated if it has a blkcg_css, instead of an io_context,
associated with it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Vivek Goyal <vgoyal@redhat.com>
---
 block/bio.c         |   24 +++++++++++++++++++++++-
 include/linux/bio.h |    3 +++
 2 files changed, 26 insertions(+), 1 deletion(-)

--- a/block/bio.c
+++ b/block/bio.c
@@ -1981,6 +1981,28 @@ struct bio_set *bioset_create_nobvec(uns
 EXPORT_SYMBOL(bioset_create_nobvec);
 
 #ifdef CONFIG_BLK_CGROUP
+
+/**
+ * bio_associate_blkcg - associate a bio with the specified blkcg
+ * @bio: target bio
+ * @blkcg_css: the css of the blkcg to associate
+ *
+ * Associate @bio with the blkcg specified by @blkcg_css.  Block layer will
+ * treat @bio as if it were issued by a task which belongs to the blkcg.
+ *
+ * This function takes an extra reference of @blkcg_css which will be put
+ * when @bio is released.  The caller must own @bio and is responsible for
+ * synchronizing calls to this function.
+ */
+int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css)
+{
+	if (unlikely(bio->bi_css))
+		return -EBUSY;
+	css_get(blkcg_css);
+	bio->bi_css = blkcg_css;
+	return 0;
+}
+
 /**
  * bio_associate_current - associate a bio with %current
  * @bio: target bio
@@ -1998,7 +2020,7 @@ int bio_associate_current(struct bio *bi
 {
 	struct io_context *ioc;
 
-	if (bio->bi_ioc)
+	if (bio->bi_css)
 		return -EBUSY;
 
 	ioc = current->io_context;
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -470,9 +470,12 @@ extern void bvec_free(mempool_t *, struc
 extern unsigned int bvec_nr_vecs(unsigned short idx);
 
 #ifdef CONFIG_BLK_CGROUP
+int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
 int bio_associate_current(struct bio *bio);
 void bio_disassociate_task(struct bio *bio);
 #else	/* CONFIG_BLK_CGROUP */
+static inline int bio_associate_blkcg(struct bio *bio,
+			struct cgroup_subsys_state *blkcg_css) { return 0; }
 static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
 static inline void bio_disassociate_task(struct bio *bio) { }
 #endif	/* CONFIG_BLK_CGROUP */

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH block/for-next 1/4] blkcg: move block/blk-cgroup.h to include/linux/blk-cgroup.h
  2014-11-17 21:13 [PATCH block/for-next 1/4] blkcg: move block/blk-cgroup.h to include/linux/blk-cgroup.h Tejun Heo
  2014-11-17 21:13 ` [PATCH block/for-next 2/4] blkcg: add blkcg_root_css Tejun Heo
@ 2014-11-20 20:10 ` Vivek Goyal
  1 sibling, 0 replies; 10+ messages in thread
From: Vivek Goyal @ 2014-11-20 20:10 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Jens Axboe, linux-kernel

On Mon, Nov 17, 2014 at 04:13:21PM -0500, Tejun Heo wrote:
> cgroup aware writeback support will require exposing some of blkcg
> details.  In preprataion, move block/blk-cgroup.h to
> include/linux/blk-cgroup.h.  This patch is pure file move.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Cc: Vivek Goyal <vgoyal@redhat.com>

Acked-by: Vivek Goyal <vgoyal@redhat.com>

Thanks
Vivek

> ---
> Hello, Jens.
> 
> These four are misc prep patches on blkcg for cgroup writeback
> support.
> 
> Thanks.
> 
>  block/blk-cgroup.c         |    2 
>  block/blk-cgroup.h         |  603 ---------------------------------------------
>  block/blk-core.c           |    2 
>  block/blk-sysfs.c          |    2 
>  block/blk-throttle.c       |    2 
>  block/cfq-iosched.c        |    2 
>  block/elevator.c           |    2 
>  include/linux/blk-cgroup.h |  603 +++++++++++++++++++++++++++++++++++++++++++++
>  8 files changed, 609 insertions(+), 609 deletions(-)
> 
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -19,7 +19,7 @@
>  #include <linux/genhd.h>
>  #include <linux/delay.h>
>  #include <linux/atomic.h>
> -#include "blk-cgroup.h"
> +#include <linux/blk-cgroup.h>
>  #include "blk.h"
>  
>  #define MAX_KEY_LEN 100
> --- a/block/blk-cgroup.h
> +++ /dev/null
> @@ -1,603 +0,0 @@
> -#ifndef _BLK_CGROUP_H
> -#define _BLK_CGROUP_H
> -/*
> - * Common Block IO controller cgroup interface
> - *
> - * Based on ideas and code from CFQ, CFS and BFQ:
> - * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
> - *
> - * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
> - *		      Paolo Valente <paolo.valente@unimore.it>
> - *
> - * Copyright (C) 2009 Vivek Goyal <vgoyal@redhat.com>
> - * 	              Nauman Rafique <nauman@google.com>
> - */
> -
> -#include <linux/cgroup.h>
> -#include <linux/u64_stats_sync.h>
> -#include <linux/seq_file.h>
> -#include <linux/radix-tree.h>
> -#include <linux/blkdev.h>
> -#include <linux/atomic.h>
> -
> -/* Max limits for throttle policy */
> -#define THROTL_IOPS_MAX		UINT_MAX
> -
> -/* CFQ specific, out here for blkcg->cfq_weight */
> -#define CFQ_WEIGHT_MIN		10
> -#define CFQ_WEIGHT_MAX		1000
> -#define CFQ_WEIGHT_DEFAULT	500
> -
> -#ifdef CONFIG_BLK_CGROUP
> -
> -enum blkg_rwstat_type {
> -	BLKG_RWSTAT_READ,
> -	BLKG_RWSTAT_WRITE,
> -	BLKG_RWSTAT_SYNC,
> -	BLKG_RWSTAT_ASYNC,
> -
> -	BLKG_RWSTAT_NR,
> -	BLKG_RWSTAT_TOTAL = BLKG_RWSTAT_NR,
> -};
> -
> -struct blkcg_gq;
> -
> -struct blkcg {
> -	struct cgroup_subsys_state	css;
> -	spinlock_t			lock;
> -
> -	struct radix_tree_root		blkg_tree;
> -	struct blkcg_gq			*blkg_hint;
> -	struct hlist_head		blkg_list;
> -
> -	/* TODO: per-policy storage in blkcg */
> -	unsigned int			cfq_weight;	/* belongs to cfq */
> -	unsigned int			cfq_leaf_weight;
> -};
> -
> -struct blkg_stat {
> -	struct u64_stats_sync		syncp;
> -	uint64_t			cnt;
> -};
> -
> -struct blkg_rwstat {
> -	struct u64_stats_sync		syncp;
> -	uint64_t			cnt[BLKG_RWSTAT_NR];
> -};
> -
> -/*
> - * A blkcg_gq (blkg) is association between a block cgroup (blkcg) and a
> - * request_queue (q).  This is used by blkcg policies which need to track
> - * information per blkcg - q pair.
> - *
> - * There can be multiple active blkcg policies and each has its private
> - * data on each blkg, the size of which is determined by
> - * blkcg_policy->pd_size.  blkcg core allocates and frees such areas
> - * together with blkg and invokes pd_init/exit_fn() methods.
> - *
> - * Such private data must embed struct blkg_policy_data (pd) at the
> - * beginning and pd_size can't be smaller than pd.
> - */
> -struct blkg_policy_data {
> -	/* the blkg and policy id this per-policy data belongs to */
> -	struct blkcg_gq			*blkg;
> -	int				plid;
> -
> -	/* used during policy activation */
> -	struct list_head		alloc_node;
> -};
> -
> -/* association between a blk cgroup and a request queue */
> -struct blkcg_gq {
> -	/* Pointer to the associated request_queue */
> -	struct request_queue		*q;
> -	struct list_head		q_node;
> -	struct hlist_node		blkcg_node;
> -	struct blkcg			*blkcg;
> -
> -	/* all non-root blkcg_gq's are guaranteed to have access to parent */
> -	struct blkcg_gq			*parent;
> -
> -	/* request allocation list for this blkcg-q pair */
> -	struct request_list		rl;
> -
> -	/* reference count */
> -	atomic_t			refcnt;
> -
> -	/* is this blkg online? protected by both blkcg and q locks */
> -	bool				online;
> -
> -	struct blkg_policy_data		*pd[BLKCG_MAX_POLS];
> -
> -	struct rcu_head			rcu_head;
> -};
> -
> -typedef void (blkcg_pol_init_pd_fn)(struct blkcg_gq *blkg);
> -typedef void (blkcg_pol_online_pd_fn)(struct blkcg_gq *blkg);
> -typedef void (blkcg_pol_offline_pd_fn)(struct blkcg_gq *blkg);
> -typedef void (blkcg_pol_exit_pd_fn)(struct blkcg_gq *blkg);
> -typedef void (blkcg_pol_reset_pd_stats_fn)(struct blkcg_gq *blkg);
> -
> -struct blkcg_policy {
> -	int				plid;
> -	/* policy specific private data size */
> -	size_t				pd_size;
> -	/* cgroup files for the policy */
> -	struct cftype			*cftypes;
> -
> -	/* operations */
> -	blkcg_pol_init_pd_fn		*pd_init_fn;
> -	blkcg_pol_online_pd_fn		*pd_online_fn;
> -	blkcg_pol_offline_pd_fn		*pd_offline_fn;
> -	blkcg_pol_exit_pd_fn		*pd_exit_fn;
> -	blkcg_pol_reset_pd_stats_fn	*pd_reset_stats_fn;
> -};
> -
> -extern struct blkcg blkcg_root;
> -
> -struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, struct request_queue *q);
> -struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,
> -				    struct request_queue *q);
> -int blkcg_init_queue(struct request_queue *q);
> -void blkcg_drain_queue(struct request_queue *q);
> -void blkcg_exit_queue(struct request_queue *q);
> -
> -/* Blkio controller policy registration */
> -int blkcg_policy_register(struct blkcg_policy *pol);
> -void blkcg_policy_unregister(struct blkcg_policy *pol);
> -int blkcg_activate_policy(struct request_queue *q,
> -			  const struct blkcg_policy *pol);
> -void blkcg_deactivate_policy(struct request_queue *q,
> -			     const struct blkcg_policy *pol);
> -
> -void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,
> -		       u64 (*prfill)(struct seq_file *,
> -				     struct blkg_policy_data *, int),
> -		       const struct blkcg_policy *pol, int data,
> -		       bool show_total);
> -u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v);
> -u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
> -			 const struct blkg_rwstat *rwstat);
> -u64 blkg_prfill_stat(struct seq_file *sf, struct blkg_policy_data *pd, int off);
> -u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
> -		       int off);
> -
> -u64 blkg_stat_recursive_sum(struct blkg_policy_data *pd, int off);
> -struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkg_policy_data *pd,
> -					     int off);
> -
> -struct blkg_conf_ctx {
> -	struct gendisk			*disk;
> -	struct blkcg_gq			*blkg;
> -	u64				v;
> -};
> -
> -int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
> -		   const char *input, struct blkg_conf_ctx *ctx);
> -void blkg_conf_finish(struct blkg_conf_ctx *ctx);
> -
> -
> -static inline struct blkcg *css_to_blkcg(struct cgroup_subsys_state *css)
> -{
> -	return css ? container_of(css, struct blkcg, css) : NULL;
> -}
> -
> -static inline struct blkcg *task_blkcg(struct task_struct *tsk)
> -{
> -	return css_to_blkcg(task_css(tsk, blkio_cgrp_id));
> -}
> -
> -static inline struct blkcg *bio_blkcg(struct bio *bio)
> -{
> -	if (bio && bio->bi_css)
> -		return css_to_blkcg(bio->bi_css);
> -	return task_blkcg(current);
> -}
> -
> -/**
> - * blkcg_parent - get the parent of a blkcg
> - * @blkcg: blkcg of interest
> - *
> - * Return the parent blkcg of @blkcg.  Can be called anytime.
> - */
> -static inline struct blkcg *blkcg_parent(struct blkcg *blkcg)
> -{
> -	return css_to_blkcg(blkcg->css.parent);
> -}
> -
> -/**
> - * blkg_to_pdata - get policy private data
> - * @blkg: blkg of interest
> - * @pol: policy of interest
> - *
> - * Return pointer to private data associated with the @blkg-@pol pair.
> - */
> -static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
> -						  struct blkcg_policy *pol)
> -{
> -	return blkg ? blkg->pd[pol->plid] : NULL;
> -}
> -
> -/**
> - * pdata_to_blkg - get blkg associated with policy private data
> - * @pd: policy private data of interest
> - *
> - * @pd is policy private data.  Determine the blkg it's associated with.
> - */
> -static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd)
> -{
> -	return pd ? pd->blkg : NULL;
> -}
> -
> -/**
> - * blkg_path - format cgroup path of blkg
> - * @blkg: blkg of interest
> - * @buf: target buffer
> - * @buflen: target buffer length
> - *
> - * Format the path of the cgroup of @blkg into @buf.
> - */
> -static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen)
> -{
> -	char *p;
> -
> -	p = cgroup_path(blkg->blkcg->css.cgroup, buf, buflen);
> -	if (!p) {
> -		strncpy(buf, "<unavailable>", buflen);
> -		return -ENAMETOOLONG;
> -	}
> -
> -	memmove(buf, p, buf + buflen - p);
> -	return 0;
> -}
> -
> -/**
> - * blkg_get - get a blkg reference
> - * @blkg: blkg to get
> - *
> - * The caller should be holding an existing reference.
> - */
> -static inline void blkg_get(struct blkcg_gq *blkg)
> -{
> -	WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
> -	atomic_inc(&blkg->refcnt);
> -}
> -
> -void __blkg_release_rcu(struct rcu_head *rcu);
> -
> -/**
> - * blkg_put - put a blkg reference
> - * @blkg: blkg to put
> - */
> -static inline void blkg_put(struct blkcg_gq *blkg)
> -{
> -	WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
> -	if (atomic_dec_and_test(&blkg->refcnt))
> -		call_rcu(&blkg->rcu_head, __blkg_release_rcu);
> -}
> -
> -struct blkcg_gq *__blkg_lookup(struct blkcg *blkcg, struct request_queue *q,
> -			       bool update_hint);
> -
> -/**
> - * blkg_for_each_descendant_pre - pre-order walk of a blkg's descendants
> - * @d_blkg: loop cursor pointing to the current descendant
> - * @pos_css: used for iteration
> - * @p_blkg: target blkg to walk descendants of
> - *
> - * Walk @c_blkg through the descendants of @p_blkg.  Must be used with RCU
> - * read locked.  If called under either blkcg or queue lock, the iteration
> - * is guaranteed to include all and only online blkgs.  The caller may
> - * update @pos_css by calling css_rightmost_descendant() to skip subtree.
> - * @p_blkg is included in the iteration and the first node to be visited.
> - */
> -#define blkg_for_each_descendant_pre(d_blkg, pos_css, p_blkg)		\
> -	css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css)	\
> -		if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css),	\
> -					      (p_blkg)->q, false)))
> -
> -/**
> - * blkg_for_each_descendant_post - post-order walk of a blkg's descendants
> - * @d_blkg: loop cursor pointing to the current descendant
> - * @pos_css: used for iteration
> - * @p_blkg: target blkg to walk descendants of
> - *
> - * Similar to blkg_for_each_descendant_pre() but performs post-order
> - * traversal instead.  Synchronization rules are the same.  @p_blkg is
> - * included in the iteration and the last node to be visited.
> - */
> -#define blkg_for_each_descendant_post(d_blkg, pos_css, p_blkg)		\
> -	css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css)	\
> -		if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css),	\
> -					      (p_blkg)->q, false)))
> -
> -/**
> - * blk_get_rl - get request_list to use
> - * @q: request_queue of interest
> - * @bio: bio which will be attached to the allocated request (may be %NULL)
> - *
> - * The caller wants to allocate a request from @q to use for @bio.  Find
> - * the request_list to use and obtain a reference on it.  Should be called
> - * under queue_lock.  This function is guaranteed to return non-%NULL
> - * request_list.
> - */
> -static inline struct request_list *blk_get_rl(struct request_queue *q,
> -					      struct bio *bio)
> -{
> -	struct blkcg *blkcg;
> -	struct blkcg_gq *blkg;
> -
> -	rcu_read_lock();
> -
> -	blkcg = bio_blkcg(bio);
> -
> -	/* bypass blkg lookup and use @q->root_rl directly for root */
> -	if (blkcg == &blkcg_root)
> -		goto root_rl;
> -
> -	/*
> -	 * Try to use blkg->rl.  blkg lookup may fail under memory pressure
> -	 * or if either the blkcg or queue is going away.  Fall back to
> -	 * root_rl in such cases.
> -	 */
> -	blkg = blkg_lookup_create(blkcg, q);
> -	if (unlikely(IS_ERR(blkg)))
> -		goto root_rl;
> -
> -	blkg_get(blkg);
> -	rcu_read_unlock();
> -	return &blkg->rl;
> -root_rl:
> -	rcu_read_unlock();
> -	return &q->root_rl;
> -}
> -
> -/**
> - * blk_put_rl - put request_list
> - * @rl: request_list to put
> - *
> - * Put the reference acquired by blk_get_rl().  Should be called under
> - * queue_lock.
> - */
> -static inline void blk_put_rl(struct request_list *rl)
> -{
> -	/* root_rl may not have blkg set */
> -	if (rl->blkg && rl->blkg->blkcg != &blkcg_root)
> -		blkg_put(rl->blkg);
> -}
> -
> -/**
> - * blk_rq_set_rl - associate a request with a request_list
> - * @rq: request of interest
> - * @rl: target request_list
> - *
> - * Associate @rq with @rl so that accounting and freeing can know the
> - * request_list @rq came from.
> - */
> -static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl)
> -{
> -	rq->rl = rl;
> -}
> -
> -/**
> - * blk_rq_rl - return the request_list a request came from
> - * @rq: request of interest
> - *
> - * Return the request_list @rq is allocated from.
> - */
> -static inline struct request_list *blk_rq_rl(struct request *rq)
> -{
> -	return rq->rl;
> -}
> -
> -struct request_list *__blk_queue_next_rl(struct request_list *rl,
> -					 struct request_queue *q);
> -/**
> - * blk_queue_for_each_rl - iterate through all request_lists of a request_queue
> - *
> - * Should be used under queue_lock.
> - */
> -#define blk_queue_for_each_rl(rl, q)	\
> -	for ((rl) = &(q)->root_rl; (rl); (rl) = __blk_queue_next_rl((rl), (q)))
> -
> -static inline void blkg_stat_init(struct blkg_stat *stat)
> -{
> -	u64_stats_init(&stat->syncp);
> -}
> -
> -/**
> - * blkg_stat_add - add a value to a blkg_stat
> - * @stat: target blkg_stat
> - * @val: value to add
> - *
> - * Add @val to @stat.  The caller is responsible for synchronizing calls to
> - * this function.
> - */
> -static inline void blkg_stat_add(struct blkg_stat *stat, uint64_t val)
> -{
> -	u64_stats_update_begin(&stat->syncp);
> -	stat->cnt += val;
> -	u64_stats_update_end(&stat->syncp);
> -}
> -
> -/**
> - * blkg_stat_read - read the current value of a blkg_stat
> - * @stat: blkg_stat to read
> - *
> - * Read the current value of @stat.  This function can be called without
> - * synchroniztion and takes care of u64 atomicity.
> - */
> -static inline uint64_t blkg_stat_read(struct blkg_stat *stat)
> -{
> -	unsigned int start;
> -	uint64_t v;
> -
> -	do {
> -		start = u64_stats_fetch_begin_irq(&stat->syncp);
> -		v = stat->cnt;
> -	} while (u64_stats_fetch_retry_irq(&stat->syncp, start));
> -
> -	return v;
> -}
> -
> -/**
> - * blkg_stat_reset - reset a blkg_stat
> - * @stat: blkg_stat to reset
> - */
> -static inline void blkg_stat_reset(struct blkg_stat *stat)
> -{
> -	stat->cnt = 0;
> -}
> -
> -/**
> - * blkg_stat_merge - merge a blkg_stat into another
> - * @to: the destination blkg_stat
> - * @from: the source
> - *
> - * Add @from's count to @to.
> - */
> -static inline void blkg_stat_merge(struct blkg_stat *to, struct blkg_stat *from)
> -{
> -	blkg_stat_add(to, blkg_stat_read(from));
> -}
> -
> -static inline void blkg_rwstat_init(struct blkg_rwstat *rwstat)
> -{
> -	u64_stats_init(&rwstat->syncp);
> -}
> -
> -/**
> - * blkg_rwstat_add - add a value to a blkg_rwstat
> - * @rwstat: target blkg_rwstat
> - * @rw: mask of REQ_{WRITE|SYNC}
> - * @val: value to add
> - *
> - * Add @val to @rwstat.  The counters are chosen according to @rw.  The
> - * caller is responsible for synchronizing calls to this function.
> - */
> -static inline void blkg_rwstat_add(struct blkg_rwstat *rwstat,
> -				   int rw, uint64_t val)
> -{
> -	u64_stats_update_begin(&rwstat->syncp);
> -
> -	if (rw & REQ_WRITE)
> -		rwstat->cnt[BLKG_RWSTAT_WRITE] += val;
> -	else
> -		rwstat->cnt[BLKG_RWSTAT_READ] += val;
> -	if (rw & REQ_SYNC)
> -		rwstat->cnt[BLKG_RWSTAT_SYNC] += val;
> -	else
> -		rwstat->cnt[BLKG_RWSTAT_ASYNC] += val;
> -
> -	u64_stats_update_end(&rwstat->syncp);
> -}
> -
> -/**
> - * blkg_rwstat_read - read the current values of a blkg_rwstat
> - * @rwstat: blkg_rwstat to read
> - *
> - * Read the current snapshot of @rwstat and return it as the return value.
> - * This function can be called without synchronization and takes care of
> - * u64 atomicity.
> - */
> -static inline struct blkg_rwstat blkg_rwstat_read(struct blkg_rwstat *rwstat)
> -{
> -	unsigned int start;
> -	struct blkg_rwstat tmp;
> -
> -	do {
> -		start = u64_stats_fetch_begin_irq(&rwstat->syncp);
> -		tmp = *rwstat;
> -	} while (u64_stats_fetch_retry_irq(&rwstat->syncp, start));
> -
> -	return tmp;
> -}
> -
> -/**
> - * blkg_rwstat_total - read the total count of a blkg_rwstat
> - * @rwstat: blkg_rwstat to read
> - *
> - * Return the total count of @rwstat regardless of the IO direction.  This
> - * function can be called without synchronization and takes care of u64
> - * atomicity.
> - */
> -static inline uint64_t blkg_rwstat_total(struct blkg_rwstat *rwstat)
> -{
> -	struct blkg_rwstat tmp = blkg_rwstat_read(rwstat);
> -
> -	return tmp.cnt[BLKG_RWSTAT_READ] + tmp.cnt[BLKG_RWSTAT_WRITE];
> -}
> -
> -/**
> - * blkg_rwstat_reset - reset a blkg_rwstat
> - * @rwstat: blkg_rwstat to reset
> - */
> -static inline void blkg_rwstat_reset(struct blkg_rwstat *rwstat)
> -{
> -	memset(rwstat->cnt, 0, sizeof(rwstat->cnt));
> -}
> -
> -/**
> - * blkg_rwstat_merge - merge a blkg_rwstat into another
> - * @to: the destination blkg_rwstat
> - * @from: the source
> - *
> - * Add @from's counts to @to.
> - */
> -static inline void blkg_rwstat_merge(struct blkg_rwstat *to,
> -				     struct blkg_rwstat *from)
> -{
> -	struct blkg_rwstat v = blkg_rwstat_read(from);
> -	int i;
> -
> -	u64_stats_update_begin(&to->syncp);
> -	for (i = 0; i < BLKG_RWSTAT_NR; i++)
> -		to->cnt[i] += v.cnt[i];
> -	u64_stats_update_end(&to->syncp);
> -}
> -
> -#else	/* CONFIG_BLK_CGROUP */
> -
> -struct cgroup;
> -struct blkcg;
> -
> -struct blkg_policy_data {
> -};
> -
> -struct blkcg_gq {
> -};
> -
> -struct blkcg_policy {
> -};
> -
> -static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, void *key) { return NULL; }
> -static inline int blkcg_init_queue(struct request_queue *q) { return 0; }
> -static inline void blkcg_drain_queue(struct request_queue *q) { }
> -static inline void blkcg_exit_queue(struct request_queue *q) { }
> -static inline int blkcg_policy_register(struct blkcg_policy *pol) { return 0; }
> -static inline void blkcg_policy_unregister(struct blkcg_policy *pol) { }
> -static inline int blkcg_activate_policy(struct request_queue *q,
> -					const struct blkcg_policy *pol) { return 0; }
> -static inline void blkcg_deactivate_policy(struct request_queue *q,
> -					   const struct blkcg_policy *pol) { }
> -
> -static inline struct blkcg *bio_blkcg(struct bio *bio) { return NULL; }
> -
> -static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
> -						  struct blkcg_policy *pol) { return NULL; }
> -static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd) { return NULL; }
> -static inline char *blkg_path(struct blkcg_gq *blkg) { return NULL; }
> -static inline void blkg_get(struct blkcg_gq *blkg) { }
> -static inline void blkg_put(struct blkcg_gq *blkg) { }
> -
> -static inline struct request_list *blk_get_rl(struct request_queue *q,
> -					      struct bio *bio) { return &q->root_rl; }
> -static inline void blk_put_rl(struct request_list *rl) { }
> -static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl) { }
> -static inline struct request_list *blk_rq_rl(struct request *rq) { return &rq->q->root_rl; }
> -
> -#define blk_queue_for_each_rl(rl, q)	\
> -	for ((rl) = &(q)->root_rl; (rl); (rl) = NULL)
> -
> -#endif	/* CONFIG_BLK_CGROUP */
> -#endif	/* _BLK_CGROUP_H */
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -32,12 +32,12 @@
>  #include <linux/delay.h>
>  #include <linux/ratelimit.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/blk-cgroup.h>
>  
>  #define CREATE_TRACE_POINTS
>  #include <trace/events/block.h>
>  
>  #include "blk.h"
> -#include "blk-cgroup.h"
>  #include "blk-mq.h"
>  
>  EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_remap);
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -8,9 +8,9 @@
>  #include <linux/blkdev.h>
>  #include <linux/blktrace_api.h>
>  #include <linux/blk-mq.h>
> +#include <linux/blk-cgroup.h>
>  
>  #include "blk.h"
> -#include "blk-cgroup.h"
>  #include "blk-mq.h"
>  
>  struct queue_sysfs_entry {
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -9,7 +9,7 @@
>  #include <linux/blkdev.h>
>  #include <linux/bio.h>
>  #include <linux/blktrace_api.h>
> -#include "blk-cgroup.h"
> +#include <linux/blk-cgroup.h>
>  #include "blk.h"
>  
>  /* Max dispatch from a group in 1 round */
> --- a/block/cfq-iosched.c
> +++ b/block/cfq-iosched.c
> @@ -14,8 +14,8 @@
>  #include <linux/rbtree.h>
>  #include <linux/ioprio.h>
>  #include <linux/blktrace_api.h>
> +#include <linux/blk-cgroup.h>
>  #include "blk.h"
> -#include "blk-cgroup.h"
>  
>  /*
>   * tunables
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -35,11 +35,11 @@
>  #include <linux/hash.h>
>  #include <linux/uaccess.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/blk-cgroup.h>
>  
>  #include <trace/events/block.h>
>  
>  #include "blk.h"
> -#include "blk-cgroup.h"
>  
>  static DEFINE_SPINLOCK(elv_list_lock);
>  static LIST_HEAD(elv_list);
> --- /dev/null
> +++ b/include/linux/blk-cgroup.h
> @@ -0,0 +1,603 @@
> +#ifndef _BLK_CGROUP_H
> +#define _BLK_CGROUP_H
> +/*
> + * Common Block IO controller cgroup interface
> + *
> + * Based on ideas and code from CFQ, CFS and BFQ:
> + * Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
> + *
> + * Copyright (C) 2008 Fabio Checconi <fabio@gandalf.sssup.it>
> + *		      Paolo Valente <paolo.valente@unimore.it>
> + *
> + * Copyright (C) 2009 Vivek Goyal <vgoyal@redhat.com>
> + * 	              Nauman Rafique <nauman@google.com>
> + */
> +
> +#include <linux/cgroup.h>
> +#include <linux/u64_stats_sync.h>
> +#include <linux/seq_file.h>
> +#include <linux/radix-tree.h>
> +#include <linux/blkdev.h>
> +#include <linux/atomic.h>
> +
> +/* Max limits for throttle policy */
> +#define THROTL_IOPS_MAX		UINT_MAX
> +
> +/* CFQ specific, out here for blkcg->cfq_weight */
> +#define CFQ_WEIGHT_MIN		10
> +#define CFQ_WEIGHT_MAX		1000
> +#define CFQ_WEIGHT_DEFAULT	500
> +
> +#ifdef CONFIG_BLK_CGROUP
> +
> +enum blkg_rwstat_type {
> +	BLKG_RWSTAT_READ,
> +	BLKG_RWSTAT_WRITE,
> +	BLKG_RWSTAT_SYNC,
> +	BLKG_RWSTAT_ASYNC,
> +
> +	BLKG_RWSTAT_NR,
> +	BLKG_RWSTAT_TOTAL = BLKG_RWSTAT_NR,
> +};
> +
> +struct blkcg_gq;
> +
> +struct blkcg {
> +	struct cgroup_subsys_state	css;
> +	spinlock_t			lock;
> +
> +	struct radix_tree_root		blkg_tree;
> +	struct blkcg_gq			*blkg_hint;
> +	struct hlist_head		blkg_list;
> +
> +	/* TODO: per-policy storage in blkcg */
> +	unsigned int			cfq_weight;	/* belongs to cfq */
> +	unsigned int			cfq_leaf_weight;
> +};
> +
> +struct blkg_stat {
> +	struct u64_stats_sync		syncp;
> +	uint64_t			cnt;
> +};
> +
> +struct blkg_rwstat {
> +	struct u64_stats_sync		syncp;
> +	uint64_t			cnt[BLKG_RWSTAT_NR];
> +};
> +
> +/*
> + * A blkcg_gq (blkg) is association between a block cgroup (blkcg) and a
> + * request_queue (q).  This is used by blkcg policies which need to track
> + * information per blkcg - q pair.
> + *
> + * There can be multiple active blkcg policies and each has its private
> + * data on each blkg, the size of which is determined by
> + * blkcg_policy->pd_size.  blkcg core allocates and frees such areas
> + * together with blkg and invokes pd_init/exit_fn() methods.
> + *
> + * Such private data must embed struct blkg_policy_data (pd) at the
> + * beginning and pd_size can't be smaller than pd.
> + */
> +struct blkg_policy_data {
> +	/* the blkg and policy id this per-policy data belongs to */
> +	struct blkcg_gq			*blkg;
> +	int				plid;
> +
> +	/* used during policy activation */
> +	struct list_head		alloc_node;
> +};
> +
> +/* association between a blk cgroup and a request queue */
> +struct blkcg_gq {
> +	/* Pointer to the associated request_queue */
> +	struct request_queue		*q;
> +	struct list_head		q_node;
> +	struct hlist_node		blkcg_node;
> +	struct blkcg			*blkcg;
> +
> +	/* all non-root blkcg_gq's are guaranteed to have access to parent */
> +	struct blkcg_gq			*parent;
> +
> +	/* request allocation list for this blkcg-q pair */
> +	struct request_list		rl;
> +
> +	/* reference count */
> +	atomic_t			refcnt;
> +
> +	/* is this blkg online? protected by both blkcg and q locks */
> +	bool				online;
> +
> +	struct blkg_policy_data		*pd[BLKCG_MAX_POLS];
> +
> +	struct rcu_head			rcu_head;
> +};
> +
> +typedef void (blkcg_pol_init_pd_fn)(struct blkcg_gq *blkg);
> +typedef void (blkcg_pol_online_pd_fn)(struct blkcg_gq *blkg);
> +typedef void (blkcg_pol_offline_pd_fn)(struct blkcg_gq *blkg);
> +typedef void (blkcg_pol_exit_pd_fn)(struct blkcg_gq *blkg);
> +typedef void (blkcg_pol_reset_pd_stats_fn)(struct blkcg_gq *blkg);
> +
> +struct blkcg_policy {
> +	int				plid;
> +	/* policy specific private data size */
> +	size_t				pd_size;
> +	/* cgroup files for the policy */
> +	struct cftype			*cftypes;
> +
> +	/* operations */
> +	blkcg_pol_init_pd_fn		*pd_init_fn;
> +	blkcg_pol_online_pd_fn		*pd_online_fn;
> +	blkcg_pol_offline_pd_fn		*pd_offline_fn;
> +	blkcg_pol_exit_pd_fn		*pd_exit_fn;
> +	blkcg_pol_reset_pd_stats_fn	*pd_reset_stats_fn;
> +};
> +
> +extern struct blkcg blkcg_root;
> +
> +struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, struct request_queue *q);
> +struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,
> +				    struct request_queue *q);
> +int blkcg_init_queue(struct request_queue *q);
> +void blkcg_drain_queue(struct request_queue *q);
> +void blkcg_exit_queue(struct request_queue *q);
> +
> +/* Blkio controller policy registration */
> +int blkcg_policy_register(struct blkcg_policy *pol);
> +void blkcg_policy_unregister(struct blkcg_policy *pol);
> +int blkcg_activate_policy(struct request_queue *q,
> +			  const struct blkcg_policy *pol);
> +void blkcg_deactivate_policy(struct request_queue *q,
> +			     const struct blkcg_policy *pol);
> +
> +void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,
> +		       u64 (*prfill)(struct seq_file *,
> +				     struct blkg_policy_data *, int),
> +		       const struct blkcg_policy *pol, int data,
> +		       bool show_total);
> +u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v);
> +u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
> +			 const struct blkg_rwstat *rwstat);
> +u64 blkg_prfill_stat(struct seq_file *sf, struct blkg_policy_data *pd, int off);
> +u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
> +		       int off);
> +
> +u64 blkg_stat_recursive_sum(struct blkg_policy_data *pd, int off);
> +struct blkg_rwstat blkg_rwstat_recursive_sum(struct blkg_policy_data *pd,
> +					     int off);
> +
> +struct blkg_conf_ctx {
> +	struct gendisk			*disk;
> +	struct blkcg_gq			*blkg;
> +	u64				v;
> +};
> +
> +int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
> +		   const char *input, struct blkg_conf_ctx *ctx);
> +void blkg_conf_finish(struct blkg_conf_ctx *ctx);
> +
> +
> +static inline struct blkcg *css_to_blkcg(struct cgroup_subsys_state *css)
> +{
> +	return css ? container_of(css, struct blkcg, css) : NULL;
> +}
> +
> +static inline struct blkcg *task_blkcg(struct task_struct *tsk)
> +{
> +	return css_to_blkcg(task_css(tsk, blkio_cgrp_id));
> +}
> +
> +static inline struct blkcg *bio_blkcg(struct bio *bio)
> +{
> +	if (bio && bio->bi_css)
> +		return css_to_blkcg(bio->bi_css);
> +	return task_blkcg(current);
> +}
> +
> +/**
> + * blkcg_parent - get the parent of a blkcg
> + * @blkcg: blkcg of interest
> + *
> + * Return the parent blkcg of @blkcg.  Can be called anytime.
> + */
> +static inline struct blkcg *blkcg_parent(struct blkcg *blkcg)
> +{
> +	return css_to_blkcg(blkcg->css.parent);
> +}
> +
> +/**
> + * blkg_to_pdata - get policy private data
> + * @blkg: blkg of interest
> + * @pol: policy of interest
> + *
> + * Return pointer to private data associated with the @blkg-@pol pair.
> + */
> +static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
> +						  struct blkcg_policy *pol)
> +{
> +	return blkg ? blkg->pd[pol->plid] : NULL;
> +}
> +
> +/**
> + * pdata_to_blkg - get blkg associated with policy private data
> + * @pd: policy private data of interest
> + *
> + * @pd is policy private data.  Determine the blkg it's associated with.
> + */
> +static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd)
> +{
> +	return pd ? pd->blkg : NULL;
> +}
> +
> +/**
> + * blkg_path - format cgroup path of blkg
> + * @blkg: blkg of interest
> + * @buf: target buffer
> + * @buflen: target buffer length
> + *
> + * Format the path of the cgroup of @blkg into @buf.
> + */
> +static inline int blkg_path(struct blkcg_gq *blkg, char *buf, int buflen)
> +{
> +	char *p;
> +
> +	p = cgroup_path(blkg->blkcg->css.cgroup, buf, buflen);
> +	if (!p) {
> +		strncpy(buf, "<unavailable>", buflen);
> +		return -ENAMETOOLONG;
> +	}
> +
> +	memmove(buf, p, buf + buflen - p);
> +	return 0;
> +}
> +
> +/**
> + * blkg_get - get a blkg reference
> + * @blkg: blkg to get
> + *
> + * The caller should be holding an existing reference.
> + */
> +static inline void blkg_get(struct blkcg_gq *blkg)
> +{
> +	WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
> +	atomic_inc(&blkg->refcnt);
> +}
> +
> +void __blkg_release_rcu(struct rcu_head *rcu);
> +
> +/**
> + * blkg_put - put a blkg reference
> + * @blkg: blkg to put
> + */
> +static inline void blkg_put(struct blkcg_gq *blkg)
> +{
> +	WARN_ON_ONCE(atomic_read(&blkg->refcnt) <= 0);
> +	if (atomic_dec_and_test(&blkg->refcnt))
> +		call_rcu(&blkg->rcu_head, __blkg_release_rcu);
> +}
> +
> +struct blkcg_gq *__blkg_lookup(struct blkcg *blkcg, struct request_queue *q,
> +			       bool update_hint);
> +
> +/**
> + * blkg_for_each_descendant_pre - pre-order walk of a blkg's descendants
> + * @d_blkg: loop cursor pointing to the current descendant
> + * @pos_css: used for iteration
> + * @p_blkg: target blkg to walk descendants of
> + *
> + * Walk @c_blkg through the descendants of @p_blkg.  Must be used with RCU
> + * read locked.  If called under either blkcg or queue lock, the iteration
> + * is guaranteed to include all and only online blkgs.  The caller may
> + * update @pos_css by calling css_rightmost_descendant() to skip subtree.
> + * @p_blkg is included in the iteration and the first node to be visited.
> + */
> +#define blkg_for_each_descendant_pre(d_blkg, pos_css, p_blkg)		\
> +	css_for_each_descendant_pre((pos_css), &(p_blkg)->blkcg->css)	\
> +		if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css),	\
> +					      (p_blkg)->q, false)))
> +
> +/**
> + * blkg_for_each_descendant_post - post-order walk of a blkg's descendants
> + * @d_blkg: loop cursor pointing to the current descendant
> + * @pos_css: used for iteration
> + * @p_blkg: target blkg to walk descendants of
> + *
> + * Similar to blkg_for_each_descendant_pre() but performs post-order
> + * traversal instead.  Synchronization rules are the same.  @p_blkg is
> + * included in the iteration and the last node to be visited.
> + */
> +#define blkg_for_each_descendant_post(d_blkg, pos_css, p_blkg)		\
> +	css_for_each_descendant_post((pos_css), &(p_blkg)->blkcg->css)	\
> +		if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css),	\
> +					      (p_blkg)->q, false)))
> +
> +/**
> + * blk_get_rl - get request_list to use
> + * @q: request_queue of interest
> + * @bio: bio which will be attached to the allocated request (may be %NULL)
> + *
> + * The caller wants to allocate a request from @q to use for @bio.  Find
> + * the request_list to use and obtain a reference on it.  Should be called
> + * under queue_lock.  This function is guaranteed to return non-%NULL
> + * request_list.
> + */
> +static inline struct request_list *blk_get_rl(struct request_queue *q,
> +					      struct bio *bio)
> +{
> +	struct blkcg *blkcg;
> +	struct blkcg_gq *blkg;
> +
> +	rcu_read_lock();
> +
> +	blkcg = bio_blkcg(bio);
> +
> +	/* bypass blkg lookup and use @q->root_rl directly for root */
> +	if (blkcg == &blkcg_root)
> +		goto root_rl;
> +
> +	/*
> +	 * Try to use blkg->rl.  blkg lookup may fail under memory pressure
> +	 * or if either the blkcg or queue is going away.  Fall back to
> +	 * root_rl in such cases.
> +	 */
> +	blkg = blkg_lookup_create(blkcg, q);
> +	if (unlikely(IS_ERR(blkg)))
> +		goto root_rl;
> +
> +	blkg_get(blkg);
> +	rcu_read_unlock();
> +	return &blkg->rl;
> +root_rl:
> +	rcu_read_unlock();
> +	return &q->root_rl;
> +}
> +
> +/**
> + * blk_put_rl - put request_list
> + * @rl: request_list to put
> + *
> + * Put the reference acquired by blk_get_rl().  Should be called under
> + * queue_lock.
> + */
> +static inline void blk_put_rl(struct request_list *rl)
> +{
> +	/* root_rl may not have blkg set */
> +	if (rl->blkg && rl->blkg->blkcg != &blkcg_root)
> +		blkg_put(rl->blkg);
> +}
> +
> +/**
> + * blk_rq_set_rl - associate a request with a request_list
> + * @rq: request of interest
> + * @rl: target request_list
> + *
> + * Associate @rq with @rl so that accounting and freeing can know the
> + * request_list @rq came from.
> + */
> +static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl)
> +{
> +	rq->rl = rl;
> +}
> +
> +/**
> + * blk_rq_rl - return the request_list a request came from
> + * @rq: request of interest
> + *
> + * Return the request_list @rq is allocated from.
> + */
> +static inline struct request_list *blk_rq_rl(struct request *rq)
> +{
> +	return rq->rl;
> +}
> +
> +struct request_list *__blk_queue_next_rl(struct request_list *rl,
> +					 struct request_queue *q);
> +/**
> + * blk_queue_for_each_rl - iterate through all request_lists of a request_queue
> + *
> + * Should be used under queue_lock.
> + */
> +#define blk_queue_for_each_rl(rl, q)	\
> +	for ((rl) = &(q)->root_rl; (rl); (rl) = __blk_queue_next_rl((rl), (q)))
> +
> +static inline void blkg_stat_init(struct blkg_stat *stat)
> +{
> +	u64_stats_init(&stat->syncp);
> +}
> +
> +/**
> + * blkg_stat_add - add a value to a blkg_stat
> + * @stat: target blkg_stat
> + * @val: value to add
> + *
> + * Add @val to @stat.  The caller is responsible for synchronizing calls to
> + * this function.
> + */
> +static inline void blkg_stat_add(struct blkg_stat *stat, uint64_t val)
> +{
> +	u64_stats_update_begin(&stat->syncp);
> +	stat->cnt += val;
> +	u64_stats_update_end(&stat->syncp);
> +}
> +
> +/**
> + * blkg_stat_read - read the current value of a blkg_stat
> + * @stat: blkg_stat to read
> + *
> + * Read the current value of @stat.  This function can be called without
> + * synchroniztion and takes care of u64 atomicity.
> + */
> +static inline uint64_t blkg_stat_read(struct blkg_stat *stat)
> +{
> +	unsigned int start;
> +	uint64_t v;
> +
> +	do {
> +		start = u64_stats_fetch_begin_irq(&stat->syncp);
> +		v = stat->cnt;
> +	} while (u64_stats_fetch_retry_irq(&stat->syncp, start));
> +
> +	return v;
> +}
> +
> +/**
> + * blkg_stat_reset - reset a blkg_stat
> + * @stat: blkg_stat to reset
> + */
> +static inline void blkg_stat_reset(struct blkg_stat *stat)
> +{
> +	stat->cnt = 0;
> +}
> +
> +/**
> + * blkg_stat_merge - merge a blkg_stat into another
> + * @to: the destination blkg_stat
> + * @from: the source
> + *
> + * Add @from's count to @to.
> + */
> +static inline void blkg_stat_merge(struct blkg_stat *to, struct blkg_stat *from)
> +{
> +	blkg_stat_add(to, blkg_stat_read(from));
> +}
> +
> +static inline void blkg_rwstat_init(struct blkg_rwstat *rwstat)
> +{
> +	u64_stats_init(&rwstat->syncp);
> +}
> +
> +/**
> + * blkg_rwstat_add - add a value to a blkg_rwstat
> + * @rwstat: target blkg_rwstat
> + * @rw: mask of REQ_{WRITE|SYNC}
> + * @val: value to add
> + *
> + * Add @val to @rwstat.  The counters are chosen according to @rw.  The
> + * caller is responsible for synchronizing calls to this function.
> + */
> +static inline void blkg_rwstat_add(struct blkg_rwstat *rwstat,
> +				   int rw, uint64_t val)
> +{
> +	u64_stats_update_begin(&rwstat->syncp);
> +
> +	if (rw & REQ_WRITE)
> +		rwstat->cnt[BLKG_RWSTAT_WRITE] += val;
> +	else
> +		rwstat->cnt[BLKG_RWSTAT_READ] += val;
> +	if (rw & REQ_SYNC)
> +		rwstat->cnt[BLKG_RWSTAT_SYNC] += val;
> +	else
> +		rwstat->cnt[BLKG_RWSTAT_ASYNC] += val;
> +
> +	u64_stats_update_end(&rwstat->syncp);
> +}
> +
> +/**
> + * blkg_rwstat_read - read the current values of a blkg_rwstat
> + * @rwstat: blkg_rwstat to read
> + *
> + * Read the current snapshot of @rwstat and return it as the return value.
> + * This function can be called without synchronization and takes care of
> + * u64 atomicity.
> + */
> +static inline struct blkg_rwstat blkg_rwstat_read(struct blkg_rwstat *rwstat)
> +{
> +	unsigned int start;
> +	struct blkg_rwstat tmp;
> +
> +	do {
> +		start = u64_stats_fetch_begin_irq(&rwstat->syncp);
> +		tmp = *rwstat;
> +	} while (u64_stats_fetch_retry_irq(&rwstat->syncp, start));
> +
> +	return tmp;
> +}
> +
> +/**
> + * blkg_rwstat_total - read the total count of a blkg_rwstat
> + * @rwstat: blkg_rwstat to read
> + *
> + * Return the total count of @rwstat regardless of the IO direction.  This
> + * function can be called without synchronization and takes care of u64
> + * atomicity.
> + */
> +static inline uint64_t blkg_rwstat_total(struct blkg_rwstat *rwstat)
> +{
> +	struct blkg_rwstat tmp = blkg_rwstat_read(rwstat);
> +
> +	return tmp.cnt[BLKG_RWSTAT_READ] + tmp.cnt[BLKG_RWSTAT_WRITE];
> +}
> +
> +/**
> + * blkg_rwstat_reset - reset a blkg_rwstat
> + * @rwstat: blkg_rwstat to reset
> + */
> +static inline void blkg_rwstat_reset(struct blkg_rwstat *rwstat)
> +{
> +	memset(rwstat->cnt, 0, sizeof(rwstat->cnt));
> +}
> +
> +/**
> + * blkg_rwstat_merge - merge a blkg_rwstat into another
> + * @to: the destination blkg_rwstat
> + * @from: the source
> + *
> + * Add @from's counts to @to.
> + */
> +static inline void blkg_rwstat_merge(struct blkg_rwstat *to,
> +				     struct blkg_rwstat *from)
> +{
> +	struct blkg_rwstat v = blkg_rwstat_read(from);
> +	int i;
> +
> +	u64_stats_update_begin(&to->syncp);
> +	for (i = 0; i < BLKG_RWSTAT_NR; i++)
> +		to->cnt[i] += v.cnt[i];
> +	u64_stats_update_end(&to->syncp);
> +}
> +
> +#else	/* CONFIG_BLK_CGROUP */
> +
> +struct cgroup;
> +struct blkcg;
> +
> +struct blkg_policy_data {
> +};
> +
> +struct blkcg_gq {
> +};
> +
> +struct blkcg_policy {
> +};
> +
> +static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, void *key) { return NULL; }
> +static inline int blkcg_init_queue(struct request_queue *q) { return 0; }
> +static inline void blkcg_drain_queue(struct request_queue *q) { }
> +static inline void blkcg_exit_queue(struct request_queue *q) { }
> +static inline int blkcg_policy_register(struct blkcg_policy *pol) { return 0; }
> +static inline void blkcg_policy_unregister(struct blkcg_policy *pol) { }
> +static inline int blkcg_activate_policy(struct request_queue *q,
> +					const struct blkcg_policy *pol) { return 0; }
> +static inline void blkcg_deactivate_policy(struct request_queue *q,
> +					   const struct blkcg_policy *pol) { }
> +
> +static inline struct blkcg *bio_blkcg(struct bio *bio) { return NULL; }
> +
> +static inline struct blkg_policy_data *blkg_to_pd(struct blkcg_gq *blkg,
> +						  struct blkcg_policy *pol) { return NULL; }
> +static inline struct blkcg_gq *pd_to_blkg(struct blkg_policy_data *pd) { return NULL; }
> +static inline char *blkg_path(struct blkcg_gq *blkg) { return NULL; }
> +static inline void blkg_get(struct blkcg_gq *blkg) { }
> +static inline void blkg_put(struct blkcg_gq *blkg) { }
> +
> +static inline struct request_list *blk_get_rl(struct request_queue *q,
> +					      struct bio *bio) { return &q->root_rl; }
> +static inline void blk_put_rl(struct request_list *rl) { }
> +static inline void blk_rq_set_rl(struct request *rq, struct request_list *rl) { }
> +static inline struct request_list *blk_rq_rl(struct request *rq) { return &rq->q->root_rl; }
> +
> +#define blk_queue_for_each_rl(rl, q)	\
> +	for ((rl) = &(q)->root_rl; (rl); (rl) = NULL)
> +
> +#endif	/* CONFIG_BLK_CGROUP */
> +#endif	/* _BLK_CGROUP_H */

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH block/for-next 2/4] blkcg: add blkcg_root_css
  2014-11-17 21:13 ` [PATCH block/for-next 2/4] blkcg: add blkcg_root_css Tejun Heo
  2014-11-17 21:15   ` [PATCH block/for-next 3/4] cgroup, block: implement task_get_css() and use it in bio_associate_current() Tejun Heo
@ 2014-11-20 20:16   ` Vivek Goyal
  2015-01-06 22:37     ` Tejun Heo
  1 sibling, 1 reply; 10+ messages in thread
From: Vivek Goyal @ 2014-11-20 20:16 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Jens Axboe, linux-kernel

On Mon, Nov 17, 2014 at 04:13:57PM -0500, Tejun Heo wrote:
[..]
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -1408,6 +1408,9 @@ int kblockd_schedule_delayed_work(struct
>  int kblockd_schedule_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay);
>  
>  #ifdef CONFIG_BLK_CGROUP
> +
> +extern struct cgroup_subsys_state * const blkcg_root_css;

Hi Tejun,

Would it make sense to keep this in include/linux/blk-cgroup.h

Thanks
Vivek

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH block/for-next 3/4] cgroup, block: implement task_get_css() and use it in bio_associate_current()
  2014-11-17 21:15   ` [PATCH block/for-next 3/4] cgroup, block: implement task_get_css() and use it in bio_associate_current() Tejun Heo
  2014-11-17 21:16     ` [PATCH block/for-next 4/4] block: implement bio_associate_blkcg() Tejun Heo
@ 2014-11-20 20:27     ` Vivek Goyal
  1 sibling, 0 replies; 10+ messages in thread
From: Vivek Goyal @ 2014-11-20 20:27 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Jens Axboe, linux-kernel, Li Zefan

On Mon, Nov 17, 2014 at 04:15:46PM -0500, Tejun Heo wrote:
> bio_associate_current() currently open codes task_css() and
> css_tryget_online() to find and pin $current's blkcg css.  Abstract it
> into task_get_css() which is implemented from cgroup side.  As a task
> is always associated with an online css for every subsystem except
> while the css_set update is propagating, task_get_css() retries till
> css_tryget_online() succeeds.
> 
> This is a cleanup and shouldn't lead to noticeable behavior changes.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Cc: Li Zefan <lizefan@huawei.com>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Vivek Goyal <vgoyal@redhat.com>

Looks good to me.

Acked-by: Vivek Goyal <vgoyal@redhat.com>

Vivek

> ---
> Hello,
> 
> This one can be routed through either cgroup or block tree but I think
> it'd be easier to route this through block as there will be more block
> changes in the area.
> 
> Thanks.
> 
>  block/bio.c            |   11 +----------
>  include/linux/cgroup.h |   25 +++++++++++++++++++++++++
>  2 files changed, 26 insertions(+), 10 deletions(-)
> 
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -1997,7 +1997,6 @@ EXPORT_SYMBOL(bioset_create_nobvec);
>  int bio_associate_current(struct bio *bio)
>  {
>  	struct io_context *ioc;
> -	struct cgroup_subsys_state *css;
>  
>  	if (bio->bi_ioc)
>  		return -EBUSY;
> @@ -2006,17 +2005,9 @@ int bio_associate_current(struct bio *bi
>  	if (!ioc)
>  		return -ENOENT;
>  
> -	/* acquire active ref on @ioc and associate */
>  	get_io_context_active(ioc);
>  	bio->bi_ioc = ioc;
> -
> -	/* associate blkcg if exists */
> -	rcu_read_lock();
> -	css = task_css(current, blkio_cgrp_id);
> -	if (css && css_tryget_online(css))
> -		bio->bi_css = css;
> -	rcu_read_unlock();
> -
> +	bio->bi_css = task_get_css(current, blkio_cgrp_id);
>  	return 0;
>  }
>  
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -748,6 +748,31 @@ static inline struct cgroup_subsys_state
>  }
>  
>  /**
> + * task_get_css - find and get the css for (task, subsys)
> + * @task: the target task
> + * @subsys_id: the target subsystem ID
> + *
> + * Find the css for the (@task, @subsys_id) combination, increment a
> + * reference on and return it.  This function is guaranteed to return a
> + * valid css.
> + */
> +static inline struct cgroup_subsys_state *
> +task_get_css(struct task_struct *task, int subsys_id)
> +{
> +	struct cgroup_subsys_state *css;
> +
> +	rcu_read_lock();
> +	while (true) {
> +		css = task_css(task, subsys_id);
> +		if (likely(css_tryget_online(css)))
> +			break;
> +		cpu_relax();
> +	}
> +	rcu_read_unlock();
> +	return css;
> +}
> +
> +/**
>   * task_css_is_root - test whether a task belongs to the root css
>   * @task: the target task
>   * @subsys_id: the target subsystem ID

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH block/for-next 4/4] block: implement bio_associate_blkcg()
  2014-11-17 21:16     ` [PATCH block/for-next 4/4] block: implement bio_associate_blkcg() Tejun Heo
@ 2014-11-20 21:15       ` Vivek Goyal
  2015-01-06 23:12         ` Tejun Heo
  0 siblings, 1 reply; 10+ messages in thread
From: Vivek Goyal @ 2014-11-20 21:15 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Jens Axboe, linux-kernel

On Mon, Nov 17, 2014 at 04:16:19PM -0500, Tejun Heo wrote:
> Currently, a bio can only be associated with the io_context and blkcg
> of %current using bio_associate_current().  This is too restrictive
> for cgroup writeback support.  Implement bio_associate_blkcg() which
> associates a bio with the specified blkcg.
> 
> bio_associate_blkcg() leaves the io_context unassociated.
> bio_associate_current() is updated so that it considers a bio as
> already associated if it has a blkcg_css, instead of an io_context,
> associated with it.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Vivek Goyal <vgoyal@redhat.com>
> ---
>  block/bio.c         |   24 +++++++++++++++++++++++-
>  include/linux/bio.h |    3 +++
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -1981,6 +1981,28 @@ struct bio_set *bioset_create_nobvec(uns
>  EXPORT_SYMBOL(bioset_create_nobvec);
>  
>  #ifdef CONFIG_BLK_CGROUP
> +
> +/**
> + * bio_associate_blkcg - associate a bio with the specified blkcg
> + * @bio: target bio
> + * @blkcg_css: the css of the blkcg to associate
> + *
> + * Associate @bio with the blkcg specified by @blkcg_css.  Block layer will
> + * treat @bio as if it were issued by a task which belongs to the blkcg.
> + *
> + * This function takes an extra reference of @blkcg_css which will be put
> + * when @bio is released.  The caller must own @bio and is responsible for
> + * synchronizing calls to this function.
> + */
> +int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css)
> +{
> +	if (unlikely(bio->bi_css))
> +		return -EBUSY;
> +	css_get(blkcg_css);
> +	bio->bi_css = blkcg_css;
> +	return 0;
> +}
> +
>  /**
>   * bio_associate_current - associate a bio with %current
>   * @bio: target bio
> @@ -1998,7 +2020,7 @@ int bio_associate_current(struct bio *bi
>  {
>  	struct io_context *ioc;
>  
> -	if (bio->bi_ioc)
> +	if (bio->bi_css)
>  		return -EBUSY;

Hi Tejun,

Have a query. So if somebody calls bio_associate_blkcg(), that bio will
not have io context information. That means io context information of
submitter will be used in CFQ. That will also mean that if we select
differnt thread to IO of same cgroup or use a thread to submit IO of
different cgroup, check_blkcg_changed() will be true and we will
unnecessary drop sync queue despite the fact that IO we are submitting
now is async. And everytime a submitter submits IO for a different cgroup,
it will drop its existing sync queue. Sounds suboptimal.

I guess ideally io context of original writer who wrote data in page
cache should be used. But we probably don't have that information as
we might be planning to get block cgroup information from inode of
the file being written.

Not sure what can be done about this. May be a notion of per
block cgroup per device io context and always use that io context
when bio has cgroup info but not io context info. 

Thanks
Vivek

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH block/for-next 2/4] blkcg: add blkcg_root_css
  2014-11-20 20:16   ` [PATCH block/for-next 2/4] blkcg: add blkcg_root_css Vivek Goyal
@ 2015-01-06 22:37     ` Tejun Heo
  0 siblings, 0 replies; 10+ messages in thread
From: Tejun Heo @ 2015-01-06 22:37 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: Jens Axboe, linux-kernel

On Thu, Nov 20, 2014 at 03:16:09PM -0500, Vivek Goyal wrote:
> On Mon, Nov 17, 2014 at 04:13:57PM -0500, Tejun Heo wrote:
> [..]
> > --- a/include/linux/blkdev.h
> > +++ b/include/linux/blkdev.h
> > @@ -1408,6 +1408,9 @@ int kblockd_schedule_delayed_work(struct
> >  int kblockd_schedule_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay);
> >  
> >  #ifdef CONFIG_BLK_CGROUP
> > +
> > +extern struct cgroup_subsys_state * const blkcg_root_css;
> 
> Hi Tejun,
> 
> Would it make sense to keep this in include/linux/blk-cgroup.h

Moved in the new version which just got posted.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH block/for-next 4/4] block: implement bio_associate_blkcg()
  2014-11-20 21:15       ` Vivek Goyal
@ 2015-01-06 23:12         ` Tejun Heo
  0 siblings, 0 replies; 10+ messages in thread
From: Tejun Heo @ 2015-01-06 23:12 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: Jens Axboe, linux-kernel

Hello, Vivek.

Sorry about the delay.

On Thu, Nov 20, 2014 at 04:15:06PM -0500, Vivek Goyal wrote:
> Not sure what can be done about this. May be a notion of per
> block cgroup per device io context and always use that io context
> when bio has cgroup info but not io context info. 

I think the right thing to do here is having a dedicated ioc for
writeback traffic per cgroup and channel writebacks of the cgroup
through there.  We'd be simply extending the current global model into
each group.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-01-06 23:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-17 21:13 [PATCH block/for-next 1/4] blkcg: move block/blk-cgroup.h to include/linux/blk-cgroup.h Tejun Heo
2014-11-17 21:13 ` [PATCH block/for-next 2/4] blkcg: add blkcg_root_css Tejun Heo
2014-11-17 21:15   ` [PATCH block/for-next 3/4] cgroup, block: implement task_get_css() and use it in bio_associate_current() Tejun Heo
2014-11-17 21:16     ` [PATCH block/for-next 4/4] block: implement bio_associate_blkcg() Tejun Heo
2014-11-20 21:15       ` Vivek Goyal
2015-01-06 23:12         ` Tejun Heo
2014-11-20 20:27     ` [PATCH block/for-next 3/4] cgroup, block: implement task_get_css() and use it in bio_associate_current() Vivek Goyal
2014-11-20 20:16   ` [PATCH block/for-next 2/4] blkcg: add blkcg_root_css Vivek Goyal
2015-01-06 22:37     ` Tejun Heo
2014-11-20 20:10 ` [PATCH block/for-next 1/4] blkcg: move block/blk-cgroup.h to include/linux/blk-cgroup.h Vivek Goyal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.