linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Jiang Liu <liuj97@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	sworddragon2@aol.com, Jiang Liu <jiang.liu@huawei.com>,
	bugzilla-daemon@bugzilla.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 2/2] mm: protect si_meminfo() and si_meminfo_node() from memory hotplug operations
Date: Tue, 19 Feb 2013 13:32:23 -0800 (PST)	[thread overview]
Message-ID: <alpine.DEB.2.02.1302191331210.6322@chino.kir.corp.google.com> (raw)
In-Reply-To: <1361032046-1725-2-git-send-email-jiang.liu@huawei.com>

On Sun, 17 Feb 2013, Jiang Liu wrote:

> There's typical usage of si_meminfo as below:
> 	si_meminfo(&si);
> 	threshold = si->totalram - si.totalhigh;
> 
> It may cause underflow if memory hotplug races with si_meminfo() because
> there's no mechanism to protect si_meminfo() from memory hotplug
> operations. And some callers expects that si_meminfo() is a lightweight
> operations. So introduce a lightweight mechanism to protect si_meminfo()
> from memory hotplug operations.
> 

Instead of this, I think it would be appropriate to add a comment that 
requires synchronization if two fields are going to be compared, i.e. use 
{lock,unlock}_memory_hotplug() in the caller to si_meminfo(), or 
appropriate underflow checking is done upon return.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2013-02-19 21:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-53501-27@https.bugzilla.kernel.org/>
2013-02-13  0:51 ` [Bug 53501] New: Duplicated MemTotal with different values Andrew Morton
2013-02-13  1:45   ` David Rientjes
2013-02-13  3:59     ` Andrew Morton
2013-02-14  3:19       ` David Rientjes
2013-02-14  4:01         ` Jiang Liu
2013-02-15  0:26           ` David Rientjes
2013-02-20  5:21             ` Simon Jeons
2013-02-20  7:09               ` David Rientjes
2013-03-02  2:21                 ` Simon Jeons
2013-03-04 11:18                   ` David Rientjes
2013-03-04 23:39                     ` Simon Jeons
2013-03-05 21:53                       ` David Rientjes
2013-02-16 16:27         ` [PATCH 1/2] vm: add 'MemManaged' field to /proc/meminfo and /sys/.../nodex/meminfo Jiang Liu
2013-02-19 21:29           ` David Rientjes
2013-02-20 17:27             ` [PATCH v2] mm: let /proc/meminfo report physical memory installed as "MemTotal" Jiang Liu
2013-02-20 22:49               ` Andrew Morton
2013-02-21 17:26                 ` Jiang Liu
2013-02-21 21:31                   ` Andrew Morton
2013-02-22 19:22                     ` Jiang Liu
2013-02-16 16:27         ` [PATCH 2/2] mm: protect si_meminfo() and si_meminfo_node() from memory hotplug operations Jiang Liu
2013-02-19 21:32           ` David Rientjes [this message]

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=alpine.DEB.2.02.1302191331210.6322@chino.kir.corp.google.com \
    --to=rientjes@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --cc=jiang.liu@huawei.com \
    --cc=linux-mm@kvack.org \
    --cc=liuj97@gmail.com \
    --cc=sworddragon2@aol.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