diff options
| author | franciscofranco <franciscofranco.1990@gmail.com> | 2015-12-05 04:01:17 +0000 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-12-25 16:11:14 +0100 |
| commit | 2d6a958ab8f0aaa9c20738a0ac22ba94ae000362 (patch) | |
| tree | 1c2fafd423477f54ef91480567b8937d9a5215dc /kernel | |
| parent | e5a41b03c4e0a299623929f41a3a1e17fa82076a (diff) | |
arm64: use the new *_relaxed macros for lower power usage
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Joe Maples <joe@frap129.org>
Signed-off-by: Mister Oyster <oysterized@gmail.com>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/cpuset.c | 6 | ||||
| -rw-r--r-- | kernel/freezer.c | 2 | ||||
| -rw-r--r-- | kernel/irq_work.c | 4 | ||||
| -rw-r--r-- | kernel/mutex.c | 8 | ||||
| -rw-r--r-- | kernel/sched/core.c | 13 | ||||
| -rw-r--r-- | kernel/smp.c | 5 |
6 files changed, 20 insertions, 18 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 66a980fcf..d384b9d21 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c @@ -973,7 +973,7 @@ static void cpuset_change_task_nodemask(struct task_struct *tsk, * Allow tasks that have access to memory reserves because they have * been OOM killed to get memory anywhere. */ - if (unlikely(test_thread_flag(TIF_MEMDIE))) + if (unlikely(test_thread_flag_relaxed(TIF_MEMDIE))) return; if (current->flags & PF_EXITING) /* Let dying task have memory */ return; @@ -2451,7 +2451,7 @@ int __cpuset_node_allowed_softwall(int node, gfp_t gfp_mask) * Allow tasks that have access to memory reserves because they have * been OOM killed to get memory anywhere. */ - if (unlikely(test_thread_flag(TIF_MEMDIE))) + if (unlikely(test_thread_flag_relaxed(TIF_MEMDIE))) return 1; if (gfp_mask & __GFP_HARDWALL) /* If hardwall request, stop here */ return 0; @@ -2504,7 +2504,7 @@ int __cpuset_node_allowed_hardwall(int node, gfp_t gfp_mask) * Allow tasks that have access to memory reserves because they have * been OOM killed to get memory anywhere. */ - if (unlikely(test_thread_flag(TIF_MEMDIE))) + if (unlikely(test_thread_flag_relaxed(TIF_MEMDIE))) return 1; return 0; } diff --git a/kernel/freezer.c b/kernel/freezer.c index 4ada72f5f..adf590772 100644 --- a/kernel/freezer.c +++ b/kernel/freezer.c @@ -42,7 +42,7 @@ bool freezing_slow_path(struct task_struct *p) if (p->flags & PF_NOFREEZE) return false; - if (test_thread_flag(TIF_MEMDIE)) + if (test_thread_flag_relaxed(TIF_MEMDIE)) return false; if (pm_nosig_freezing || cgroup_freezing(p)) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index 55fcce606..4bcbeafc6 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -91,7 +91,7 @@ bool irq_work_needs_cpu(void) struct llist_head *this_list; this_list = &__get_cpu_var(irq_work_list); - if (llist_empty(this_list)) + if (llist_empty_relaxed(this_list)) return false; /* All work should have been flushed before going offline */ @@ -116,7 +116,7 @@ static void __irq_work_run(void) barrier(); this_list = &__get_cpu_var(irq_work_list); - if (llist_empty(this_list)) + if (llist_empty_relaxed(this_list)) return; BUG_ON(!irqs_disabled()); diff --git a/kernel/mutex.c b/kernel/mutex.c index d77807b1e..9d953374e 100644 --- a/kernel/mutex.c +++ b/kernel/mutex.c @@ -143,8 +143,8 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node) ACCESS_ONCE(prev->next) = node; smp_wmb(); /* Wait until the lock holder passes the lock down */ - while (!ACCESS_ONCE(node->locked)) - arch_mutex_cpu_relax(); + while (!cpu_relaxed_read(&(node->locked))) + cpu_read_relax(); } static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node) @@ -158,8 +158,8 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node) if (cmpxchg(lock, node, NULL) == node) return; /* Wait until the next pointer is set */ - while (!(next = ACCESS_ONCE(node->next))) - arch_mutex_cpu_relax(); + while (!(next = (struct mspin_node*)(cpu_relaxed_read_long(&(node->next))))) + cpu_read_relax(); } ACCESS_ONCE(next->locked) = 1; smp_wmb(); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index c6d3219b1..265f8359e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1271,9 +1271,10 @@ unsigned long wait_task_inactive(struct task_struct *p, long match_state) * is actually now running somewhere else! */ while (task_running(rq, p)) { - if (match_state && unlikely(p->state != match_state)) + if (match_state && unlikely(cpu_relaxed_read_long + (&(p->state)) != match_state)) return 0; - cpu_relax(); + cpu_read_relax(); } /* @@ -1603,7 +1604,7 @@ enum ipi_msg_type { }; void scheduler_ipi(void) { - if (llist_empty(&this_rq()->wake_list) + if (llist_empty_relaxed(&this_rq()->wake_list) && !tick_nohz_full_cpu(smp_processor_id()) && !got_nohz_idle_kick()){ mt_trace_ISR_start(IPI_RESCHEDULE); @@ -1753,8 +1754,8 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) * If the owning (remote) cpu is still in the middle of schedule() with * this task as prev, wait until its done referencing the task. */ - while (p->on_cpu) - cpu_relax(); + while (cpu_relaxed_read(&(p->on_cpu))) + cpu_read_relax(); /* * Pairs with the smp_wmb() in finish_lock_switch(). */ @@ -4261,7 +4262,7 @@ int idle_cpu(int cpu) return 0; #ifdef CONFIG_SMP - if (!llist_empty(&rq->wake_list)) + if (!llist_empty_relaxed(&rq->wake_list)) return 0; #endif diff --git a/kernel/smp.c b/kernel/smp.c index 87f82e6cc..d02575408 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -12,6 +12,7 @@ #include <linux/gfp.h> #include <linux/smp.h> #include <linux/cpu.h> +#include <asm/relaxed.h> #include "smpboot.h" @@ -101,8 +102,8 @@ void __init call_function_init(void) */ static void csd_lock_wait(struct call_single_data *csd) { - while (csd->flags & CSD_FLAG_LOCK) - cpu_relax(); + while (cpu_relaxed_read_short(&csd->flags) & CSD_FLAG_LOCK) + cpu_read_relax(); } static void csd_lock(struct call_single_data *csd) |
