linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Michal Hocko <mhocko@kernel.org>, Dave Hansen <dave.hansen@intel.com>
Cc: "Odzioba, Lukasz" <lukasz.odzioba@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"Shutemov, Kirill" <kirill.shutemov@intel.com>,
	"Anaczkowski, Lukasz" <lukasz.anaczkowski@intel.com>
Subject: Re: mm: pages are not freed from lru_add_pvecs after process termination
Date: Fri, 13 May 2016 13:29:18 +0200	[thread overview]
Message-ID: <5735BA8E.3080201@suse.cz> (raw)
In-Reply-To: <20160511075313.GE16677@dhcp22.suse.cz>

On 05/11/2016 09:53 AM, Michal Hocko wrote:
> On Fri 06-05-16 09:04:34, Dave Hansen wrote:
>> On 05/06/2016 08:10 AM, Odzioba, Lukasz wrote:
>>> On Thu 05-05-16 09:21:00, Michal Hocko wrote:
>>>> Or maybe the async nature of flushing turns
>>>> out to be just impractical and unreliable and we will end up skipping
>>>> THP (or all compound pages) for pcp LRU add cache. Let's see...
>>>
>>> What if we simply skip lru_add pvecs for compound pages?
>>> That way we still have compound pages on LRU's, but the problem goes
>>> away.  It is not quite what this naive patch does, but it works nice for me.
>>>
>>> diff --git a/mm/swap.c b/mm/swap.c
>>> index 03aacbc..c75d5e1 100644
>>> --- a/mm/swap.c
>>> +++ b/mm/swap.c
>>> @@ -392,7 +392,9 @@ static void __lru_cache_add(struct page *page)
>>>          get_page(page);
>>>          if (!pagevec_space(pvec))
>>>                  __pagevec_lru_add(pvec);
>>>          pagevec_add(pvec, page);
>>> +       if (PageCompound(page))
>>> +               __pagevec_lru_add(pvec);
>>>          put_cpu_var(lru_add_pvec);
>>>   }
>>
>> That's not _quite_ what I had in mind since that drains the entire pvec
>> every time a large page is encountered.  But I'm conflicted about what
>> the right behavior _is_.
>>
>> We'd taking the LRU lock for 'page' anyway, so we might as well drain
>> the pvec.

Note that pages in the pagevec can come from different zones, so this is 
not universally true.

>
> Yes I think this makes sense. The only case where it would be suboptimal
> is when the pagevec was already full and then we just created a single
> page pvec to drain it. This can be handled better though by:
>
> diff --git a/mm/swap.c b/mm/swap.c
> index 95916142fc46..3fe4f180e8bf 100644
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -391,9 +391,8 @@ static void __lru_cache_add(struct page *page)
>   	struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
>
>   	get_page(page);
> -	if (!pagevec_space(pvec))
> +	if (!pagevec_add(pvec, page) || PageCompound(page))
>   		__pagevec_lru_add(pvec);
> -	pagevec_add(pvec, page);
>   	put_cpu_var(lru_add_pvec);
>   }

Yeah that could work. There might be more complex solutions at the level
of lru_cache_add_active_or_unevictable() where we call it either from
base page code (mm/memory.c) or functions in mm/huge_memory.c. We could
redirect it at that point, but likely not worth the trouble unless this
simple solution doesn't show some performance regression...

>> Or, does the additional work to put the page on to a pvec and then
>> immediately drain it overwhelm that advantage?
>
> pagevec_add is quite trivial so I would be really surprised if it
> mattered.
>

--
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-05-13 11:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27 17:01 Odzioba, Lukasz
2016-04-27 17:11 ` Dave Hansen
2016-04-28 14:37   ` Michal Hocko
2016-05-02 13:00     ` Michal Hocko
2016-05-04 19:41       ` Odzioba, Lukasz
2016-05-04 20:16         ` Dave Hansen
2016-05-04 20:36         ` Michal Hocko
2016-05-05  7:21           ` Michal Hocko
2016-05-05 17:25             ` Odzioba, Lukasz
2016-05-11  7:38               ` Michal Hocko
2016-05-06 15:10             ` Odzioba, Lukasz
2016-05-06 16:04               ` Dave Hansen
2016-05-11  7:53                 ` Michal Hocko
2016-05-13 11:29                   ` Vlastimil Babka [this message]
2016-05-13 12:05                   ` Odzioba, Lukasz
2016-06-07  9:02                   ` Odzioba, Lukasz
2016-06-07 11:19                     ` Michal Hocko
2016-06-08  8:51                       ` Odzioba, Lukasz
2016-05-02 14:39   ` Vlastimil Babka
2016-05-02 15:01     ` Kirill A. Shutemov
2016-05-02 15:13       ` Vlastimil Babka
2016-05-02 15:49       ` Dave Hansen
2016-05-02 16:02         ` Kirill A. Shutemov
2016-05-03  7:37           ` Michal Hocko
2016-05-03 10:07             ` Kirill A. Shutemov

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=5735BA8E.3080201@suse.cz \
    --to=vbabka@suse.cz \
    --cc=dave.hansen@intel.com \
    --cc=kirill.shutemov@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lukasz.anaczkowski@intel.com \
    --cc=lukasz.odzioba@intel.com \
    --cc=mhocko@kernel.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