update schedule 09-tuning

This commit is contained in:
Cheng Jian
2019-07-26 16:45:36 +08:00
parent 581411df5f
commit b871dab562
5 changed files with 124 additions and 95 deletions
+4 -1
View File
@@ -13,7 +13,10 @@ MODULE_DESCRIPTION("hello world");
static int hello_init(void)
{
return 0;
set_current_state(TASK_UNINTERRUPTIBLE);
schedule();
return 0;
}
-47
View File
@@ -1,47 +0,0 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
//#include <linux/list.h>
//#include <linux/mm.h>
//#include <linux/mm_types.h>
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Gatieme");
MODULE_DESCRIPTION("hello world");
/*
* print the module information
*/
static void print_module(void)
{
struct module *mod;
printk(KERN_ALERT "this module: %p==%p\n", &__this_module, THIS_MODULE);
printk(KERN_ALERT "module state: %d\n", THIS_MODULE->state);
printk(KERN_ALERT "module name: %s\n", THIS_MODULE->name);
list_for_each_entry(mod, *(&THIS_MODULE->list.prev), list);
printk(KERN_ALERT "module name: %s\n", mod->name);
printk(KERN_ALERT "module state: %d\n", THIS_MODULE->state);
}
static int hello_init(void)
{
print_module();
printk(KERN_ALERT "run in cpu %d\n", get_cpu());
printk(KERN_ALERT "PAGE_OFFSET : 0x%lx, TASK_SIZE : 0x%lx", PAGE_OFFSET,
TASK_SIZE);
return 0;
}
static void hello_exit(void)
{
printk(KERN_ERR "exit");
}
module_init(hello_init);
module_exit(hello_exit);
-47
View File
@@ -1,47 +0,0 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
//#include <linux/list.h>
//#include <linux/mm.h>
//#include <linux/mm_types.h>
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Gatieme");
MODULE_DESCRIPTION("hello world");
/*
* print the module information
*/
static void print_module(void)
{
struct module *mod;
printk(KERN_ALERT "this module: %p==%p\n", &__this_module, THIS_MODULE);
printk(KERN_ALERT "module state: %d\n", THIS_MODULE->state);
printk(KERN_ALERT "module name: %s\n", THIS_MODULE->name);
list_for_each_entry(mod, *(&THIS_MODULE->list.prev), list);
printk(KERN_ALERT "module name: %s\n", mod->name);
printk(KERN_ALERT "module state: %d\n", THIS_MODULE->state);
}
static int hello_init(void)
{
print_module();
printk(KERN_ALERT "run in cpu %d\n", get_cpu());
printk(KERN_ALERT "PAGE_OFFSET : 0x%lx, TASK_SIZE : 0x%lx", PAGE_OFFSET,
TASK_SIZE);
return 0;
}
static void hello_exit(void)
{
printk(KERN_ERR "exit");
}
module_init(hello_init);
module_exit(hello_exit);
@@ -0,0 +1,78 @@
# ------------------------------------------------------------------------------
#
# Makefile for the LDD-LinuxDeviceDrivers.
#
# Author: gatieme
# Create: 2016-07-29 15:50:46
# Last modified: 2016-07-29 16:10:29
# Description:
# This program is loaded as a kernel(v2.6.18 or later) module.
# Use "make install" to load it into kernel.
# Use "make remove" to remove the module out of kernel.
#
# ------------------------------------------------------------------------------
ROOT=..
#PLATFORM=$(shell $(ROOT)/systype.sh)
#include $(ROOT)/Make.defines.$(PLATFORM)
# my driver description
DRIVER_VERSION := "1.0.0"
DRIVER_AUTHOR := "Gatieme @ AderStep Inc..."
DRIVER_DESC := "Linux input module for Elo MultiTouch(MT) devices"
DRIVER_LICENSE := "Dual BSD/GPL"
MODULE_NAME := hello
ifneq ($(KERNELRELEASE),)
#CFG_FLAGS += -O2 -I./
#EXTRA_CFLAGS += $(C_FLAGS) $(CFG_INC) $(CFG_INC)
obj-m := $(MODULE_NAME).o #print_vmarea.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
make -C $(KERNELDIR) M=$(PWD) modules
modules_install:
make -C $(KERNELDIR) M=$(PWD) modules_install
insmod:
sudo insmod $(MODULE_NAME).ko
reinsmod:
sudo rmmod $(MODULE_NAME)
sudo insmod $(MODULE_NAME).ko
github:
cd $(ROOT) && make github
rmmod:
sudo rmmod $(MODULE_NAME)
test :
sudo ../injector/memInjector -l stack -m random -t word_0 --time 1 --timeout 3 -p 1
clean:
make -C $(KERNELDIR) M=$(PWD) clean
rm -f modules.order Module.symvers Module.markers
.PHNOY:
modules modules_install clean
endif
@@ -0,0 +1,42 @@
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <asm/uaccess.h>
#include <linux/irq_work.h>
DEFINE_SPINLOCK(lock);
static void scheduling(struct irq_work *work)
{
schedule();
}
DEFINE_IRQ_WORK(irq_work, scheduling);
static int __init hello_init(void)
{
irq_work_queue(&irq_work);
return 0;
}
module_init(hello_init);
static void __exit hello_exit(void)
{
}
module_exit(hello_exit);
/* Driver Information */
#define DRIVER_VERSION "1.0.0"
#define DRIVER_AUTHOR "Gatieme @ AderStep Inc..."
#define DRIVER_DESC "Linux input module for Elo MultiTouch(MT) devices"
#define DRIVER_LICENSE "Dual BSD/GPL"
/* Kernel Module Information */
MODULE_VERSION(DRIVER_VERSION);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE(DRIVER_LICENSE);