linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zi Yan <ziy@nvidia.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: "Pankaj Raghav (Samsung)" <kernel@pankajraghav.com>,
	Shuah Khan <shuah@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	gost.dev@samsung.com, mcgrof@kernel.org,
	linux-kselftest@vger.kernel.org,
	Pankaj Raghav <p.raghav@samsung.com>
Subject: Re: [PATCH] selftests/mm: use volatile keyword to not optimize mmap read variable
Date: Thu, 06 Jun 2024 08:19:15 -0700	[thread overview]
Message-ID: <4821478C-1B80-4229-9C14-47DDB6BBC823@nvidia.com> (raw)
In-Reply-To: <ZmHJMyo37QdtTWee@casper.infradead.org>

[-- Attachment #1: Type: text/plain, Size: 957 bytes --]

On 6 Jun 2024, at 7:35, Matthew Wilcox wrote:

> On Thu, Jun 06, 2024 at 01:58:35PM +0000, Pankaj Raghav (Samsung) wrote:
>> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
>> @@ -300,7 +300,7 @@ int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size, int *fd,
>>  		char **addr)
>>  {
>>  	size_t i;
>> -	int __attribute__((unused)) dummy = 0;
>> +	volatile int __attribute__((unused)) dummy = 0;
>
> The mistake made by whoever wrote this test was making 'dummy' a stack

That was me. :(

> variable.  That lets the compiler figure out that it's unused.  If you
> make it a top-level variable (not static) so the compiler can't tell
> whether it's referenced by a different compilation unit, it can't make
> that deduction.  And you don't need the stupid attibute or volatile on it.

It is better to just move “dummy” like you suggested instead of adding more
keywords to fix it.

-
Best Regards,
Yan, Zi

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]

  reply	other threads:[~2024-06-06 15:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06 13:58 Pankaj Raghav (Samsung)
2024-06-06 14:21 ` Zi Yan
2024-06-06 14:35 ` Matthew Wilcox
2024-06-06 15:19   ` Zi Yan [this message]
2024-06-06 15:28   ` Pankaj Raghav (Samsung)
2024-06-06 15:56 ` David Hildenbrand
2024-06-06 15:57   ` David Hildenbrand
2024-06-06 20:18     ` Pankaj Raghav (Samsung)
2024-06-06 20:21       ` David Hildenbrand
2024-06-06 20:30         ` Pankaj Raghav (Samsung)

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=4821478C-1B80-4229-9C14-47DDB6BBC823@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=gost.dev@samsung.com \
    --cc=kernel@pankajraghav.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mcgrof@kernel.org \
    --cc=p.raghav@samsung.com \
    --cc=shuah@kernel.org \
    --cc=willy@infradead.org \
    /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