Kernel Newbies archive on lore.kernel.org
 help / Atom feed
* How to detect slab memory leak
@ 2018-12-16  6:23 Naruto Nguyen
  2018-12-18  7:42 ` Mulyadi Santosa
  0 siblings, 1 reply; 5+ messages in thread
From: Naruto Nguyen @ 2018-12-16  6:23 UTC (permalink / raw)
  To: kernelnewbies

Hi everyone,

When using slabtop to display the cache size growing, I see that
kmalloc-1024 and kmalloc-256 are increasing about 200MB after 1 hour.
Is there any way to detect which kernel components cause this slab
increase?

Thanks a lot,
Brs,
Naruto

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Re: How to detect slab memory leak
  2018-12-16  6:23 How to detect slab memory leak Naruto Nguyen
@ 2018-12-18  7:42 ` Mulyadi Santosa
  2018-12-18  8:31   ` Harsh Jain
  0 siblings, 1 reply; 5+ messages in thread
From: Mulyadi Santosa @ 2018-12-18  7:42 UTC (permalink / raw)
  To: Naruto Nguyen; +Cc: kernelnewbies

[-- Attachment #1.1: Type: text/plain, Size: 855 bytes --]

On Sun, Dec 16, 2018 at 1:25 PM Naruto Nguyen <narutonguyen2018@gmail.com>
wrote:

> Hi everyone,
>
> When using slabtop to display the cache size growing, I see that
> kmalloc-1024 and kmalloc-256 are increasing about 200MB after 1 hour.
> Is there any way to detect which kernel components cause this slab
> increase?
>
> Thanks a lot,
> Brs,
> Naruto
>
>
Hello Naruto

I think you can do it by instrumenting call to kmalloc(). These days, eBPF
is the hot stuff to try for this matter. See if it fits yours too.

regards,

Mulyadi


> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>


-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

[-- Attachment #1.2: Type: text/html, Size: 1827 bytes --]

<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Dec 16, 2018 at 1:25 PM Naruto Nguyen &lt;<a href="mailto:narutonguyen2018@gmail.com">narutonguyen2018@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi everyone,<br>
<br>
When using slabtop to display the cache size growing, I see that<br>
kmalloc-1024 and kmalloc-256 are increasing about 200MB after 1 hour.<br>
Is there any way to detect which kernel components cause this slab<br>
increase?<br>
<br>
Thanks a lot,<br>
Brs,<br>
Naruto<br>
<br></blockquote><div><br></div><div>Hello Naruto</div><div><br></div><div>I think you can do it by instrumenting call to kmalloc(). These days, eBPF is the hot stuff to try for this matter. See if it fits yours too.</div><div><br></div><div>regards,</div><div><br></div><div>Mulyadi<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
<a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">regards,<br><br>Mulyadi Santosa<br>Freelance Linux trainer and consultant<br><br>blog: <a href="http://the-hydra.blogspot.com" target="_blank">the-hydra.blogspot.com</a><br>training: <a href="http://mulyaditraining.blogspot.com" target="_blank">mulyaditraining.blogspot.com</a></div></div>

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Re: How to detect slab memory leak
  2018-12-18  7:42 ` Mulyadi Santosa
@ 2018-12-18  8:31   ` Harsh Jain
  2018-12-19 11:58     ` Naruto Nguyen
  0 siblings, 1 reply; 5+ messages in thread
From: Harsh Jain @ 2018-12-18  8:31 UTC (permalink / raw)
  To: Mulyadi Santosa; +Cc: Naruto Nguyen, kernelnewbies

You can try kernel config option "CONFIG_DEBUG_KMEMLEAK".


https://www.kernel.org/doc/html/v4.10/dev-tools/kmemleak.html

On Tue, Dec 18, 2018 at 1:14 PM Mulyadi Santosa
<mulyadi.santosa@gmail.com> wrote:
>
>
>
> On Sun, Dec 16, 2018 at 1:25 PM Naruto Nguyen <narutonguyen2018@gmail.com> wrote:
>>
>> Hi everyone,
>>
>> When using slabtop to display the cache size growing, I see that
>> kmalloc-1024 and kmalloc-256 are increasing about 200MB after 1 hour.
>> Is there any way to detect which kernel components cause this slab
>> increase?
>>
>> Thanks a lot,
>> Brs,
>> Naruto
>>
>
> Hello Naruto
>
> I think you can do it by instrumenting call to kmalloc(). These days, eBPF is the hot stuff to try for this matter. See if it fits yours too.
>
> regards,
>
> Mulyadi
>
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Re: How to detect slab memory leak
  2018-12-18  8:31   ` Harsh Jain
@ 2018-12-19 11:58     ` Naruto Nguyen
  2018-12-21  7:32       ` Mulyadi Santosa
  0 siblings, 1 reply; 5+ messages in thread
From: Naruto Nguyen @ 2018-12-19 11:58 UTC (permalink / raw)
  To: Harsh Jain; +Cc: Mulyadi Santosa, kernelnewbies

Hi Harsh and Mulyadi,

Thanks a lot  for your reply.

Just another question, in the slabtop output, I see that we have
kmalloc-64 and kmalloc-96 cache, when these caches increase their
size, is it calculated in the "cache" of the "free" command or in
"used". Is it reclaimable? and count in SReclaimable or SUnreclaim of
cat /proc/meminfo? I know some cache like dentry or inode cache will
be calculated in "cache" of free command output and SReclaimable of
cat /proc/meminfo and can be freed by "echo 3 >
/proc/sys/vm/drop_caches" but not sure if it the same situation for
kmalloc-64 and kmalloc-96 cache.

Thanks again,
Brs,
Bao

On Tue, 18 Dec 2018 at 15:31, Harsh Jain <harshjain.prof@gmail.com> wrote:
>
> You can try kernel config option "CONFIG_DEBUG_KMEMLEAK".
>
>
> https://www.kernel.org/doc/html/v4.10/dev-tools/kmemleak.html
>
> On Tue, Dec 18, 2018 at 1:14 PM Mulyadi Santosa
> <mulyadi.santosa@gmail.com> wrote:
> >
> >
> >
> > On Sun, Dec 16, 2018 at 1:25 PM Naruto Nguyen <narutonguyen2018@gmail.com> wrote:
> >>
> >> Hi everyone,
> >>
> >> When using slabtop to display the cache size growing, I see that
> >> kmalloc-1024 and kmalloc-256 are increasing about 200MB after 1 hour.
> >> Is there any way to detect which kernel components cause this slab
> >> increase?
> >>
> >> Thanks a lot,
> >> Brs,
> >> Naruto
> >>
> >
> > Hello Naruto
> >
> > I think you can do it by instrumenting call to kmalloc(). These days, eBPF is the hot stuff to try for this matter. See if it fits yours too.
> >
> > regards,
> >
> > Mulyadi
> >
> >>
> >> _______________________________________________
> >> Kernelnewbies mailing list
> >> Kernelnewbies@kernelnewbies.org
> >> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
> >
> >
> > --
> > regards,
> >
> > Mulyadi Santosa
> > Freelance Linux trainer and consultant
> >
> > blog: the-hydra.blogspot.com
> > training: mulyaditraining.blogspot.com
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies@kernelnewbies.org
> > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Re: How to detect slab memory leak
  2018-12-19 11:58     ` Naruto Nguyen
@ 2018-12-21  7:32       ` Mulyadi Santosa
  0 siblings, 0 replies; 5+ messages in thread
From: Mulyadi Santosa @ 2018-12-21  7:32 UTC (permalink / raw)
  To: kernelnewbies

[-- Attachment #1.1: Type: text/plain, Size: 3015 bytes --]

On Wed, Dec 19, 2018 at 6:58 PM Naruto Nguyen <narutonguyen2018@gmail.com>
wrote:

> Hi Harsh and Mulyadi,
>
> Thanks a lot  for your reply.
>
> Just another question, in the slabtop output, I see that we have
> kmalloc-64 and kmalloc-96 cache, when these caches increase their
> size, is it calculated in the "cache" of the "free" command or in
> "used".


If the cache is used for page cache related operations, then AFAIK it is
calculated in cache. If not, say for mmap non file backed operation, then
it is calculated in overall used.


> Is it reclaimable?


AFAIK yes, as long as it is not locked after being allocated.


> and count in SReclaimable or SUnreclaim of
> cat /proc/meminfo? I know some cache like dentry or inode cache will
> be calculated in "cache" of free command output and SReclaimable of
> cat /proc/meminfo and can be freed by "echo 3 >
> /proc/sys/vm/drop_caches" but not sure if it the same situation for
> kmalloc-64 and kmalloc-96 cache.
>
> Thanks again,
> Brs,
> Bao
>
> On Tue, 18 Dec 2018 at 15:31, Harsh Jain <harshjain.prof@gmail.com> wrote:
> >
> > You can try kernel config option "CONFIG_DEBUG_KMEMLEAK".
> >
> >
> > https://www.kernel.org/doc/html/v4.10/dev-tools/kmemleak.html
> >
> > On Tue, Dec 18, 2018 at 1:14 PM Mulyadi Santosa
> > <mulyadi.santosa@gmail.com> wrote:
> > >
> > >
> > >
> > > On Sun, Dec 16, 2018 at 1:25 PM Naruto Nguyen <
> narutonguyen2018@gmail.com> wrote:
> > >>
> > >> Hi everyone,
> > >>
> > >> When using slabtop to display the cache size growing, I see that
> > >> kmalloc-1024 and kmalloc-256 are increasing about 200MB after 1 hour.
> > >> Is there any way to detect which kernel components cause this slab
> > >> increase?
> > >>
> > >> Thanks a lot,
> > >> Brs,
> > >> Naruto
> > >>
> > >
> > > Hello Naruto
> > >
> > > I think you can do it by instrumenting call to kmalloc(). These days,
> eBPF is the hot stuff to try for this matter. See if it fits yours too.
> > >
> > > regards,
> > >
> > > Mulyadi
> > >
> > >>
> > >> _______________________________________________
> > >> Kernelnewbies mailing list
> > >> Kernelnewbies@kernelnewbies.org
> > >> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> > >
> > >
> > >
> > > --
> > > regards,
> > >
> > > Mulyadi Santosa
> > > Freelance Linux trainer and consultant
> > >
> > > blog: the-hydra.blogspot.com
> > > training: mulyaditraining.blogspot.com
> > > _______________________________________________
> > > Kernelnewbies mailing list
> > > Kernelnewbies@kernelnewbies.org
> > > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>


-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

[-- Attachment #1.2: Type: text/html, Size: 5941 bytes --]

<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 19, 2018 at 6:58 PM Naruto Nguyen &lt;<a href="mailto:narutonguyen2018@gmail.com">narutonguyen2018@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Harsh and Mulyadi,<br>
<br>
Thanks a lot  for your reply.<br>
<br>
Just another question, in the slabtop output, I see that we have<br>
kmalloc-64 and kmalloc-96 cache, when these caches increase their<br>
size, is it calculated in the &quot;cache&quot; of the &quot;free&quot; command or in<br>
&quot;used&quot;. </blockquote><div><br></div><div>If the cache is used for page cache related operations, then AFAIK it is calculated in cache. If not, say for mmap non file backed operation, then it is calculated in overall used.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Is it reclaimable?</blockquote><div><br></div><div>AFAIK yes, as long as it is not locked after being allocated.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> and count in SReclaimable or SUnreclaim of<br>
cat /proc/meminfo? I know some cache like dentry or inode cache will<br>
be calculated in &quot;cache&quot; of free command output and SReclaimable of<br>
cat /proc/meminfo and can be freed by &quot;echo 3 &gt;<br>
/proc/sys/vm/drop_caches&quot; but not sure if it the same situation for<br>
kmalloc-64 and kmalloc-96 cache.<br>
<br>
Thanks again,<br>
Brs,<br>
Bao<br>
<br>
On Tue, 18 Dec 2018 at 15:31, Harsh Jain &lt;<a href="mailto:harshjain.prof@gmail.com" target="_blank">harshjain.prof@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; You can try kernel config option &quot;CONFIG_DEBUG_KMEMLEAK&quot;.<br>
&gt;<br>
&gt;<br>
&gt; <a href="https://www.kernel.org/doc/html/v4.10/dev-tools/kmemleak.html" rel="noreferrer" target="_blank">https://www.kernel.org/doc/html/v4.10/dev-tools/kmemleak.html</a><br>
&gt;<br>
&gt; On Tue, Dec 18, 2018 at 1:14 PM Mulyadi Santosa<br>
&gt; &lt;<a href="mailto:mulyadi.santosa@gmail.com" target="_blank">mulyadi.santosa@gmail.com</a>&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; On Sun, Dec 16, 2018 at 1:25 PM Naruto Nguyen &lt;<a href="mailto:narutonguyen2018@gmail.com" target="_blank">narutonguyen2018@gmail.com</a>&gt; wrote:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Hi everyone,<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; When using slabtop to display the cache size growing, I see that<br>
&gt; &gt;&gt; kmalloc-1024 and kmalloc-256 are increasing about 200MB after 1 hour.<br>
&gt; &gt;&gt; Is there any way to detect which kernel components cause this slab<br>
&gt; &gt;&gt; increase?<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Thanks a lot,<br>
&gt; &gt;&gt; Brs,<br>
&gt; &gt;&gt; Naruto<br>
&gt; &gt;&gt;<br>
&gt; &gt;<br>
&gt; &gt; Hello Naruto<br>
&gt; &gt;<br>
&gt; &gt; I think you can do it by instrumenting call to kmalloc(). These days, eBPF is the hot stuff to try for this matter. See if it fits yours too.<br>
&gt; &gt;<br>
&gt; &gt; regards,<br>
&gt; &gt;<br>
&gt; &gt; Mulyadi<br>
&gt; &gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; _______________________________________________<br>
&gt; &gt;&gt; Kernelnewbies mailing list<br>
&gt; &gt;&gt; <a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
&gt; &gt;&gt; <a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; regards,<br>
&gt; &gt;<br>
&gt; &gt; Mulyadi Santosa<br>
&gt; &gt; Freelance Linux trainer and consultant<br>
&gt; &gt;<br>
&gt; &gt; blog: <a href="http://the-hydra.blogspot.com" rel="noreferrer" target="_blank">the-hydra.blogspot.com</a><br>
&gt; &gt; training: <a href="http://mulyaditraining.blogspot.com" rel="noreferrer" target="_blank">mulyaditraining.blogspot.com</a><br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Kernelnewbies mailing list<br>
&gt; &gt; <a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
&gt; &gt; <a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">regards,<br><br>Mulyadi Santosa<br>Freelance Linux trainer and consultant<br><br>blog: <a href="http://the-hydra.blogspot.com" target="_blank">the-hydra.blogspot.com</a><br>training: <a href="http://mulyaditraining.blogspot.com" target="_blank">mulyaditraining.blogspot.com</a></div></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
	<tr>
        <td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
		<td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" target="_blank" style="color:#4453ea">www.avast.com</a>
		</td>
	</tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-16  6:23 How to detect slab memory leak Naruto Nguyen
2018-12-18  7:42 ` Mulyadi Santosa
2018-12-18  8:31   ` Harsh Jain
2018-12-19 11:58     ` Naruto Nguyen
2018-12-21  7:32       ` Mulyadi Santosa

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org kernelnewbies@archiver.kernel.org
	public-inbox-index kernelnewbies


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/ public-inbox