日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux qos 实现机制,linux的qos机制 - cgroup篇 (4)

發布時間:2025/4/5 linux 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux qos 实现机制,linux的qos机制 - cgroup篇 (4) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

下面來看各個子系統對cgroup的支持,第一篇先研究blkio子系統

blkio子系統支持三種類型的QoS控制:

blkio.weight, blkio.weight_device:這些是基于設備權重值的控制方式

blkio.throttle.read_bps_device,blkio.throttle.write_bps_device:這些是基于帶寬的控制方式

blkio.throttle.read_iops_device,blkio.throttle.write_iops_device:這些是基于iops的控制方式

其中基于權重的控制方式,必須依賴于CFQ調度器,而基于throttle的控制方式則只需要在通用塊層實現就可以了

1) 基于blkio的cgroup_subsys的定義如下:

struct cgroup_subsys blkio_subsys = {

.name = "blkio",

.create = blkiocg_create,

.can_attach_task = blkiocg_can_attach_task,

.attach_task = blkiocg_attach_task,

.destroy = blkiocg_destroy,

.populate = blkiocg_populate,

#ifdef CONFIG_BLK_CGROUP

/* note: blkio_subsys_id is otherwise defined in blk-cgroup.h */

.subsys_id = blkio_subsys_id,

#endif

.use_id = 1,

.module = THIS_MODULE,

};

blkiocg_create(struct cgroup_subsys *subsys, struct cgroup *cgroup):初始化一個blkio_cgroup結構,并初始化blkio_cgroup->policy_list, blkio_cgroup->blkg_list

blkiocg_destroy(struct cgroup_subsys *subsys, struct cgroup *cgroup):略過

blkiocg_populate(struct cgroup_subsys *subsys, struct cgroup *cgroup):初始化好blkio_files里所有的blkio_policy_node對應的cgroup文件系統的文件

blkiocg_can_attach_task(struct cgroup *cgrp, struct task_struct *tsk):

/*

* We cannot support shared io contexts, as we have no mean to support

* two tasks with the same ioc in two different groups without major rework

* of the main cic data structures. ?For now we allow a task to change

* its cgroup only if it's the only owner of its ioc.

*/

2) 基于blkio的policy的數據結構定義如下:

struct blkio_policy_node {

struct list_head node;

dev_t dev;

/* This node belongs to max bw policy or porportional weight policy */

enum blkio_policy_id plid;

/* cgroup file to which this rule belongs to */

int fileid;

union {

unsigned int weight;

/*

* Rate read/write in terms of byptes per second

* Whether this rate represents read or write is determined

* by file type "fileid".

*/

u64 bps;

unsigned int iops;

} val;

};

struct blkio_policy_ops {

blkio_unlink_group_fn *blkio_unlink_group_fn;

blkio_update_group_weight_fn *blkio_update_group_weight_fn;

blkio_update_group_read_bps_fn *blkio_update_group_read_bps_fn;

blkio_update_group_write_bps_fn *blkio_update_group_write_bps_fn;

blkio_update_group_read_iops_fn *blkio_update_group_read_iops_fn;

blkio_update_group_write_iops_fn *blkio_update_group_write_iops_fn;

};

enum blkio_policy_id {

BLKIO_POLICY_PROP = 0,/* Proportional Bandwidth division */

BLKIO_POLICY_THROTL,/* Throttling */

};

struct blkio_policy_type {

struct list_head list;

struct blkio_policy_ops ops;

enum blkio_policy_id plid;

};

blkio_policy_node,基本上可以看做一個cgroup文件系統下的一個配置文件對應一個blkio_policy_node,一個cgroup目錄的所有的policy_node都會被鏈在一個blkio_cgroup->policy_list的鏈表中

blkio_policy_type根據不同的blkio_policy_id有不同的blkio_policy_ops,blkio_policy_register在cfq_init,throtl_init時被調用,這兩個初始化函數分別對應基于權重的控制和基于閥值的控制,目前有兩個全局的blkio_policy_type的變量:

static struct blkio_policy_type blkio_policy_cfq = {

.ops = {

.blkio_unlink_group_fn =cfq_unlink_blkio_group,

.blkio_update_group_weight_fn =cfq_update_blkio_group_weight,

},

.plid = BLKIO_POLICY_PROP,

};

以及

static struct blkio_policy_type blkio_policy_throtl = {

.ops = {

.blkio_unlink_group_fn = throtl_unlink_blkio_group,

.blkio_update_group_read_bps_fn =

throtl_update_blkio_group_read_bps,

.blkio_update_group_write_bps_fn =

throtl_update_blkio_group_write_bps,

.blkio_update_group_read_iops_fn =

throtl_update_blkio_group_read_iops,

.blkio_update_group_write_iops_fn =

throtl_update_blkio_group_write_iops,

},

.plid = BLKIO_POLICY_THROTL,

};

3) 基于blkio的cgroup文件系統的數據結構如下:

struct cftype blkio_files[] = {

{

.name = "weight_device",

.private = BLKIOFILE_PRIVATE(BLKIO_POLICY_PROP,

BLKIO_PROP_weight_device),

.read_seq_string = blkiocg_file_read,

.write_string = blkiocg_file_write,

.max_write_len = 256,

},

{

.name = "weight",

.private = BLKIOFILE_PRIVATE(BLKIO_POLICY_PROP,

BLKIO_PROP_weight),

.read_u64 = blkiocg_file_read_u64,

.write_u64 = blkiocg_file_write_u64,

},

{

.name = "throttle.read_bps_device",

.private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL,

BLKIO_THROTL_read_bps_device),

.read_seq_string = blkiocg_file_read,

.write_string = blkiocg_file_write,

.max_write_len = 256,

},

{

.name = "throttle.write_bps_device",

.private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL,

BLKIO_THROTL_write_bps_device),

.read_seq_string = blkiocg_file_read,

.write_string = blkiocg_file_write,

.max_write_len = 256,

},

{

.name = "throttle.read_iops_device",

.private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL,

BLKIO_THROTL_read_iops_device),

.read_seq_string = blkiocg_file_read,

.write_string = blkiocg_file_write,

.max_write_len = 256,

},

{

.name = "throttle.write_iops_device",

.private = BLKIOFILE_PRIVATE(BLKIO_POLICY_THROTL,

BLKIO_THROTL_write_iops_device),

.read_seq_string = blkiocg_file_read,

.write_string = blkiocg_file_write,

.max_write_len = 256,

},

基本上調用的都是blkiocg_file_read,blkiocg_file_write

blkio_files中的struct cftype有個private成員變量,通過BLKIOFILE_PRIVATE宏來賦值,e.g.

.private = BLKIOFILE_PRIVATE(BLKIO_POLICY_PROP,?BLKIO_PROP_weight_device)

之后可以通過BLKIOFILE_POLICY獲取其policy類型:BLKIO_POLICY_THROTL或者BLKIO_POLICY_PROP,通過BLKIOFILE_ATTR獲取其文件名,所有的配置文件都有如下定義:

/* cgroup files owned by proportional weight policy */

enum blkcg_file_name_prop {

BLKIO_PROP_weight = 1,

BLKIO_PROP_weight_device,

BLKIO_PROP_io_service_bytes,

BLKIO_PROP_io_serviced,

BLKIO_PROP_time,

BLKIO_PROP_sectors,

BLKIO_PROP_unaccounted_time,

BLKIO_PROP_io_service_time,

BLKIO_PROP_io_wait_time,

BLKIO_PROP_io_merged,

BLKIO_PROP_io_queued,

BLKIO_PROP_avg_queue_size,

BLKIO_PROP_group_wait_time,

BLKIO_PROP_idle_time,

BLKIO_PROP_empty_time,

BLKIO_PROP_dequeue,

};

/* cgroup files owned by throttle policy */

enum blkcg_file_name_throtl {

BLKIO_THROTL_read_bps_device,

BLKIO_THROTL_write_bps_device,

BLKIO_THROTL_read_iops_device,

BLKIO_THROTL_write_iops_device,

BLKIO_THROTL_io_service_bytes,

BLKIO_THROTL_io_serviced,

};

static int blkiocg_file_read(struct cgroup *cgrp, struct cftype *cft,?struct seq_file *m):通過cftype得到POLICY_ID, POLICY_FILE_NAME,通過struct cgroup得到struct blkio_cgroup,然后調用blkio_read_policy_node_files,按照一定格式存到一個seq_file里面,可以參考blkio_print_policy_node函數

static int blkiocg_file_write(struct cgroup *cgrp, struct cftype *cft,?const char *buffer):先調用blkio_policy_parse_and_set生成一個新的blkio_policy_node,下面的步驟就是先刪了已有的policy node,再把新的policy node插入到blkio_cgroup->policy_list里面,最后調用blkio_update_policy_node_blkg,該函數對blkio_cgroup下面的所有blkio_group,都調用blkio_update_blkg_policy,該函數會根據blkio_policy_node的plid, fileid,調用不同的 blkio_update_xxxxx函數,以weight為例,最終調用到blkio_update_group_weight,后者又調用cfq_update_blkio_group_weight(這是跟CFQ緊耦合的一個函數,這里不做介紹了)

4) 幾個關鍵的數據結構blkio_cgroup和blkio_group

struct blkio_cgroup {

struct cgroup_subsys_state css;

unsigned int weight;

spinlock_t lock;

struct hlist_head blkg_list;

struct list_head policy_list; /* list of blkio_policy_node */

};

struct blkio_group {

/* An rcu protected unique identifier for the group */

void *key;

struct hlist_node blkcg_node;

unsigned short blkcg_id;

/* Store cgroup path */

char path[128];

/* The device MKDEV(major, minor), this group has been created for */

dev_t dev;

/* policy which owns this blk group */

enum blkio_policy_id plid;

/* Need to serialize the stats in the case of reset/update */

spinlock_t stats_lock;

struct blkio_group_stats stats;

/* Per cpu stats pointer */

struct blkio_group_stats_cpu __percpu *stats_cpu;

};

blkio_cgroup代表了一個cgroup,但是這個cgroup里的進程有可能會讀寫多個塊設備,所有通過一個cfq_data或者throtl_data的結構作為紅黑樹的key,把多個blkio_group關聯到一個blkio_cgroup中。每個cfq_data或者throtl_data(根據policy的不同)實際上代表了一個塊設備

《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的linux qos 实现机制,linux的qos机制 - cgroup篇 (4)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 日本人妻伦在线中文字幕 | 欧美成人不卡视频 | 欧美性猛交乱大交3 | 黑鬼巨鞭白妞冒白浆 | 成人福利视频网 | 国产一二三视频 | sm久久捆绑调教精品一区 | 亚洲玖玖爱 | 国产激情综合 | 天天艹av| 西西人体44www大胆无码 | 黑人精品一区二区三区不 | 欧美偷拍一区二区 | 日本视频在线观看 | 国产精品欧美综合 | 看看毛片 | 久久成人国产精品入口 | 色哟哟免费观看 | 国产无套精品 | 成人av电影在线观看 | 永久黄网站 | 97超碰在线免费 | 岛国av免费看 | 青草福利在线 | 少妇色综合 | 国产精品一级 | 91大神一区二区 | 亚洲精品第三页 | 拍真实国产伦偷精品 | 久久视频热 | 欧美一级性视频 | 丰满人妻一区二区三区无码av | 国产精品成人久久久 | 久久久精品视频在线观看 | 欧美三级一区 | 国产伦精品一区二区三区视频1 | 五月婷婷六月香 | 小泽玛利亚一区二区三区视频 | 日韩不卡在线 | 精品乱码一区二区三四区视频 | 亚洲综合视频在线 | 中文久久久 | 欧美日韩在线一区二区三区 | 中国美女黄色 | 男人天堂成人 | 亚洲亚洲人成综合网络 | 日本黄色播放器 | 日日舔夜夜摸 | 日韩一区高清 | 午夜精品一区二区三区在线观看 | 91麻豆精品一二三区在线 | 黄色成人免费观看 | 女生下面流水视频 | 好妞色妞国产在线视频 | 日韩在线一二三区 | 久久久老熟女一区二区三区91 | 韩国三级做爰高潮 | wwww黄色片 | 欧美成人xxxx | 国产特黄大片aaaa毛片 | 69视频污| 国产亚洲精品自拍 | 欧美肉丝袜videos办公室 | 午夜在线观看影院 | 欧美成人精品欧美一级私黄 | 性欧美欧美巨大69 | 在线免费看黄色 | 国产精品久久久久久久久久久久久 | 国产香蕉视频在线观看 | 欧美精品手机在线 | 中国美女一级黄色片 | 国产精品天天操 | 在线视频精品一区 | 国产免费无码一区二区视频 | videos另类灌满极品另类 | 亚洲v欧美v| 精品人妻伦一二三区久久 | 久久久久久一级片 | 性生活视频网站 | 色一情一区二 | 中文在线观看高清视频 | 秋霞毛片少妇激情免费 | 一区二区精品在线观看 | 青青操网 | www.69视频 | 天天干干干| aa一级视频 | 成人激情小视频 | 可以直接看的毛片 | 国产欧美视频一区二区 | 三级不卡 | 日本一区免费电影 | 波多野结衣一区二区三区 | 人禽高h交 | 欧美熟妇7777一区二区 | 国产福利在线看 | 毛片毛片毛片毛片毛片毛片毛片毛片 | 99久久久久成人国产免费 | 日日夜夜骑 |