Skip to contentSkip to conversation

block: cleanup cgroup

PATCH Applied Ming Lei 3 participants 7 messages Feb 11, 2022

Subsystems (3)
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

cover block: cleanup cgroup

Hello,

The 1st two patches cleans up blk-cgroup code a bit.

The 3rd patch moves block layer internal definition into one private header of block/blk-cgroup.h, as suggested by Christoph, and the idea is that just small amount of structures & functions need to be exported, and most of them are block layer internal structures and functions.

Ming Lei (3):
block: remove THROTL_IOPS_MAX
block: move initialization of q->blkg_list into blkcg_init_queue
block: partition include/linux/blk-cgroup.h

 block/bfq-iosched.h         |   1 -
 block/bio.c                 |   2 +-
 block/blk-cgroup-rwstat.h   |   2 +-
 block/blk-cgroup.c          |   4 +-
 block/blk-cgroup.h          | 477 ++++++++++++++++++++++++++++++++++++
 block/blk-core.c            |   5 +-
 block/blk-crypto-fallback.c |   2 +-
 block/blk-iocost.c          |   2 +-
 block/blk-iolatency.c       |   2 +-
 block/blk-ioprio.c          |   2 +-
 block/blk-sysfs.c           |   2 +-
 block/blk-throttle.c        |   1 -
 block/bounce.c              |   2 +-
 block/elevator.c            |   2 +-
 include/linux/blk-cgroup.h  | 461 +---------------------------------
 15 files changed, 495 insertions(+), 472 deletions(-)
 create mode 100644 block/blk-cgroup.h
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH 1/3 block: remove THROTL_IOPS_MAX

No one uses THROTL_IOPS_MAX any more, so remove it.

---
 include/linux/blk-cgroup.h | 2 --
 1 file changed, 2 deletions(-)
include/linux/blk-cgroup.h +0 -2
index b4de2010fba5..bdc49bd4eef0 100644
@@ -28,8 +28,6 @@
 /* percpu_counter batch for blkg_[rw]stats, per-cpu drift doesn't matter */
 #define BLKG_STAT_CPU_BATCH	(INT_MAX / 2)
 
-/* Max limits for throttle policy */
-#define THROTL_IOPS_MAX		UINT_MAX
 #define FC_APPID_LEN              129
 
 
Signature · 1 line
2.31.1
author
#3 lore raw

PATCH 2/3 block: move initialization of q->blkg_list into blkcg_init_queue

In reply to Ming Lei

q->blkg_list is only used by blkcg code, so move it into blkcg_init_queue.

---
 block/blk-cgroup.c | 2 ++
 block/blk-core.c   | 3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)
block/blk-cgroup.c +2 -0
index 671debbae941..35deaceba1f0 100644
@@ -1175,6 +1175,8 @@ int blkcg_init_queue(struct request_queue *q)
 	bool preloaded;
 	int ret;
 
+	INIT_LIST_HEAD(&q->blkg_list);
+
 	new_blkg = blkg_alloc(&blkcg_root, q, GFP_KERNEL);
 	if (!new_blkg)
 		return -ENOMEM;
block/blk-core.c +0 -3
index be8812f5489d..ff972b968f25 100644
@@ -476,9 +476,6 @@ struct request_queue *blk_alloc_queue(int node_id, bool alloc_srcu)
 	timer_setup(&q->timeout, blk_rq_timed_out_timer, 0);
 	INIT_WORK(&q->timeout_work, blk_timeout_work);
 	INIT_LIST_HEAD(&q->icq_list);
-#ifdef CONFIG_BLK_CGROUP
-	INIT_LIST_HEAD(&q->blkg_list);
-#endif
 
 	kobject_init(&q->kobj, &blk_queue_ktype);
 
Signature · 1 line
2.31.1
author
#4 lore raw

PATCH 3/3 block: partition include/linux/blk-cgroup.h

In reply to Ming Lei

Partition include/linux/blk-cgroup.h into two parts: one is public part, the other is block layer private part.

Suggested by Christoph Hellwig.

---
 block/bfq-iosched.h         |   1 -
 block/bio.c                 |   2 +-
 block/blk-cgroup-rwstat.h   |   2 +-
 block/blk-cgroup.c          |   2 +-
 block/blk-cgroup.h          | 477 ++++++++++++++++++++++++++++++++++++
 block/blk-core.c            |   2 +-
 block/blk-crypto-fallback.c |   2 +-
 block/blk-iocost.c          |   2 +-
 block/blk-iolatency.c       |   2 +-
 block/blk-ioprio.c          |   2 +-
 block/blk-sysfs.c           |   2 +-
 block/blk-throttle.c        |   1 -
 block/bounce.c              |   2 +-
 block/elevator.c            |   2 +-
 include/linux/blk-cgroup.h  | 459 +---------------------------------
 15 files changed, 493 insertions(+), 467 deletions(-)
 create mode 100644 block/blk-cgroup.h
block/bfq-iosched.h +0 -1
index 07288b9da389..72255ec44f8f 100644
@@ -8,7 +8,6 @@
 
 #include <linux/blktrace_api.h>
 #include <linux/hrtimer.h>
-#include <linux/blk-cgroup.h>
 
 #include "blk-cgroup-rwstat.h"
 
block/bio.c +1 -1
index 18d34b33351b..b15f5466ce08 100644
@@ -15,7 +15,6 @@
 #include <linux/mempool.h>
 #include <linux/workqueue.h>
 #include <linux/cgroup.h>
-#include <linux/blk-cgroup.h>
 #include <linux/highmem.h>
 #include <linux/sched/sysctl.h>
 #include <linux/blk-crypto.h>
@@ -24,6 +23,7 @@
 #include <trace/events/block.h>
 #include "blk.h"
 #include "blk-rq-qos.h"
+#include "blk-cgroup.h"
 
 struct bio_alloc_cache {
 	struct bio		*free_list;
block/blk-cgroup-rwstat.h +1 -1
index ee746919c41f..9f2723b34b75 100644
@@ -6,7 +6,7 @@
 #ifndef _BLK_CGROUP_RWSTAT_H
 #define _BLK_CGROUP_RWSTAT_H
 
-#include <linux/blk-cgroup.h>
+#include "blk-cgroup.h"
 
 enum blkg_rwstat_type {
 	BLKG_RWSTAT_READ,
block/blk-cgroup.c +1 -1
index 35deaceba1f0..4108d445c73a 100644
@@ -26,11 +26,11 @@
 #include <linux/delay.h>
 #include <linux/atomic.h>
 #include <linux/ctype.h>
-#include <linux/blk-cgroup.h>
 #include <linux/tracehook.h>
 #include <linux/psi.h>
 #include <linux/part_stat.h>
 #include "blk.h"
+#include "blk-cgroup.h"
 #include "blk-ioprio.h"
 #include "blk-throttle.h"
 
block/blk-cgroup.h new file +477 -0

477 lines not on this page · raw message

block/blk-core.c +1 -1
index ff972b968f25..5a4a59041629 100644
@@ -34,7 +34,6 @@
 #include <linux/delay.h>
 #include <linux/ratelimit.h>
 #include <linux/pm_runtime.h>
-#include <linux/blk-cgroup.h>
 #include <linux/t10-pi.h>
 #include <linux/debugfs.h>
 #include <linux/bpf.h>
@@ -49,6 +48,7 @@
 #include "blk.h"
 #include "blk-mq-sched.h"
 #include "blk-pm.h"
+#include "blk-cgroup.h"
 #include "blk-throttle.h"
 
 struct dentry *blk_debugfs_root;
block/blk-crypto-fallback.c +1 -1
index c87aba8584c6..18c8eafe20b9 100644
@@ -10,7 +10,6 @@
 #define pr_fmt(fmt) "blk-crypto-fallback: " fmt
 
 #include <crypto/skcipher.h>
-#include <linux/blk-cgroup.h>
 #include <linux/blk-crypto.h>
 #include <linux/blk-crypto-profile.h>
 #include <linux/blkdev.h>
@@ -20,6 +19,7 @@
 #include <linux/random.h>
 #include <linux/scatterlist.h>
 
+#include "blk-cgroup.h"
 #include "blk-crypto-internal.h"
 
 static unsigned int num_prealloc_bounce_pg = 32;
block/blk-iocost.c +1 -1
index 769b64394298..70a0a3d680a3 100644
@@ -178,12 +178,12 @@
 #include <linux/time64.h>
 #include <linux/parser.h>
 #include <linux/sched/signal.h>
-#include <linux/blk-cgroup.h>
 #include <asm/local.h>
 #include <asm/local64.h>
 #include "blk-rq-qos.h"
 #include "blk-stat.h"
 #include "blk-wbt.h"
+#include "blk-cgroup.h"
 
 #ifdef CONFIG_TRACEPOINTS
 
block/blk-iolatency.c +1 -1
index 6593c7123b97..010e658d44a8 100644
@@ -74,9 +74,9 @@
 #include <linux/sched/signal.h>
 #include <trace/events/block.h>
 #include <linux/blk-mq.h>
-#include <linux/blk-cgroup.h>
 #include "blk-rq-qos.h"
 #include "blk-stat.h"
+#include "blk-cgroup.h"
 #include "blk.h"
 
 #define DEFAULT_SCALE_COOKIE 1000000U
block/blk-ioprio.c +1 -1
index 2e7f10e1c03f..79e797f5d194 100644
@@ -12,11 +12,11 @@
  *   Documentation/admin-guide/cgroup-v2.rst.
  */
 
-#include <linux/blk-cgroup.h>
 #include <linux/blk-mq.h>
 #include <linux/blk_types.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include "blk-cgroup.h"
 #include "blk-ioprio.h"
 #include "blk-rq-qos.h"
 
block/blk-sysfs.c +1 -1
index 9f32882ceb2f..4c6b7dff71e5 100644
@@ -10,7 +10,6 @@
 #include <linux/backing-dev.h>
 #include <linux/blktrace_api.h>
 #include <linux/blk-mq.h>
-#include <linux/blk-cgroup.h>
 #include <linux/debugfs.h>
 
 #include "blk.h"
@@ -18,6 +17,7 @@
 #include "blk-mq-debugfs.h"
 #include "blk-mq-sched.h"
 #include "blk-wbt.h"
+#include "blk-cgroup.h"
 #include "blk-throttle.h"
 
 struct queue_sysfs_entry {
block/blk-throttle.c +0 -1
index 7c462c006b26..73640d80e99e 100644
@@ -10,7 +10,6 @@
 #include <linux/blkdev.h>
 #include <linux/bio.h>
 #include <linux/blktrace_api.h>
-#include <linux/blk-cgroup.h>
 #include "blk.h"
 #include "blk-cgroup-rwstat.h"
 #include "blk-stat.h"
block/bounce.c +1 -1
index 3fd3bc6fd5db..3d50d19cde72 100644
@@ -14,7 +14,6 @@
 #include <linux/pagemap.h>
 #include <linux/mempool.h>
 #include <linux/blkdev.h>
-#include <linux/blk-cgroup.h>
 #include <linux/backing-dev.h>
 #include <linux/init.h>
 #include <linux/hash.h>
@@ -24,6 +23,7 @@
 
 #include <trace/events/block.h>
 #include "blk.h"
+#include "blk-cgroup.h"
 
 #define POOL_SIZE	64
 #define ISA_POOL_SIZE	16
block/elevator.c +1 -1
index ec98aed39c4f..6847ab6e7aa5 100644
@@ -35,7 +35,6 @@
 #include <linux/hash.h>
 #include <linux/uaccess.h>
 #include <linux/pm_runtime.h>
-#include <linux/blk-cgroup.h>
 
 #include <trace/events/block.h>
 
@@ -44,6 +43,7 @@
 #include "blk-mq-sched.h"
 #include "blk-pm.h"
 #include "blk-wbt.h"
+#include "blk-cgroup.h"
 
 static DEFINE_SPINLOCK(elv_list_lock);
 static LIST_HEAD(elv_list);
include/linux/blk-cgroup.h +5 -454

528 lines not on this page · raw message

Signature · 1 line
2.31.1
Reviewed-by on v1 3/3
#5 lore raw

Re: [PATCH 3/3] block: partition include/linux/blk-cgroup.h

Quoted 2 lines · Ming Lei

Partition include/linux/blk-cgroup.h into two parts: one is public part, the other is block layer private part.

I'd say split instead of partition, but the actual patch looks good:

maintainer Applied
#6 lore raw
In reply to Ming Lei
Quoted 8 lines · Ming Lei

The 1st two patches cleans up blk-cgroup code a bit.

The 3rd patch moves block layer internal definition into one private header of block/blk-cgroup.h, as suggested by Christoph, and the idea is that just small amount of structures & functions need to be exported, and most of them are block layer internal structures and functions.

[...]

Applied, thanks!

[1/3] block: remove THROTL_IOPS_MAX

      commit: 0e51e2ab49a99bc5077760aa083dfa1c3bf9899b
[2/3] block: move initialization of q->blkg_list into blkcg_init_queue
      commit: 472e4314c039d6cf36e28783b1c63f87b5b394c2
[3/3] block: partition include/linux/blk-cgroup.h
      commit: 672fdcf0e7de3b1e39416ac85abf178f023271f1

Best regards,

Signature · 1 line
Jens Axboe