linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tim Chen <tim.c.chen@linux.intel.com>
To: "Huang, Ying" <ying.huang@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrea Arcangeli <aarcange@redhat.com>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Hugh Dickins <hughd@google.com>, Shaohua Li <shli@kernel.org>,
	Minchan Kim <minchan@kernel.org>, Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH -mm -v6 3/9] mm, THP, swap: Add swap cluster allocate/free functions
Date: Wed, 15 Mar 2017 10:15:42 -0700	[thread overview]
Message-ID: <1489598142.2733.60.camel@linux.intel.com> (raw)
In-Reply-To: <87wpbrcp5s.fsf@yhuang-dev.intel.com>

On Wed, 2017-03-15 at 09:19 +0800, Huang, Ying wrote:
> Tim Chen <tim.c.chen@linux.intel.com> writes:
> 
> > 
> > On Wed, 2017-03-08 at 15:26 +0800, Huang, Ying wrote:
> > > 
> > > From: Huang Ying <ying.huang@intel.com>
> > > 
> > > The swap cluster allocation/free functions are added based on the
> > > existing swap cluster management mechanism for SSD.A A These functions
> > > don't work for the rotating hard disks because the existing swap cluster
> > > management mechanism doesn't work for them.A A The hard disks support may
> > > be added if someone really need it.A A But that needn't be included in
> > > this patchset.
> > > 
> > > This will be used for the THP (Transparent Huge Page) swap support.
> > > Where one swap cluster will hold the contents of each THP swapped out.
> > > 
> > > Cc: Andrea Arcangeli <aarcange@redhat.com>
> > > Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > > Cc: Hugh Dickins <hughd@google.com>
> > > Cc: Shaohua Li <shli@kernel.org>
> > > Cc: Minchan Kim <minchan@kernel.org>
> > > Cc: Rik van Riel <riel@redhat.com>
> > > Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
> > > ---
> > > A mm/swapfile.c | 217 +++++++++++++++++++++++++++++++++++++++++-----------------
> > > A 1 file changed, 156 insertions(+), 61 deletions(-)
> > > 
> > > diff --git a/mm/swapfile.c b/mm/swapfile.c
> > > index a744604384ff..91876c33114b 100644
> > > --- a/mm/swapfile.c
> > > +++ b/mm/swapfile.c
> > > @@ -378,6 +378,14 @@ static void swap_cluster_schedule_discard(struct swap_info_struct *si,
> > > A 	schedule_work(&si->discard_work);
> > > A }
> > > A 
> > > +static void __free_cluster(struct swap_info_struct *si, unsigned long idx)
> > > +{
> > > +	struct swap_cluster_info *ci = si->cluster_info;
> > > +
> > > +	cluster_set_flag(ci + idx, CLUSTER_FLAG_FREE);
> > > +	cluster_list_add_tail(&si->free_clusters, ci, idx);
> > > +}
> > > +
> > > A /*
> > > A  * Doing discard actually. After a cluster discard is finished, the cluster
> > > A  * will be added to free cluster list. caller should hold si->lock.
> > > @@ -398,10 +406,7 @@ static void swap_do_scheduled_discard(struct swap_info_struct *si)
> > > A 
> > > A 		spin_lock(&si->lock);
> > > A 		ci = lock_cluster(si, idx * SWAPFILE_CLUSTER);
> > > -		cluster_set_flag(ci, CLUSTER_FLAG_FREE);
> > > -		unlock_cluster(ci);
> > > -		cluster_list_add_tail(&si->free_clusters, info, idx);
> > > -		ci = lock_cluster(si, idx * SWAPFILE_CLUSTER);
> > > +		__free_cluster(si, idx);
> > > A 		memset(si->swap_map + idx * SWAPFILE_CLUSTER,
> > > A 				0, SWAPFILE_CLUSTER);
> > > A 		unlock_cluster(ci);
> > The __free_cluster definition and the above change to eliminate
> > the extra unlock_cluster and lock_cluster can perhaps be broken up
> > as a separate patch. A It can be independent of THP changes.
> I think the change may have no value by itself without THP changes.
> There will be only 1 user of __free_cluster() and the lock change is
> trivial too.A A So I think it may be better just to keep it as that?
> 

Seems like the extra unlock and lock of cluster in existing code should be taken out
irrespective of the THP changes:
A 
		cluster_set_flag(ci, CLUSTER_FLAG_FREE);
-		unlock_cluster(ci);
		cluster_list_add_tail(&si->free_clusters, info, idx);
-		ci = lock_cluster(si, idx * SWAPFILE_CLUSTER);
		memset(si->swap_map + idx * SWAPFILE_CLUSTER,
A A 				0, SWAPFILE_CLUSTER);

Tim

--
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:[~2017-03-15 17:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-08  7:26 [PATCH -v6 0/9] THP swap: Delay splitting THP during swapping out Huang, Ying
2017-03-08  7:26 ` [PATCH -mm -v6 1/9] mm, swap: Make swap cluster size same of THP size on x86_64 Huang, Ying
2017-03-08 12:56   ` Matthew Wilcox
2017-03-09  1:45     ` Huang, Ying
2017-03-08  7:26 ` [PATCH -mm -v6 2/9] mm, memcg: Support to charge/uncharge multiple swap entries Huang, Ying
2017-03-08 11:37   ` Balbir Singh
2017-03-09  1:28     ` Huang, Ying
2017-03-09 21:22       ` Balbir Singh
2017-03-08  7:26 ` [PATCH -mm -v6 3/9] mm, THP, swap: Add swap cluster allocate/free functions Huang, Ying
2017-03-14 23:13   ` Tim Chen
2017-03-15  1:19     ` Huang, Ying
2017-03-15 17:15       ` Tim Chen [this message]
2017-03-16  6:31         ` Huang, Ying
2017-03-08  7:26 ` [PATCH -mm -v6 4/9] mm, THP, swap: Add get_huge_swap_page() Huang, Ying
2017-03-14 23:40   ` Tim Chen
2017-03-15  1:08     ` Huang, Ying
2017-03-08  7:26 ` [PATCH -mm -v6 5/9] mm, THP, swap: Support to clear SWAP_HAS_CACHE for huge page Huang, Ying
2017-03-15  0:14   ` Tim Chen
2017-03-15  0:54     ` Huang, Ying
2017-03-08  7:26 ` [PATCH -mm -v6 6/9] mm, THP, swap: Support to add/delete THP to/from swap cache Huang, Ying
2017-03-08  7:26 ` [PATCH -mm -v6 7/9] mm, THP: Add can_split_huge_page() Huang, Ying
2017-03-08  7:26 ` [PATCH -mm -v6 8/9] mm, THP, swap: Support to split THP in swap cache Huang, Ying
2017-03-08  7:26 ` [PATCH -mm -v6 9/9] mm, THP, swap: Delay splitting THP during swap out Huang, Ying

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=1489598142.2733.60.camel@linux.intel.com \
    --to=tim.c.chen@linux.intel.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=riel@redhat.com \
    --cc=shli@kernel.org \
    --cc=ying.huang@intel.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;
as well as URLs for NNTP newsgroup(s).