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:	Mon, 27 Jul 2009 11:24:08 -0400
From:	Christoph Hellwig <hch@...radead.org>
To:	Thomas Gleixner <tglx@...utronix.de>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ingo Molnar <mingo@...e.hu>,
	Peter Zijlstra <peterz@...radead.org>
Subject: Re: [Patch RFC 01/37] semaphore: Add DEFINE_SEMAPHORE,
	semaphore_init, semaphore_init_locked

On Sun, Jul 26, 2009 at 08:17:11AM -0000, Thomas Gleixner wrote:
> The full cleanup of init_MUTEX[_LOCKED] and DECLARE_MUTEX has not been
> done. Some of the users are real semaphores and we should name them as
> such instead of confusing everyone with "MUTEX".

> +#define DEFINE_SEMAPHORE(name)	\
> +	struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
> +

> +static inline void semaphore_init(struct semanphore *sem)
> +{
> +	sema_init(sem, 1);
> +}
> +
> +/*
> + * semaphore_init_locked() is mostly a sign for a mutex which is
> + * abused as completion.
> + */
> +static inline void __deprecated semaphore_init_locked(struct semanphore *sem)
> +{
> +	sema_init(sem, 0);
> +}

The CS literature doesn't really know about a default value for counting
semaphores.  I think you're better off converting init_MUTEX and
init_MUTEX_locked to explicit sema_init use than adding these and
introducing another semaphore_* namespace in addition to the sema_* we
already have.  Adding a DEFINE_SEMAPHORE makes sense, but it should take
a second argument for it's initial value.

--
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