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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161027151420.GG3175@twins.programming.kicks-ass.net>
Date:   Thu, 27 Oct 2016 17:14:20 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     David Herrmann <dh.herrmann@...il.com>
Cc:     linux-kernel@...r.kernel.org,
        Andy Lutomirski <luto@...capital.net>,
        Jiri Kosina <jikos@...nel.org>, Greg KH <greg@...ah.com>,
        Hannes Reinecke <hare@...e.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Arnd Bergmann <arnd@...db.de>, Tom Gundersen <teg@...m.no>,
        Josh Triplett <josh@...htriplett.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [RFC v1 05/14] bus1: util - pool utility library

On Wed, Oct 26, 2016 at 09:18:01PM +0200, David Herrmann wrote:

All small nits..

> +void bus1_pool_deinit(struct bus1_pool *pool)
> +{
> +	struct bus1_pool_slice *slice;
> +
> +	if (!pool || !pool->f)
> +		return;
> +
> +	while ((slice = list_first_entry_or_null(&pool->slices,
> +						 struct bus1_pool_slice,
> +						 entry))) {
> +		WARN_ON(slice->ref_kernel);
> +		list_del(&slice->entry);
> +		bus1_pool_slice_free(slice);
> +	}

I prefer to write that loop like:

	while (!list_empty(&pool->slices)) {
		slice = list_first_entry(&pool->slices, struct bus1_pool_slice, entry);
		list_del(&slice->entry);

		// ...
	}



> +static void bus1_pool_free(struct bus1_pool *pool,
> +			   struct bus1_pool_slice *slice)
> +{
> +	struct bus1_pool_slice *ps;
> +
> +	/* don't free the slice if either has a reference */
> +	if (slice->ref_kernel || slice->ref_user || WARN_ON(slice->free))
> +		return;
> +
> +	/*
> +	 * To release a pool-slice, we first drop it from the busy-tree, then
> +	 * merge it with possible previous/following free slices and re-add it
> +	 * to the free-tree.
> +	 */
> +
> +	rb_erase(&slice->rb, &pool->slices_busy);
> +
> +	if (!WARN_ON(slice->size > pool->allocated_size))
> +		pool->allocated_size -= slice->size;
> +
> +	if (pool->slices.next != &slice->entry) {
> +		ps = container_of(slice->entry.prev, struct bus1_pool_slice,
> +				  entry);

		ps = list_prev_entry(slice, entry);

> +		if (ps->free) {
> +			rb_erase(&ps->rb, &pool->slices_free);
> +			list_del(&slice->entry);
> +			ps->size += slice->size;
> +			bus1_pool_slice_free(slice);
> +			slice = ps; /* switch to previous slice */
> +		}
> +	}
> +
> +	if (pool->slices.prev != &slice->entry) {
> +		ps = container_of(slice->entry.next, struct bus1_pool_slice,
> +				  entry);

		ps = list_next_entry(slice, entry);

> +		if (ps->free) {
> +			rb_erase(&ps->rb, &pool->slices_free);
> +			list_del(&ps->entry);
> +			slice->size += ps->size;
> +			bus1_pool_slice_free(ps);
> +		}
> +	}
> +
> +	slice->free = true;
> +	bus1_pool_slice_link_free(slice, pool);
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ