Modify p_text_section_(un)lock API

Move 'module_mutex' under text section (un)lock API.
This commit is contained in:
Adam_pi3 2020-10-26 23:02:12 -04:00
parent cb882e83a7
commit f9f215d17b
No known key found for this signature in database
GPG key ID: 7C0A38B52323F571
5 changed files with 4 additions and 42 deletions

View file

@ -140,9 +140,6 @@ int p_cpu_online_action(unsigned int p_cpu) {
int tmp_online_CPUs = p_db.p_cpu.online_CPUs;
p_text_section_lock();
/* We are heavily consuming module list here - take 'module_mutex' */
mutex_lock(&module_mutex);
spin_lock(&p_db_lock);
smp_call_function_single(p_cpu,p_dump_CPU_metadata,p_db.p_CPU_metadata_array,true);
@ -198,8 +195,6 @@ int p_cpu_online_action(unsigned int p_cpu) {
/* God mode off ;) */
// spin_unlock_irqrestore(&p_db_lock,p_db_flags);
spin_unlock(&p_db_lock);
/* Release the 'module_mutex' */
mutex_unlock(&module_mutex);
p_text_section_unlock();
return 0x0;
@ -210,9 +205,6 @@ int p_cpu_dead_action(unsigned int p_cpu) {
int tmp_online_CPUs = p_db.p_cpu.online_CPUs;
p_text_section_lock();
/* We are heavily consuming module list here - take 'module_mutex' */
mutex_lock(&module_mutex);
spin_lock(&p_db_lock);
p_db.p_CPU_metadata_array[p_cpu].p_cpu_online = P_CPU_OFFLINE;
@ -276,8 +268,6 @@ int p_cpu_dead_action(unsigned int p_cpu) {
/* God mode off ;) */
// spin_unlock_irqrestore(&p_db_lock,p_db_flags);
spin_unlock(&p_db_lock);
/* Release the 'module_mutex' */
mutex_unlock(&module_mutex);
p_text_section_unlock();
return 0x0;

View file

@ -173,10 +173,14 @@ int hash_from_iommu_table(void);
static inline void p_text_section_lock(void) {
mutex_lock(P_SYM(p_text_mutex));
/* We are heavily consuming module list here - take 'module_mutex' */
mutex_lock(&module_mutex);
}
static inline void p_text_section_unlock(void) {
/* Release the 'module_mutex' */
mutex_unlock(&module_mutex);
mutex_unlock(P_SYM(p_text_mutex));
}

View file

@ -213,9 +213,6 @@ void p_check_integrity(struct work_struct *p_work) {
p_text_section_lock();
/* We are heavily consuming module list here - take 'module_mutex' */
mutex_lock(&module_mutex);
/*
* Memory allocation may fail... let's loop here!
*/
@ -231,8 +228,6 @@ void p_check_integrity(struct work_struct *p_work) {
schedule();
}
/*
* Release the 'module_mutex' *
mutex_unlock(&module_mutex);
p_text_section_unlock();
*/
@ -1776,8 +1771,6 @@ void p_check_integrity(struct work_struct *p_work) {
p_check_integrity_cancel:
/* Release the 'module_mutex' */
mutex_unlock(&module_mutex);
p_text_section_unlock();
if (p_tmp_cpus) {
kzfree(p_tmp_cpus);

View file

@ -94,7 +94,6 @@ static unsigned int p_count_modules_from_module_list(void) {
unsigned int p_cnt = 0x0;
struct module *p_mod;
// mutex_lock(&module_mutex);
list_for_each_entry(p_mod, P_SYM(p_global_modules), list) {
/*
@ -115,7 +114,6 @@ static unsigned int p_count_modules_from_module_list(void) {
p_cnt++;
}
// mutex_unlock(&module_mutex);
return p_cnt;
}
@ -130,7 +128,6 @@ static int p_list_from_module_list(p_module_list_mem *p_arg, char p_flag) {
struct module *p_mod;
unsigned int p_cnt = 0x0;
// mutex_lock(&module_mutex);
list_for_each_entry(p_mod, P_SYM(p_global_modules), list) {
/*
if (p_mod->state >= MODULE_STATE_UNFORMED ||
@ -173,7 +170,6 @@ static int p_list_from_module_list(p_module_list_mem *p_arg, char p_flag) {
p_cnt++;
}
// mutex_unlock(&module_mutex);
return P_LKRG_SUCCESS;
}

View file

@ -108,17 +108,7 @@ static int p_module_event_notifier(struct notifier_block *p_this, unsigned long
* We must keep in track that information ;)
*/
p_module_event_notifier_going_retry:
p_text_section_lock();
/* We are heavily consuming module list here - take 'module_mutex' */
// mutex_lock(&module_mutex);
while (!mutex_trylock(&module_mutex)) {
p_text_section_unlock();
schedule();
goto p_module_event_notifier_going_retry;
}
/*
* First, synchronize possible database changes with other LKRG components...
* We want to be as fast as possible to get this lock! :)
@ -187,16 +177,7 @@ p_module_event_notifier_going_retry:
* and recalculate global module hashes...
*/
p_module_event_notifier_live_retry:
p_text_section_lock();
/* We are heavily consuming module list here - take 'module_mutex' */
//mutex_lock(&module_mutex);
while (!mutex_trylock(&module_mutex)) {
p_text_section_unlock();
schedule();
goto p_module_event_notifier_live_retry;
}
/*
* First, synchronize possible database changes with other LKRG components...
@ -250,8 +231,6 @@ p_module_event_notifier_unlock_out:
/* God mode off ;) */
// spin_unlock_irqrestore(&p_db_lock,p_db_flags);
spin_unlock(&p_db_lock);
/* Release the 'module_mutex' */
mutex_unlock(&module_mutex);
p_text_section_unlock();
p_module_event_notifier_activity_out: