linux的nvme驱动参数调优
nvme的设备,可以调优的参数比较少,相关的代码如下:
blk_sysfs.c
static struct queue_sysfs_entry queue_requests_entry = {
.attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR },
.show = queue_requests_show,
.store = queue_requests_store,
};
static struct queue_sysfs_entry queue_ra_entry = {
.attr = {.name = "read_ahead_kb", .mode = S_IRUGO | S_IWUSR },
.show = queue_ra_show,
.store = queue_ra_store,
};
static struct queue_sysfs_entry queue_max_sectors_entry = {
.attr = {.name = "max_sectors_kb", .mode = S_IRUGO | S_IWUSR },
.show = queue_max_sectors_show,
.store = queue_max_sectors_store,
};
static struct queue_sysfs_entry queue_max_hw_sectors_entry = {
.attr = {.name = "max_hw_sectors_kb", .mode = S_IRUGO },
.show = queue_max_hw_sectors_show,
};
static struct queue_sysfs_entry queue_max_segments_entry = {
.attr = {.name = "max_segments", .mode = S_IRUGO },
.show = queue_max_segments_show,
};
static struct queue_sysfs_entry queue_max_integrity_segments_entry = {
.attr = {.name = "max_integrity_segments", .mode = S_IRUGO },
.show = queue_max_integrity_segments_show,
};
static struct queue_sysfs_entry queue_max_segment_size_entry = {
.attr = {.name = "max_segment_size", .mode = S_IRUGO },
.show = queue_max_segment_size_show,
};
static struct queue_sysfs_entry queue_iosched_entry = {
.attr = {.name = "scheduler", .mode = S_IRUGO | S_IWUSR },
.show = elv_iosched_show,
.store = elv_iosched_store,
};
static struct queue_sysfs_entry queue_hw_sector_size_entry = {
.attr = {.name = "hw_sector_size", .mode = S_IRUGO },
.show = queue_logical_block_size_show,
};
static struct queue_sysfs_entry queue_logical_block_size_entry = {
.attr = {.name = "logical_block_size", .mode = S_IRUGO },
.show = queue_logical_block_size_show,
};
static struct queue_sysfs_entry queue_physical_block_size_entry = {
.attr = {.name = "physical_block_size", .mode = S_IRUGO },
.show = queue_physical_block_size_show,
};
static struct queue_sysfs_entry queue_io_min_entry = {
.attr = {.name = "minimum_io_size", .mode = S_IRUGO },
.show = queue_io_min_show,
};
static struct queue_sysfs_entry queue_io_opt_entry = {
.attr = {.name = "optimal_io_size", .mode = S_IRUGO },
.show = queue_io_opt_show,
};
static struct queue_sysfs_entry queue_discard_granularity_entry = {
.attr = {.name = "discard_granularity", .mode = S_IRUGO },
.show = queue_discard_granularity_show,
};
static struct queue_sysfs_entry queue_discard_max_entry = {
.attr = {.name = "discard_max_bytes", .mode = S_IRUGO },
.show = queue_discard_max_show,
};
static struct queue_sysfs_entry queue_discard_zeroes_data_entry = {
.attr = {.name = "discard_zeroes_data", .mode = S_IRUGO },
.show = queue_discard_zeroes_data_show,
};
static struct queue_sysfs_entry queue_write_same_max_entry = {
.attr = {.name = "write_same_max_bytes", .mode = S_IRUGO },
.show = queue_write_same_max_show,
};
static struct queue_sysfs_entry queue_nonrot_entry = {
.attr = {.name = "rotational", .mode = S_IRUGO | S_IWUSR },
.show = queue_show_nonrot,
.store = queue_store_nonrot,
};
static struct queue_sysfs_entry queue_unpriv_sgio_entry = {
.attr = {.name = "unpriv_sgio", .mode = S_IRUGO | S_IWUSR },
.show = queue_show_unpriv_sgio,
.store = queue_store_unpriv_sgio,
};
static struct queue_sysfs_entry queue_nomerges_entry = {
.attr = {.name = "nomerges", .mode = S_IRUGO | S_IWUSR },
.show = queue_nomerges_show,
.store = queue_nomerges_store,
};
static struct queue_sysfs_entry queue_rq_affinity_entry = {
.attr = {.name = "rq_affinity", .mode = S_IRUGO | S_IWUSR },
.show = queue_rq_affinity_show,
.store = queue_rq_affinity_store,
};
static struct queue_sysfs_entry queue_iostats_entry = {
.attr = {.name = "iostats", .mode = S_IRUGO | S_IWUSR },
.show = queue_show_iostats,
.store = queue_store_iostats,
};
static struct queue_sysfs_entry queue_random_entry = {
.attr = {.name = "add_random", .mode = S_IRUGO | S_IWUSR },
.show = queue_show_random,
.store = queue_store_random,
};
参数列表如下:
[root@localhost queue]# ls -alrt *
-rw-r--r-- root root Dec : read_ahead_kb
-rw-r--r-- root root Dec : nomerges
-rw-r--r-- root root Dec : rq_affinity
-rw-r--r-- root root Dec : max_sectors_kb
-rw-r--r-- root root Dec : nr_requests
-rw-r--r-- root root Dec : iostats
-r--r--r-- root root Dec : write_same_max_bytes
-rw-r--r-- root root Dec : unpriv_sgio
-rw-r--r-- root root Dec : scheduler
-rw-r--r-- root root Dec : rotational
-r--r--r-- root root Dec : physical_block_size
-r--r--r-- root root Dec : optimal_io_size
-r--r--r-- root root Dec : minimum_io_size
-r--r--r-- root root Dec : max_segments
-r--r--r-- root root Dec : max_segment_size
-r--r--r-- root root Dec : max_integrity_segments
-r--r--r-- root root Dec : max_hw_sectors_kb
-r--r--r-- root root Dec : logical_block_size
-r--r--r-- root root Dec : hw_sector_size
-r--r--r-- root root Dec : discard_zeroes_data
-r--r--r-- root root Dec : discard_max_bytes
-r--r--r-- root root Dec : discard_granularity
-rw-r--r-- root root Dec : add_random
其中属性为只读的,肯定直接通过/sys/没法修改,有的硬编码的跟驱动相关,可以尝试修改驱动。其余可以尝试调优的参数如下:
1.nomerges (RW)
------------- This enables the user to disable the lookup logic involved with IO merging requests in the block layer. By default (0) all merges are enabled. When set to 1 only simple one-hit merges will be tried. When set to 2 no merge algorithms will be tried (including one-hit or more complex tree/hash lookups).
这个根据打开的统计,发现iostat里面前面的两列关于merge的,都一直为0,所以干脆设置为不要merge,可以减少一段代码逻辑,代码中会判断queue的merge属性,
当其值为0,说明 QUEUE_FLAG_NOXMERGES 和 QUEUE_FLAG_NOMERGES 都没有设置。这个设置为2,表示不需要merge,机械盘一般设置为需要merge,相关代码如下:
static ssize_t queue_nomerges_store(struct request_queue *q, const char *page,
size_t count)
{
unsigned long nm;
ssize_t ret = queue_var_store(&nm, page, count); if (ret < )
return ret; spin_lock_irq(q->queue_lock);
queue_flag_clear(QUEUE_FLAG_NOMERGES, q);
queue_flag_clear(QUEUE_FLAG_NOXMERGES, q);
if (nm == )
queue_flag_set(QUEUE_FLAG_NOMERGES, q);-----------值为2,则设置QUEUE_FLAG_NOMERGES
else if (nm)
queue_flag_set(QUEUE_FLAG_NOXMERGES, q); ----------值为非0,则设置QUEUE_FLAG_NOXMERGES
spin_unlock_irq(q->queue_lock);
return ret;
}
2.rq_affinity (RW)
---------------- If this option is '1', the block layer will migrate request completions to the cpu "group" that originally submitted the request. For some workloads this provides a significant reduction in CPU cycles due to caching effects.
For storage configurations that need to maximize distribution of completion processing setting this option to '2' forces the completion to run on the requesting cpu (bypassing the "group" aggregation logic).
因为cache的命中,这个设置为2,可以减少cpu使用。
3.add_random (RW)
---------------- This file allows to trun off the disk entropy contribution. Default value of this file is '1'(on).
这个最好设置为0,可以减少一点点性能消耗。
readahead参数,是如何影响nvme的性能的?一开始以为这个对机械盘影响较大,后来根据追踪代码,发现对io的及时性还是有较大的提高。
下面的代码描述了初始化阶段设置的大小,这个如果可以的话,建议设置大一些,比如1M。
struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
{
struct request_queue *q;
struct queue_limits_aux *limits_aux = NULL;
int err; q = kmem_cache_alloc_node(blk_requestq_cachep,
gfp_mask | __GFP_ZERO, node_id);
if (!q)
return NULL; q->id = ida_simple_get(&blk_queue_ida, , , gfp_mask);
if (q->id < )
goto fail_q; q->backing_dev_info.ra_pages =
(VM_MAX_READAHEAD * ) / PAGE_CACHE_SIZE;//初始化预读参数,默认为128k
4.中断绑核
我们知道,nvme的队列名称,其实是根据核数来编号的,因为admin的队列和io队列的第一个是共享一个中断的,所以他俩的中断数会相对比其他io队列多一些,由于队列默认就是跟随
cpu号而绑定的,所以中断号,最好送到指定的cpu上去,因为中断上下文毕竟是要访问内存的,具体怎么绑,可以参照如下:
查看/proc/interrupt,中断名称是nvme0q0,当然类似的nvme1q0也是,以此类推,这个肯定是admin队列。
io队列就是nvme0q1----nvme0qx,其中x就是cpu的核数。
nvme0q1这个对列,其实默认就是在cpu0上,那么对应的中断,最好也绑在cpu0上。
nvme0q30这个队列,默认在cpu29上,那么对应的中断,最好也绑在cpu29上。以此类推。
linux的nvme驱动参数调优的更多相关文章
- Linux内核 TCP/IP参数调优
http://www.360doc.com/content/14/0606/16/3300331_384326124.shtml
- Linux内核 TCP/IP、Socket参数调优
Linux内核 TCP/IP.Socket参数调优 2014-06-06 Harrison.... 阅 9611 转 165 转藏到我的图书馆 微信分享: Doc1: /proc/sy ...
- Linux Linux内核参数调优
Linux内核参数调优 by:授客 QQ:1033553122 关于调优的建议: 1.出错时,可以查看操作系统日志,可能会找到一些有用的信息 2.尽量不要“批量”修改内核参数,笔者就曾这么干过,结果“ ...
- (转)linux IO 内核参数调优 之 参数调节和场景分析
1. pdflush刷新脏数据条件 (linux IO 内核参数调优 之 原理和参数介绍)上一章节讲述了IO内核调优介个重要参数参数. 总结可知cached中的脏数据满足如下几个条件中一个或者多个的时 ...
- Linux上TCP的几个内核参数调优
Linux作为一个强大的操作系统,提供了一系列内核参数供我们进行调优.光TCP的调优参数就有50多个.在和线上问题斗智斗勇的过程中,笔者积累了一些在内网环境应该进行调优的参数.在此分享出来,希望对大家 ...
- linux 服务器安全加固和内核参数调优 nf_conntrack
0.内部设置跳板机,服务器只能通过跳板机登录1.禁止ROOT用户远程登录和登录端口 禁止ROOT用户远程登录 .打开 /etc/ssh/sshd_config PermitRootLogin no . ...
- 大数据集群Linux CentOS 7.6 系统调优篇
大数据集群Linux CentOS 7.6 系统调优篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.设置主机hosts文件 1>.修改主机名 [root@node100 ...
- (转)JVM参数调优八大技巧
这里和大家分享一下JVM参数调优的八条经验,JVM参数调优,这是很头痛的问题,设置的不好,JVM不断执行FullGC,导致整个系统变得很慢,网站停滞时间能达10秒以上,相信通过本文的学习你对JVM参数 ...
- JVM性能参数调优实践,不会执行Full GC,网站无停滞
原文来自:http://bbs.csdn.net/topics/310110257 本文只做整理记录,供个人学习. 1 JVM参数调优是个很头痛的问题,设置的不好,JVM不断执行Full GC,导致整 ...
随机推荐
- IDEA第六章----快捷键
第一节:解决快捷键冲突 idea支持很多快捷键,这样就导致了很多快捷键和其他应用冲突,所以需要把其他应用的快捷键去掉,下面以输入法和QQ为例. QQ我就留下了提取消息和截图,这个是个人习惯问题. 第二 ...
- angular4.0项目build发布后,刷新页面报错404
angular4.0项目执行npm run build后,进入页面正常显示. 但是当刷新页面时,报错404,页面未找到. 出现这个问题的原因,应该是找不到路由地址导致的,然后找到了下面的解决方案. 找 ...
- js上传图片
额 呆坐许久 感觉 有很多想写的 就是不知从何写起..贼尴尬. 其实 我平时项目中 基本上传图片什么的 都是跟着from 表单 一起提交给后台的 实行起来 简单暴力 连图片预览的都没有写 ...
- Repair MySQL 5.6 GTID replication by injecting empty transactions
Since SQL_SLAVE_SKIP_COUNTER doesn’t work with GTID we need to find a way to ignore that transaction ...
- 14.7.1.2 MySQL创建用户句法
14.7.1.2 CREATE USER Syntax 单击此处查看原文 以下是MySQL 5.7.6及以上版本的CREATE USER句法 CREATE USER [IF NOT EXISTS] u ...
- Android的Environment.getExternalStorageState的使用
1.sd状态 sd状态 现象描述 /mnt/sdcard目录是否存在 canRead返回 canWrite返回 MEDIA_MOUNTED SD卡正常挂载 true true true MEDIA ...
- python中的与 和 或
上周五写程序碰到需要处理多重判断的一个逻辑,一般正确的写法是: if a or b or (c and d) or e: pass 因为变量很长,看上去比较杂乱,自己灵机一动写成了如下的样子: if ...
- 数据结构之二叉树(BinaryTree)
导读 二叉树是一种很常见的数据结构,但要注意的是,二叉树并不是树的特殊情况,二叉树与树是两种不一样的数据结构. 目录 一. 二叉树的定义 二.二叉树为何不是特殊的树 三.二叉树的五种基本形态 四.二叉 ...
- javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
前言 今天一个朋友让我帮他做一下tomcat的https配置,中间遇到了标题中这个错误,因此记录了一下过程,服务器.域名.证书.tomcat都已经准备好,就是需要配置一下即可,用的是阿里云的证书服务, ...
- java基础,集合,Arraylist,源码解析(基础)
ArrayList 是什么,定义? 这是动态的数组,它提供了动态的增加和减少元素,实现了List接口(List实现Collection,所以也实现Collection接口)灵活的设置数组的大小等好处 ...