[2/3] mm/mempolicy: Avoid the fallthrough with MPOLD_BIND in mpol_misplaced.

Message ID bf7e6779f842fb65cf7bb9b2c617feb2af271cb7.1708097962.git.donettom@linux.ibm.com
State New
Headers
Series [1/3] mm/mempolicy: Use the already fetched local variable |

Commit Message

Donet Tom Feb. 17, 2024, 7:31 a.m. UTC
  We will update MPOL_PREFERRED_MANY in the follow up patch. This change
is required for that.

Signed-off-by: Aneesh Kumar K.V (IBM) <aneesh.kumar@kernel.org>
Signed-off-by: Donet Tom <donettom@linux.ibm.com>
---
 mm/mempolicy.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
  

Comments

Michal Hocko Feb. 19, 2024, 12:02 p.m. UTC | #1
On Sat 17-02-24 01:31:34, Donet Tom wrote:
> We will update MPOL_PREFERRED_MANY in the follow up patch. This change
> is required for that.

Why is it a separate patch then? Does it make review of the next patch
easier? If so make it explicit in the changelog.

> 
> Signed-off-by: Aneesh Kumar K.V (IBM) <aneesh.kumar@kernel.org>
> Signed-off-by: Donet Tom <donettom@linux.ibm.com>
> ---
>  mm/mempolicy.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 8478574c000c..73d698e21dae 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -2515,7 +2515,15 @@ int mpol_misplaced(struct folio *folio, struct vm_area_struct *vma,
>  				break;
>  			goto out;
>  		}
> -		fallthrough;
> +
> +		if (node_isset(curnid, pol->nodes))
> +			goto out;
> +		z = first_zones_zonelist(
> +				node_zonelist(thisnid, GFP_HIGHUSER),
> +				gfp_zone(GFP_HIGHUSER),
> +				&pol->nodes);
> +		polnid = zone_to_nid(z->zone);
> +		break;
>  
>  	case MPOL_PREFERRED_MANY:
>  		/*
> -- 
> 2.39.3
  
Donet Tom Feb. 19, 2024, 3:18 p.m. UTC | #2
On 2/19/24 17:32, Michal Hocko wrote:
> On Sat 17-02-24 01:31:34, Donet Tom wrote:
>> We will update MPOL_PREFERRED_MANY in the follow up patch. This change
>> is required for that.
> Why is it a separate patch then? Does it make review of the next patch
> easier? If so make it explicit in the changelog.

Hi Michal

In this patch there is no functional changes. This is just re-arrangement of code. Patch 3 is the actual fix .It will not look nice if we mix these patches. As you said it is easy for reviewing also. That's why we kept it as a separate patch.

Thanks
Donet Tom

>
>> Signed-off-by: Aneesh Kumar K.V (IBM) <aneesh.kumar@kernel.org>
>> Signed-off-by: Donet Tom <donettom@linux.ibm.com>
>> ---
>>   mm/mempolicy.c | 10 +++++++++-
>>   1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
>> index 8478574c000c..73d698e21dae 100644
>> --- a/mm/mempolicy.c
>> +++ b/mm/mempolicy.c
>> @@ -2515,7 +2515,15 @@ int mpol_misplaced(struct folio *folio, struct vm_area_struct *vma,
>>   				break;
>>   			goto out;
>>   		}
>> -		fallthrough;
>> +
>> +		if (node_isset(curnid, pol->nodes))
>> +			goto out;
>> +		z = first_zones_zonelist(
>> +				node_zonelist(thisnid, GFP_HIGHUSER),
>> +				gfp_zone(GFP_HIGHUSER),
>> +				&pol->nodes);
>> +		polnid = zone_to_nid(z->zone);
>> +		break;
>>   
>>   	case MPOL_PREFERRED_MANY:
>>   		/*
>> -- 
>> 2.39.3
  

Patch

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 8478574c000c..73d698e21dae 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2515,7 +2515,15 @@  int mpol_misplaced(struct folio *folio, struct vm_area_struct *vma,
 				break;
 			goto out;
 		}
-		fallthrough;
+
+		if (node_isset(curnid, pol->nodes))
+			goto out;
+		z = first_zones_zonelist(
+				node_zonelist(thisnid, GFP_HIGHUSER),
+				gfp_zone(GFP_HIGHUSER),
+				&pol->nodes);
+		polnid = zone_to_nid(z->zone);
+		break;
 
 	case MPOL_PREFERRED_MANY:
 		/*