Skip to contentSkip to conversation

shmem : remove redundant code

PATCH In review Huang Shijie 5 participants 11 messages Mar 8, 2010 – Mar 11, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shmem : remove redundant code

The prep_new_page() will call set_page_private(page, 0) to initiate the page.

So the code is redundant.

---
 mm/shmem.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
mm/shmem.c +0 -2
index eef4ebe..dde4363 100644
@@ -433,8 +433,6 @@ static swp_entry_t *shmem_swp_alloc(struct shmem_inode_info *info, unsigned long
 
 		spin_unlock(&info->lock);
 		page = shmem_dir_alloc(mapping_gfp_mask(inode->i_mapping));
-		if (page)
-			set_page_private(page, 0);
 		spin_lock(&info->lock);
 
 		if (!page) {
Signature · 7 lines
1.6.6

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Huang Shijie

The prep_new_page() will call set_page_private(page, 0) to initiate the page.

So the code is redundant.

Long time ago, nr_swapped named is meaningful as a comment at least. But as split page table lock is introduced in 4c21e2f2441, it was changed by just set_page_private.
So even it's not meaningful any more as a comment, I think. So let's remove redundant code.

Signature · 9 lines
Kind regards,
Minchan Kim


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
Quoted 12 lines · Huang Shijie
Quoted 8 lines

The prep_new_page() will call set_page_private(page, 0) to initiate the page.

So the code is redundant.

Thanks Minchan. :)

Quoted 7 lines

Long time ago, nr_swapped named is meaningful as a comment at least. But as split page table lock is introduced in 4c21e2f2441, it was changed by just set_page_private.
So even it's not meaningful any more as a comment, I think. So let's remove redundant code.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw

PATCH 1/1 kvm : remove redundant initialization of page->private

In reply to Huang Shijie
Quoted 15 lines · Huang Shijie

The prep_new_page() will call set_page_private(page, 0) to initiate the page.

So the code is redundant.

---
 mm/shmem.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
mm/shmem.c +0 -0
index eef4ebe..dde4363 100644

mm/shmem.c static swp_entry_t *shmem_swp_alloc(struct shmem_inode_info *info, unsigned long · line 438

Quoted 8 lines
mm/shmem.c +0 -2
@@ -433,8 +433,6 @@ static swp_entry_t *shmem_swp_alloc(struct shmem_inode_info *info, unsigned long
 
 		spin_unlock(&info->lock);
 		page = shmem_dir_alloc(mapping_gfp_mask(inode->i_mapping));
-		if (page)
-			set_page_private(page, 0);
 		spin_lock(&info->lock);
 
 		if (!page) {

And I found another place while I review the code.

Quoted 1 line

From e64322cde914e43d080d8f3be6f72459d809a934 Mon Sep 17 00:00:00 2001

From: Minchan Kim <barrios@barrios-desktop.(none)>
Date: Tue, 9 Mar 2010 01:09:56 +0900
Subject: [PATCH] kvm : remove redundant initialization of page->private.

The prep_new_page() in page allocator calls set_page_private(page, 0). So we don't need to reinitialize private of page.

---
 arch/x86/kvm/mmu.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
arch/x86/kvm/mmu.c +0 -0
index 741373e..9851d0e 100644
@@ -326,7 +326,6 @@ static int mmu_topup_memory_cache_page(struct

kvm_mmu_memory_cache *cache,
page = alloc_page(GFP_KERNEL);
if (!page)
return -ENOMEM;
- set_page_private(page, 0);
cache->objects[cache->nobjs++] = page_address(page);
}
return 0;

Signature · 14 lines
1.6.5



-- 
Kind regards,
Minchan Kim


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#4 lore raw

Re: [PATCH] kvm : remove redundant initialization of page->private

Quoted 54 lines · Minchan Kim
Quoted 16 lines · Huang Shijie

The prep_new_page() will call set_page_private(page, 0) to initiate the page.

So the code is redundant.

---
  mm/shmem.c |    2 --
  1 files changed, 0 insertions(+), 2 deletions(-)
mm/shmem.c +0 -0
index eef4ebe..dde4363 100644

mm/shmem.c static swp_entry_t *shmem_swp_alloc(struct shmem_inode_info *info, unsigned long · line 438

Quoted 8 lines
mm/shmem.c +0 -2
@@ -433,8 +433,6 @@ static swp_entry_t *shmem_swp_alloc(struct shmem_inode_info *info, unsigned long
 
  		spin_unlock(&info->lock);
  		page = shmem_dir_alloc(mapping_gfp_mask(inode->i_mapping));
-		if (page)
-			set_page_private(page, 0);
  		spin_lock(&info->lock);
 
  		if (!page) {

And I found another place while I review the code.

Quoted 1 line

From e64322cde914e43d080d8f3be6f72459d809a934 Mon Sep 17 00:00:00 2001

From: Minchan Kim<barrios@barrios-desktop.(none)>
Date: Tue, 9 Mar 2010 01:09:56 +0900
Subject: [PATCH] kvm : remove redundant initialization of page->private.

The prep_new_page() in page allocator calls set_page_private(page, 0). So we don't need to reinitialize private of page.

---
  arch/x86/kvm/mmu.c |    1 -
  1 files changed, 0 insertions(+), 1 deletions(-)
arch/x86/kvm/mmu.c +0 -1
index 741373e..9851d0e 100644
@@ -326,7 +326,6 @@ static int mmu_topup_memory_cache_page(struct
 kvm_mmu_memory_cache *cache,
  		page = alloc_page(GFP_KERNEL);
  		if (!page)
  			return -ENOMEM;
-		set_page_private(page, 0);
  		cache->objects[cache->nobjs++] = page_address(page);
  	}
Quoted 2 lines

return 0;

Whitespace damage, please resend.

Signature · 7 lines
error compiling committee.c: too many arguments to function

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#5 lore raw

Re: [PATCH] kvm : remove redundant initialization of page->private

Quoted 2 lines · Avi Kivity

Whitespace damage, please resend.

Sorry for forgetting preformatted option of mail client. Here is resend version.

== CUT_HERE ==

Quoted 1 line

From e64322cde914e43d080d8f3be6f72459d809a934 Mon Sep 17 00:00:00 2001

From: Minchan Kim<barrios@barrios-desktop.(none)>
Date: Tue, 9 Mar 2010 01:09:56 +0900
Subject: [PATCH] kvm : remove redundant initialization of page->private.

The prep_new_page() in page allocator calls set_page_private(page, 0). So we don't need to reinitialize private of page.

---
 arch/x86/kvm/mmu.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
arch/x86/kvm/mmu.c +0 -1
index 741373e..9851d0e 100644
@@ -326,7 +326,6 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
 		page = alloc_page(GFP_KERNEL);
 		if (!page)
 			return -ENOMEM;
-		set_page_private(page, 0);
 		cache->objects[cache->nobjs++] = page_address(page);
 	}
 	return 0;
Signature · 15 lines
1.6.5



-- 
Kind regards,
Minchan Kim



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Applied
#6 lore raw

Re: [PATCH] kvm : remove redundant initialization of page->private

Quoted 5 lines · Minchan Kim

The prep_new_page() in page allocator calls set_page_private(page, 0). So we don't need to reinitialize private of page.

Applied, thanks. Please copy the kvm mailing list in the future on kvm patches.

arch/x86/kvm/mmu.c static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache, · line 331

Quoted 13 lines
arch/x86/kvm/mmu.c +0 -1
index 741373e..9851d0e 100644
@@ -326,7 +326,6 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
  		page = alloc_page(GFP_KERNEL);
  		if (!page)
  			return -ENOMEM;
-		set_page_private(page, 0);
  		cache->objects[cache->nobjs++] = page_address(page);
  	}
  	return 0;

Jan, this is kvm-kmod unfriendly. kvm_alloc_page()?

Signature · 7 lines
error compiling committee.c: too many arguments to function

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw

Re: [PATCH] kvm : remove redundant initialization of page->private

Quoted 9 lines · Avi Kivity
Quoted 4 lines · Minchan Kim

The prep_new_page() in page allocator calls set_page_private(page, 0). So we don't need to reinitialize private of page.

Applied, thanks. Please copy the kvm mailing list in the future on kvm patches.

Quoted 16 lines

arch/x86/kvm/mmu.c static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache, · line 331

Quoted 13 lines
arch/x86/kvm/mmu.c +0 -1
index 741373e..9851d0e 100644
@@ -326,7 +326,6 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
  		page = alloc_page(GFP_KERNEL);
  		if (!page)
  			return -ENOMEM;
-		set_page_private(page, 0);
  		cache->objects[cache->nobjs++] = page_address(page);
  	}
  	return 0;

Jan, this is kvm-kmod unfriendly. kvm_alloc_page()?

Thanks for pointing out! Since which kernel can we rely on the implicit set_page_private?

Jan

Signature · 8 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#8 lore raw

Re: [PATCH] kvm : remove redundant initialization of page->private

Quoted 30 lines · Jan Kiszka
Quoted 11 lines · Avi Kivity
Quoted 5 lines · Minchan Kim

The prep_new_page() in page allocator calls set_page_private(page, 0). So we don't need to reinitialize private of page.

Applied, thanks. Please copy the kvm mailing list in the future on kvm patches.

Quoted 17 lines
Quoted 7 lines
arch/x86/kvm/mmu.c +0 -0
index 741373e..9851d0e 100644

arch/x86/kvm/mmu.c static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache, · line 331

Quoted 7 lines
arch/x86/kvm/mmu.c +0 -1
@@ -326,7 +326,6 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
   		page = alloc_page(GFP_KERNEL);
   		if (!page)
   			return -ENOMEM;
-		set_page_private(page, 0);
   		cache->objects[cache->nobjs++] = page_address(page);
   	}
   	return 0;

Jan, this is kvm-kmod unfriendly. kvm_alloc_page()?

Quoted 4 lines

Thanks for pointing out! Since which kernel can we rely on the implicit set_page_private?

Um, git blame shows it goes all the way back to 2.6.12. So it was redundant all along.

Signature · 7 lines
error compiling committee.c: too many arguments to function

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#9 lore raw

Re: [PATCH] kvm : remove redundant initialization of page->private

Quoted 7 lines · Avi Kivity
Quoted 3 lines · Jan Kiszka
Quoted 1 line

Thanks for pointing out! Since which kernel can we rely on the implicit set_page_private?

Um, git blame shows it goes all the way back to 2.6.12. So it was redundant all along.

Not that it matters at all, but no, that was just the dawning of the git age. prep_new_page() started initializing page->private in 2.6.0-test3:

<[email protected]>

	[PATCH] initialise page->private
	
	From: Nathan Scott <[email protected]>
	
	XFS wants to use page->private as a bitmap of uptodate indicators for
	sub-page-sized blocks (which is one of the things ->provate was intended
	for).
	
	But someone needs to initialise ->private somewhere.  best to do it in the
	page allocator, so the zeroness of a new page's ->private becomes a
	system-wide thing.

Hugh

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by on v1 1/1
#10 lore raw
In reply to Huang Shijie
Quoted 6 lines · Huang Shijie

The prep_new_page() will call set_page_private(page, 0) to initiate the page.

So the code is redundant.

I didn't feel too enthusiastic at first, since private used not to be initialized by page allocation, and I don't know of a strong reason why it should be: we do strongly demand that page->mapping be NULL on allocation, but we leave page->index with whatever it already contains, and I had thought page->_private the same.

But it seems we have been initializing private to 0 for nearly seven years now, and it was done intentionally for something (XFS) to depend upon, so yes, let's rely on that here too - thanks.

Hugh

Quoted 19 lines
---
 mm/shmem.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
mm/shmem.c +0 -2
index eef4ebe..dde4363 100644
@@ -433,8 +433,6 @@ static swp_entry_t *shmem_swp_alloc(struct shmem_inode_info *info, unsigned long
 
 		spin_unlock(&info->lock);
 		page = shmem_dir_alloc(mapping_gfp_mask(inode->i_mapping));
-		if (page)
-			set_page_private(page, 0);
 		spin_lock(&info->lock);
 
 		if (!page) {
Signature · 1 line
1.6.6

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>