* [PATCH] mm: zsmalloc: Replace return type int with bool
@ 2018-02-19 19:42 Souptick Joarder
2018-02-19 19:43 ` Randy Dunlap
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Souptick Joarder @ 2018-02-19 19:42 UTC (permalink / raw)
To: minchan, ngupta, sergey.senozhatsky.work; +Cc: linux-mm
zs_register_migration() returns either 0 or 1.
So the return type int should be replaced with bool.
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
mm/zsmalloc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index c301350..e238354 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -295,7 +295,7 @@ struct mapping_area {
};
#ifdef CONFIG_COMPACTION
-static int zs_register_migration(struct zs_pool *pool);
+static bool zs_register_migration(struct zs_pool *pool);
static void zs_unregister_migration(struct zs_pool *pool);
static void migrate_lock_init(struct zspage *zspage);
static void migrate_read_lock(struct zspage *zspage);
@@ -306,7 +306,7 @@ struct mapping_area {
#else
static int zsmalloc_mount(void) { return 0; }
static void zsmalloc_unmount(void) {}
-static int zs_register_migration(struct zs_pool *pool) { return 0; }
+static bool zs_register_migration(struct zs_pool *pool) { return 0; }
static void zs_unregister_migration(struct zs_pool *pool) {}
static void migrate_lock_init(struct zspage *zspage) {}
static void migrate_read_lock(struct zspage *zspage) {}
@@ -2101,17 +2101,17 @@ void zs_page_putback(struct page *page)
.putback_page = zs_page_putback,
};
-static int zs_register_migration(struct zs_pool *pool)
+static bool zs_register_migration(struct zs_pool *pool)
{
pool->inode = alloc_anon_inode(zsmalloc_mnt->mnt_sb);
if (IS_ERR(pool->inode)) {
pool->inode = NULL;
- return 1;
+ return true;
}
pool->inode->i_mapping->private_data = pool;
pool->inode->i_mapping->a_ops = &zsmalloc_aops;
- return 0;
+ return false;
}
static void zs_unregister_migration(struct zs_pool *pool)
--
1.9.1
--
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>
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] mm: zsmalloc: Replace return type int with bool 2018-02-19 19:42 [PATCH] mm: zsmalloc: Replace return type int with bool Souptick Joarder @ 2018-02-19 19:43 ` Randy Dunlap 2018-02-20 3:37 ` kbuild test robot 2018-02-20 3:37 ` [PATCH] mm: zsmalloc: fix boolreturn.cocci warnings kbuild test robot 2 siblings, 0 replies; 10+ messages in thread From: Randy Dunlap @ 2018-02-19 19:43 UTC (permalink / raw) To: Souptick Joarder, minchan, ngupta, sergey.senozhatsky.work; +Cc: linux-mm On 02/19/18 11:42, Souptick Joarder wrote: > zs_register_migration() returns either 0 or 1. > So the return type int should be replaced with bool. > > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com> > --- > mm/zsmalloc.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index c301350..e238354 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c > @@ -295,7 +295,7 @@ struct mapping_area { > }; > > #ifdef CONFIG_COMPACTION > -static int zs_register_migration(struct zs_pool *pool); > +static bool zs_register_migration(struct zs_pool *pool); > static void zs_unregister_migration(struct zs_pool *pool); > static void migrate_lock_init(struct zspage *zspage); > static void migrate_read_lock(struct zspage *zspage); > @@ -306,7 +306,7 @@ struct mapping_area { > #else > static int zsmalloc_mount(void) { return 0; } > static void zsmalloc_unmount(void) {} > -static int zs_register_migration(struct zs_pool *pool) { return 0; } > +static bool zs_register_migration(struct zs_pool *pool) { return 0; } return false; > static void zs_unregister_migration(struct zs_pool *pool) {} > static void migrate_lock_init(struct zspage *zspage) {} > static void migrate_read_lock(struct zspage *zspage) {} > @@ -2101,17 +2101,17 @@ void zs_page_putback(struct page *page) > .putback_page = zs_page_putback, > }; > > -static int zs_register_migration(struct zs_pool *pool) > +static bool zs_register_migration(struct zs_pool *pool) > { > pool->inode = alloc_anon_inode(zsmalloc_mnt->mnt_sb); > if (IS_ERR(pool->inode)) { > pool->inode = NULL; > - return 1; > + return true; > } > > pool->inode->i_mapping->private_data = pool; > pool->inode->i_mapping->a_ops = &zsmalloc_aops; > - return 0; > + return false; > } > > static void zs_unregister_migration(struct zs_pool *pool) > -- thanks, -- ~Randy -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: zsmalloc: Replace return type int with bool 2018-02-19 19:42 [PATCH] mm: zsmalloc: Replace return type int with bool Souptick Joarder 2018-02-19 19:43 ` Randy Dunlap @ 2018-02-20 3:37 ` kbuild test robot 2018-02-20 7:39 ` Souptick Joarder 2018-02-20 3:37 ` [PATCH] mm: zsmalloc: fix boolreturn.cocci warnings kbuild test robot 2 siblings, 1 reply; 10+ messages in thread From: kbuild test robot @ 2018-02-20 3:37 UTC (permalink / raw) To: Souptick Joarder Cc: kbuild-all, minchan, ngupta, sergey.senozhatsky.work, linux-mm Hi Souptick, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on mmotm/master] [also build test WARNING on v4.16-rc2 next-20180219] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Souptick-Joarder/mm-zsmalloc-Replace-return-type-int-with-bool/20180220-070147 base: git://git.cmpxchg.org/linux-mmotm.git master coccinelle warnings: (new ones prefixed by >>) >> mm/zsmalloc.c:309:65-66: WARNING: return of 0/1 in function 'zs_register_migration' with return type bool Please review and possibly fold the followup patch. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: zsmalloc: Replace return type int with bool 2018-02-20 3:37 ` kbuild test robot @ 2018-02-20 7:39 ` Souptick Joarder 2018-02-20 9:08 ` Minchan Kim 0 siblings, 1 reply; 10+ messages in thread From: Souptick Joarder @ 2018-02-20 7:39 UTC (permalink / raw) To: kbuild test robot Cc: kbuild-all, minchan, Nitin Gupta, sergey.senozhatsky.work, Linux-MM On Tue, Feb 20, 2018 at 9:07 AM, kbuild test robot <lkp@intel.com> wrote: > Hi Souptick, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on mmotm/master] > [also build test WARNING on v4.16-rc2 next-20180219] > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] > > url: https://github.com/0day-ci/linux/commits/Souptick-Joarder/mm-zsmalloc-Replace-return-type-int-with-bool/20180220-070147 > base: git://git.cmpxchg.org/linux-mmotm.git master > > > coccinelle warnings: (new ones prefixed by >>) > >>> mm/zsmalloc.c:309:65-66: WARNING: return of 0/1 in function 'zs_register_migration' with return type bool > > Please review and possibly fold the followup patch. > OK, I will send the v2. > --- > 0-DAY kernel test infrastructure Open Source Technology Center > https://lists.01.org/pipermail/kbuild-all Intel Corporation -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: zsmalloc: Replace return type int with bool 2018-02-20 7:39 ` Souptick Joarder @ 2018-02-20 9:08 ` Minchan Kim 2018-02-20 10:55 ` Souptick Joarder 0 siblings, 1 reply; 10+ messages in thread From: Minchan Kim @ 2018-02-20 9:08 UTC (permalink / raw) To: Souptick Joarder Cc: kbuild test robot, kbuild-all, Nitin Gupta, sergey.senozhatsky.work, Linux-MM Hi Souptick, On Tue, Feb 20, 2018 at 01:09:26PM +0530, Souptick Joarder wrote: > On Tue, Feb 20, 2018 at 9:07 AM, kbuild test robot <lkp@intel.com> wrote: > > Hi Souptick, > > > > Thank you for the patch! Perhaps something to improve: > > > > [auto build test WARNING on mmotm/master] > > [also build test WARNING on v4.16-rc2 next-20180219] > > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] > > > > url: https://github.com/0day-ci/linux/commits/Souptick-Joarder/mm-zsmalloc-Replace-return-type-int-with-bool/20180220-070147 > > base: git://git.cmpxchg.org/linux-mmotm.git master > > > > > > coccinelle warnings: (new ones prefixed by >>) > > > >>> mm/zsmalloc.c:309:65-66: WARNING: return of 0/1 in function 'zs_register_migration' with return type bool > > > > Please review and possibly fold the followup patch. > > > > OK, I will send the v2. First of all, thanks for the patch. Yub, bool could be more appropriate. However, there are lots of other places in kernel where use int instead of bool. If we fix every such places with each patch, it would be very painful. If you believe it's really worth, it would be better to find/fix every such places in one patch. But I'm not sure it's worth. Thanks. -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: zsmalloc: Replace return type int with bool 2018-02-20 9:08 ` Minchan Kim @ 2018-02-20 10:55 ` Souptick Joarder 2018-02-20 12:52 ` Matthew Wilcox 0 siblings, 1 reply; 10+ messages in thread From: Souptick Joarder @ 2018-02-20 10:55 UTC (permalink / raw) To: Minchan Kim Cc: kbuild test robot, kbuild-all, Nitin Gupta, sergey.senozhatsky.work, Linux-MM On Tue, Feb 20, 2018 at 2:38 PM, Minchan Kim <minchan@kernel.org> wrote: > Hi Souptick, > > On Tue, Feb 20, 2018 at 01:09:26PM +0530, Souptick Joarder wrote: >> On Tue, Feb 20, 2018 at 9:07 AM, kbuild test robot <lkp@intel.com> wrote: >> > Hi Souptick, >> > >> > Thank you for the patch! Perhaps something to improve: >> > >> > [auto build test WARNING on mmotm/master] >> > [also build test WARNING on v4.16-rc2 next-20180219] >> > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] >> > >> > url: https://github.com/0day-ci/linux/commits/Souptick-Joarder/mm-zsmalloc-Replace-return-type-int-with-bool/20180220-070147 >> > base: git://git.cmpxchg.org/linux-mmotm.git master >> > >> > >> > coccinelle warnings: (new ones prefixed by >>) >> > >> >>> mm/zsmalloc.c:309:65-66: WARNING: return of 0/1 in function 'zs_register_migration' with return type bool >> > >> > Please review and possibly fold the followup patch. >> > >> >> OK, I will send the v2. > > First of all, thanks for the patch. > > Yub, bool could be more appropriate. However, there are lots of other places > in kernel where use int instead of bool. > If we fix every such places with each patch, it would be very painful. > If you believe it's really worth, it would be better to find/fix every > such places in one patch. But I'm not sure it's worth. > Sure, I will create patch series and send it. > Thanks. -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: zsmalloc: Replace return type int with bool 2018-02-20 10:55 ` Souptick Joarder @ 2018-02-20 12:52 ` Matthew Wilcox 2018-02-20 13:37 ` Matthew Wilcox 0 siblings, 1 reply; 10+ messages in thread From: Matthew Wilcox @ 2018-02-20 12:52 UTC (permalink / raw) To: Souptick Joarder Cc: Minchan Kim, kbuild test robot, kbuild-all, Nitin Gupta, sergey.senozhatsky.work, Linux-MM On Tue, Feb 20, 2018 at 04:25:15PM +0530, Souptick Joarder wrote: > On Tue, Feb 20, 2018 at 2:38 PM, Minchan Kim <minchan@kernel.org> wrote: > > Yub, bool could be more appropriate. However, there are lots of other places > > in kernel where use int instead of bool. > > If we fix every such places with each patch, it would be very painful. > > If you believe it's really worth, it would be better to find/fix every > > such places in one patch. But I'm not sure it's worth. > > > > Sure, I will create patch series and send it. Please don't. If you're touching a function for another reason, it's fine to convert it to return bool. A series of patches converting every function in the kernel that could be converted will not make friends. -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: zsmalloc: Replace return type int with bool 2018-02-20 12:52 ` Matthew Wilcox @ 2018-02-20 13:37 ` Matthew Wilcox 2018-02-20 15:18 ` Souptick Joarder 0 siblings, 1 reply; 10+ messages in thread From: Matthew Wilcox @ 2018-02-20 13:37 UTC (permalink / raw) To: Souptick Joarder Cc: Minchan Kim, kbuild test robot, kbuild-all, Nitin Gupta, sergey.senozhatsky.work, Linux-MM On Tue, Feb 20, 2018 at 04:52:46AM -0800, Matthew Wilcox wrote: > On Tue, Feb 20, 2018 at 04:25:15PM +0530, Souptick Joarder wrote: > > On Tue, Feb 20, 2018 at 2:38 PM, Minchan Kim <minchan@kernel.org> wrote: > > > Yub, bool could be more appropriate. However, there are lots of other places > > > in kernel where use int instead of bool. > > > If we fix every such places with each patch, it would be very painful. > > > If you believe it's really worth, it would be better to find/fix every > > > such places in one patch. But I'm not sure it's worth. > > > > > > > Sure, I will create patch series and send it. > > Please don't. If you're touching a function for another reason, it's > fine to convert it to return bool. A series of patches converting every > function in the kernel that could be converted will not make friends. ... but if you're looking for something to do, here's something from my TODO list that's in the same category. The vm_ops fault, huge_fault, page_mkwrite and pfn_mkwrite handlers are currently defined to return an int (see linux/mm.h). Unlike the majority of functions which return int, these functions are supposed to return one or more of the VM_FAULT flags. There's general agreement that this should become a new typedef, vm_fault_t. We can do a gradual conversion; start off by adding typedef int vm_fault_t; to linux/mm.h. Then the individual drivers can be converted (one patch per driver) to return vm_fault_t from those handlers (probably about 180 patches, so take it slowly). Once all drivers are converted, we can change that typedef to: typedef enum { VM_FAULT_OOM = 1, VM_FAULT_SIGBUS = 2, VM_FAULT_MAJOR = 4, ... } vm_fault_t; and then the compiler will warn if anyone tries to introduce a new handler that returns int. -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: zsmalloc: Replace return type int with bool 2018-02-20 13:37 ` Matthew Wilcox @ 2018-02-20 15:18 ` Souptick Joarder 0 siblings, 0 replies; 10+ messages in thread From: Souptick Joarder @ 2018-02-20 15:18 UTC (permalink / raw) To: Matthew Wilcox Cc: Minchan Kim, kbuild test robot, Nitin Gupta, sergey.senozhatsky.work, Linux-MM Hi Matthew, On Tue, Feb 20, 2018 at 7:07 PM, Matthew Wilcox <willy@infradead.org> wrote: > On Tue, Feb 20, 2018 at 04:52:46AM -0800, Matthew Wilcox wrote: >> On Tue, Feb 20, 2018 at 04:25:15PM +0530, Souptick Joarder wrote: >> > On Tue, Feb 20, 2018 at 2:38 PM, Minchan Kim <minchan@kernel.org> wrote: >> > > Yub, bool could be more appropriate. However, there are lots of other places >> > > in kernel where use int instead of bool. >> > > If we fix every such places with each patch, it would be very painful. >> > > If you believe it's really worth, it would be better to find/fix every >> > > such places in one patch. But I'm not sure it's worth. >> > > >> > >> > Sure, I will create patch series and send it. >> >> Please don't. If you're touching a function for another reason, it's >> fine to convert it to return bool. A series of patches converting every >> function in the kernel that could be converted will not make friends. > > ... but if you're looking for something to do, here's something from my > TODO list that's in the same category. Thanks. I would like to take it. > > The vm_ops fault, huge_fault, page_mkwrite and pfn_mkwrite handlers are > currently defined to return an int (see linux/mm.h). Unlike the majority > of functions which return int, these functions are supposed to return > one or more of the VM_FAULT flags. There's general agreement that this > should become a new typedef, vm_fault_t. We can do a gradual conversion; > start off by adding > > typedef int vm_fault_t; > > to linux/mm.h. Then the individual drivers can be converted (one patch > per driver) to return vm_fault_t from those handlers (probably about > 180 patches, so take it slowly). Once all drivers are converted, we > can change that typedef to: > > typedef enum { > VM_FAULT_OOM = 1, > VM_FAULT_SIGBUS = 2, > VM_FAULT_MAJOR = 4, > ... > } vm_fault_t; > > and then the compiler will warn if anyone tries to introduce a new handler > that returns int. > Let me go through the shared details and will reply you back before making any changes. -Souptick -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] mm: zsmalloc: fix boolreturn.cocci warnings 2018-02-19 19:42 [PATCH] mm: zsmalloc: Replace return type int with bool Souptick Joarder 2018-02-19 19:43 ` Randy Dunlap 2018-02-20 3:37 ` kbuild test robot @ 2018-02-20 3:37 ` kbuild test robot 2 siblings, 0 replies; 10+ messages in thread From: kbuild test robot @ 2018-02-20 3:37 UTC (permalink / raw) To: Souptick Joarder Cc: kbuild-all, minchan, ngupta, sergey.senozhatsky.work, linux-mm From: Fengguang Wu <fengguang.wu@intel.com> mm/zsmalloc.c:309:65-66: WARNING: return of 0/1 in function 'zs_register_migration' with return type bool Return statements in functions returning bool should use true/false instead of 1/0. Generated by: scripts/coccinelle/misc/boolreturn.cocci Fixes: 3d58cbb028bb ("mm: zsmalloc: Replace return type int with bool") CC: Souptick Joarder <jrdr.linux@gmail.com> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> --- zsmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -306,7 +306,7 @@ static void SetZsPageMovable(struct zs_p #else static int zsmalloc_mount(void) { return 0; } static void zsmalloc_unmount(void) {} -static bool zs_register_migration(struct zs_pool *pool) { return 0; } +static bool zs_register_migration(struct zs_pool *pool) { return false; } static void zs_unregister_migration(struct zs_pool *pool) {} static void migrate_lock_init(struct zspage *zspage) {} static void migrate_read_lock(struct zspage *zspage) {} -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-02-20 15:19 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-02-19 19:42 [PATCH] mm: zsmalloc: Replace return type int with bool Souptick Joarder 2018-02-19 19:43 ` Randy Dunlap 2018-02-20 3:37 ` kbuild test robot 2018-02-20 7:39 ` Souptick Joarder 2018-02-20 9:08 ` Minchan Kim 2018-02-20 10:55 ` Souptick Joarder 2018-02-20 12:52 ` Matthew Wilcox 2018-02-20 13:37 ` Matthew Wilcox 2018-02-20 15:18 ` Souptick Joarder 2018-02-20 3:37 ` [PATCH] mm: zsmalloc: fix boolreturn.cocci warnings kbuild test robot
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).