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] [day] [month] [year] [list]
Date:	Fri, 30 May 2014 14:23:05 +0530
From:	Raghavendra K T <raghavendra.kt@...ux.vnet.ibm.com>
To:	Waiman Long <waiman.long@...com>
CC:	tglx@...utronix.de, mingo@...hat.com, hpa@...or.com,
	konrad.wilk@...cle.com, pbonzini@...hat.com, gleb@...hat.com,
	peterz@...radead.org, paulmck@...ux.vnet.ibm.com,
	torvalds@...ux-foundation.org, davej@...hat.com, oleg@...hat.com,
	x86@...nel.org, jeremy@...p.org, paul.gortmaker@...driver.com,
	ak@...ux.intel.com, jasowang@...hat.com, fernando_b1@....ntt.co.jp,
	linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
	virtualization@...ts.linux-foundation.org,
	xen-devel@...ts.xenproject.org, riel@...hat.com,
	mtosatti@...hat.com, chegu_vinod@...com
Subject: Re: [RFC] Implement Batched (group) ticket lock

On 05/30/2014 04:15 AM, Waiman Long wrote:
> On 05/28/2014 08:16 AM, Raghavendra K T wrote:
>> - we need an intelligent way to nullify the effect of batching for
>> baremetal
>>   (because extra cmpxchg is not required).
>
> To do this, you will need to have 2 slightly different algorithms
> depending on the paravirt_ticketlocks_enabled jump label.

Thanks for the hint Waiman.

[...]
>> +spin:
>> +    for (;;) {
>> +        inc.head = ACCESS_ONCE(lock->tickets.head);
>> +        if (!(inc.head&  TICKET_LOCK_HEAD_INC)) {
>> +            new.head = inc.head | TICKET_LOCK_HEAD_INC;
>> +            if (cmpxchg(&lock->tickets.head, inc.head, new.head)
>> +                    == inc.head)
>> +                goto out;
>> +        }
>> +        cpu_relax();
>> +    }
>> +
>
> It had taken me some time to figure out the the LSB of inc.head is used
> as a bit lock for the contending tasks in the spin loop. I would suggest
> adding some comment here to make it easier to look at.

Agree. 'll add a comment.

[...]
>> +#define TICKET_BATCH    0x4 /* 4 waiters can contend simultaneously */
>> +#define TICKET_LOCK_BATCH_MASK
>> (~(TICKET_BATCH<<TICKET_LOCK_INC_SHIFT) + \
>> +                  TICKET_LOCK_TAIL_INC - 1)
>
> I don't think TAIL_INC has anything to do with setting the BATCH_MASK.
> It works here because TAIL_INC is 2. I think it is clearer to define it
> as either "(~(TICKET_BATCH<<TICKET_LOCK_INC_SHIFT) + 1)" or
> (~((TICKET_BATCH<<TICKET_LOCK_INC_SHIFT) - 1)).

You are right.
Thanks for pointing out. Your expression is simple and clearer. 'll use
one of them.

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