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]
Message-Id: <20100930094558.97c9afa2.akpm@linux-foundation.org>
Date:	Thu, 30 Sep 2010 09:45:58 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Eric Dumazet <eric.dumazet@...il.com>
Cc:	Dave Chinner <david@...morbit.com>, linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fs: inode per-cpu last_ino allocator

On Thu, 30 Sep 2010 12:22:16 +0200 Eric Dumazet <eric.dumazet@...il.com> wrote:

> Le jeudi 30 septembre 2010 __ 01:14 -0700, Andrew Morton a __crit :
> 
> > Perhaps
> > 
> > 	WARN_ON_ONCE(preemptible());
> > 
> > if we had a developer-only version of WARN_ON_ONCE, which we don't.
> 
> Or just use a regular PER_CPU variable, even on !SMP, and get preempt
> safe implementation.

Good stuff.

> What do you think of following patch, on top of current linux-2.6 tree ?
>
> ...
>
> +static noinline unsigned int last_ino_get(void)
> +{
> +	unsigned int *p = &get_cpu_var(last_ino);
> +	unsigned int res = *p;
> +
> +#ifdef CONFIG_SMP
> +	if (unlikely((res & (LAST_INO_BATCH - 1)) == 0)) {
> +		static atomic_t shared_last_ino;
> +		int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
> +
> +		res = next - LAST_INO_BATCH;
> +	}
> +#endif
> +	*p = ++res;
> +	put_cpu_var(last_ino);
> +	return res;
> +}

Could eliminate `p' I guess, but that would involve using
__get_cpu_var() as an lval, which looks vile and might generate worse
code.

Readers of this code won't know why last_ino_get() was marked noinline.
It looks wrong, really.
--
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