Re: [PATCH] mm: compaction.c: Propagate return value upstream

2019-01-02 Thread Mel Gorman
On Wed, Dec 26, 2018 at 07:50:29PM -0800, Matthew Wilcox wrote:
> On Wed, Dec 26, 2018 at 01:42:56PM -0600, Aditya Pakki wrote:
> > In sysctl_extfrag_handler(), proc_dointvec_minmax() can return an
> > error. The fix propagates the error upstream in case of failure.
> 
> Why not just ...
> 
> Mel, Randy?  You seem to have been the prime instigators on this.
> 

Patch seems fine.

Acked-by: Mel Gorman 

-- 
Mel Gorman
SUSE Labs


Re: [PATCH] mm: compaction.c: Propagate return value upstream

2018-12-27 Thread Randy Dunlap
On 12/26/18 7:50 PM, Matthew Wilcox wrote:
> On Wed, Dec 26, 2018 at 01:42:56PM -0600, Aditya Pakki wrote:
>> In sysctl_extfrag_handler(), proc_dointvec_minmax() can return an
>> error. The fix propagates the error upstream in case of failure.
> 
> Why not just ...

Yes, this change (below) makes sense to me.

> Mel, Randy?  You seem to have been the prime instigators on this.

I expect that all I did was move the location of the source code lines of
the sysctl, but that is just a guess, based on this commit message:
  [randy.dun...@oracle.com: Fix build errors when proc fs is not configured]

> diff --git a/include/linux/compaction.h b/include/linux/compaction.h
> index 68250a57aace..70d0256edd31 100644
> --- a/include/linux/compaction.h
> +++ b/include/linux/compaction.h
> @@ -88,8 +88,6 @@ extern int sysctl_compact_memory;
>  extern int sysctl_compaction_handler(struct ctl_table *table, int write,
>   void __user *buffer, size_t *length, loff_t *ppos);
>  extern int sysctl_extfrag_threshold;
> -extern int sysctl_extfrag_handler(struct ctl_table *table, int write,
> - void __user *buffer, size_t *length, loff_t *ppos);
>  extern int sysctl_compact_unevictable_allowed;
>  
>  extern int fragmentation_index(struct zone *zone, unsigned int order);
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 5fc724e4e454..e9c69247fc29 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -1439,7 +1439,7 @@ static struct ctl_table vm_table[] = {
>   .data   = _extfrag_threshold,
>   .maxlen = sizeof(int),
>   .mode   = 0644,
> - .proc_handler   = sysctl_extfrag_handler,
> + .proc_handler   = proc_dointvec_minmax,
>   .extra1 = _extfrag_threshold,
>   .extra2 = _extfrag_threshold,
>   },
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 7c607479de4a..80b941d9b6e7 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -1876,14 +1876,6 @@ int sysctl_compaction_handler(struct ctl_table *table, 
> int write,
>   return 0;
>  }
>  
> -int sysctl_extfrag_handler(struct ctl_table *table, int write,
> - void __user *buffer, size_t *length, loff_t *ppos)
> -{
> - proc_dointvec_minmax(table, write, buffer, length, ppos);
> -
> - return 0;
> -}
> -
>  #if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
>  static ssize_t sysfs_compact_node(struct device *dev,
>   struct device_attribute *attr,
> 


-- 
~Randy


Re: [PATCH] mm: compaction.c: Propagate return value upstream

2018-12-26 Thread Matthew Wilcox
On Wed, Dec 26, 2018 at 01:42:56PM -0600, Aditya Pakki wrote:
> In sysctl_extfrag_handler(), proc_dointvec_minmax() can return an
> error. The fix propagates the error upstream in case of failure.

Why not just ...

Mel, Randy?  You seem to have been the prime instigators on this.

diff --git a/include/linux/compaction.h b/include/linux/compaction.h
index 68250a57aace..70d0256edd31 100644
--- a/include/linux/compaction.h
+++ b/include/linux/compaction.h
@@ -88,8 +88,6 @@ extern int sysctl_compact_memory;
 extern int sysctl_compaction_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *length, loff_t *ppos);
 extern int sysctl_extfrag_threshold;
-extern int sysctl_extfrag_handler(struct ctl_table *table, int write,
-   void __user *buffer, size_t *length, loff_t *ppos);
 extern int sysctl_compact_unevictable_allowed;
 
 extern int fragmentation_index(struct zone *zone, unsigned int order);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 5fc724e4e454..e9c69247fc29 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1439,7 +1439,7 @@ static struct ctl_table vm_table[] = {
.data   = _extfrag_threshold,
.maxlen = sizeof(int),
.mode   = 0644,
-   .proc_handler   = sysctl_extfrag_handler,
+   .proc_handler   = proc_dointvec_minmax,
.extra1 = _extfrag_threshold,
.extra2 = _extfrag_threshold,
},
diff --git a/mm/compaction.c b/mm/compaction.c
index 7c607479de4a..80b941d9b6e7 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1876,14 +1876,6 @@ int sysctl_compaction_handler(struct ctl_table *table, 
int write,
return 0;
 }
 
-int sysctl_extfrag_handler(struct ctl_table *table, int write,
-   void __user *buffer, size_t *length, loff_t *ppos)
-{
-   proc_dointvec_minmax(table, write, buffer, length, ppos);
-
-   return 0;
-}
-
 #if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
 static ssize_t sysfs_compact_node(struct device *dev,
struct device_attribute *attr,


[PATCH] mm: compaction.c: Propagate return value upstream

2018-12-26 Thread Aditya Pakki
In sysctl_extfrag_handler(), proc_dointvec_minmax() can return an
error. The fix propagates the error upstream in case of failure.

Signed-off-by: Aditya Pakki 
---
 mm/compaction.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 7c607479de4a..d108974d0867 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1879,9 +1879,7 @@ int sysctl_compaction_handler(struct ctl_table *table, 
int write,
 int sysctl_extfrag_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *length, loff_t *ppos)
 {
-   proc_dointvec_minmax(table, write, buffer, length, ppos);
-
-   return 0;
+   return proc_dointvec_minmax(table, write, buffer, length, ppos);
 }
 
 #if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
-- 
2.17.1



Re: [PATCH] mm: compaction.c: Propagate return value upstream

2018-12-26 Thread Matthew Wilcox
On Wed, Dec 26, 2018 at 01:07:49PM -0600, Aditya Pakki wrote:
>  {
> + return
>   proc_dointvec_minmax(table, write, buffer, length, ppos);
> -
> - return 0;

Don't do this.  If you're going to return something, it should be on the same
line as the return statement.

ie:

+   return proc_dointvec_minmax(table, write, buffer, length, ppos);



[PATCH] mm: compaction.c: Propagate return value upstream

2018-12-26 Thread Aditya Pakki
In sysctl_extfrag_handler(), proc_dointvec_minmax() can return an
error. The fix propagates the error upstream in case of failure.

Signed-off-by: Aditya Pakki 
---
 mm/compaction.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 7c607479de4a..5703b4051796 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1879,9 +1879,8 @@ int sysctl_compaction_handler(struct ctl_table *table, 
int write,
 int sysctl_extfrag_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *length, loff_t *ppos)
 {
+   return
proc_dointvec_minmax(table, write, buffer, length, ppos);
-
-   return 0;
 }
 
 #if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
-- 
2.17.1