Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1600949 > unrolled thread
| Started by | Tim Chen <tim.c.chen@linux.intel.com> |
|---|---|
| First post | 2017-03-15 00:20 +0100 |
| Last post | 2017-03-16 07:40 +0100 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH -mm -v6 3/9] mm, THP, swap: Add swap cluster allocate/free functions Tim Chen <tim.c.chen@linux.intel.com> - 2017-03-15 00:20 +0100
Re: [PATCH -mm -v6 3/9] mm, THP, swap: Add swap cluster allocate/free functions "Huang\, Ying" <ying.huang@intel.com> - 2017-03-15 02:20 +0100
Re: [PATCH -mm -v6 3/9] mm, THP, swap: Add swap cluster allocate/free functions Tim Chen <tim.c.chen@linux.intel.com> - 2017-03-15 18:20 +0100
Re: [PATCH -mm -v6 3/9] mm, THP, swap: Add swap cluster allocate/free functions "Huang\, Ying" <ying.huang@intel.com> - 2017-03-16 07:40 +0100
| From | Tim Chen <tim.c.chen@linux.intel.com> |
|---|---|
| Date | 2017-03-15 00:20 +0100 |
| Subject | Re: [PATCH -mm -v6 3/9] mm, THP, swap: Add swap cluster allocate/free functions |
| Message-ID | <tl3Ts-7ky-5@gated-at.bofh.it> |
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. These functions
> don't work for the rotating hard disks because the existing swap cluster
> management mechanism doesn't work for them. The hard disks support may
> be added if someone really need it. 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>
> ---
> mm/swapfile.c | 217 +++++++++++++++++++++++++++++++++++++++++-----------------
> 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,
> schedule_work(&si->discard_work);
> }
>
> +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);
> +}
> +
> /*
> * Doing discard actually. After a cluster discard is finished, the cluster
> * 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)
>
> spin_lock(&si->lock);
> 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);
> memset(si->swap_map + idx * SWAPFILE_CLUSTER,
> 0, SWAPFILE_CLUSTER);
> 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. It can be independent of THP changes.
Tim
[toc] | [next] | [standalone]
| From | "Huang\, Ying" <ying.huang@intel.com> |
|---|---|
| Date | 2017-03-15 02:20 +0100 |
| Subject | Re: [PATCH -mm -v6 3/9] mm, THP, swap: Add swap cluster allocate/free functions |
| Message-ID | <tl5LA-a2-11@gated-at.bofh.it> |
| In reply to | #1600949 |
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. These functions
>> don't work for the rotating hard disks because the existing swap cluster
>> management mechanism doesn't work for them. The hard disks support may
>> be added if someone really need it. 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>
>> ---
>> mm/swapfile.c | 217 +++++++++++++++++++++++++++++++++++++++++-----------------
>> 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,
>> schedule_work(&si->discard_work);
>> }
>>
>> +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);
>> +}
>> +
>> /*
>> * Doing discard actually. After a cluster discard is finished, the cluster
>> * 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)
>>
>> spin_lock(&si->lock);
>> 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);
>> memset(si->swap_map + idx * SWAPFILE_CLUSTER,
>> 0, SWAPFILE_CLUSTER);
>> 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. 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. So I think it may be better just to keep it as that?
Best Regards,
Huang, Ying
[toc] | [prev] | [next] | [standalone]
| From | Tim Chen <tim.c.chen@linux.intel.com> |
|---|---|
| Date | 2017-03-15 18:20 +0100 |
| Message-ID | <tlkKC-2iu-19@gated-at.bofh.it> |
| In reply to | #1600980 |
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. These functions
> > > don't work for the rotating hard disks because the existing swap cluster
> > > management mechanism doesn't work for them. The hard disks support may
> > > be added if someone really need it. 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>
> > > ---
> > > mm/swapfile.c | 217 +++++++++++++++++++++++++++++++++++++++++-----------------
> > > 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,
> > > schedule_work(&si->discard_work);
> > > }
> > >
> > > +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);
> > > +}
> > > +
> > > /*
> > > * Doing discard actually. After a cluster discard is finished, the cluster
> > > * 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)
> > >
> > > spin_lock(&si->lock);
> > > 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);
> > > memset(si->swap_map + idx * SWAPFILE_CLUSTER,
> > > 0, SWAPFILE_CLUSTER);
> > > 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. 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. 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:
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,
0, SWAPFILE_CLUSTER);
Tim
[toc] | [prev] | [next] | [standalone]
| From | "Huang\, Ying" <ying.huang@intel.com> |
|---|---|
| Date | 2017-03-16 07:40 +0100 |
| Subject | Re: [PATCH -mm -v6 3/9] mm, THP, swap: Add swap cluster allocate/free functions |
| Message-ID | <tlxeO-2IL-13@gated-at.bofh.it> |
| In reply to | #1601579 |
Tim Chen <tim.c.chen@linux.intel.com> writes:
> 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. These functions
>> > > don't work for the rotating hard disks because the existing swap cluster
>> > > management mechanism doesn't work for them. The hard disks support may
>> > > be added if someone really need it. 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>
>> > > ---
>> > > mm/swapfile.c | 217 +++++++++++++++++++++++++++++++++++++++++-----------------
>> > > 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,
>> > > schedule_work(&si->discard_work);
>> > > }
>> > >
>> > > +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);
>> > > +}
>> > > +
>> > > /*
>> > > * Doing discard actually. After a cluster discard is finished, the cluster
>> > > * 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)
>> > >
>> > > spin_lock(&si->lock);
>> > > 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);
>> > > memset(si->swap_map + idx * SWAPFILE_CLUSTER,
>> > > 0, SWAPFILE_CLUSTER);
>> > > 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. 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. 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:
>
> 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,
> 0, SWAPFILE_CLUSTER);
>
This is not a functionality fix or performance optimization. Because
the lock on the swap_info_struct is held during the operation and there
are no operations on cluster with index "idx" in
cluster_list_add_tail(). The change here is just to make the resulting
code a little simpler. Is this deserved a separate patch?
Best Regards,
Huang, Ying
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web