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] [day] [month] [year] [list]
Message-ID: <551E2847.8020201@linaro.org>
Date:	Fri, 03 Apr 2015 11:12:31 +0530
From:	viresh kumar <viresh.kumar@...aro.org>
To:	Peter Zijlstra <peterz@...radead.org>
CC:	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	Linaro Kernel Mailman List <linaro-kernel@...ts.linaro.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] hrtimer: create for_each_active_base() to iterate
 over active clock-bases

On 2 April 2015 at 19:15, Peter Zijlstra <peterz@...radead.org> wrote:
> On Thu, Apr 02, 2015 at 04:21:22PM +0530, Viresh Kumar wrote:
>> +#define for_each_active_base(_index, _base, _cpu_base, _active_bases)        \
>> +     for ((_active_bases) = (_cpu_base)->active_bases;               \
>> +             (_index) = ffs(_active_bases),                          \
>> +             (_base) = (_cpu_base)->clock_base + (_index) - 1, (_index); \
>> +             (_active_bases) &= ~(1 << ((_index) - 1)))
>
> Can't use ffs here, some people end up using asm-generic/bitops/ffs.h
> and that sucks.
>
> Esp for small vectors like here, the unconditional iteration is faster.

Okay what about this instead (This is the best I could write :).) ?

+static inline int __next_bit(unsigned int active_bases, int bit)
+{
+       do {
+               if (active_bases & (1 << bit))
+                       return bit;
+       } while (++bit < HRTIMER_MAX_CLOCK_BASES);
+
+       /* We should never reach here */
+       return 0;
+}
+/*
+ * for_each_active_base: iterate over all active clock bases
+ * @_bit: 'int' variable for internal purpose
+ * @_base: holds pointer to a active clock base
+ * @_cpu_base: cpu base to iterate on
+ * @_active_bases: 'unsigned int' variable for internal purpose
+ */
+#define for_each_active_base(_bit, _base, _cpu_base, _active_bases)    \
+       for ((_active_bases) = (_cpu_base)->active_bases, (_bit) = -1;  \
+               (_active_bases) &&                                      \
+               ((_bit) = __next_bit(_active_bases, ++_bit),            \
+               (_base) = (_cpu_base)->clock_base + _bit);              \
+               (_active_bases) &= ~(1 << (_bit)))
+


Tested it well with the help of: http://pastebin.com/cYyB513D, with
inputs from 0 to 15.

I will send it formally if it looks fine to you ..
--
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