All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pstore/ram: Use reminder directly
@ 2022-01-24 14:42 wonder_rock
  0 siblings, 0 replies; 2+ messages in thread
From: wonder_rock @ 2022-01-24 14:42 UTC (permalink / raw)
  To: keescook, anton, ccross, tony.luck; +Cc: linux-kernel, Deyan Wang

From: Deyan Wang <wonder_rock@126.com>

The remainder is more efficient, we directly use the remainder.

Signed-off-by: Deyan Wang <wonder_rock@126.com>
---
 fs/pstore/ram_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index fe5305028c6e..69928a59e28b 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -61,8 +61,8 @@ static size_t buffer_start_add(struct persistent_ram_zone *prz, size_t a)
 
 	old = atomic_read(&prz->buffer->start);
 	new = old + a;
-	while (unlikely(new >= prz->buffer_size))
-		new -= prz->buffer_size;
+	if (unlikely(new >= prz->buffer_size))
+		new %= prz->buffer_size;
 	atomic_set(&prz->buffer->start, new);
 
 	if (!(prz->flags & PRZ_FLAG_NO_LOCK))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] pstore/ram: Use reminder directly
@ 2022-02-08  2:43 Deyan Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Deyan Wang @ 2022-02-08  2:43 UTC (permalink / raw)
  To: keescook, anton, ccross, tony.luck; +Cc: linux-kernel, Deyan Wang

From: Deyan Wang <wonder_rock@126.com>

The remainder is more efficient, we directly use the remainder.

Signed-off-by: Deyan Wang <wonder_rock@126.com>
---
 fs/pstore/ram_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index fe5305028c6e..69928a59e28b 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -61,8 +61,8 @@ static size_t buffer_start_add(struct persistent_ram_zone *prz, size_t a)
 
 	old = atomic_read(&prz->buffer->start);
 	new = old + a;
-	while (unlikely(new >= prz->buffer_size))
-		new -= prz->buffer_size;
+	if (unlikely(new >= prz->buffer_size))
+		new %= prz->buffer_size;
 	atomic_set(&prz->buffer->start, new);
 
 	if (!(prz->flags & PRZ_FLAG_NO_LOCK))
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-08  3:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 14:42 [PATCH] pstore/ram: Use reminder directly wonder_rock
2022-02-08  2:43 Deyan Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.