linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fix the type of a parameter
@ 2021-11-25 19:43 Yixuan Cao
  2021-11-25 20:28 ` Matthew Wilcox
  0 siblings, 1 reply; 4+ messages in thread
From: Yixuan Cao @ 2021-11-25 19:43 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Yixuan Cao

The type of "last_migrate_reason" in struct page_owner is short.
However, the type of "reason" in the argument list of function
__set_page_owner_migrate_reason is int,
which is inconsistent.

Signed-off-by: Yixuan Cao <caoyixuan2019@email.szu.edu.cn>
---
 mm/page_owner.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/page_owner.c b/mm/page_owner.c
index 4f924957ce7a..4c23e910caf9 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -182,7 +182,7 @@ noinline void __set_page_owner(struct page *page, unsigned short order,
 	__set_page_owner_handle(page_ext, handle, order, gfp_mask);
 }
 
-void __set_page_owner_migrate_reason(struct page *page, int reason)
+void __set_page_owner_migrate_reason(struct page *page, short reason)
 {
 	struct page_ext *page_ext = lookup_page_ext(page);
 	struct page_owner *page_owner;
-- 
2.31.1




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

* Re: [PATCH] mm: fix the type of a parameter
  2021-11-25 19:43 [PATCH] mm: fix the type of a parameter Yixuan Cao
@ 2021-11-25 20:28 ` Matthew Wilcox
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2021-11-25 20:28 UTC (permalink / raw)
  To: Yixuan Cao; +Cc: akpm, linux-mm, linux-kernel

On Fri, Nov 26, 2021 at 03:43:01AM +0800, Yixuan Cao wrote:
> The type of "last_migrate_reason" in struct page_owner is short.
> However, the type of "reason" in the argument list of function
> __set_page_owner_migrate_reason is int,
> which is inconsistent.

Did you try compiling this patch?

> Signed-off-by: Yixuan Cao <caoyixuan2019@email.szu.edu.cn>
> ---
>  mm/page_owner.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/page_owner.c b/mm/page_owner.c
> index 4f924957ce7a..4c23e910caf9 100644
> --- a/mm/page_owner.c
> +++ b/mm/page_owner.c
> @@ -182,7 +182,7 @@ noinline void __set_page_owner(struct page *page, unsigned short order,
>  	__set_page_owner_handle(page_ext, handle, order, gfp_mask);
>  }
>  
> -void __set_page_owner_migrate_reason(struct page *page, int reason)
> +void __set_page_owner_migrate_reason(struct page *page, short reason)
>  {
>  	struct page_ext *page_ext = lookup_page_ext(page);
>  	struct page_owner *page_owner;
> -- 
> 2.31.1
> 
> 
> 
> 

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

* Re: [PATCH] mm: fix the type of a parameter
  2021-12-01 18:12 Yixuan Cao
@ 2021-12-02  3:34 ` Andrew Morton
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2021-12-02  3:34 UTC (permalink / raw)
  To: Yixuan Cao; +Cc: linux-mm, linux-kernel

On Thu,  2 Dec 2021 02:12:36 +0800 Yixuan Cao <caoyixuan2019@email.szu.edu.cn> wrote:

> The type of "last_migrate_reason" in struct page_owner is short.
> However, the type of "reason" in the argument list of following functions
> __set_page_owner_migrate_reason
> set_page_owner_migrate_reason
> 
> is int, which is inconsistent.

Well.

I'd say "no", because `int' is a natural type and the packing of that
scalar into a `short' is an expedient little space-saving hack (ie, an
"implementation detail") which should be hidden from callers rather
than propagated back up the call stack.

However, all these `int's should be of type `enum migrate_reason'.  And
the lowest-level hack of stuffing that enum into a `short' should
remain an implementation detail, hidden from callers.


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

* [PATCH] mm: fix the type of a parameter
@ 2021-12-01 18:12 Yixuan Cao
  2021-12-02  3:34 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Yixuan Cao @ 2021-12-01 18:12 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Yixuan Cao

The type of "last_migrate_reason" in struct page_owner is short.
However, the type of "reason" in the argument list of following functions
__set_page_owner_migrate_reason
set_page_owner_migrate_reason

is int, which is inconsistent.

Signed-off-by: Yixuan Cao <caoyixuan2019@email.szu.edu.cn>
---
 include/linux/page_owner.h | 6 +++---
 mm/page_owner.c            | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/page_owner.h b/include/linux/page_owner.h
index 119a0c9d2a8b..c537315ec02f 100644
--- a/include/linux/page_owner.h
+++ b/include/linux/page_owner.h
@@ -13,7 +13,7 @@ extern void __set_page_owner(struct page *page,
 			unsigned short order, gfp_t gfp_mask);
 extern void __split_page_owner(struct page *page, unsigned int nr);
 extern void __folio_copy_owner(struct folio *newfolio, struct folio *old);
-extern void __set_page_owner_migrate_reason(struct page *page, int reason);
+extern void __set_page_owner_migrate_reason(struct page *page, short reason);
 extern void __dump_page_owner(const struct page *page);
 extern void pagetypeinfo_showmixedcount_print(struct seq_file *m,
 					pg_data_t *pgdat, struct zone *zone);
@@ -41,7 +41,7 @@ static inline void folio_copy_owner(struct folio *newfolio, struct folio *old)
 	if (static_branch_unlikely(&page_owner_inited))
 		__folio_copy_owner(newfolio, old);
 }
-static inline void set_page_owner_migrate_reason(struct page *page, int reason)
+static inline void set_page_owner_migrate_reason(struct page *page, short reason)
 {
 	if (static_branch_unlikely(&page_owner_inited))
 		__set_page_owner_migrate_reason(page, reason);
@@ -66,7 +66,7 @@ static inline void split_page_owner(struct page *page,
 static inline void folio_copy_owner(struct folio *newfolio, struct folio *folio)
 {
 }
-static inline void set_page_owner_migrate_reason(struct page *page, int reason)
+static inline void set_page_owner_migrate_reason(struct page *page, short reason)
 {
 }
 static inline void dump_page_owner(const struct page *page)
diff --git a/mm/page_owner.c b/mm/page_owner.c
index 4f924957ce7a..4c23e910caf9 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -182,7 +182,7 @@ noinline void __set_page_owner(struct page *page, unsigned short order,
 	__set_page_owner_handle(page_ext, handle, order, gfp_mask);
 }
 
-void __set_page_owner_migrate_reason(struct page *page, int reason)
+void __set_page_owner_migrate_reason(struct page *page, short reason)
 {
 	struct page_ext *page_ext = lookup_page_ext(page);
 	struct page_owner *page_owner;
-- 
2.31.1




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

end of thread, other threads:[~2021-12-02  3:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25 19:43 [PATCH] mm: fix the type of a parameter Yixuan Cao
2021-11-25 20:28 ` Matthew Wilcox
2021-12-01 18:12 Yixuan Cao
2021-12-02  3:34 ` Andrew Morton

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).