lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Sun, 13 Apr 2008 22:26:54 -0700 (PDT)
From:	Eus <eus@...ber.fsf.org>
To:	Linux Networking Mailing List <netdev@...r.kernel.org>
Subject: proto_register() - the justification for requesting slab allocation

Hi Ho!

Currently I am trying to implement a new type of socket in Linux kernel 2.6.21.5.
I am really curious about this function:
        int proto_register(struct proto *prot, int alloc_slab)

I have investigated the source code and knew that, if alloc_slab is set to a
non-zero integer, kmem_cache_create() will create a memory slab for prot->slab.
At the end, when a socket needs to be created and sk_alloc() is invoked to create
the socket object, if prot->slab has been initialized with kmem_cache_create(),
sk_alloc() will simply create the socket object in the slab with
kmem_cache_alloc. Otherwise, sk_alloc() will create the socket object in the
ordinary way with kmalloc().

IMO, kmem_cache_alloc() should be less expensive than kmalloc() and, therefore,
it is a good thing to request slab allocation when invoking proto_register().
But, from all networking protocols that invoke proto_register(), 50% of them,
most of them are data link protocols, does not request slab allocation. The rest
that request slab allocation mainly is network layer protocols. That is why I
wonder whether or not there is an advantage of using kmalloc() over using
kmem_cache_alloc().

A friend of mine said that those that do not request slab allocation do so
because they are rarely used. But, I disagree because, although they are rarely
used, once they are used, they are used heavily, for example AF_PACKET, so that
it is a good idea to request slab allocation.

Therefore, what is the justification for requesting slab allocation or not?

Please put me in the CC list when replying.

Thank you very much.

Best regards,
Eus


      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ