jdb2/kworker
创始人
2024-05-08 14:12:38
0

测试代码出自:块设备IO优化的典型案例分析_papaofdoudou的博客-CSDN博客_kworker/u2:2-2-

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include //O_DIRECT        
#define __USE_GNU 1
#include 
#include 
#include 
#include int fallocate(int , int , off_t, off_t);
static void write_test(int fdno)
{int origin_len;int reallen;void *mp;int len = 1 * 1024 * 1024;origin_len = len;len = len + (getpagesize() - len%getpagesize());//printf("%s line %d, len = %d.\n", __func__, __LINE__, len);unsigned char *p = malloc(len + getpagesize());if(p == NULL){printf("%s line %d, malloc failure.\n", __func__, __LINE__);return;}mp = p;unsigned char *q = (unsigned char *)(((unsigned long)p + getpagesize())&(~(getpagesize()-1)));p = q;//printf("q = %p, mp = %p.\n", q, mp);memset(p, 0x00, len);//lseek(fdno, 0, SEEK_SET);//int reallen = read(fdno, p,len);//printf("%s line %d, reallen %d read failure.er %s\n", __func__, __LINE__, reallen, strerror(errno));//printf("%s line %d, fdno = %d\n", __func__, __LINE__, fdno);//lseek(fdno, 0, SEEK_SET);reallen = write(fdno, p, origin_len);//printf("%s line %d, reallen = %d.\n", __func__, __LINE__, reallen);//lseek(fdno, 0, SEEK_SET);free(mp);mp = NULL;return;
}static void* write_thread1(void *p)
{int fdno;fdno = open("./fuck.bin", O_DIRECT|O_RDWR|O_CREAT, 0666);//fdno = open("./fuck.bin", O_RDWR|O_CREAT, 0666);if(fdno < 0){printf("%s line %d, open file failure.\n", __func__, __LINE__);return NULL;}fallocate(fdno, 1, 0, 100*1024*1024);//fallocate(fdno, 0, 0, 100*1024*1024);//return NULL;while(1){write_test(fdno);}close(fdno);return NULL;
}static void* write_thread2(void *p)
{int fdno;fdno = open("./new.bin", O_DIRECT|O_RDWR|O_CREAT, 0666);if(fdno < 0){printf("%s line %d, open file failure.\n", __func__, __LINE__);return NULL;}fallocate(fdno, 1, 0, 100*1024*1024);//fallocate(fdno, 0, 0, 100*1024*1024);//return NULL;while(1){write_test(fdno);}close(fdno);return NULL;
}int main(int argc,char **argv)
{pthread_t t1,t2;pthread_create(&t1,0,write_thread1,NULL);pthread_create(&t2,0,write_thread2,NULL);pthread_join(t1,NULL);pthread_join(t2,NULL);return 0;
}

块起始分别为9961472、9961984、9962496、9963008,每个需要512 sectiors 扇区,本次写1M的文件,需要4*512=1024个扇区,即每个扇区是1K

[281277.215000] test_emmc(14438): dirtied inode 1572868 (fuck.bin) on mmcblk0
[281277.215000] test_emmc(14438): WRITE block 9961472 on mmcblk0 (512 sectors)
[281277.215000] test_emmc(14438): WRITE block 9961984 on mmcblk0 (512 sectors)
[281277.219000] test_emmc(14438): WRITE block 9962496 on mmcblk0 (512 sectors)
[281277.220000] test_emmc(14438): WRITE block 9963008 on mmcblk0 (512 sectors)
[281283.008000] jbd2/mmcblk0-8(833): WRITE block 29730136 on mmcblk0 (8 sectors)
[281283.008000] jbd2/mmcblk0-8(833): WRITE block 29730144 on mmcblk0 (8 sectors)
[281283.013000] jbd2/mmcblk0-8(833): WRITE block 29730152 on mmcblk0 (8 sectors)
[281284.018000] kworker/u2:0(14315): WRITE block 50331904 on mmcblk0 (8 sectors)

问题1:jbd2/mmcblk0-8和kworker/u2:0有什么差别?

kworker线程创建

路径:kernel\workqueue.c

 

JBD2(journaling block device 2)

关于JBD介绍:https://help.aliyun.com/document_detail/155605.html

JDB的工作原理

JBD2(journaling block device 2)系统分析(一)-dessasic-ChinaUnix博客

性能分析之解决 jbd2 引起 IO 高问题_zuozewei的博客-CSDN博客

JDB2线程创建

[root@szclou mmcblk0-8]$ps -aux | grep jbd*
root       833  0.0  0.0      0     0 ?        S    Jan04   0:06 [jbd2/mmcblk0-8]
root     14546  0.0  0.3   1860   876 pts/2    S+   14:49   0:00 grep jbd*

JBD2源代码路径:fs\jbd2\journal.c

某大神发现jbd2日志更新时会引发io访问100%,是内核代码有bug,链接:性能分析之解决 jbd2 引起 IO 高问题_zuozewei的博客-CSDN博客

 而本人的内核却是还存在这个bug

int jbd2_log_start_commit(journal_t *journal, tid_t tid)
{int ret;write_lock(&journal->j_state_lock);ret = __jbd2_log_start_commit(journal, tid);write_unlock(&journal->j_state_lock);return ret;
}

 

相关内容

热门资讯

监控摄像头接入GB28181平... 流程简介将监控摄像头的视频在网站和APP中直播,要解决的几个问题是:1&...
Windows10添加群晖磁盘... 在使用群晖NAS时,我们需要通过本地映射的方式把NAS映射成本地的一块磁盘使用。 通过...
protocol buffer... 目录 目录 什么是protocol buffer 1.protobuf 1.1安装  1.2使用...
在Word、WPS中插入AxM... 引言 我最近需要写一些文章,在排版时发现AxMath插入的公式竟然会导致行间距异常&#...
【PdgCntEditor】解... 一、问题背景 大部分的图书对应的PDF,目录中的页码并非PDF中直接索引的页码...
Fluent中创建监测点 1 概述某些仿真问题,需要创建监测点,用于获取空间定点的数据࿰...
educoder数据结构与算法...                                                   ...
MySQL下载和安装(Wind... 前言:刚换了一台电脑,里面所有东西都需要重新配置,习惯了所...
修复 爱普生 EPSON L4... L4151 L4153 L4156 L4158 L4163 L4165 L4166 L4168 L4...
MFC文件操作  MFC提供了一个文件操作的基类CFile,这个类提供了一个没有缓存的二进制格式的磁盘...