aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/futex.c69
-rw-r--r--kernel/locking/lockdep.c7
2 files changed, 41 insertions, 35 deletions
diff --git a/kernel/futex.c b/kernel/futex.c
index 4b5b468c58b6..6d50728ef2e7 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -471,6 +471,37 @@ enum futex_access {
471}; 471};
472 472
473/** 473/**
474 * futex_setup_timer - set up the sleeping hrtimer.
475 * @time: ptr to the given timeout value
476 * @timeout: the hrtimer_sleeper structure to be set up
477 * @flags: futex flags
478 * @range_ns: optional range in ns
479 *
480 * Return: Initialized hrtimer_sleeper structure or NULL if no timeout
481 * value given
482 */
483static inline struct hrtimer_sleeper *
484futex_setup_timer(ktime_t *time, struct hrtimer_sleeper *timeout,
485 int flags, u64 range_ns)
486{
487 if (!time)
488 return NULL;
489
490 hrtimer_init_on_stack(&timeout->timer, (flags & FLAGS_CLOCKRT) ?
491 CLOCK_REALTIME : CLOCK_MONOTONIC,
492 HRTIMER_MODE_ABS);
493 hrtimer_init_sleeper(timeout, current);
494
495 /*
496 * If range_ns is 0, calling hrtimer_set_expires_range_ns() is
497 * effectively the same as calling hrtimer_set_expires().
498 */
499 hrtimer_set_expires_range_ns(&timeout->timer, *time, range_ns);
500
501 return timeout;
502}
503
504/**
474 * get_futex_key() - Get parameters which are the keys for a futex 505 * get_futex_key() - Get parameters which are the keys for a futex
475 * @uaddr: virtual address of the futex 506 * @uaddr: virtual address of the futex
476 * @fshared: 0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED 507 * @fshared: 0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED
@@ -2679,7 +2710,7 @@ out:
2679static int futex_wait(u32 __user *uaddr, unsigned int flags, u32 val, 2710static int futex_wait(u32 __user *uaddr, unsigned int flags, u32 val,
2680 ktime_t *abs_time, u32 bitset) 2711 ktime_t *abs_time, u32 bitset)
2681{ 2712{
2682 struct hrtimer_sleeper timeout, *to = NULL; 2713 struct hrtimer_sleeper timeout, *to;
2683 struct restart_block *restart; 2714 struct restart_block *restart;
2684 struct futex_hash_bucket *hb; 2715 struct futex_hash_bucket *hb;
2685 struct futex_q q = futex_q_init; 2716 struct futex_q q = futex_q_init;
@@ -2689,17 +2720,8 @@ static int futex_wait(u32 __user *uaddr, unsigned int flags, u32 val,
2689 return -EINVAL; 2720 return -EINVAL;
2690 q.bitset = bitset; 2721 q.bitset = bitset;
2691 2722
2692 if (abs_time) { 2723 to = futex_setup_timer(abs_time, &timeout, flags,
2693 to = &timeout; 2724 current->timer_slack_ns);
2694
2695 hrtimer_init_on_stack(&to->timer, (flags & FLAGS_CLOCKRT) ?
2696 CLOCK_REALTIME : CLOCK_MONOTONIC,
2697 HRTIMER_MODE_ABS);
2698 hrtimer_init_sleeper(to, current);
2699 hrtimer_set_expires_range_ns(&to->timer, *abs_time,
2700 current->timer_slack_ns);
2701 }
2702
2703retry: 2725retry:
2704 /* 2726 /*
2705 * Prepare to wait on uaddr. On success, holds hb lock and increments 2727 * Prepare to wait on uaddr. On success, holds hb lock and increments
@@ -2779,7 +2801,7 @@ static long futex_wait_restart(struct restart_block *restart)
2779static int futex_lock_pi(u32 __user *uaddr, unsigned int flags, 2801static int futex_lock_pi(u32 __user *uaddr, unsigned int flags,
2780 ktime_t *time, int trylock) 2802 ktime_t *time, int trylock)
2781{ 2803{
2782 struct hrtimer_sleeper timeout, *to = NULL; 2804 struct hrtimer_sleeper timeout, *to;
2783 struct futex_pi_state *pi_state = NULL; 2805 struct futex_pi_state *pi_state = NULL;
2784 struct rt_mutex_waiter rt_waiter; 2806 struct rt_mutex_waiter rt_waiter;
2785 struct futex_hash_bucket *hb; 2807 struct futex_hash_bucket *hb;
@@ -2792,13 +2814,7 @@ static int futex_lock_pi(u32 __user *uaddr, unsigned int flags,
2792 if (refill_pi_state_cache()) 2814 if (refill_pi_state_cache())
2793 return -ENOMEM; 2815 return -ENOMEM;
2794 2816
2795 if (time) { 2817 to = futex_setup_timer(time, &timeout, FLAGS_CLOCKRT, 0);
2796 to = &timeout;
2797 hrtimer_init_on_stack(&to->timer, CLOCK_REALTIME,
2798 HRTIMER_MODE_ABS);
2799 hrtimer_init_sleeper(to, current);
2800 hrtimer_set_expires(&to->timer, *time);
2801 }
2802 2818
2803retry: 2819retry:
2804 ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q.key, FUTEX_WRITE); 2820 ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q.key, FUTEX_WRITE);
@@ -3195,7 +3211,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
3195 u32 val, ktime_t *abs_time, u32 bitset, 3211 u32 val, ktime_t *abs_time, u32 bitset,
3196 u32 __user *uaddr2) 3212 u32 __user *uaddr2)
3197{ 3213{
3198 struct hrtimer_sleeper timeout, *to = NULL; 3214 struct hrtimer_sleeper timeout, *to;
3199 struct futex_pi_state *pi_state = NULL; 3215 struct futex_pi_state *pi_state = NULL;
3200 struct rt_mutex_waiter rt_waiter; 3216 struct rt_mutex_waiter rt_waiter;
3201 struct futex_hash_bucket *hb; 3217 struct futex_hash_bucket *hb;
@@ -3212,15 +3228,8 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,
3212 if (!bitset) 3228 if (!bitset)
3213 return -EINVAL; 3229 return -EINVAL;
3214 3230
3215 if (abs_time) { 3231 to = futex_setup_timer(abs_time, &timeout, flags,
3216 to = &timeout; 3232 current->timer_slack_ns);
3217 hrtimer_init_on_stack(&to->timer, (flags & FLAGS_CLOCKRT) ?
3218 CLOCK_REALTIME : CLOCK_MONOTONIC,
3219 HRTIMER_MODE_ABS);
3220 hrtimer_init_sleeper(to, current);
3221 hrtimer_set_expires_range_ns(&to->timer, *abs_time,
3222 current->timer_slack_ns);
3223 }
3224 3233
3225 /* 3234 /*
3226 * The waiter is allocated on our stack, manipulated by the requeue 3235 * The waiter is allocated on our stack, manipulated by the requeue
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index c47788fa85f9..8d32ae7768a7 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -732,7 +732,8 @@ look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)
732 * Huh! same key, different name? Did someone trample 732 * Huh! same key, different name? Did someone trample
733 * on some memory? We're most confused. 733 * on some memory? We're most confused.
734 */ 734 */
735 WARN_ON_ONCE(class->name != lock->name); 735 WARN_ON_ONCE(class->name != lock->name &&
736 lock->key != &__lockdep_no_validate__);
736 return class; 737 return class;
737 } 738 }
738 } 739 }
@@ -2817,10 +2818,6 @@ static inline int validate_chain(struct task_struct *curr,
2817{ 2818{
2818 return 1; 2819 return 1;
2819} 2820}
2820
2821static void print_lock_trace(struct lock_trace *trace, unsigned int spaces)
2822{
2823}
2824#endif 2821#endif
2825 2822
2826/* 2823/*