linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: linux-mm@kvack.org
Cc: bugzilla-daemon@bugzilla.kernel.org, terragonjohn@yahoo.com
Subject: Re: [Bug 200105] New: High paging activity as soon as the swap is touched (with steps and code to reproduce it)
Date: Mon, 18 Jun 2018 16:17:35 -0700	[thread overview]
Message-ID: <20180618161735.72a1c9036057ee08d17aaaf4@linux-foundation.org> (raw)
In-Reply-To: <bug-200105-27@https.bugzilla.kernel.org/>


(switched to email.  Please respond via emailed reply-to-all, not via the
bugzilla web interface).

On Sun, 17 Jun 2018 21:56:23 +0000 bugzilla-daemon@bugzilla.kernel.org wrote:

> https://bugzilla.kernel.org/show_bug.cgi?id=200105
> 
>             Bug ID: 200105
>            Summary: High paging activity as soon as the swap is touched
>                     (with steps and code to reproduce it)
>            Product: Memory Management
>            Version: 2.5
>     Kernel Version: 4.14 4.15 4.16 4.17
>           Hardware: All
>                 OS: Linux
>               Tree: Mainline
>             Status: NEW
>           Severity: normal
>           Priority: P1
>          Component: Page Allocator
>           Assignee: akpm@linux-foundation.org
>           Reporter: terragonjohn@yahoo.com
>         Regression: No
> 
> Hi.
> 
> Under any desktop environment, as soon as the swap is touched the kernel starts
> paging out gigabytes of memory for no apparent reason causing the system to
> freeze for at least a minute.
> 
> 
> This happens with normal desktop usage but I'm able to reproduce this behavior
> systematically by using the code included at the end of this report, let's call
> it "memeater". memeater takes three parameters: totalmem, chunksize, sleeptime.
> It allocates (and initializes to 0) totalmem bytes of memory in chunks of
> chunksize bytes each. After each chunk allocation it sleeps for sleeptime
> seconds. If sleeptime=0, it does not sleep in between chunk allocations.
> After totalmem bytes of memory have been allocated it sleeps indefinitely.
> 
> To reproduce the behaviour using memeater:
> 
> 1) start a desktop environment (in my case KDE plasma).
> 2) invoke "memeater x y 0" to bring the system to the brink of swapping. I
> usually execute "memeater x y 0" multiple times where x is 4 gigs and y is 20
> megs.(I've got 16GB of memory so I usually go up to 14/15 GB of used memory).
> 3) invoke "memeater x y 1" one last time so that it slowly fills up the memory
> with small chunks of a few megs each (again, I tried it with x=4 gigs and y=20
> megs).
> 
> When the last memeater fills the memory (and keeps allocating chunks) I would
> expect the mm system to swap out few megabytes worth of pages to accomodate the
> new requests slowly coming from the last memeater. 
> However, what actually happens is that the mm starts to swap out gigabytes
> worth of pages completely freezing the system for one or two minutes.
> 
> I've verified this on various desktop systems, all using SSDs.
> Obviously, I'm willing to provide more info and to test patches.
> 
> 
> ####### memeater #######################à
> 
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> #include <unistd.h>
> 
> 
> 
> int main(int argc, char** argv) {
>     long int max = -1;
>     int mb = 0;
>     long int size = 0;
>     long int total = 0;
>     int sleep_time = 0;
>     char* buffer;
> 
>     if(argc > 1)
>       {
>         max = atol(argv[1]);
>         size = atol(argv[2]);
>         sleep_time = atoi(argv[3]);
>       }
>     printf("Max: %lu bytes\n", max);
>     while((buffer=malloc(size)) != NULL && total < max) {
>         memset(buffer, 0, size);
>         mb++;
>         total=mb*size;
>         printf("Allocated %lu bytes\n", total);
>         if (sleep_time) sleep(sleep_time);
>     }      
> sleep(3000000);
> return 0;
> }
> 
> -- 
> You are receiving this mail because:
> You are the assignee for the bug.

       reply	other threads:[~2018-06-18 23:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-200105-27@https.bugzilla.kernel.org/>
2018-06-18 23:17 ` Andrew Morton [this message]
2018-06-21 15:13   ` 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=20180618161735.72a1c9036057ee08d17aaaf4@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=terragonjohn@yahoo.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