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>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20170320060830.GA1789@avx2>
Date:   Mon, 20 Mar 2017 09:08:30 +0300
From:   Alexey Dobriyan <adobriyan@...il.com>
To:     Eric Dumazet <eric.dumazet@...il.com>
Cc:     steffen.klassert@...unet.com, herbert@...dor.apana.org.au,
        davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH 2/4] flowcache: make flow_cache_hash_size() return
 "unsigned int"

On Sun, Mar 19, 2017 at 04:13:41PM -0700, Eric Dumazet wrote:
> On Mon, 2017-03-20 at 01:24 +0300, Alexey Dobriyan wrote:
> > Hash size can't negative so "unsigned int" is logically correct.
> 
> 
> >  	struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu);
> > -	size_t sz = sizeof(struct hlist_head) * flow_cache_hash_size(fc);
> > +	unsigned int sz = sizeof(struct hlist_head) * flow_cache_hash_size(fc);
> >  
> >  	if (!fcp->hash_table) {
> >  		fcp->hash_table = kzalloc_node(sz, GFP_KERNEL, cpu_to_node(cpu));
> >  		if (!fcp->hash_table) {
> > -			pr_err("NET: failed to allocate flow cache sz %zu\n", sz);
> > +			pr_err("NET: failed to allocate flow cache sz %u\n", sz);
> 
> 
> I do not see any improvement here.
> 
> What is wrong with size_t exactly ?

REX prefixes and sign extensions, lots of them.

Before:
	ffffffff8505b1b5:       41 bd 01 00 00 00       mov    r13d,0x1
	ffffffff8505b1bb:       41 d3 e5                shl    r13d,cl
	ffffffff8505b1be:       4d 63 ed                movsxd r13,r13d
	ffffffff8505b1c1:       49 c1 e5 03             shl    r13,0x3
	ffffffff8505b1c5:       e8 86 28 0a fc          call   __cpu_to_node
			...
	ffffffff8505b20b:       4c 89 ee                mov    rsi,r13

After:
	ffffffff8505b1b5:       41 bd 08 00 00 00       mov    r13d,0x8
	ffffffff8505b1bb:       41 d3 e5                shl    r13d,cl
	ffffffff8505b1be:       e8 8d 28 0a fc          call   __cpu_to_node
			...
	ffffffff8505b1c3:       44 89 ef                mov    edi,r13d

Basically, one can do s/size_t/unsigned int/g across whole networking
stack and nothing will change but the code becomes smaller (including
things like sendmsg() because VFS truncates lengths at INT_MAX).

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ