From 5c12e9a3091a25046c577e551c7b50bf68604b45 Mon Sep 17 00:00:00 2001 From: Alfred Chen Date: Wed, 30 Oct 2024 14:53:40 +0000 Subject: [PATCH] sched/alt: Simpifly migrate_enable/disable design. Simpifly Project C task migrate_enable/disable design by removing migration_flags and unused migration_pending in task structure. --- include/linux/sched.h | 4 ++++ kernel/sched/alt_core.c | 12 ------------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 324ba63e8b7a57..57f4c6375196e9 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -872,11 +872,15 @@ struct task_struct { const cpumask_t *cpus_ptr; cpumask_t *user_cpus_ptr; cpumask_t cpus_mask; +#ifndef CONFIG_SCHED_ALT void *migration_pending; +#endif #ifdef CONFIG_SMP unsigned short migration_disabled; #endif +#ifndef CONFIG_SCHED_ALT unsigned short migration_flags; +#endif #ifdef CONFIG_PREEMPT_RCU int rcu_read_lock_nesting; diff --git a/kernel/sched/alt_core.c b/kernel/sched/alt_core.c index 81f22c061bae30..492b6dbfd418b8 100644 --- a/kernel/sched/alt_core.c +++ b/kernel/sched/alt_core.c @@ -1438,8 +1438,6 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu) __set_task_cpu(p, new_cpu); } -#define MDF_FORCE_ENABLED 0x80 - static void __do_set_cpus_ptr(struct task_struct *p, const struct cpumask *new_mask) { @@ -1474,8 +1472,6 @@ void migrate_disable(void) if (cpumask_test_cpu(cpu, &p->cpus_mask)) { cpu_rq(cpu)->nr_pinned++; p->migration_disabled = 1; - p->migration_flags &= ~MDF_FORCE_ENABLED; - /* * Violates locking rules! see comment in __do_set_cpus_ptr(). */ @@ -1505,10 +1501,6 @@ void migrate_enable(void) * __set_cpus_allowed_ptr(SCA_MIGRATE_ENABLE) doesn't schedule(). */ guard(preempt)(); - /* - * Assumption: current should be running on allowed cpu - */ - WARN_ON_ONCE(!cpumask_test_cpu(smp_processor_id(), &p->cpus_mask)); if (p->cpus_ptr != &p->cpus_mask) __do_set_cpus_ptr(p, &p->cpus_mask); /* @@ -2004,7 +1996,6 @@ static int affine_move_task(struct rq *rq, struct task_struct *p, int dest_cpu, if (likely(p->cpus_ptr != &p->cpus_mask)) __do_set_cpus_ptr(p, &p->cpus_mask); p->migration_disabled = 0; - p->migration_flags |= MDF_FORCE_ENABLED; /* When p is migrate_disabled, rq->lock should be held */ rq->nr_pinned--; } @@ -6461,9 +6452,6 @@ void __cant_migrate(const char *file, int line) if (preempt_count() > 0) return; - if (current->migration_flags & MDF_FORCE_ENABLED) - return; - if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy) return; prev_jiffy = jiffies;