2023-06-16 09:28:30

by 李培锋

[permalink] [raw]
Subject: [PATCH] mm: vmscan: export func:shrink_slab

From: lipeifeng <[email protected]>

Some of shrinkers during shrink_slab would enter synchronous-wait
due to lock or other reasons, which would causes kswapd or
direct_reclaim to be blocked.

This patch export shrink_slab so that it can be called in drivers
which can shrink memory independently.

Signed-off-by: lipeifeng <[email protected]>
---
mm/vmscan.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 6d0cd2840cf0..2e54fa52e7ec 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1043,7 +1043,7 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
*
* Returns the number of reclaimed slab objects.
*/
-static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
+unsigned long shrink_slab(gfp_t gfp_mask, int nid,
struct mem_cgroup *memcg,
int priority)
{
@@ -1087,6 +1087,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
cond_resched();
return freed;
}
+EXPORT_SYMBOL_GPL(shrink_slab);

static unsigned long drop_slab_node(int nid)
{
--
2.34.1



2023-06-16 09:49:19

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH] mm: vmscan: export func:shrink_slab

On 16.06.23 11:21, [email protected] wrote:
> From: lipeifeng <[email protected]>
>
> Some of shrinkers during shrink_slab would enter synchronous-wait
> due to lock or other reasons, which would causes kswapd or
> direct_reclaim to be blocked.
>
> This patch export shrink_slab so that it can be called in drivers
> which can shrink memory independently.
>
> Signed-off-by: lipeifeng <[email protected]>
> ---
> mm/vmscan.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 6d0cd2840cf0..2e54fa52e7ec 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1043,7 +1043,7 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
> *
> * Returns the number of reclaimed slab objects.
> */
> -static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> +unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> struct mem_cgroup *memcg,
> int priority)
> {
> @@ -1087,6 +1087,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> cond_resched();
> return freed;
> }
> +EXPORT_SYMBOL_GPL(shrink_slab);
>
> static unsigned long drop_slab_node(int nid)
> {

It feels like something we don't want arbitrary drivers to call.

Unrelated to that, this better be sent along with actual driver usage.

--
Cheers,

David / dhildenb


2023-06-20 03:11:08

by 李培锋

[permalink] [raw]
Subject: 回复: [PATCH] mm: vmscan: export func:shrin k_slab

On 16.06.23 11:21, [email protected] wrote:
>> From: lipeifeng <[email protected]>
>>
>> Some of shrinkers during shrink_slab would enter synchronous-wait due
>> to lock or other reasons, which would causes kswapd or direct_reclaim
>> to be blocked.
>>
>> This patch export shrink_slab so that it can be called in drivers
>> which can shrink memory independently.
>>
>> Signed-off-by: lipeifeng <[email protected]>
>> ---
>> mm/vmscan.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c index
>> 6d0cd2840cf0..2e54fa52e7ec 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -1043,7 +1043,7 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
>> *
>> * Returns the number of reclaimed slab objects.
>> */
>> -static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>> +unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>> struct mem_cgroup *memcg,
>> int priority)
>> {
>> @@ -1087,6 +1087,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>> cond_resched();
>> return freed;
>> }
>> +EXPORT_SYMBOL_GPL(shrink_slab);
>>
>> static unsigned long drop_slab_node(int nid)
>> {
>
>It feels like something we don't want arbitrary drivers to call.
>
>Unrelated to that, this better be sent along with actual driver usage.

Hi Sir:

Virtually, we have implemented async shrink_slabd isolated from kswapd and direct_reclaim.
The goal above it is to avoid the sync-wait in kswapd or direct_reclaim due to some shrinkers.

But the async shrink_slabd was only applied to mobile products so that I didn't make sure any
risk in other products. For the above reasons, I wanna merge the patch to export shrink_slab
and the patch of drivers would be considered to be pushed if I check all the risks.

Some informal code files of driver are attached for your reference.

-----邮件原件-----
发件人: David Hildenbrand <[email protected]>
发送时间: 2023年6月16日 17:43
收件人: 李培锋(wink) <[email protected]>; [email protected]
抄送: [email protected]; [email protected]; [email protected]; [email protected]
主题: Re: [PATCH] mm: vmscan: export func:shrink_slab

On 16.06.23 11:21, [email protected] wrote:
> From: lipeifeng <[email protected]>
>
> Some of shrinkers during shrink_slab would enter synchronous-wait due
> to lock or other reasons, which would causes kswapd or direct_reclaim
> to be blocked.
>
> This patch export shrink_slab so that it can be called in drivers
> which can shrink memory independently.
>
> Signed-off-by: lipeifeng <[email protected]>
> ---
> mm/vmscan.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c index
> 6d0cd2840cf0..2e54fa52e7ec 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1043,7 +1043,7 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
> *
> * Returns the number of reclaimed slab objects.
> */
> -static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> +unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> struct mem_cgroup *memcg,
> int priority)
> {
> @@ -1087,6 +1087,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> cond_resched();
> return freed;
> }
> +EXPORT_SYMBOL_GPL(shrink_slab);
>
> static unsigned long drop_slab_node(int nid)
> {

It feels like something we don't want arbitrary drivers to call.

Unrelated to that, this better be sent along with actual driver usage.

--
Cheers,

David / dhildenb


Attachments:
kshrink_slabd.c (5.32 kB)
kshrink_slabd.c

2023-06-25 09:56:06

by Greg KH

[permalink] [raw]
Subject: Re: 回复 : [PATCH] mm: vmscan: export func:shrink_slab

On Tue, Jun 20, 2023 at 03:05:27AM +0000, 李培锋(wink) wrote:
> On 16.06.23 11:21, [email protected] wrote:
> >> From: lipeifeng <[email protected]>
> >>
> >> Some of shrinkers during shrink_slab would enter synchronous-wait due
> >> to lock or other reasons, which would causes kswapd or direct_reclaim
> >> to be blocked.
> >>
> >> This patch export shrink_slab so that it can be called in drivers
> >> which can shrink memory independently.
> >>
> >> Signed-off-by: lipeifeng <[email protected]>
> >> ---
> >> mm/vmscan.c | 3 ++-
> >> 1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/mm/vmscan.c b/mm/vmscan.c index
> >> 6d0cd2840cf0..2e54fa52e7ec 100644
> >> --- a/mm/vmscan.c
> >> +++ b/mm/vmscan.c
> >> @@ -1043,7 +1043,7 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
> >> *
> >> * Returns the number of reclaimed slab objects.
> >> */
> >> -static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> >> +unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> >> struct mem_cgroup *memcg,
> >> int priority)
> >> {
> >> @@ -1087,6 +1087,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> >> cond_resched();
> >> return freed;
> >> }
> >> +EXPORT_SYMBOL_GPL(shrink_slab);
> >>
> >> static unsigned long drop_slab_node(int nid)
> >> {
> >
> >It feels like something we don't want arbitrary drivers to call.
> >
> >Unrelated to that, this better be sent along with actual driver usage.
>
> Hi Sir:
>
> Virtually, we have implemented async shrink_slabd isolated from kswapd and direct_reclaim.
> The goal above it is to avoid the sync-wait in kswapd or direct_reclaim due to some shrinkers.
>
> But the async shrink_slabd was only applied to mobile products so that I didn't make sure any
> risk in other products. For the above reasons, I wanna merge the patch to export shrink_slab
> and the patch of drivers would be considered to be pushed if I check all the risks.
>
> Some informal code files of driver are attached for your reference.

You have to submit this as a real series, we can not accept exports for
no in-kernel users (nor would you want us to, as that ends up being an
unmaintainable mess.)

So please resubmit this as a proper patch series, with the user of this
function, and then it can be properly evaluated. As-is, this can not be
accepted at all.

thanks,

greg k-h

2023-06-25 09:56:12

by 李培锋

[permalink] [raw]
Subject: 回复: [PATCH] mm: vmscan: export func:shrin k_slab

>>> On 16.06.23 11:21, [email protected] wrote:
>>> From: lipeifeng <[email protected]>
>>>
>>> Some of shrinkers during shrink_slab would enter synchronous-wait due
>>> to lock or other reasons, which would causes kswapd or direct_reclaim
>>> to be blocked.
>>>
>>> This patch export shrink_slab so that it can be called in drivers
>>> which can shrink memory independently.
>>>
>>> Signed-off-by: lipeifeng <[email protected]>
>>> ---
>>> mm/vmscan.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/mm/vmscan.c b/mm/vmscan.c index
>>> 6d0cd2840cf0..2e54fa52e7ec 100644
>>> --- a/mm/vmscan.c
>>> +++ b/mm/vmscan.c
>>> @@ -1043,7 +1043,7 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
>>> *
>>> * Returns the number of reclaimed slab objects.
>>> */
>>> -static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>>> +unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>>> struct mem_cgroup *memcg,
>>> int priority)
>>> {
>>> @@ -1087,6 +1087,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>>> cond_resched();
>>> return freed;
>>> }
>>> +EXPORT_SYMBOL_GPL(shrink_slab);
>>>
>>> static unsigned long drop_slab_node(int nid)
>>> {
>>
>>It feels like something we don't want arbitrary drivers to call.
>>
>>Unrelated to that, this better be sent along with actual driver usage.
>
>Hi Sir:
>
>Virtually, we have implemented async shrink_slabd isolated from kswapd and direct_reclaim.
>The goal above it is to avoid the sync-wait in kswapd or direct_reclaim due to some shrinkers.
>
>But the async shrink_slabd was only applied to mobile products so that I didn't make sure any risk in other products. For the above reasons, I wanna merge the patch to export shrink_slab and the patch of drivers would be considered to be pushed if I check all the risks.
>
>Some informal code files of driver are attached for your reference.

Hi Sir:

Pls help to review the patch merge it if no problems, thanks you very much.

-----邮件原件-----
发件人: 李培锋(wink)
发送时间: 2023年6月20日 11:05
收件人: David Hildenbrand <[email protected]>; [email protected]
抄送: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; 郭健 <[email protected]>
主题: 回复: [PATCH] mm: vmscan: export func:shrink_slab

On 16.06.23 11:21, [email protected] wrote:
>> From: lipeifeng <[email protected]>
>>
>> Some of shrinkers during shrink_slab would enter synchronous-wait due
>> to lock or other reasons, which would causes kswapd or direct_reclaim
>> to be blocked.
>>
>> This patch export shrink_slab so that it can be called in drivers
>> which can shrink memory independently.
>>
>> Signed-off-by: lipeifeng <[email protected]>
>> ---
>> mm/vmscan.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c index
>> 6d0cd2840cf0..2e54fa52e7ec 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -1043,7 +1043,7 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
>> *
>> * Returns the number of reclaimed slab objects.
>> */
>> -static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>> +unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>> struct mem_cgroup *memcg,
>> int priority)
>> {
>> @@ -1087,6 +1087,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>> cond_resched();
>> return freed;
>> }
>> +EXPORT_SYMBOL_GPL(shrink_slab);
>>
>> static unsigned long drop_slab_node(int nid)
>> {
>
>It feels like something we don't want arbitrary drivers to call.
>
>Unrelated to that, this better be sent along with actual driver usage.

Hi Sir:

Virtually, we have implemented async shrink_slabd isolated from kswapd and direct_reclaim.
The goal above it is to avoid the sync-wait in kswapd or direct_reclaim due to some shrinkers.

But the async shrink_slabd was only applied to mobile products so that I didn't make sure any risk in other products. For the above reasons, I wanna merge the patch to export shrink_slab and the patch of drivers would be considered to be pushed if I check all the risks.

Some informal code files of driver are attached for your reference.

-----邮件原件-----
发件人: David Hildenbrand <[email protected]>
发送时间: 2023年6月16日 17:43
收件人: 李培锋(wink) <[email protected]>; [email protected]
抄送: [email protected]; [email protected]; [email protected]; [email protected]
主题: Re: [PATCH] mm: vmscan: export func:shrink_slab

On 16.06.23 11:21, [email protected] wrote:
> From: lipeifeng <[email protected]>
>
> Some of shrinkers during shrink_slab would enter synchronous-wait due
> to lock or other reasons, which would causes kswapd or direct_reclaim
> to be blocked.
>
> This patch export shrink_slab so that it can be called in drivers
> which can shrink memory independently.
>
> Signed-off-by: lipeifeng <[email protected]>
> ---
> mm/vmscan.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c index
> 6d0cd2840cf0..2e54fa52e7ec 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1043,7 +1043,7 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
> *
> * Returns the number of reclaimed slab objects.
> */
> -static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> +unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> struct mem_cgroup *memcg,
> int priority)
> {
> @@ -1087,6 +1087,7 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
> cond_resched();
> return freed;
> }
> +EXPORT_SYMBOL_GPL(shrink_slab);
>
> static unsigned long drop_slab_node(int nid)
> {

It feels like something we don't want arbitrary drivers to call.

Unrelated to that, this better be sent along with actual driver usage.

--
Cheers,

David / dhildenb