Re: Re: ksm slab do not show up in /proc/slabinfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks, I also found the codes that merge slab and add alias in
kernel 3.10.0-862.el7:
  kmem_cache_create()
  -> kmem_cache_create_memcg()
    -> __kmem_cache_alias()
       	{
		struct kmem_cache *s;

		s = find_mergeable(size, align, flags, name, ctor);
		if (s) {
			s->refcount++;
			/*
			 * Adjust the object sizes so that we clear
			 * the complete object on kzalloc.
			 */
			s->object_size = max(s->object_size, (int)size);
			s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));

			if (sysfs_slab_alias(s, name)) {
				s->refcount--;
				s = NULL;
			}
		}

		return s;
	}

> -----Original Messages-----
> From: "Aurélien Cedeyn" <aurelien.cedeyn@xxxxxxxxx>
> Sent Time: 2019-01-18 07:16:22 (Friday)
> To: wuzhouhui <wuzhouhui14@xxxxxxxxxxxxxxxx>
> Cc: linux-newbie@xxxxxxxxxxxxxxx
> Subject: Re: ksm slab do not show up in /proc/slabinfo
> 
> On Thu, Jan 17, 2019 at 11:18:09PM +0100, Aurélien Cedeyn wrote:
> > On Thu, Jan 17, 2019 at 02:14:56PM +0800, wuzhouhui wrote:
> > > Hi, maybe it is a stupid question, but I just couldn't figure it out,
> > > since codes of ksm in 2.6.32 and 3.10.0 are similar.
> > > 
> > > In CentOS 6 (kernel 2.6.32 based), I can see ksm slab from /proc/slabinfo:
> > > $ grep ksm /proc/slabinfo 
> > > ksm_mm_slot            5     77     48   77    1 : tunables  120   60    8 : slabdata      1      1      0
> > > ksm_stable_node   414575 446016     40   92    1 : tunables  120   60    8 : slabdata   4848   4848      0
> > > ksm_rmap_item     43617468 43617638     64   59    1 : tunables  120   60    8 : slabdata 739282 739282      0
> > > 
> > > But in CentOS 7 (kernel 3.10.0 based), they gone:
> > > $ sudo grep ksm /proc/slabinfo 
> > > $
> > > 
> > > Why? ksm is compiled in kernel for both centos6 and centos7.
> > 
> > Hi,
> > 
> > Maybe you should try to add this option to the kernel command line :
> > 
> > --------------------
> >     slab_nomerge    [MM]
> >             Disable merging of slabs with similar size. May be
> >             necessary if there is some reason to distinguish
> >             allocs to different slabs, especially in hardened
> >             environments where the risk of heap overflows and
> >             layout control by attackers can usually be
> >             frustrated by disabling merging. This will reduce
> >             most of the exposure of a heap attack to a single
> >             cache (risks via metadata attacks are mostly
> >             unchanged). Debug options disable merging on their
> >             own.
> >             For more information see Documentation/vm/slub.rst.
> > --------------------
> > 
> > By default the slab are merged in CentOS 7.
> > I had this behaviour when switching from CentOS 6 to CentOS 7.
> > 
> 
> To complete my answer, you can access/view which slab are linked
> together:
> # grep ksm /proc/slabinfo
> #
> # ls /sys/kernel/slab/ -l | grep ksm
> lrwxrwxrwx 1 root root 0 janv. 18 00:11 ksm_mm_slot -> :t-0000048
> lrwxrwxrwx 1 root root 0 janv. 18 00:11 ksm_rmap_item -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:11 ksm_stable_node -> :t-0000064
> # ls /sys/kernel/slab/ -l | grep  :t-0000048
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 fasync_cache -> :t-0000048
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 ftrace_event_field -> :t-0000048
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 ip_fib_trie -> :t-0000048
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 jbd2_inode -> :t-0000048
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 ksm_mm_slot -> :t-0000048
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 shared_policy_node -> :t-0000048
> drwxr-xr-x 3 root root 0 janv. 18 00:13 :t-0000048
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 t10_alua_lba_map_cache -> :t-0000048
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 t10_alua_lu_gp_mem_cache -> :t-0000048
> # ls /sys/kernel/slab/ -l | grep  :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 anon_vma_chain -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 dccp_ackvec_record -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 dccp_bind_bucket -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 dmaengine-unmap-2 -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 ecryptfs_global_auth_tok_cache -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 ecryptfs_key_sig_cache -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 fanotify_perm_event_info -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 fs_cache -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 io -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 kmalloc-64 -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 ksm_rmap_item -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 ksm_stable_node -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 lio_dr_cache -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 lio_ooo_cache -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 lio_r2t_cache -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 secpath_cache -> :t-0000064
> drwxr-xr-x 3 root root 0 janv. 18 00:13 :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 task_delay_info -> :t-0000064
> lrwxrwxrwx 1 root root 0 janv. 18 00:13 tcp_bind_bucket -> :t-0000064
> 
> 
> -- 
> Aurélien




[Index of Archives]     [Audio]     [Hams]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Fedora Users]

  Powered by Linux