All of lore.kernel.org
 help / color / mirror / Atom feed
* a question about slub in function __slab_free()
@ 2016-03-02 12:26 ` Xishi Qiu
  0 siblings, 0 replies; 8+ messages in thread
From: Xishi Qiu @ 2016-03-02 12:26 UTC (permalink / raw)
  To: LKML, Linux MM

___slab_alloc()
	deactivate_slab()
		add_full(s, n, page);
The page will be added to full list and the frozen is 0, right?

__slab_free()
	prior = page->freelist;  // prior is NULL
	was_frozen = new.frozen;  // was_frozen is 0
	...
		/*
		 * Slab was on no list before and will be
		 * partially empty
		 * We can defer the list move and instead
		 * freeze it.
		 */
		new.frozen = 1;
	...

I don't understand why "Slab was on no list before"?

Thanks,
Xishi Qiu

^ permalink raw reply	[flat|nested] 8+ messages in thread

* a question about slub in function __slab_free()
@ 2016-03-02 12:26 ` Xishi Qiu
  0 siblings, 0 replies; 8+ messages in thread
From: Xishi Qiu @ 2016-03-02 12:26 UTC (permalink / raw)
  To: LKML, Linux MM

___slab_alloc()
	deactivate_slab()
		add_full(s, n, page);
The page will be added to full list and the frozen is 0, right?

__slab_free()
	prior = page->freelist;  // prior is NULL
	was_frozen = new.frozen;  // was_frozen is 0
	...
		/*
		 * Slab was on no list before and will be
		 * partially empty
		 * We can defer the list move and instead
		 * freeze it.
		 */
		new.frozen = 1;
	...

I don't understand why "Slab was on no list before"?

Thanks,
Xishi Qiu

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: a question about slub in function __slab_free()
  2016-03-02 12:26 ` Xishi Qiu
@ 2016-03-02 14:38   ` Joonsoo Kim
  -1 siblings, 0 replies; 8+ messages in thread
From: Joonsoo Kim @ 2016-03-02 14:38 UTC (permalink / raw)
  To: Xishi Qiu; +Cc: LKML, Linux MM

2016-03-02 21:26 GMT+09:00 Xishi Qiu <qiuxishi@huawei.com>:
> ___slab_alloc()
>         deactivate_slab()
>                 add_full(s, n, page);
> The page will be added to full list and the frozen is 0, right?
>
> __slab_free()
>         prior = page->freelist;  // prior is NULL
>         was_frozen = new.frozen;  // was_frozen is 0
>         ...
>                 /*
>                  * Slab was on no list before and will be
>                  * partially empty
>                  * We can defer the list move and instead
>                  * freeze it.
>                  */
>                 new.frozen = 1;
>         ...
>
> I don't understand why "Slab was on no list before"?

add_full() is defined only for CONFIG_SLUB_DEBUG.
And, actual add happens if slub_debug=u is enabled.
In other cases, fully used slab isn't attached on any list.

Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: a question about slub in function __slab_free()
@ 2016-03-02 14:38   ` Joonsoo Kim
  0 siblings, 0 replies; 8+ messages in thread
From: Joonsoo Kim @ 2016-03-02 14:38 UTC (permalink / raw)
  To: Xishi Qiu; +Cc: LKML, Linux MM

2016-03-02 21:26 GMT+09:00 Xishi Qiu <qiuxishi@huawei.com>:
> ___slab_alloc()
>         deactivate_slab()
>                 add_full(s, n, page);
> The page will be added to full list and the frozen is 0, right?
>
> __slab_free()
>         prior = page->freelist;  // prior is NULL
>         was_frozen = new.frozen;  // was_frozen is 0
>         ...
>                 /*
>                  * Slab was on no list before and will be
>                  * partially empty
>                  * We can defer the list move and instead
>                  * freeze it.
>                  */
>                 new.frozen = 1;
>         ...
>
> I don't understand why "Slab was on no list before"?

add_full() is defined only for CONFIG_SLUB_DEBUG.
And, actual add happens if slub_debug=u is enabled.
In other cases, fully used slab isn't attached on any list.

Thanks.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: a question about slub in function __slab_free()
  2016-03-02 12:26 ` Xishi Qiu
@ 2016-03-02 15:12   ` Jianyu Zhan
  -1 siblings, 0 replies; 8+ messages in thread
From: Jianyu Zhan @ 2016-03-02 15:12 UTC (permalink / raw)
  To: Xishi Qiu; +Cc: LKML, Linux MM, js1304

On Wed, Mar 2, 2016 at 8:26 PM, Xishi Qiu <qiuxishi@huawei.com> wrote:
> __slab_free()
>         prior = page->freelist;  // prior is NULL
>         was_frozen = new.frozen;  // was_frozen is 0
>         ...
>                 /*
>                  * Slab was on no list before and will be
>                  * partially empty
>                  * We can defer the list move and instead
>                  * freeze it.
>                  */
>                 new.frozen = 1;
>         ...
>
> I don't understand why "Slab was on no list before"?

in this  __slab_free() code path, we are freeing an object to a remote CPU.

Consider the condition that leads to this branch, that is:

new.inuse  && !prior && !was_frozen

new.inuse means that slab page has free objects after we do this free operiton.

!prior && !was_frozen together means  that slab page has previously
depleted all objects
and forgotten(SLUB don't remember a slab page that has got all its
object allocated).

All these 3 conditions mean that,

A slab page on a remote CPU has got all tis objects allocated and it
was forgotten by SLUB,
so  "Slab was on no list before",

and then at the present, we (on local CPU) are freeing object back to
that CPU,  that "will make
the slab page partially empty".

But we don't bother to immediately add it back to the node partial
list( to avoid the list->lock contention),
so "we can defer the list move".

But how do we handle this?  Easy, just mark it frozen,  and latter
that CPU's  per-cpu freelist queue will
use it.


Regards,
Jianyu Zhan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: a question about slub in function __slab_free()
@ 2016-03-02 15:12   ` Jianyu Zhan
  0 siblings, 0 replies; 8+ messages in thread
From: Jianyu Zhan @ 2016-03-02 15:12 UTC (permalink / raw)
  To: Xishi Qiu; +Cc: LKML, Linux MM, js1304

On Wed, Mar 2, 2016 at 8:26 PM, Xishi Qiu <qiuxishi@huawei.com> wrote:
> __slab_free()
>         prior = page->freelist;  // prior is NULL
>         was_frozen = new.frozen;  // was_frozen is 0
>         ...
>                 /*
>                  * Slab was on no list before and will be
>                  * partially empty
>                  * We can defer the list move and instead
>                  * freeze it.
>                  */
>                 new.frozen = 1;
>         ...
>
> I don't understand why "Slab was on no list before"?

in this  __slab_free() code path, we are freeing an object to a remote CPU.

Consider the condition that leads to this branch, that is:

new.inuse  && !prior && !was_frozen

new.inuse means that slab page has free objects after we do this free operiton.

!prior && !was_frozen together means  that slab page has previously
depleted all objects
and forgotten(SLUB don't remember a slab page that has got all its
object allocated).

All these 3 conditions mean that,

A slab page on a remote CPU has got all tis objects allocated and it
was forgotten by SLUB,
so  "Slab was on no list before",

and then at the present, we (on local CPU) are freeing object back to
that CPU,  that "will make
the slab page partially empty".

But we don't bother to immediately add it back to the node partial
list( to avoid the list->lock contention),
so "we can defer the list move".

But how do we handle this?  Easy, just mark it frozen,  and latter
that CPU's  per-cpu freelist queue will
use it.


Regards,
Jianyu Zhan

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: a question about slub in function __slab_free()
  2016-03-02 14:38   ` Joonsoo Kim
@ 2016-03-03  1:26     ` Xishi Qiu
  -1 siblings, 0 replies; 8+ messages in thread
From: Xishi Qiu @ 2016-03-03  1:26 UTC (permalink / raw)
  To: Joonsoo Kim; +Cc: LKML, Linux MM

On 2016/3/2 22:38, Joonsoo Kim wrote:

> 2016-03-02 21:26 GMT+09:00 Xishi Qiu <qiuxishi@huawei.com>:
>> ___slab_alloc()
>>         deactivate_slab()
>>                 add_full(s, n, page);
>> The page will be added to full list and the frozen is 0, right?
>>
>> __slab_free()
>>         prior = page->freelist;  // prior is NULL
>>         was_frozen = new.frozen;  // was_frozen is 0
>>         ...
>>                 /*
>>                  * Slab was on no list before and will be
>>                  * partially empty
>>                  * We can defer the list move and instead
>>                  * freeze it.
>>                  */
>>                 new.frozen = 1;
>>         ...
>>
>> I don't understand why "Slab was on no list before"?
> 
> add_full() is defined only for CONFIG_SLUB_DEBUG.
> And, actual add happens if slub_debug=u is enabled.
> In other cases, fully used slab isn't attached on any list.
> 
> Thanks.
> 

Hi Joonsoo,

You are right, thank you very much!

> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: a question about slub in function __slab_free()
@ 2016-03-03  1:26     ` Xishi Qiu
  0 siblings, 0 replies; 8+ messages in thread
From: Xishi Qiu @ 2016-03-03  1:26 UTC (permalink / raw)
  To: Joonsoo Kim; +Cc: LKML, Linux MM

On 2016/3/2 22:38, Joonsoo Kim wrote:

> 2016-03-02 21:26 GMT+09:00 Xishi Qiu <qiuxishi@huawei.com>:
>> ___slab_alloc()
>>         deactivate_slab()
>>                 add_full(s, n, page);
>> The page will be added to full list and the frozen is 0, right?
>>
>> __slab_free()
>>         prior = page->freelist;  // prior is NULL
>>         was_frozen = new.frozen;  // was_frozen is 0
>>         ...
>>                 /*
>>                  * Slab was on no list before and will be
>>                  * partially empty
>>                  * We can defer the list move and instead
>>                  * freeze it.
>>                  */
>>                 new.frozen = 1;
>>         ...
>>
>> I don't understand why "Slab was on no list before"?
> 
> add_full() is defined only for CONFIG_SLUB_DEBUG.
> And, actual add happens if slub_debug=u is enabled.
> In other cases, fully used slab isn't attached on any list.
> 
> Thanks.
> 

Hi Joonsoo,

You are right, thank you very much!

> 



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-03-03  1:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-02 12:26 a question about slub in function __slab_free() Xishi Qiu
2016-03-02 12:26 ` Xishi Qiu
2016-03-02 14:38 ` Joonsoo Kim
2016-03-02 14:38   ` Joonsoo Kim
2016-03-03  1:26   ` Xishi Qiu
2016-03-03  1:26     ` Xishi Qiu
2016-03-02 15:12 ` Jianyu Zhan
2016-03-02 15:12   ` Jianyu Zhan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.