linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bob Liu <bob.liu@oracle.com>
To: Dan Streetman <ddstreet@ieee.org>
Cc: Weijie Yang <weijie.yang.kh@gmail.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	xen-devel@lists.xenproject.org, Mel Gorman <mgorman@suse.de>,
	Hugh Dickins <hughd@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@suse.cz>,
	Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>,
	Shaohua Li <shli@fusionio.com>, Weijie Yang <weijieut@gmail.com>,
	Linux-MM <linux-mm@kvack.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	David Vrabel <david.vrabel@citrix.com>
Subject: Re: [PATCH 1/2] swap: change swap_info singly-linked list to list_head
Date: Sun, 04 May 2014 17:39:40 +0800	[thread overview]
Message-ID: <53660ADC.8000306@oracle.com> (raw)
In-Reply-To: <CALZtONBDdo7KGKPZHuH-gHUS8ntBW+mYGPKKnh5GcQAsL5Zrfw@mail.gmail.com>


On 05/03/2014 04:00 AM, Dan Streetman wrote:
> On Fri, Apr 25, 2014 at 12:15 AM, Weijie Yang <weijie.yang.kh@gmail.com> wrote:
>> On Fri, Apr 25, 2014 at 2:48 AM, Dan Streetman <ddstreet@ieee.org> wrote:
>>> On Wed, Apr 23, 2014 at 6:34 AM, Mel Gorman <mgorman@suse.de> wrote:
>>>> On Sat, Apr 12, 2014 at 05:00:53PM -0400, Dan Streetman wrote:
> <SNIP>
>>>>> diff --git a/mm/frontswap.c b/mm/frontswap.c
>>>>> index 1b24bdc..fae1160 100644
>>>>> --- a/mm/frontswap.c
>>>>> +++ b/mm/frontswap.c
>>>>> @@ -327,15 +327,12 @@ EXPORT_SYMBOL(__frontswap_invalidate_area);
>>>>>
>>>>>  static unsigned long __frontswap_curr_pages(void)
>>>>>  {
>>>>> -     int type;
>>>>>       unsigned long totalpages = 0;
>>>>>       struct swap_info_struct *si = NULL;
>>>>>
>>>>>       assert_spin_locked(&swap_lock);
>>>>> -     for (type = swap_list.head; type >= 0; type = si->next) {
>>>>> -             si = swap_info[type];
>>>>> +     list_for_each_entry(si, &swap_list_head, list)
>>>>>               totalpages += atomic_read(&si->frontswap_pages);
>>>>> -     }
>>>>>       return totalpages;
>>>>>  }
>>>>>
>>>>> @@ -347,11 +344,9 @@ static int __frontswap_unuse_pages(unsigned long total, unsigned long *unused,
>>>>>       int si_frontswap_pages;
>>>>>       unsigned long total_pages_to_unuse = total;
>>>>>       unsigned long pages = 0, pages_to_unuse = 0;
>>>>> -     int type;
>>>>>
>>>>>       assert_spin_locked(&swap_lock);
>>>>> -     for (type = swap_list.head; type >= 0; type = si->next) {
>>>>> -             si = swap_info[type];
>>>>> +     list_for_each_entry(si, &swap_list_head, list) {
>>>>>               si_frontswap_pages = atomic_read(&si->frontswap_pages);
>>>>>               if (total_pages_to_unuse < si_frontswap_pages) {
>>>>>                       pages = pages_to_unuse = total_pages_to_unuse;
>>>>
>>>> The frontswap shrink code looks suspicious. If the target is smaller than
>>>> the total number of frontswap pages then it does nothing. The callers

__frontswap_unuse_pages() is called only to get the correct value of
pages_to_unuse which will pass to try_to_unuse(), perhaps we should
rename it to __frontswap_unuse_pages_nr()..

------
ret = __frontswap_shrink(target_pages, &pages_to_unuse, &type);
	->  __frontswap_unuse_pages(total_pages_to_unuse, pages_to_unuse, type);

try_to_unuse(type, true, pages_to_unuse);
------

>>>> appear to get this right at least. Similarly, if the first swapfile has
>>>> fewer frontswap pages than the target then it does not unuse the target
>>>> number of pages because it only handles one swap file. It's outside the
>>>> scope of your patch to address this or wonder if xen balloon driver is
>>>> really using it the way it's expected.
>>>
>>> I didn't look into the frontswap shrinking code, but I agree the
>>> existing logic there doesn't look right.  I'll review frontswap in
>>> more detail to see if it needs changing here, unless anyone else gets
>>> it to first :-)
>>>
>>
>> FYI, I drop the frontswap_shrink code in a patch
>> see: https://lkml.org/lkml/2014/1/27/98
> 
> frontswap_shrink() is actually used (only) by drivers/xen/xen-selfballoon.c.
> 
> However, I completely agree with you that the backend should be doing
> the shrinking, not from a frontswap api.  Forcing frontswap to shrink
> is backwards - xen-selfballoon appears to be assuming that xem/tmem is
> the only possible frontswap backend.  It certainly doensn't make any
> sense for xen-selfballoon to force zswap to shrink itself, does it?
> 
> If xen-selfballoon wants to shrink its frontswap backend tmem, it
> should do that by telling tmem directly to shrink itself (which it
> looks like tmem would have to implement, just like zswap sends its LRU
> pages back to swapcache when it becomes full).
> 

Yes, it's possible in theory, but tmem is located in xen(host) which
can't put back pages to swap cache(in guest os) directly. Use
frontswap_shrink() can make things simple and easier.

And I think frontswap shrink isn't a blocker of this patch set, so
please keep it.

-- 
Regards,
-Bob

  reply	other threads:[~2014-05-04  9:40 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13 10:42 [PATCH] mm: swap: Use swapfiles in priority order Mel Gorman
2014-02-13 15:58 ` Weijie Yang
2014-02-14 10:17   ` Mel Gorman
2014-02-14 13:33     ` Weijie Yang
     [not found]   ` <loom.20140214T135753-812@post.gmane.org>
     [not found]     ` <CABdxLJHS5kw0rpD=+77iQtc6PMeRXoWnh-nh5VzjjfGHJ5wLGQ@mail.gmail.com>
2014-02-24  8:28       ` Hugh Dickins
2014-04-12 21:00         ` [PATCH 0/2] swap: simplify/fix swap_list handling and iteration Dan Streetman
2014-04-12 21:00           ` [PATCH 1/2] swap: change swap_info singly-linked list to list_head Dan Streetman
2014-04-23 10:34             ` Mel Gorman
2014-04-24  0:17               ` Shaohua Li
2014-04-24  8:30                 ` Mel Gorman
2014-04-24 18:48               ` Dan Streetman
2014-04-25  4:15                 ` Weijie Yang
2014-05-02 20:00                   ` Dan Streetman
2014-05-04  9:39                     ` Bob Liu [this message]
2014-05-04 20:16                       ` Dan Streetman
2014-04-25  8:38                 ` Mel Gorman
2014-04-12 21:00           ` [PATCH 2/2] swap: use separate priority list for available swap_infos Dan Streetman
2014-04-23 13:14             ` Mel Gorman
2014-04-24 17:52               ` Dan Streetman
2014-04-25  8:49                 ` Mel Gorman
2014-05-02 19:02           ` [PATCHv2 0/4] swap: simplify/fix swap_list handling and iteration Dan Streetman
2014-05-02 19:02             ` [PATCHv2 1/4] swap: change swap_info singly-linked list to list_head Dan Streetman
2014-05-02 19:02             ` [PATCH 2/4] plist: add helper functions Dan Streetman
2014-05-12 10:35               ` Mel Gorman
2014-05-02 19:02             ` [PATCH 3/4] plist: add plist_rotate Dan Streetman
2014-05-06  2:18               ` Steven Rostedt
2014-05-06 20:12                 ` Dan Streetman
2014-05-06 20:39                   ` Steven Rostedt
2014-05-06 21:47                     ` Dan Streetman
2014-05-06 22:43                       ` Steven Rostedt
2014-05-02 19:02             ` [PATCH 4/4] swap: change swap_list_head to plist, add swap_avail_head Dan Streetman
2014-05-05 15:51               ` Dan Streetman
2014-05-05 19:13               ` Steven Rostedt
2014-05-05 19:38                 ` Peter Zijlstra
2014-05-09 20:42                 ` [PATCH] plist: make CONFIG_DEBUG_PI_LIST selectable Dan Streetman
2014-05-09 21:17                   ` Steven Rostedt
2014-05-12 11:11               ` [PATCH 4/4] swap: change swap_list_head to plist, add swap_avail_head Mel Gorman
2014-05-12 13:00                 ` Dan Streetman
2014-05-12 16:38             ` [PATCHv3 0/4] swap: simplify/fix swap_list handling and iteration Dan Streetman
2014-05-12 16:38               ` [PATCHv2 1/4] swap: change swap_info singly-linked list to list_head Dan Streetman
2014-05-12 16:38               ` [PATCH 2/4] plist: add helper functions Dan Streetman
2014-05-12 16:38               ` [PATCHv2 3/4] plist: add plist_requeue Dan Streetman
2014-05-13 10:33                 ` Mel Gorman
2014-05-12 16:38               ` [PATCHv2 4/4] swap: change swap_list_head to plist, add swap_avail_head Dan Streetman
2014-05-13 10:34                 ` Mel Gorman

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=53660ADC.8000306@oracle.com \
    --to=bob.liu@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=ddstreet@ieee.org \
    --cc=ehrhardt@linux.vnet.ibm.com \
    --cc=hughd@google.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.cz \
    --cc=shli@fusionio.com \
    --cc=weijie.yang.kh@gmail.com \
    --cc=weijieut@gmail.com \
    --cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).