* [PATCH v1] mm: Re-use DEFINE_SHOW_ATTRIBUTE() macro
@ 2018-02-14 15:46 Andy Shevchenko
2018-02-14 16:04 ` Matthew Wilcox
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-02-14 15:46 UTC (permalink / raw)
To: Tejun Heo, Christoph Lameter, Dennis Zhou, Minchan Kim,
Nitin Gupta, Sergey Senozhatsky, linux-mm, Andrew Morton
Cc: Andy Shevchenko
...instead of open coding file operations followed by custom ->open()
callbacks per each attribute.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
mm/backing-dev.c | 12 +-----------
mm/memblock.c | 12 +-----------
mm/percpu-stats.c | 12 +-----------
mm/zsmalloc.c | 12 +-----------
4 files changed, 4 insertions(+), 44 deletions(-)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index ffa0c6b9e78a..71292de5f026 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -101,17 +101,7 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v)
return 0;
}
-static int bdi_debug_stats_open(struct inode *inode, struct file *file)
-{
- return single_open(file, bdi_debug_stats_show, inode->i_private);
-}
-
-static const struct file_operations bdi_debug_stats_fops = {
- .open = bdi_debug_stats_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(bdi_debug_stats);
static int bdi_debug_register(struct backing_dev_info *bdi, const char *name)
{
diff --git a/mm/memblock.c b/mm/memblock.c
index 5a9ca2a1751b..c2e5925ebdc4 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1847,17 +1847,7 @@ static int memblock_debug_show(struct seq_file *m, void *private)
return 0;
}
-static int memblock_debug_open(struct inode *inode, struct file *file)
-{
- return single_open(file, memblock_debug_show, inode->i_private);
-}
-
-static const struct file_operations memblock_debug_fops = {
- .open = memblock_debug_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(memblock_debug);
static int __init memblock_init_debugfs(void)
{
diff --git a/mm/percpu-stats.c b/mm/percpu-stats.c
index 7a58460bfd27..0305cc4cbc3e 100644
--- a/mm/percpu-stats.c
+++ b/mm/percpu-stats.c
@@ -224,17 +224,7 @@ static int percpu_stats_show(struct seq_file *m, void *v)
return 0;
}
-static int percpu_stats_open(struct inode *inode, struct file *filp)
-{
- return single_open(filp, percpu_stats_show, NULL);
-}
-
-static const struct file_operations percpu_stats_fops = {
- .open = percpu_stats_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(percpu_stats);
static int __init init_percpu_stats_debugfs(void)
{
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index c3013505c305..1b5cea3fe9fe 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -642,17 +642,7 @@ static int zs_stats_size_show(struct seq_file *s, void *v)
return 0;
}
-static int zs_stats_size_open(struct inode *inode, struct file *file)
-{
- return single_open(file, zs_stats_size_show, inode->i_private);
-}
-
-static const struct file_operations zs_stat_size_ops = {
- .open = zs_stats_size_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(zs_stats_size);
static void zs_pool_stat_create(struct zs_pool *pool, const char *name)
{
--
2.15.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] 6+ messages in thread
* Re: [PATCH v1] mm: Re-use DEFINE_SHOW_ATTRIBUTE() macro
2018-02-14 15:46 [PATCH v1] mm: Re-use DEFINE_SHOW_ATTRIBUTE() macro Andy Shevchenko
@ 2018-02-14 16:04 ` Matthew Wilcox
2018-02-14 17:18 ` Christopher Lameter
2018-02-16 2:17 ` Sergey Senozhatsky
2018-02-17 13:53 ` kbuild test robot
2 siblings, 1 reply; 6+ messages in thread
From: Matthew Wilcox @ 2018-02-14 16:04 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Tejun Heo, Christoph Lameter, Dennis Zhou, Minchan Kim,
Nitin Gupta, Sergey Senozhatsky, linux-mm, Andrew Morton
On Wed, Feb 14, 2018 at 05:46:44PM +0200, Andy Shevchenko wrote:
> ...instead of open coding file operations followed by custom ->open()
> callbacks per each attribute.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
--
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] 6+ messages in thread
* Re: [PATCH v1] mm: Re-use DEFINE_SHOW_ATTRIBUTE() macro
2018-02-14 16:04 ` Matthew Wilcox
@ 2018-02-14 17:18 ` Christopher Lameter
0 siblings, 0 replies; 6+ messages in thread
From: Christopher Lameter @ 2018-02-14 17:18 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Andy Shevchenko, Tejun Heo, Dennis Zhou, Minchan Kim,
Nitin Gupta, Sergey Senozhatsky, linux-mm, Andrew Morton
Acked-by: Christoph Lameter <cl@linux.com>
On Wed, 14 Feb 2018, Matthew Wilcox wrote:
> On Wed, Feb 14, 2018 at 05:46:44PM +0200, Andy Shevchenko wrote:
> > ...instead of open coding file operations followed by custom ->open()
> > callbacks per each attribute.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
>
--
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] 6+ messages in thread
* Re: [PATCH v1] mm: Re-use DEFINE_SHOW_ATTRIBUTE() macro
2018-02-14 15:46 [PATCH v1] mm: Re-use DEFINE_SHOW_ATTRIBUTE() macro Andy Shevchenko
2018-02-14 16:04 ` Matthew Wilcox
@ 2018-02-16 2:17 ` Sergey Senozhatsky
2018-02-17 13:53 ` kbuild test robot
2 siblings, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2018-02-16 2:17 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Tejun Heo, Christoph Lameter, Dennis Zhou, Minchan Kim,
Nitin Gupta, Sergey Senozhatsky, linux-mm, Andrew Morton
On (02/14/18 17:46), Andy Shevchenko wrote:
>
> ...instead of open coding file operations followed by custom ->open()
> callbacks per each attribute.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
FWIW,
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
-ss
--
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] 6+ messages in thread
* Re: [PATCH v1] mm: Re-use DEFINE_SHOW_ATTRIBUTE() macro
2018-02-14 15:46 [PATCH v1] mm: Re-use DEFINE_SHOW_ATTRIBUTE() macro Andy Shevchenko
2018-02-14 16:04 ` Matthew Wilcox
2018-02-16 2:17 ` Sergey Senozhatsky
@ 2018-02-17 13:53 ` kbuild test robot
2018-02-17 14:31 ` Andy Shevchenko
2 siblings, 1 reply; 6+ messages in thread
From: kbuild test robot @ 2018-02-17 13:53 UTC (permalink / raw)
To: Andy Shevchenko
Cc: kbuild-all, Tejun Heo, Christoph Lameter, Dennis Zhou,
Minchan Kim, Nitin Gupta, Sergey Senozhatsky, linux-mm,
Andrew Morton
[-- Attachment #1: Type: text/plain, Size: 4382 bytes --]
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on mmotm/master]
[also build test ERROR on v4.16-rc1 next-20180216]
[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/Andy-Shevchenko/mm-Re-use-DEFINE_SHOW_ATTRIBUTE-macro/20180217-204603
base: git://git.cmpxchg.org/linux-mmotm.git master
config: i386-randconfig-a1-201806 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
mm/backing-dev.c:104:1: warning: data definition has no type or storage class
DEFINE_SHOW_ATTRIBUTE(bdi_debug_stats);
^
mm/backing-dev.c:104:1: error: type defaults to 'int' in declaration of 'DEFINE_SHOW_ATTRIBUTE' [-Werror=implicit-int]
mm/backing-dev.c:104:1: warning: parameter names (without types) in function declaration
mm/backing-dev.c: In function 'bdi_debug_register':
>> mm/backing-dev.c:116:19: error: 'bdi_debug_stats_fops' undeclared (first use in this function)
bdi, &bdi_debug_stats_fops);
^
mm/backing-dev.c:116:19: note: each undeclared identifier is reported only once for each function it appears in
mm/backing-dev.c: At top level:
mm/backing-dev.c:44:12: warning: 'bdi_debug_stats_show' defined but not used [-Wunused-function]
static int bdi_debug_stats_show(struct seq_file *m, void *v)
^
cc1: some warnings being treated as errors
--
mm/zsmalloc.c:645:1: warning: data definition has no type or storage class
DEFINE_SHOW_ATTRIBUTE(zs_stats_size);
^
mm/zsmalloc.c:645:1: error: type defaults to 'int' in declaration of 'DEFINE_SHOW_ATTRIBUTE' [-Werror=implicit-int]
mm/zsmalloc.c:645:1: warning: parameter names (without types) in function declaration
mm/zsmalloc.c: In function 'zs_pool_stat_create':
>> mm/zsmalloc.c:664:30: error: 'zs_stat_size_ops' undeclared (first use in this function)
pool->stat_dentry, pool, &zs_stat_size_ops);
^
mm/zsmalloc.c:664:30: note: each undeclared identifier is reported only once for each function it appears in
mm/zsmalloc.c: At top level:
mm/zsmalloc.c:587:12: warning: 'zs_stats_size_show' defined but not used [-Wunused-function]
static int zs_stats_size_show(struct seq_file *s, void *v)
^
cc1: some warnings being treated as errors
vim +/bdi_debug_stats_fops +116 mm/backing-dev.c
76f1418b Miklos Szeredi 2008-04-30 103
bdcdd49e Andy Shevchenko 2018-02-14 @104 DEFINE_SHOW_ATTRIBUTE(bdi_debug_stats);
76f1418b Miklos Szeredi 2008-04-30 105
97f07697 weiping zhang 2017-10-31 106 static int bdi_debug_register(struct backing_dev_info *bdi, const char *name)
76f1418b Miklos Szeredi 2008-04-30 107 {
97f07697 weiping zhang 2017-10-31 108 if (!bdi_debug_root)
97f07697 weiping zhang 2017-10-31 109 return -ENOMEM;
97f07697 weiping zhang 2017-10-31 110
76f1418b Miklos Szeredi 2008-04-30 111 bdi->debug_dir = debugfs_create_dir(name, bdi_debug_root);
97f07697 weiping zhang 2017-10-31 112 if (!bdi->debug_dir)
97f07697 weiping zhang 2017-10-31 113 return -ENOMEM;
97f07697 weiping zhang 2017-10-31 114
76f1418b Miklos Szeredi 2008-04-30 115 bdi->debug_stats = debugfs_create_file("stats", 0444, bdi->debug_dir,
76f1418b Miklos Szeredi 2008-04-30 @116 bdi, &bdi_debug_stats_fops);
97f07697 weiping zhang 2017-10-31 117 if (!bdi->debug_stats) {
97f07697 weiping zhang 2017-10-31 118 debugfs_remove(bdi->debug_dir);
97f07697 weiping zhang 2017-10-31 119 return -ENOMEM;
97f07697 weiping zhang 2017-10-31 120 }
97f07697 weiping zhang 2017-10-31 121
97f07697 weiping zhang 2017-10-31 122 return 0;
76f1418b Miklos Szeredi 2008-04-30 123 }
76f1418b Miklos Szeredi 2008-04-30 124
:::::: The code at line 116 was first introduced by commit
:::::: 76f1418b485da2707531178e517bbb5cf06b3c76 mm: bdi: move statistics to debugfs
:::::: TO: Miklos Szeredi <mszeredi@suse.cz>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 24102 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] mm: Re-use DEFINE_SHOW_ATTRIBUTE() macro
2018-02-17 13:53 ` kbuild test robot
@ 2018-02-17 14:31 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-02-17 14:31 UTC (permalink / raw)
To: kbuild test robot
Cc: kbuild-all, Tejun Heo, Christoph Lameter, Dennis Zhou,
Minchan Kim, Nitin Gupta, Sergey Senozhatsky, linux-mm,
Andrew Morton
On Sat, 2018-02-17 at 21:53 +0800, kbuild test robot wrote:
> Hi Andy,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on mmotm/master]
> [also build test ERROR on v4.16-rc1 next-20180216]
> [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/Andy-Shevchenko/mm-Re
> -use-DEFINE_SHOW_ATTRIBUTE-macro/20180217-204603
> base: git://git.cmpxchg.org/linux-mmotm.git master
> config: i386-randconfig-a1-201806 (attached as .config)
> compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
>
> All errors (new ones prefixed by >>):
>
> mm/backing-dev.c:104:1: warning: data definition has no type or
> storage class
> DEFINE_SHOW_ATTRIBUTE(bdi_debug_stats);
> ^
> mm/backing-dev.c:104:1: error: type defaults to 'int' in
> declaration of 'DEFINE_SHOW_ATTRIBUTE' [-Werror=implicit-int]
> mm/backing-dev.c:104:1: warning: parameter names (without types) in
> function declaration
> mm/backing-dev.c: In function 'bdi_debug_register':
> > > mm/backing-dev.c:116:19: error: 'bdi_debug_stats_fops' undeclared
> > > (first use in this function)
>
> bdi, &bdi_debug_stats_fops);
> ^
> mm/backing-dev.c:116:19: note: each undeclared identifier is
> reported only once for each function it appears in
But how?! DEFINE_SHOW_ATTRIBUTE() defines ->open() callback along with
struct file_operations.
I have no compilation error with gcc (Debian 7.3.0-3).
> mm/zsmalloc.c:645:1: warning: data definition has no type or
> storage class
> DEFINE_SHOW_ATTRIBUTE(zs_stats_size);
> ^
> mm/zsmalloc.c:645:1: error: type defaults to 'int' in declaration
> of 'DEFINE_SHOW_ATTRIBUTE' [-Werror=implicit-int]
> mm/zsmalloc.c:645:1: warning: parameter names (without types) in
> function declaration
> mm/zsmalloc.c: In function 'zs_pool_stat_create':
> > > mm/zsmalloc.c:664:30: error: 'zs_stat_size_ops' undeclared (first
> > > use in this function)
>
> pool->stat_dentry, pool, &zs_st
> at_size_ops); ^
This one valid. Thanks, missed compilation!
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
--
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] 6+ messages in thread
end of thread, other threads:[~2018-02-17 14:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-14 15:46 [PATCH v1] mm: Re-use DEFINE_SHOW_ATTRIBUTE() macro Andy Shevchenko
2018-02-14 16:04 ` Matthew Wilcox
2018-02-14 17:18 ` Christopher Lameter
2018-02-16 2:17 ` Sergey Senozhatsky
2018-02-17 13:53 ` kbuild test robot
2018-02-17 14:31 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.