linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Geliang Tang <geliangtang@gmail.com>
Cc: Anton Vorontsov <anton@enomsg.org>,
	Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] ramoops: use buffer_size() and buffer_start()
Date: Thu, 8 Sep 2016 13:44:31 -0700	[thread overview]
Message-ID: <CAGXu5jJLvrCxTMBs0O5SS1pbH8gc6aqcDMr6nmPL8XhNC0u30A@mail.gmail.com> (raw)
In-Reply-To: <984a112e60904a7bbbe046c5d9d2c1f10dfe02b6.1472559626.git.geliangtang@gmail.com>

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

  reply	other threads:[~2016-09-08 20:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-30 12:24 [PATCH 1/2] ramoops: move spin_lock_init after kmalloc error checking Geliang Tang
2016-08-30 12:24 ` [PATCH 2/2] ramoops: use buffer_size() and buffer_start() Geliang Tang
2016-09-08 20:44   ` Kees Cook [this message]
2016-09-08 20:45 ` [PATCH 1/2] ramoops: move spin_lock_init after kmalloc error checking Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGXu5jJLvrCxTMBs0O5SS1pbH8gc6aqcDMr6nmPL8XhNC0u30A@mail.gmail.com \
    --to=keescook@chromium.org \
    --cc=anton@enomsg.org \
    --cc=ccross@android.com \
    --cc=geliangtang@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).