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] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 30 Sep 2008 13:33:06 -0500
From:	Matt Mackall <mpm@...enic.com>
To:	Richard Kennedy <richard@....demon.co.uk>
Cc:	Christoph Lameter <cl@...ux-foundation.org>,
	penberg <penberg@...helsinki.fi>, linux-mm <linux-mm@...ck.org>,
	lkml <linux-kernel@...r.kernel.org>, Ingo Molnar <mingo@...e.hu>
Subject: Re: [PATCH] slub: reduce total stack usage of slab_err & object_err


On Tue, 2008-09-30 at 12:37 -0500, Matt Mackall wrote:
> On Tue, 2008-09-30 at 17:20 +0100, Richard Kennedy wrote:
> > Yes, using vprintk is better but you still have this path :
> > ( with your patch applied)
> > 
> > 	object_err -> slab_bug(208) -> printk(216)
> > instead of 
> > 	object_err -> slab_bug_message(8) -> printk(216)
> > 
> > unfortunately the overhead for having var_args is pretty big, at least
> > on x86_64. I haven't measured it on 32 bit yet.
> 
> That's fascinating. I tried a simple test case in userspace:
> 
> #include <stdarg.h>
> #include <stdio.h>
> 
> void p(char *fmt, ...)
> {
> 	va_list args;
> 
> 	va_start(args, fmt);
> 	vprintf(fmt, args);
> 	va_end(args);
> }
> 
> On 32-bit, I'm seeing 32 bytes of stack vs 216 on 64-bit. Disassembly
> suggests it's connected to va_list fiddling with XMM registers, which
> seems quite odd.

Ok, on closer inspection, this is part of the x86_64 calling convention.
When calling a varargs function, the caller passes the number of
floating point SSE regs used in rax. The callee then has to save these
away for va_list use. The GCC prologue apparently sets aside space for
xmm0-xmm7 (16 bytes each) all the time (plus rdi, rsi, rdx, rcx, r8, and
r9).

Obviously, we're never passing floating point args in the kernel, so
we're taking about a 40+ byte hit in code size and 128 byte hit in stack
size for every varargs call.

Looks like the gcc people have a patch in progress:

http://gcc.gnu.org/ml/gcc-patches/2008-08/msg02165.html

So I think we should assume that x86_64 will sort this out eventually.

-- 
Mathematics is the supreme nostalgia of our time.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ