Linux-mm Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] mm/madvise: replace with page_size() in madvise_inject_error()
@ 2019-11-06  7:06 Yunfeng Ye
  2019-11-06 21:28 ` David Rientjes
  0 siblings, 1 reply; 4+ messages in thread
From: Yunfeng Ye @ 2019-11-06  7:06 UTC (permalink / raw)
  To: akpm, jgg, mhocko, jglisse, minchan, peterz, jack, rppt
  Cc: linux-mm, linux-kernel, hushiyuan, linfeilong

The function page_size() is supported after the commit a50b854e073c
("mm: introduce page_size()").

Replace with page_size() in madvise_inject_error() for readability.

Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
---
 mm/madvise.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/madvise.c b/mm/madvise.c
index 2be9f3fdb05e..38c4e7fcf850 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -856,13 +856,13 @@ static int madvise_inject_error(int behavior,
 {
 	struct page *page;
 	struct zone *zone;
-	unsigned int order;
+	unsigned int size;

 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;


-	for (; start < end; start += PAGE_SIZE << order) {
+	for (; start < end; start += size) {
 		unsigned long pfn;
 		int ret;

@@ -874,9 +874,9 @@ static int madvise_inject_error(int behavior,
 		/*
 		 * When soft offlining hugepages, after migrating the page
 		 * we dissolve it, therefore in the second loop "page" will
-		 * no longer be a compound page, and order will be 0.
+		 * no longer be a compound page.
 		 */
-		order = compound_order(compound_head(page));
+		size = page_size(compound_head(page));

 		if (PageHWPoison(page)) {
 			put_page(page);
-- 
2.7.4



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/madvise: replace with page_size() in madvise_inject_error()
  2019-11-06  7:06 [PATCH] mm/madvise: replace with page_size() in madvise_inject_error() Yunfeng Ye
@ 2019-11-06 21:28 ` David Rientjes
  2019-11-07  2:05   ` Yunfeng Ye
  0 siblings, 1 reply; 4+ messages in thread
From: David Rientjes @ 2019-11-06 21:28 UTC (permalink / raw)
  To: Yunfeng Ye
  Cc: akpm, jgg, mhocko, jglisse, minchan, peterz, jack, rppt,
	linux-mm, linux-kernel, hushiyuan, linfeilong

On Wed, 6 Nov 2019, Yunfeng Ye wrote:

> The function page_size() is supported after the commit a50b854e073c
> ("mm: introduce page_size()").
> 
> Replace with page_size() in madvise_inject_error() for readability.
> 
> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
> ---
>  mm/madvise.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/madvise.c b/mm/madvise.c
> index 2be9f3fdb05e..38c4e7fcf850 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
> @@ -856,13 +856,13 @@ static int madvise_inject_error(int behavior,
>  {
>  	struct page *page;
>  	struct zone *zone;
> -	unsigned int order;
> +	unsigned int size;

Should be unsinged long.

> 
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
> 
> 
> -	for (; start < end; start += PAGE_SIZE << order) {
> +	for (; start < end; start += size) {
>  		unsigned long pfn;
>  		int ret;
> 
> @@ -874,9 +874,9 @@ static int madvise_inject_error(int behavior,
>  		/*
>  		 * When soft offlining hugepages, after migrating the page
>  		 * we dissolve it, therefore in the second loop "page" will
> -		 * no longer be a compound page, and order will be 0.
> +		 * no longer be a compound page.
>  		 */
> -		order = compound_order(compound_head(page));
> +		size = page_size(compound_head(page));
> 
>  		if (PageHWPoison(page)) {
>  			put_page(page);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/madvise: replace with page_size() in madvise_inject_error()
  2019-11-06 21:28 ` David Rientjes
@ 2019-11-07  2:05   ` Yunfeng Ye
  2019-11-07 20:48     ` David Rientjes
  0 siblings, 1 reply; 4+ messages in thread
From: Yunfeng Ye @ 2019-11-07  2:05 UTC (permalink / raw)
  To: David Rientjes
  Cc: akpm, jgg, mhocko, jglisse, minchan, peterz, jack, rppt,
	linux-mm, linux-kernel, hushiyuan, linfeilong



On 2019/11/7 5:28, David Rientjes wrote:
> On Wed, 6 Nov 2019, Yunfeng Ye wrote:
> 
>> The function page_size() is supported after the commit a50b854e073c
>> ("mm: introduce page_size()").
>>
>> Replace with page_size() in madvise_inject_error() for readability.
>>
>> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
>> ---
>>  mm/madvise.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/madvise.c b/mm/madvise.c
>> index 2be9f3fdb05e..38c4e7fcf850 100644
>> --- a/mm/madvise.c
>> +++ b/mm/madvise.c
>> @@ -856,13 +856,13 @@ static int madvise_inject_error(int behavior,
>>  {
>>  	struct page *page;
>>  	struct zone *zone;
>> -	unsigned int order;
>> +	unsigned int size;
> 
> Should be unsinged long.
> 
ok, thanks. Andrew has already help me modify the patch and add to -mm tree.

>>
>>  	if (!capable(CAP_SYS_ADMIN))
>>  		return -EPERM;
>>
>>
>> -	for (; start < end; start += PAGE_SIZE << order) {
>> +	for (; start < end; start += size) {
>>  		unsigned long pfn;
>>  		int ret;
>>
>> @@ -874,9 +874,9 @@ static int madvise_inject_error(int behavior,
>>  		/*
>>  		 * When soft offlining hugepages, after migrating the page
>>  		 * we dissolve it, therefore in the second loop "page" will
>> -		 * no longer be a compound page, and order will be 0.
>> +		 * no longer be a compound page.
>>  		 */
>> -		order = compound_order(compound_head(page));
>> +		size = page_size(compound_head(page));
>>
>>  		if (PageHWPoison(page)) {
>>  			put_page(page);
> 
> .
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/madvise: replace with page_size() in madvise_inject_error()
  2019-11-07  2:05   ` Yunfeng Ye
@ 2019-11-07 20:48     ` David Rientjes
  0 siblings, 0 replies; 4+ messages in thread
From: David Rientjes @ 2019-11-07 20:48 UTC (permalink / raw)
  To: Yunfeng Ye
  Cc: akpm, jgg, mhocko, jglisse, minchan, peterz, jack, rppt,
	linux-mm, linux-kernel, hushiyuan, linfeilong

On Thu, 7 Nov 2019, Yunfeng Ye wrote:

> >> The function page_size() is supported after the commit a50b854e073c
> >> ("mm: introduce page_size()").
> >>
> >> Replace with page_size() in madvise_inject_error() for readability.
> >>
> >> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
> >> ---
> >>  mm/madvise.c | 8 ++++----
> >>  1 file changed, 4 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/mm/madvise.c b/mm/madvise.c
> >> index 2be9f3fdb05e..38c4e7fcf850 100644
> >> --- a/mm/madvise.c
> >> +++ b/mm/madvise.c
> >> @@ -856,13 +856,13 @@ static int madvise_inject_error(int behavior,
> >>  {
> >>  	struct page *page;
> >>  	struct zone *zone;
> >> -	unsigned int order;
> >> +	unsigned int size;
> > 
> > Should be unsinged long.
> > 
> ok, thanks. Andrew has already help me modify the patch and add to -mm tree.
> 

Good deal, in that case:

Acked-by: David Rientjes <rientjes@google.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06  7:06 [PATCH] mm/madvise: replace with page_size() in madvise_inject_error() Yunfeng Ye
2019-11-06 21:28 ` David Rientjes
2019-11-07  2:05   ` Yunfeng Ye
2019-11-07 20:48     ` David Rientjes

Linux-mm Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mm/0 linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ https://lore.kernel.org/linux-mm \
		linux-mm@kvack.org
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kvack.linux-mm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git