diff options
author | Ingo Molnar <mingo@kernel.org> | 2019-06-03 05:50:18 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2019-06-03 05:50:18 -0400 |
commit | 26b73da3604cc1a6596406d136b14d1a01c3676f (patch) | |
tree | c7839809e35fce4868910742157e8ef96782b378 /kernel/locking | |
parent | 5ca584d935c32906d114924dc0e1dbfcbb13fdb2 (diff) | |
parent | f2c7c76c5d0a443053e94adb9f0918fa2fb85c3a (diff) |
Merge tag 'v5.2-rc3' into locking/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/locking')
-rw-r--r-- | kernel/locking/lock_events.h | 42 | ||||
-rw-r--r-- | kernel/locking/qrwlock.c | 11 | ||||
-rw-r--r-- | kernel/locking/qspinlock.c | 11 | ||||
-rw-r--r-- | kernel/locking/qspinlock_stat.h | 10 |
4 files changed, 43 insertions, 31 deletions
diff --git a/kernel/locking/lock_events.h b/kernel/locking/lock_events.h index feb1acc54611..46b71af8eef2 100644 --- a/kernel/locking/lock_events.h +++ b/kernel/locking/lock_events.h | |||
@@ -31,12 +31,50 @@ enum lock_events { | |||
31 | DECLARE_PER_CPU(unsigned long, lockevents[lockevent_num]); | 31 | DECLARE_PER_CPU(unsigned long, lockevents[lockevent_num]); |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * The purpose of the lock event counting subsystem is to provide a low | ||
35 | * overhead way to record the number of specific locking events by using | ||
36 | * percpu counters. It is the percpu sum that matters, not specifically | ||
37 | * how many of them happens in each cpu. | ||
38 | * | ||
39 | * It is possible that the same percpu counter may be modified in both | ||
40 | * the process and interrupt contexts. For architectures that perform | ||
41 | * percpu operation with multiple instructions, it is possible to lose | ||
42 | * count if a process context percpu update is interrupted in the middle | ||
43 | * and the same counter is updated in the interrupt context. Therefore, | ||
44 | * the generated percpu sum may not be precise. The error, if any, should | ||
45 | * be small and insignificant. | ||
46 | * | ||
47 | * For those architectures that do multi-instruction percpu operation, | ||
48 | * preemption in the middle and moving the task to another cpu may cause | ||
49 | * a larger error in the count. Again, this will be few and far between. | ||
50 | * Given the imprecise nature of the count and the possibility of resetting | ||
51 | * the count and doing the measurement again, this is not really a big | ||
52 | * problem. | ||
53 | * | ||
54 | * To get a better picture of what is happening under the hood, it is | ||
55 | * suggested that a few measurements should be taken with the counts | ||
56 | * reset in between to stamp out outliner because of these possible | ||
57 | * error conditions. | ||
58 | * | ||
59 | * To minimize overhead, we use __this_cpu_*() in all cases except when | ||
60 | * CONFIG_DEBUG_PREEMPT is defined. In this particular case, this_cpu_*() | ||
61 | * will be used to avoid the appearance of unwanted BUG messages. | ||
62 | */ | ||
63 | #ifdef CONFIG_DEBUG_PREEMPT | ||
64 | #define lockevent_percpu_inc(x) this_cpu_inc(x) | ||
65 | #define lockevent_percpu_add(x, v) this_cpu_add(x, v) | ||
66 | #else | ||
67 | #define lockevent_percpu_inc(x) __this_cpu_inc(x) | ||
68 | #define lockevent_percpu_add(x, v) __this_cpu_add(x, v) | ||
69 | #endif | ||
70 | |||
71 | /* | ||
34 | * Increment the PV qspinlock statistical counters | 72 | * Increment the PV qspinlock statistical counters |
35 | */ | 73 | */ |
36 | static inline void __lockevent_inc(enum lock_events event, bool cond) | 74 | static inline void __lockevent_inc(enum lock_events event, bool cond) |
37 | { | 75 | { |
38 | if (cond) | 76 | if (cond) |
39 | __this_cpu_inc(lockevents[event]); | 77 | lockevent_percpu_inc(lockevents[event]); |
40 | } | 78 | } |
41 | 79 | ||
42 | #define lockevent_inc(ev) __lockevent_inc(LOCKEVENT_ ##ev, true) | 80 | #define lockevent_inc(ev) __lockevent_inc(LOCKEVENT_ ##ev, true) |
@@ -44,7 +82,7 @@ static inline void __lockevent_inc(enum lock_events event, bool cond) | |||
44 | 82 | ||
45 | static inline void __lockevent_add(enum lock_events event, int inc) | 83 | static inline void __lockevent_add(enum lock_events event, int inc) |
46 | { | 84 | { |
47 | __this_cpu_add(lockevents[event], inc); | 85 | lockevent_percpu_add(lockevents[event], inc); |
48 | } | 86 | } |
49 | 87 | ||
50 | #define lockevent_add(ev, c) __lockevent_add(LOCKEVENT_ ##ev, c) | 88 | #define lockevent_add(ev, c) __lockevent_add(LOCKEVENT_ ##ev, c) |
diff --git a/kernel/locking/qrwlock.c b/kernel/locking/qrwlock.c index c7471c3fb798..fe9ca92faa2a 100644 --- a/kernel/locking/qrwlock.c +++ b/kernel/locking/qrwlock.c | |||
@@ -1,16 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * Queued read/write locks | 3 | * Queued read/write locks |
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P. | 5 | * (C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P. |
15 | * | 6 | * |
16 | * Authors: Waiman Long <waiman.long@hp.com> | 7 | * Authors: Waiman Long <waiman.long@hp.com> |
diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c index e14b32c69639..2473f10c6956 100644 --- a/kernel/locking/qspinlock.c +++ b/kernel/locking/qspinlock.c | |||
@@ -1,16 +1,7 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
1 | /* | 2 | /* |
2 | * Queued spinlock | 3 | * Queued spinlock |
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P. | 5 | * (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P. |
15 | * (C) Copyright 2013-2014,2018 Red Hat, Inc. | 6 | * (C) Copyright 2013-2014,2018 Red Hat, Inc. |
16 | * (C) Copyright 2015 Intel Corp. | 7 | * (C) Copyright 2015 Intel Corp. |
diff --git a/kernel/locking/qspinlock_stat.h b/kernel/locking/qspinlock_stat.h index 54152670ff24..e625bb410aa2 100644 --- a/kernel/locking/qspinlock_stat.h +++ b/kernel/locking/qspinlock_stat.h | |||
@@ -1,13 +1,5 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
1 | /* | 2 | /* |
2 | * This program is free software; you can redistribute it and/or modify | ||
3 | * it under the terms of the GNU General Public License as published by | ||
4 | * the Free Software Foundation; either version 2 of the License, or | ||
5 | * (at your option) any later version. | ||
6 | * | ||
7 | * This program is distributed in the hope that it will be useful, | ||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
10 | * GNU General Public License for more details. | ||
11 | * | 3 | * |
12 | * Authors: Waiman Long <longman@redhat.com> | 4 | * Authors: Waiman Long <longman@redhat.com> |
13 | */ | 5 | */ |