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:	Wed, 27 Jul 2011 16:45:55 +0200
From:	Clemens Ladisch <clemens@...isch.de>
To:	Steven Whitehouse <swhiteho@...hat.com>
CC:	Artem Bityutskiy <Artem.Bityutskiy@...ia.com>,
	Don Mullis <don.mullis@...il.com>,
	Dave Chinner <david@...morbit.com>,
	linux-kernel@...r.kernel.org
Subject: Re: list sort

Steven Whitehouse wrote:
> There seems to be an issue with list_sort trying to compare an object to
> itself. [...]
> While it appears generally harmless, since the list does appear to be
> correctly sorted, it is doing extra work needlessly.

There are sort algorithms where this happens naturally, and adding
an additional check to avoid calling the comparison function when the
pointers are equal would be more work overall than just calling cmp().

This does not happen with list_sort()'s merge sort, but I've noticed
the following hack in merge_and_restore_back_links():

	do {
		/*
		 * In worst cases this loop may run many iterations.
		 * Continue callbacks to the client even though no
		 * element comparison is needed, so the client's cmp()
		 * routine can invoke cond_resched() periodically.
		 */
		(*cmp)(priv, tail->next, tail->next);

		tail->next->prev = tail;
		tail = tail->next;
	} while (tail->next);

When there is no cond_resched() call, this is indeed needless work.

However, if the list is so short that cond_resched() is not needed,
the additional comparisons should not hurt anyway.


Regards,
Clemens
--
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