linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Michal Hocko <mhocko@kernel.org>, Arun KS <arunks@codeaurora.org>
Cc: akpm@linux-foundation.org, keescook@chromium.org,
	khlebnikov@yandex-team.ru, minchan@kernel.org, osalvador@suse.de,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	getarunks@gmail.com
Subject: Re: [PATCH v2 1/4] mm: Fix multiple evaluvations of totalram_pages and managed_pages
Date: Wed, 7 Nov 2018 09:44:00 +0100	[thread overview]
Message-ID: <c2862bb0-ced1-add1-c816-21c0d4e76bbe@suse.cz> (raw)
In-Reply-To: <20181107082037.GX27423@dhcp22.suse.cz>

On 11/7/18 9:20 AM, Michal Hocko wrote:
> On Tue 06-11-18 21:51:47, Arun KS wrote:

Hi,

there's typo in subject: evaluvations -> evaluations.

However, "fix" is also misleading (more below), so I'd suggest something
like:

mm: reference totalram_pages and managed_pages once per function

>> This patch is in preparation to a later patch which converts totalram_pages
>> and zone->managed_pages to atomic variables. This patch does not introduce
>> any functional changes.
> 
> I forgot to comment on this one. The patch makes a lot of sense. But I
> would be little bit more conservative and won't claim "no functional
> changes". As things stand now multiple reads in the same function are
> racy (without holding the lock). I do not see any example of an
> obviously harmful case but claiming the above is too strong of a
> statement. I would simply go with something like "Please note that
> re-reading the value might lead to a different value and as such it
> could lead to unexpected behavior. There are no known bugs as a result
> of the current code but it is better to prevent from them in principle."

However, the new code doesn't use READ_ONCE(), so the compiler is free
to read the value multiple times, and before the patch it was free to
read it just once, as the variables are not volatile. So strictly
speaking this is indeed not a functional change (if compiler decides
differently based on the patch, it's an implementation detail).

So even in my suggested subject above, 'reference' is meant as a source
code reference, not really a memory read reference. Couldn't think of a
better word though.

  reply	other threads:[~2018-11-07  8:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 16:21 [PATCH v2 0/4] mm: convert totalram_pages, totalhigh_pages and managed pages to atomic Arun KS
2018-11-06 16:21 ` [PATCH v2 1/4] mm: Fix multiple evaluvations of totalram_pages and managed_pages Arun KS
2018-11-07  8:20   ` Michal Hocko
2018-11-07  8:44     ` Vlastimil Babka [this message]
2018-11-07  9:23       ` Michal Hocko
2018-11-07 19:54   ` kbuild test robot
2018-11-07 20:07   ` kbuild test robot
2018-11-06 16:21 ` [PATCH v2 2/4] mm: Convert zone->managed_pages to atomic variable Arun KS
2018-11-07  8:57   ` Vlastimil Babka
2018-11-06 16:21 ` [PATCH v2 3/4] mm: convert totalram_pages and totalhigh_pages variables to atomic Arun KS
2018-11-07  9:04   ` Vlastimil Babka
2018-11-08  7:23     ` Arun KS
2018-11-07 20:07   ` kbuild test robot
2018-11-07 20:24   ` kbuild test robot
2018-11-06 16:21 ` [PATCH v2 4/4] mm: Remove managed_page_count spinlock Arun KS
2018-11-07 21:26   ` kbuild test robot

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=c2862bb0-ced1-add1-c816-21c0d4e76bbe@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=arunks@codeaurora.org \
    --cc=getarunks@gmail.com \
    --cc=keescook@chromium.org \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=minchan@kernel.org \
    --cc=osalvador@suse.de \
    /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).