Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1472455 > unrolled thread
| Started by | Geliang Tang <geliangtang@gmail.com> |
|---|---|
| First post | 2016-08-30 14:30 +0200 |
| Last post | 2016-09-08 22:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/2] ramoops: use buffer_size() and buffer_start() Geliang Tang <geliangtang@gmail.com> - 2016-08-30 14:30 +0200
Re: [PATCH 2/2] ramoops: use buffer_size() and buffer_start() Kees Cook <keescook@chromium.org> - 2016-09-08 22:50 +0200
| From | Geliang Tang <geliangtang@gmail.com> |
|---|---|
| Date | 2016-08-30 14:30 +0200 |
| Subject | [PATCH 2/2] ramoops: use buffer_size() and buffer_start() |
| Message-ID | <sbQkW-4K2-25@gated-at.bofh.it> |
Since buffer_size() and buffer_start() have been defined in ram_core.c,
use them instead of open-coding.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
fs/pstore/ram_core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 76c3f80..a8500cd 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -54,7 +54,7 @@ static size_t buffer_start_add_atomic(struct persistent_ram_zone *prz, size_t a)
int new;
do {
- old = atomic_read(&prz->buffer->start);
+ old = buffer_start(prz);
new = old + a;
while (unlikely(new >= prz->buffer_size))
new -= prz->buffer_size;
@@ -69,11 +69,11 @@ static void buffer_size_add_atomic(struct persistent_ram_zone *prz, size_t a)
size_t old;
size_t new;
- if (atomic_read(&prz->buffer->size) == prz->buffer_size)
+ if (buffer_size(prz) == prz->buffer_size)
return;
do {
- old = atomic_read(&prz->buffer->size);
+ old = buffer_size(prz);
new = old + a;
if (new > prz->buffer_size)
new = prz->buffer_size;
@@ -91,7 +91,7 @@ static size_t buffer_start_add_locked(struct persistent_ram_zone *prz, size_t a)
raw_spin_lock_irqsave(&buffer_lock, flags);
- old = atomic_read(&prz->buffer->start);
+ old = buffer_start(prz);
new = old + a;
while (unlikely(new >= prz->buffer_size))
new -= prz->buffer_size;
@@ -111,7 +111,7 @@ static void buffer_size_add_locked(struct persistent_ram_zone *prz, size_t a)
raw_spin_lock_irqsave(&buffer_lock, flags);
- old = atomic_read(&prz->buffer->size);
+ old = buffer_size(prz);
if (old == prz->buffer_size)
goto exit;
--
2.7.4
[toc] | [next] | [standalone]
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Date | 2016-09-08 22:50 +0200 |
| Message-ID | <sfeqK-2at-37@gated-at.bofh.it> |
| In reply to | #1472455 |
On Tue, Aug 30, 2016 at 5:24 AM, Geliang Tang <geliangtang@gmail.com> wrote:
> Since buffer_size() and buffer_start() have been defined in ram_core.c,
> use them instead of open-coding.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Hi!
Thanks for this clean-up. However, since the _atomic method has been
removed entirely now, I don't want to make this change, since it makes
reading the atomic_read/atomic_set in functions unmatched. I'd prefer
to leave this as-is.
-Kees
> ---
> fs/pstore/ram_core.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
> index 76c3f80..a8500cd 100644
> --- a/fs/pstore/ram_core.c
> +++ b/fs/pstore/ram_core.c
> @@ -54,7 +54,7 @@ static size_t buffer_start_add_atomic(struct persistent_ram_zone *prz, size_t a)
> int new;
>
> do {
> - old = atomic_read(&prz->buffer->start);
> + old = buffer_start(prz);
> new = old + a;
> while (unlikely(new >= prz->buffer_size))
> new -= prz->buffer_size;
> @@ -69,11 +69,11 @@ static void buffer_size_add_atomic(struct persistent_ram_zone *prz, size_t a)
> size_t old;
> size_t new;
>
> - if (atomic_read(&prz->buffer->size) == prz->buffer_size)
> + if (buffer_size(prz) == prz->buffer_size)
> return;
>
> do {
> - old = atomic_read(&prz->buffer->size);
> + old = buffer_size(prz);
> new = old + a;
> if (new > prz->buffer_size)
> new = prz->buffer_size;
> @@ -91,7 +91,7 @@ static size_t buffer_start_add_locked(struct persistent_ram_zone *prz, size_t a)
>
> raw_spin_lock_irqsave(&buffer_lock, flags);
>
> - old = atomic_read(&prz->buffer->start);
> + old = buffer_start(prz);
> new = old + a;
> while (unlikely(new >= prz->buffer_size))
> new -= prz->buffer_size;
> @@ -111,7 +111,7 @@ static void buffer_size_add_locked(struct persistent_ram_zone *prz, size_t a)
>
> raw_spin_lock_irqsave(&buffer_lock, flags);
>
> - old = atomic_read(&prz->buffer->size);
> + old = buffer_size(prz);
> if (old == prz->buffer_size)
> goto exit;
>
> --
> 2.7.4
>
--
Kees Cook
Nexus Security
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web