Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linux
linux-davinci
Commits
609368d8
Commit
609368d8
authored
Jul 25, 2009
by
Thomas Gleixner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
percpu_counter: Convert to atomic_spinlock
Signed-off-by:
Thomas Gleixner
<
tglx@linutronix.de
>
parent
0ef0a8e3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
include/linux/percpu_counter.h
include/linux/percpu_counter.h
+1
-1
lib/percpu_counter.c
lib/percpu_counter.c
+9
-9
No files found.
include/linux/percpu_counter.h
View file @
609368d8
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#ifdef CONFIG_SMP
#ifdef CONFIG_SMP
struct
percpu_counter
{
struct
percpu_counter
{
spinlock_t
lock
;
atomic_
spinlock_t
lock
;
s64
count
;
s64
count
;
#ifdef CONFIG_HOTPLUG_CPU
#ifdef CONFIG_HOTPLUG_CPU
struct
list_head
list
;
/* All percpu_counters are on a list */
struct
list_head
list
;
/* All percpu_counters are on a list */
...
...
lib/percpu_counter.c
View file @
609368d8
...
@@ -16,13 +16,13 @@ void percpu_counter_set(struct percpu_counter *fbc, s64 amount)
...
@@ -16,13 +16,13 @@ void percpu_counter_set(struct percpu_counter *fbc, s64 amount)
{
{
int
cpu
;
int
cpu
;
spin_lock
(
&
fbc
->
lock
);
atomic_
spin_lock
(
&
fbc
->
lock
);
for_each_possible_cpu
(
cpu
)
{
for_each_possible_cpu
(
cpu
)
{
s32
*
pcount
=
per_cpu_ptr
(
fbc
->
counters
,
cpu
);
s32
*
pcount
=
per_cpu_ptr
(
fbc
->
counters
,
cpu
);
*
pcount
=
0
;
*
pcount
=
0
;
}
}
fbc
->
count
=
amount
;
fbc
->
count
=
amount
;
spin_unlock
(
&
fbc
->
lock
);
atomic_
spin_unlock
(
&
fbc
->
lock
);
}
}
EXPORT_SYMBOL
(
percpu_counter_set
);
EXPORT_SYMBOL
(
percpu_counter_set
);
...
@@ -35,10 +35,10 @@ void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
...
@@ -35,10 +35,10 @@ void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
pcount
=
per_cpu_ptr
(
fbc
->
counters
,
cpu
);
pcount
=
per_cpu_ptr
(
fbc
->
counters
,
cpu
);
count
=
*
pcount
+
amount
;
count
=
*
pcount
+
amount
;
if
(
count
>=
batch
||
count
<=
-
batch
)
{
if
(
count
>=
batch
||
count
<=
-
batch
)
{
spin_lock
(
&
fbc
->
lock
);
atomic_
spin_lock
(
&
fbc
->
lock
);
fbc
->
count
+=
count
;
fbc
->
count
+=
count
;
*
pcount
=
0
;
*
pcount
=
0
;
spin_unlock
(
&
fbc
->
lock
);
atomic_
spin_unlock
(
&
fbc
->
lock
);
}
else
{
}
else
{
*
pcount
=
count
;
*
pcount
=
count
;
}
}
...
@@ -55,13 +55,13 @@ s64 __percpu_counter_sum(struct percpu_counter *fbc)
...
@@ -55,13 +55,13 @@ s64 __percpu_counter_sum(struct percpu_counter *fbc)
s64
ret
;
s64
ret
;
int
cpu
;
int
cpu
;
spin_lock
(
&
fbc
->
lock
);
atomic_
spin_lock
(
&
fbc
->
lock
);
ret
=
fbc
->
count
;
ret
=
fbc
->
count
;
for_each_online_cpu
(
cpu
)
{
for_each_online_cpu
(
cpu
)
{
s32
*
pcount
=
per_cpu_ptr
(
fbc
->
counters
,
cpu
);
s32
*
pcount
=
per_cpu_ptr
(
fbc
->
counters
,
cpu
);
ret
+=
*
pcount
;
ret
+=
*
pcount
;
}
}
spin_unlock
(
&
fbc
->
lock
);
atomic_
spin_unlock
(
&
fbc
->
lock
);
return
ret
;
return
ret
;
}
}
EXPORT_SYMBOL
(
__percpu_counter_sum
);
EXPORT_SYMBOL
(
__percpu_counter_sum
);
...
@@ -69,7 +69,7 @@ EXPORT_SYMBOL(__percpu_counter_sum);
...
@@ -69,7 +69,7 @@ EXPORT_SYMBOL(__percpu_counter_sum);
int
__percpu_counter_init
(
struct
percpu_counter
*
fbc
,
s64
amount
,
int
__percpu_counter_init
(
struct
percpu_counter
*
fbc
,
s64
amount
,
struct
lock_class_key
*
key
)
struct
lock_class_key
*
key
)
{
{
spin_lock_init
(
&
fbc
->
lock
);
atomic_
spin_lock_init
(
&
fbc
->
lock
);
lockdep_set_class
(
&
fbc
->
lock
,
key
);
lockdep_set_class
(
&
fbc
->
lock
,
key
);
fbc
->
count
=
amount
;
fbc
->
count
=
amount
;
fbc
->
counters
=
alloc_percpu
(
s32
);
fbc
->
counters
=
alloc_percpu
(
s32
);
...
@@ -126,11 +126,11 @@ static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb,
...
@@ -126,11 +126,11 @@ static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb,
s32
*
pcount
;
s32
*
pcount
;
unsigned
long
flags
;
unsigned
long
flags
;
spin_lock_irqsave
(
&
fbc
->
lock
,
flags
);
atomic_
spin_lock_irqsave
(
&
fbc
->
lock
,
flags
);
pcount
=
per_cpu_ptr
(
fbc
->
counters
,
cpu
);
pcount
=
per_cpu_ptr
(
fbc
->
counters
,
cpu
);
fbc
->
count
+=
*
pcount
;
fbc
->
count
+=
*
pcount
;
*
pcount
=
0
;
*
pcount
=
0
;
spin_unlock_irqrestore
(
&
fbc
->
lock
,
flags
);
atomic_
spin_unlock_irqrestore
(
&
fbc
->
lock
,
flags
);
}
}
mutex_unlock
(
&
percpu_counters_lock
);
mutex_unlock
(
&
percpu_counters_lock
);
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment