linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: linux-mm@kvack.org
Subject: Mlocked pages statistics shows bogus value.
Date: Tue, 19 Jan 2016 19:36:37 +0900	[thread overview]
Message-ID: <201601191936.HAI26031.HOtJQLOMFFFVOS@I-love.SAKURA.ne.jp> (raw)

While reading OOM report from Jan Stancek, I noticed that
NR_MLOCK statistics shows bogus values.


Steps to reproduce:

(1) Check Mlocked: field of /proc/meminfo or mlocked: field of SysRq-m.

(2) Compile and run below program with appropriate size as argument.
    There is no need to invoke the OOM killer.

----------
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>

int main(int argc, char *argv[])
{
	unsigned long length = atoi(argv[1]);
	void *addr = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
	if (addr == MAP_FAILED)
		printf("mmap() failed\n");
	else if (mlock(addr, length) == -1)
		printf("mlock() failed\n");
	else
		printf("MLocked %lu bytes\n", length);
	return 0;
}
----------

(3) Check Mlocked: field or mlocked: field again.
    You can see the value became very large due to
    NR_MLOCK counter going negative.

--
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:[~2016-01-19 10:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19 10:36 Tetsuo Handa [this message]
2016-01-19 12:21 ` Kirill A. Shutemov
2016-01-19 12:46   ` Tetsuo Handa
2016-01-19 13:01     ` Kirill A. Shutemov
2016-01-19 13:38       ` Tetsuo Handa
2016-01-20  9:59         ` Heiko Carstens
2016-01-20 10:04         ` Heiko Carstens
2016-01-19 18:32   ` Michal Hocko

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=201601191936.HAI26031.HOtJQLOMFFFVOS@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=linux-mm@kvack.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