cpuset: Remove unused cpuset_node_allowed

Message ID 20230227080719.20280-1-haifeng.xu@shopee.com
State New
Headers
Series cpuset: Remove unused cpuset_node_allowed |

Commit Message

Haifeng Xu Feb. 27, 2023, 8:07 a.m. UTC
  Commit 002f290627c2 ("cpuset: use static key better and convert to new API")
has used __cpuset_node_allowed instead of cpuset_node_allowed to check
whether we can allocate on a memory node. Now this function isn't used by
anyone, so we can remove it safely.

Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
---
 include/linux/cpuset.h | 12 ------------
 1 file changed, 12 deletions(-)
  

Comments

Waiman Long Feb. 27, 2023, 2:56 p.m. UTC | #1
On 2/27/23 03:07, Haifeng Xu wrote:
> Commit 002f290627c2 ("cpuset: use static key better and convert to new API")
> has used __cpuset_node_allowed instead of cpuset_node_allowed to check
> whether we can allocate on a memory node. Now this function isn't used by
> anyone, so we can remove it safely.
>
> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
> ---
>   include/linux/cpuset.h | 12 ------------
>   1 file changed, 12 deletions(-)
>
> diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
> index d58e0476ee8e..7fad5afe3bba 100644
> --- a/include/linux/cpuset.h
> +++ b/include/linux/cpuset.h
> @@ -82,13 +82,6 @@ int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
>   
>   extern bool __cpuset_node_allowed(int node, gfp_t gfp_mask);
>   
> -static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
> -{
> -	if (cpusets_enabled())
> -		return __cpuset_node_allowed(node, gfp_mask);
> -	return true;
> -}
> -
>   static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
>   {
>   	return __cpuset_node_allowed(zone_to_nid(z), gfp_mask);
> @@ -223,11 +216,6 @@ static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
>   	return 1;
>   }
>   
> -static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
> -{
> -	return true;
> -}
> -
>   static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
>   {
>   	return true;

The kernel convention is to add a "__" prefix to a function name if 
there is higher level helper without the "__" prefix that uses it. Since 
cpuset_node_allowed() is no longer used. We should just rename 
__cpuset_node_allowed() to cpuset_node_allowed() and get rid of the 
unused helper. A bit more code changes are needed for this, though.

Cheers,
Longman
  
Haifeng Xu Feb. 28, 2023, 2:40 a.m. UTC | #2
On 2023/2/27 22:56, Waiman Long wrote:
> On 2/27/23 03:07, Haifeng Xu wrote:
>> Commit 002f290627c2 ("cpuset: use static key better and convert to new API")
>> has used __cpuset_node_allowed instead of cpuset_node_allowed to check
>> whether we can allocate on a memory node. Now this function isn't used by
>> anyone, so we can remove it safely.
>>
>> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
>> ---
>>   include/linux/cpuset.h | 12 ------------
>>   1 file changed, 12 deletions(-)
>>
>> diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
>> index d58e0476ee8e..7fad5afe3bba 100644
>> --- a/include/linux/cpuset.h
>> +++ b/include/linux/cpuset.h
>> @@ -82,13 +82,6 @@ int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
>>     extern bool __cpuset_node_allowed(int node, gfp_t gfp_mask);
>>   -static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
>> -{
>> -    if (cpusets_enabled())
>> -        return __cpuset_node_allowed(node, gfp_mask);
>> -    return true;
>> -}
>> -
>>   static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
>>   {
>>       return __cpuset_node_allowed(zone_to_nid(z), gfp_mask);
>> @@ -223,11 +216,6 @@ static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
>>       return 1;
>>   }
>>   -static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
>> -{
>> -    return true;
>> -}
>> -
>>   static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
>>   {
>>       return true;
> 
> The kernel convention is to add a "__" prefix to a function name if there is higher level helper without the "__" prefix that uses it. Since cpuset_node_allowed() is no longer used. We should just rename __cpuset_node_allowed() to cpuset_node_allowed() and get rid of the unused helper. A bit more code changes are needed for this, though.
> 
> Cheers,
> Longman
> 

Maybe we can still use cpuset_node_allowed in __cpuset_zone_allowed? If so, less code need to be changed.

Thanks.
  
Waiman Long Feb. 28, 2023, 2:52 a.m. UTC | #3
On 2/27/23 21:40, Haifeng Xu wrote:
>
> On 2023/2/27 22:56, Waiman Long wrote:
>> On 2/27/23 03:07, Haifeng Xu wrote:
>>> Commit 002f290627c2 ("cpuset: use static key better and convert to new API")
>>> has used __cpuset_node_allowed instead of cpuset_node_allowed to check
>>> whether we can allocate on a memory node. Now this function isn't used by
>>> anyone, so we can remove it safely.
>>>
>>> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
>>> ---
>>>    include/linux/cpuset.h | 12 ------------
>>>    1 file changed, 12 deletions(-)
>>>
>>> diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
>>> index d58e0476ee8e..7fad5afe3bba 100644
>>> --- a/include/linux/cpuset.h
>>> +++ b/include/linux/cpuset.h
>>> @@ -82,13 +82,6 @@ int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
>>>      extern bool __cpuset_node_allowed(int node, gfp_t gfp_mask);
>>>    -static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
>>> -{
>>> -    if (cpusets_enabled())
>>> -        return __cpuset_node_allowed(node, gfp_mask);
>>> -    return true;
>>> -}
>>> -
>>>    static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
>>>    {
>>>        return __cpuset_node_allowed(zone_to_nid(z), gfp_mask);
>>> @@ -223,11 +216,6 @@ static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
>>>        return 1;
>>>    }
>>>    -static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
>>> -{
>>> -    return true;
>>> -}
>>> -
>>>    static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
>>>    {
>>>        return true;
>> The kernel convention is to add a "__" prefix to a function name if there is higher level helper without the "__" prefix that uses it. Since cpuset_node_allowed() is no longer used. We should just rename __cpuset_node_allowed() to cpuset_node_allowed() and get rid of the unused helper. A bit more code changes are needed for this, though.
>>
>> Cheers,
>> Longman
>>
> Maybe we can still use cpuset_node_allowed in __cpuset_zone_allowed? If so, less code need to be changed.
>
mm/page_alloc.c has 2 references to __cpuset_node_allowed() in their 
comments. These references should also be updated as well. That is why I 
said a bit more code needs to be touched.

Cheers,
Longman
  
Haifeng Xu Feb. 28, 2023, 3:13 a.m. UTC | #4
On 2023/2/28 10:52, Waiman Long wrote:
> On 2/27/23 21:40, Haifeng Xu wrote:
>>
>> On 2023/2/27 22:56, Waiman Long wrote:
>>> On 2/27/23 03:07, Haifeng Xu wrote:
>>>> Commit 002f290627c2 ("cpuset: use static key better and convert to new API")
>>>> has used __cpuset_node_allowed instead of cpuset_node_allowed to check
>>>> whether we can allocate on a memory node. Now this function isn't used by
>>>> anyone, so we can remove it safely.
>>>>
>>>> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
>>>> ---
>>>>    include/linux/cpuset.h | 12 ------------
>>>>    1 file changed, 12 deletions(-)
>>>>
>>>> diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
>>>> index d58e0476ee8e..7fad5afe3bba 100644
>>>> --- a/include/linux/cpuset.h
>>>> +++ b/include/linux/cpuset.h
>>>> @@ -82,13 +82,6 @@ int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
>>>>      extern bool __cpuset_node_allowed(int node, gfp_t gfp_mask);
>>>>    -static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
>>>> -{
>>>> -    if (cpusets_enabled())
>>>> -        return __cpuset_node_allowed(node, gfp_mask);
>>>> -    return true;
>>>> -}
>>>> -
>>>>    static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
>>>>    {
>>>>        return __cpuset_node_allowed(zone_to_nid(z), gfp_mask);
>>>> @@ -223,11 +216,6 @@ static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
>>>>        return 1;
>>>>    }
>>>>    -static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
>>>> -{
>>>> -    return true;
>>>> -}
>>>> -
>>>>    static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
>>>>    {
>>>>        return true;
>>> The kernel convention is to add a "__" prefix to a function name if there is higher level helper without the "__" prefix that uses it. Since cpuset_node_allowed() is no longer used. We should just rename __cpuset_node_allowed() to cpuset_node_allowed() and get rid of the unused helper. A bit more code changes are needed for this, though.
>>>
>>> Cheers,
>>> Longman
>>>
>> Maybe we can still use cpuset_node_allowed in __cpuset_zone_allowed? If so, less code need to be changed.
>>
> mm/page_alloc.c has 2 references to __cpuset_node_allowed() in their comments. These references should also be updated as well. That is why I said a bit more code needs to be touched.
> 
> Cheers,
> Longman
> 

Ok. I mean maybe we could keep cpuset_node_allowed() and use it in __cpuset_zone_allowed(). So we don't need rename __cpuset_node_allowed() or update releated comments.

Thanks.
  

Patch

diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index d58e0476ee8e..7fad5afe3bba 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -82,13 +82,6 @@  int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
 
 extern bool __cpuset_node_allowed(int node, gfp_t gfp_mask);
 
-static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
-{
-	if (cpusets_enabled())
-		return __cpuset_node_allowed(node, gfp_mask);
-	return true;
-}
-
 static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
 {
 	return __cpuset_node_allowed(zone_to_nid(z), gfp_mask);
@@ -223,11 +216,6 @@  static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
 	return 1;
 }
 
-static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
-{
-	return true;
-}
-
 static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
 {
 	return true;