lx_emul: update to linux kernel 5.14 as default

Until now, the lx_emul layer addressed a 5.11 Linux Kernel port,
now that we add new architectures it is better to update the default version
first. There are especially changes in the task_struct code,
and the signature of some functions in the paging subsystem changed.

Ref 
This commit is contained in:
Stefan Kalkowski 2022-01-07 17:10:43 +01:00 committed by Norman Feske
parent 742c40a60a
commit d7963be212
6 changed files with 42 additions and 25 deletions
repos/dde_linux/src/lib/lx_emul

@ -13,6 +13,7 @@
#include <linux/clockchips.h>
#include <linux/clocksource.h>
#include <linux/timecounter.h>
#include <linux/sched_clock.h>
#include <linux/smp.h>
#include <linux/of_clk.h>

@ -191,7 +191,7 @@ int lx_emul_irq_task_function(void * data)
struct task_struct irq_task = {
.state = 0,
.__state = 0,
.usage = REFCOUNT_INIT(2),
.flags = PF_KTHREAD,
.prio = MAX_PRIO - 20,

@ -32,7 +32,7 @@ pid_t kernel_thread(int (* fn)(void *),void * arg,unsigned long flags)
struct task_struct * task = kmalloc(sizeof(struct task_struct), GFP_KERNEL);
*task = (struct task_struct) {
.state = 0,
.__state = 0,
.usage = REFCOUNT_INIT(2),
.flags = PF_KTHREAD,
.prio = MAX_PRIO - 20,

@ -35,7 +35,7 @@ struct rq runqueues;
/*
* Type changes between kernel versions
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,14,1)
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)
typedef unsigned long nr_iowait_cpu_return_t;
typedef long wait_task_inactive_match_state_t;
#else
@ -53,24 +53,17 @@ void set_user_nice(struct task_struct * p, long nice)
}
int set_cpus_allowed_ptr(struct task_struct * p,
const struct cpumask * new_mask)
{
return 0;
}
static int
try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
{
if (!p) lx_emul_trace_and_stop(__func__);
if (!(p->state & state))
if (!(p->__state & state))
return 0;
if (p != lx_emul_task_get_current())
lx_emul_task_unblock(p);
p->state = TASK_RUNNING;
p->__state = TASK_RUNNING;
return 1;
}
@ -97,14 +90,14 @@ static void __schedule(void)
lx_emul_trace_and_stop("abort");
}
lx_emul_task_schedule(current->state != TASK_RUNNING);
lx_emul_task_schedule(current->__state != TASK_RUNNING);
}
#include "../kernel/workqueue_internal.h"
asmlinkage __visible void __sched schedule(void)
{
if (current->state) {
if (current->__state) {
unsigned int task_flags = current->flags;
if (task_flags & PF_WQ_WORKER) {
tick_nohz_idle_enter();
@ -169,7 +162,7 @@ void scheduler_tick(void)
void __sched schedule_preempt_disabled(void)
{
lx_emul_task_schedule(current->state != TASK_RUNNING);
lx_emul_task_schedule(current->__state != TASK_RUNNING);
}
@ -180,6 +173,16 @@ int sched_setscheduler_nocheck(struct task_struct * p, int policy,
}
int wake_up_state(struct task_struct * p, unsigned int state)
{
p->__state = TASK_RUNNING;
lx_emul_task_unblock(p);
return 0;
}
#ifdef CONFIG_SMP
unsigned long wait_task_inactive(struct task_struct * p,
wait_task_inactive_match_state_t match_state)
{
@ -195,15 +198,13 @@ unsigned long wait_task_inactive(struct task_struct * p,
}
int wake_up_state(struct task_struct * p, unsigned int state)
int set_cpus_allowed_ptr(struct task_struct * p,
const struct cpumask * new_mask)
{
p->state = TASK_RUNNING;
lx_emul_task_unblock(p);
return 0;
}
#ifdef CONFIG_SMP
#ifdef CONFIG_NO_HZ_COMMON
int get_nohz_timer_target(void)

@ -14,13 +14,28 @@
#include <linux/gfp.h>
#include <lx_emul/page_virt.h>
struct page * __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
int preferred_nid, nodemask_t * nodemask)
unsigned long __alloc_pages_bulk(gfp_t gfp,int preferred_nid,
nodemask_t * nodemask, int nr_pages,
struct list_head * page_list, struct page ** page_array)
{
unsigned const num_pages = (1 << order);
void * const ptr = lx_emul_mem_alloc_aligned(PAGE_SIZE*num_pages, PAGE_SIZE);
if (page_list)
lx_emul_trace_and_stop("__alloc_pages_bulk unsupported argument");
return lx_emul_virt_to_pages(ptr, num_pages);
{
void const *ptr = lx_emul_mem_alloc_aligned(PAGE_SIZE*nr_pages, PAGE_SIZE);
struct page *page = lx_emul_virt_to_pages(ptr, nr_pages);
int i;
for (i = 0; i < nr_pages; i++) {
if (page_array[i])
lx_emul_trace_and_stop("__alloc_pages_bulk: page_array entry not null");
page_array[i] = page + i;
}
}
return nr_pages;
}

@ -135,7 +135,7 @@ int lx_emul_init_task_function(void * dtb)
struct task_struct init_task = {
.state = 0,
.__state = 0,
.usage = REFCOUNT_INIT(2),
.flags = PF_KTHREAD,
.prio = MAX_PRIO - 20,