mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-30 10:33:27 +00:00
Block IO Scheduler (#158)
* Block io调度器 * process_wakeup时,对cfs的进程,重设虚拟运行时间。解决由于休眠的进程,其虚拟运行时间过小,导致其他进程饥饿的问题 * 1、为AP核启动apic_timer,使其能够运行调度 2、增加kick_cpu功能,支持让某个特定核心立即运行调度器 3、wait_queue的唤醒,改为立即唤醒。 4、增加进程在核心间迁移的功能 5、CFS调度器为每个核心设置单独的IDLE进程pcb(pid均为0) 6、pcb中增加migrate_to字段 7、当具有多核时,io调度器在核心1上运行。 * io调度器文件位置修改 * 修改io的makefile * 更新makefile中的变量名 * 修改io调度器函数名 --------- Co-authored-by: login <longjin@ringotek.cn>
This commit is contained in:
@ -40,11 +40,8 @@ struct block_device_request_packet
|
||||
uint64_t LBA_start;
|
||||
uint32_t count;
|
||||
uint64_t buffer_vaddr;
|
||||
|
||||
uint8_t device_type; // 0: ahci
|
||||
void (*end_handler)(ul num, ul arg);
|
||||
|
||||
wait_queue_node_t wait_queue;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -53,7 +50,6 @@ struct block_device_request_packet
|
||||
*/
|
||||
struct block_device_request_queue
|
||||
{
|
||||
wait_queue_node_t wait_queue_list;
|
||||
struct block_device_request_packet *in_service; // 正在请求的结点
|
||||
ul request_count;
|
||||
};
|
||||
@ -64,13 +60,12 @@ struct block_device_request_queue
|
||||
*/
|
||||
struct block_device
|
||||
{
|
||||
sector_t bd_start_sector; // 该分区的起始扇区
|
||||
uint64_t bd_start_LBA; // 起始LBA号
|
||||
sector_t bd_sectors_num; // 该分区的扇区数
|
||||
struct vfs_superblock_t *bd_superblock; // 执行超级块的指针
|
||||
struct blk_gendisk *bd_disk; // 当前分区所属的磁盘
|
||||
struct block_device_request_queue *bd_queue; // 请求队列
|
||||
uint16_t bd_partno; // 在磁盘上的分区号
|
||||
sector_t bd_start_sector; // 该分区的起始扇区
|
||||
uint64_t bd_start_LBA; // 起始LBA号
|
||||
sector_t bd_sectors_num; // 该分区的扇区数
|
||||
struct vfs_superblock_t *bd_superblock; // 执行超级块的指针
|
||||
struct blk_gendisk *bd_disk; // 当前分区所属的磁盘
|
||||
uint16_t bd_partno; // 在磁盘上的分区号
|
||||
};
|
||||
|
||||
// 定义blk_gendisk中的标志位
|
||||
@ -85,10 +80,8 @@ struct blk_gendisk
|
||||
char disk_name[DISK_NAME_LEN]; // 磁盘驱动器名称
|
||||
uint16_t part_cnt; // 磁盘分区计数
|
||||
uint16_t flags;
|
||||
struct block_device *partition; // 磁盘分区数组
|
||||
const struct block_device_operation *fops; // 磁盘操作
|
||||
struct block_device_request_queue *request_queue; // 磁盘请求队列
|
||||
struct block_device *partition; // 磁盘分区数组
|
||||
const struct block_device_operation *fops; // 磁盘操作
|
||||
void *private_data;
|
||||
|
||||
mutex_t open_mutex; // open()/close()操作的互斥锁
|
||||
};
|
@ -30,7 +30,7 @@ long wait_for_completion_interruptible_timeout(struct completion *x, long timeou
|
||||
void wait_for_multicompletion(struct completion x[], int n);
|
||||
bool try_wait_for_completion(struct completion *x);
|
||||
bool completion_done(struct completion *x);
|
||||
|
||||
struct completion *completion_alloc();
|
||||
/**
|
||||
* 测试函数声明 (测试代码辅助函数)
|
||||
*/
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/err.h>
|
||||
#include <common/numa.h>
|
||||
#include <process/proc-types.h>
|
||||
#include <common/err.h>
|
||||
#include <process/process.h>
|
||||
|
||||
/**
|
||||
@ -21,9 +21,7 @@ struct kthread_info_t
|
||||
char *full_name; // 内核线程的名称
|
||||
};
|
||||
|
||||
struct process_control_block *kthread_create_on_node(int (*thread_fn)(void *data),
|
||||
void *data,
|
||||
int node,
|
||||
struct process_control_block *kthread_create_on_node(int (*thread_fn)(void *data), void *data, int node,
|
||||
const char name_fmt[], ...);
|
||||
/**
|
||||
* @brief 在当前结点上创建一个内核线程
|
||||
@ -35,12 +33,12 @@ struct process_control_block *kthread_create_on_node(int (*thread_fn)(void *data
|
||||
*
|
||||
* 请注意,该宏会创建一个内核线程,并将其设置为停止状态
|
||||
*/
|
||||
#define kthread_create(thread_fn, data, name_fmt, arg...) \
|
||||
#define kthread_create(thread_fn, data, name_fmt, arg...) \
|
||||
kthread_create_on_node(thread_fn, data, NUMA_NO_NODE, name_fmt, ##arg)
|
||||
|
||||
/**
|
||||
* @brief 创建内核线程,并将其唤醒
|
||||
*
|
||||
*
|
||||
* @param thread_fn 该内核线程要执行的函数
|
||||
* @param data 传递给 thread_fn 的参数数据
|
||||
* @param name_fmt printf-style format string for the thread name
|
||||
@ -56,32 +54,34 @@ struct process_control_block *kthread_create_on_node(int (*thread_fn)(void *data
|
||||
|
||||
/**
|
||||
* @brief 创建内核实时线程,并将其唤醒
|
||||
*
|
||||
*
|
||||
* @param thread_fn 该内核线程要执行的函数
|
||||
* @param data 传递给 thread_fn 的参数数据
|
||||
* @param name_fmt printf-style format string for the thread name
|
||||
* @param arg name_fmt的参数
|
||||
*/
|
||||
#define kthread_run_rt(thread_fn, data, name_fmt, ...) \
|
||||
({ \
|
||||
struct process_control_block *__kt = kthread_create(thread_fn, data, name_fmt, ##__VA_ARGS__); \
|
||||
__kt=process_init_rt_pcb(__kt); \
|
||||
if (!IS_ERR(__kt)){ \
|
||||
process_wakeup(__kt);} \
|
||||
__kt; \
|
||||
#define kthread_run_rt(thread_fn, data, name_fmt, ...) \
|
||||
({ \
|
||||
struct process_control_block *__kt = kthread_create(thread_fn, data, name_fmt, ##__VA_ARGS__); \
|
||||
__kt = process_init_rt_pcb(__kt); \
|
||||
if (!IS_ERR(__kt)) \
|
||||
{ \
|
||||
process_wakeup(__kt); \
|
||||
} \
|
||||
__kt; \
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief 向kthread发送停止信号,请求其结束
|
||||
*
|
||||
*
|
||||
* @param pcb 内核线程的pcb
|
||||
* @return int 错误码
|
||||
*/
|
||||
int kthread_stop(struct process_control_block * pcb);
|
||||
int kthread_stop(struct process_control_block *pcb);
|
||||
|
||||
/**
|
||||
* @brief 内核线程调用该函数,检查自身的标志位,判断自己是否应该执行完任务后退出
|
||||
*
|
||||
*
|
||||
* @return true 内核线程应该退出
|
||||
* @return false 无需退出
|
||||
*/
|
||||
@ -89,14 +89,14 @@ bool kthread_should_stop(void);
|
||||
|
||||
/**
|
||||
* @brief 让当前内核线程退出,并返回result参数给kthread_stop()函数
|
||||
*
|
||||
*
|
||||
* @param result 返回值
|
||||
*/
|
||||
void kthread_exit(long result);
|
||||
|
||||
/**
|
||||
* @brief 初始化kthread机制(只应被process_init调用)
|
||||
*
|
||||
*
|
||||
* @return int 错误码
|
||||
*/
|
||||
int kthread_mechanism_init();
|
||||
@ -119,7 +119,7 @@ struct kthread_info_t *to_kthread(struct process_control_block *pcb);
|
||||
|
||||
/**
|
||||
* @brief 释放pcb指向的worker private
|
||||
*
|
||||
*
|
||||
* @param pcb 要释放的pcb
|
||||
*/
|
||||
void free_kthread_struct(struct process_control_block *pcb);
|
Reference in New Issue
Block a user