2024-05-31 11:13:15

by Dev Jain

[permalink] [raw]
Subject: [QUESTION] mm: Redundant const parameter?

Hi Chengming,

In mm/slub.c, you had defined slab_test_node_partial() to take a const
parameter.

Is there any point of taking in a const, when you are anyways
typecasting it to

a (struct folio *) from (const struct folio *) ? In fact, at the place
where you call

slab_test_node_partial(), the struct slab *slab is not const.

Please comment.


Thanks

DJ





2024-05-31 11:32:05

by Dev Jain

[permalink] [raw]
Subject: Re: [QUESTION] mm: Redundant const parameter?

I guess it would be better if I send this as a patch and wait for comments.

On 5/31/24 16:42, Dev Jain wrote:
> Hi Chengming,
>
> In mm/slub.c, you had defined slab_test_node_partial() to take a const
> parameter.
>
> Is there any point of taking in a const, when you are anyways
> typecasting it to
>
> a (struct folio *) from (const struct folio *) ? In fact, at the place
> where you call
>
> slab_test_node_partial(), the struct slab *slab is not const.
>
> Please comment.
>
>
> Thanks
>
> DJ
>
>
>
>

2024-05-31 12:24:53

by Dev Jain

[permalink] [raw]
Subject: Re: [QUESTION] mm: Redundant const parameter?

I was just about to hit git send-email for a patch-series of 2, I
noticed your reply :)


On 5/31/24 17:47, Matthew Wilcox wrote:
> On Fri, May 31, 2024 at 04:42:59PM +0530, Dev Jain wrote:
>> Hi Chengming,
>>
>> In mm/slub.c, you had defined slab_test_node_partial() to take a const
>> parameter.
>>
>> Is there any point of taking in a const, when you are anyways typecasting it
>> to
>>
>> a (struct folio *) from (const struct folio *) ? In fact, at the place where
>> you call
>>
>> slab_test_node_partial(), the struct slab *slab is not const.
> I have a patch to fix this; hang on a second ...

2024-05-31 12:37:59

by Chengming Zhou

[permalink] [raw]
Subject: Re: [External] Re: [QUESTION] mm: Redundant const parameter?

On 2024/5/31 19:31, Dev Jain wrote:
> I guess it would be better if I send this as a patch and wait for comments.

Ah, you're right. I think it should be:

return folio_test_workingset(slab_folio(slab));

Right? Don't notice there isn't any build warning about this "const" discard.

Thanks.

>
> On 5/31/24 16:42, Dev Jain wrote:
>> Hi Chengming,
>>
>> In mm/slub.c, you had defined slab_test_node_partial() to take a const parameter.
>>
>> Is there any point of taking in a const, when you are anyways typecasting it to
>>
>> a (struct folio *) from (const struct folio *) ? In fact, at the place where you call
>>
>> slab_test_node_partial(), the struct slab *slab is not const.
>>
>> Please comment.
>>
>>
>> Thanks
>>
>> DJ
>>
>>
>>
>>

2024-05-31 12:40:19

by Dev Jain

[permalink] [raw]
Subject: Re: [External] Re: [QUESTION] mm: Redundant const parameter?

Yes; Matthew just did a wider fix:

https://lore.kernel.org/all/[email protected]/


On 5/31/24 18:00, Chengming Zhou wrote:
> On 2024/5/31 19:31, Dev Jain wrote:
>> I guess it would be better if I send this as a patch and wait for comments.
> Ah, you're right. I think it should be:
>
> return folio_test_workingset(slab_folio(slab));
>
> Right? Don't notice there isn't any build warning about this "const" discard.
>
> Thanks.
>
>> On 5/31/24 16:42, Dev Jain wrote:
>>> Hi Chengming,
>>>
>>> In mm/slub.c, you had defined slab_test_node_partial() to take a const parameter.
>>>
>>> Is there any point of taking in a const, when you are anyways typecasting it to
>>>
>>> a (struct folio *) from (const struct folio *) ? In fact, at the place where you call
>>>
>>> slab_test_node_partial(), the struct slab *slab is not const.
>>>
>>> Please comment.
>>>
>>>
>>> Thanks
>>>
>>> DJ
>>>
>>>
>>>
>>>

2024-05-31 15:57:38

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [QUESTION] mm: Redundant const parameter?

On Fri, May 31, 2024 at 04:42:59PM +0530, Dev Jain wrote:
> Hi Chengming,
>
> In mm/slub.c, you had defined slab_test_node_partial() to take a const
> parameter.
>
> Is there any point of taking in a const, when you are anyways typecasting it
> to
>
> a (struct folio *) from (const struct folio *) ? In fact, at the place where
> you call
>
> slab_test_node_partial(), the struct slab *slab is not const.

I have a patch to fix this; hang on a second ...

2024-05-31 18:22:52

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [External] Re: [QUESTION] mm: Redundant const parameter?

On Fri, May 31, 2024 at 08:30:08PM +0800, Chengming Zhou wrote:
> On 2024/5/31 19:31, Dev Jain wrote:
> > I guess it would be better if I send this as a patch and wait for comments.
>
> Ah, you're right. I think it should be:
>
> return folio_test_workingset(slab_folio(slab));
>
> Right? Don't notice there isn't any build warning about this "const" discard.

But there used to be! I fixed that in ce3467af6bde dated Feb 27 2024,
which took a fair amount of prep work to make happen.