linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Zhen Lei <thunder.leizhen@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] mm/page_poison: slightly optimize check_poison_mem()
Date: Wed, 21 Aug 2024 13:28:08 +0200	[thread overview]
Message-ID: <8d40e74e-c68b-4f94-ae1e-42c4430d55e2@redhat.com> (raw)
In-Reply-To: <20240821075311.1953-1-thunder.leizhen@huawei.com>

On 21.08.24 09:53, Zhen Lei wrote:
> When the debug information needs to be suppressed due to ratelimit,
> it is unnecessary to determine the end of the corrupted memory.
> 
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
>   mm/page_poison.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/page_poison.c b/mm/page_poison.c
> index 3e9037363cf9d85..23fa799214720f1 100644
> --- a/mm/page_poison.c
> +++ b/mm/page_poison.c
> @@ -55,14 +55,15 @@ static void check_poison_mem(struct page *page, unsigned char *mem, size_t bytes
>   	if (!start)
>   		return;
>   
> +	if (!__ratelimit(&ratelimit))
> +		return;
> +
>   	for (end = mem + bytes - 1; end > start; end--) {
>   		if (*end != PAGE_POISON)
>   			break;
>   	}
>   
> -	if (!__ratelimit(&ratelimit))
> -		return;
> -	else if (start == end && single_bit_flip(*start, PAGE_POISON))
> +	if (start == end && single_bit_flip(*start, PAGE_POISON))
>   		pr_err("pagealloc: single bit error\n");
>   	else
>   		pr_err("pagealloc: memory corruption\n");

This way, you will be ratelimiting on every function call, possibly 
skipping PAGE_POISON checks even if there was no prior corruption detected?

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-08-21 11:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-21  7:53 Zhen Lei
2024-08-21 11:28 ` David Hildenbrand [this message]
2024-08-22  1:27   ` Leizhen (ThunderTown)

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=8d40e74e-c68b-4f94-ae1e-42c4430d55e2@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=thunder.leizhen@huawei.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