summaryrefslogtreecommitdiffstats
path: root/kernel/include/linux/osq_lock.h
blob: 703ea5c30a33f84bd60fcc19415b48c53084f5c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef __LINUX_OSQ_LOCK_H
#define __LINUX_OSQ_LOCK_H

/*
 * An MCS like lock especially tailored for optimistic spinning for sleeping
 * lock implementations (mutex, rwsem, etc).
 */
struct optimistic_spin_node {
	struct optimistic_spin_node *next, *prev;
	int locked; /* 1 if lock acquired */
	int cpu; /* encoded CPU # + 1 value */
};

struct optimistic_spin_queue {
	/*
	 * Stores an encoded value of the CPU # of the tail node in the queue.
	 * If the queue is empty, then it's set to OSQ_UNLOCKED_VAL.
	 */
	atomic_t tail;
};

#define OSQ_UNLOCKED_VAL (0)

/* Init macro and function. */
#define OSQ_LOCK_UNLOCKED { ATOMIC_INIT(OSQ_UNLOCKED_VAL) }

static inline void osq_lock_init(struct optimistic_spin_queue *lock)
{
	atomic_set(&lock->tail, OSQ_UNLOCKED_VAL);
}

extern bool osq_lock(struct optimistic_spin_queue *lock);
extern void osq_unlock(struct optimistic_spin_queue *lock);

static inline bool osq_is_locked(struct optimistic_spin_queue *lock)
{
	return atomic_read(&lock->tail) != OSQ_UNLOCKED_VAL;
}

#endif
an> 'opnfv-tech-discuss@lists.opnfv.org' tag: '[releng]' realtime_discussion: type: 'irc' server: 'freenode.net' channel: '#lf-releng' meetings: - type: 'gotomeeting+irc' agenda: 'https://wiki.opnfv.org/display/INF/Infra+Working+Group' url: 'https://global.gotomeeting.com/join/819733085' server: 'freenode.net' channel: '#opnfv-meeting' repeats: 'weekly' time: '16:00 UTC' repositories: - 'releng' - 'releng-anteater' - 'releng-testresults' - 'releng-utils' - 'releng-xci' committers: - <<: *opnfv_releng_ptl - name: 'Fatih Degirmenci' email: 'fatih.degirmenci@ericsson.com' company: 'Ericsson' id: 'fdegir' timezone: 'Europe/Stockholm' - name: 'Aric Gardner' email: 'agardner@linuxfoundation.org' company: 'The Linux Foundation' id: 'agardner' timezone: 'America/New_York' - name: 'Tim Rozet' email: 'trozet@redhat.com' company: 'Red Hat' id: 'trozet' timezone: 'America/New_York' - name: 'Morgan Richomme' email: 'morgan.richomme@orange.com' company: 'Orange' id: 'mrichomme' timezone: 'Europe/Paris' - name: 'Jose Lausuch' company: 'SUSE' email: 'jose.lausuch@ericsson.com' id: 'jose.lausuch' timezone: 'Europe/Madrid' - name: 'Ryota Mibu' company: 'NEC' email: 'r-mibu@cq.jp.nec.com' id: 'r-mibu' timezone: 'Asia/Tokyo' - name: 'Mei Mei' company: 'Huawei' email: 'meimei@huawei.com' id: 'm00133142' timezone: 'Asia/Shanghai' - name: 'Serena Feng' company: 'ZTE' email: 'feng.xiaowei@zte.com.cn' id: 'SerenaFeng' timezone: 'Asia/Shanghai' - name: 'Yolanda Robla Mota' company: 'Red Hat' email: 'yroblamo@redhat.com' id: 'yrobla' timezone: 'America/New_York' - name: 'Markos Chandras' company: 'SUSE' email: 'mchandras@suse.de' id: 'mchandras' timezone: 'Europe/Berlin' - name: 'Luke Hinds' company: 'Red Hat' email: 'lhinds@redhat.com' id: 'lukehinds' timezone: 'Europe/London' - name: 'Cédric Ollivier' email: 'cedric.ollivier@orange.com' company: 'orange' id: 'ollivier' timezone: 'Europe/Paris' - name: 'Alexandru Avadanii' email: 'Alexandru.Avadanii@enea.com' company: 'enea.com' id: 'AlexandruAvadanii' tsc: approval: 'http://ircbot.wl.linuxfoundation.org/meetings/opnfv-meeting/2015/opnfv-meeting.2015-07-14-14.00.html' changes: - type: 'removal' name: 'Guy Rodrigue Koffi' link: '' - type: 'removal' name: 'Victor Laza' link: 'http://meetbot.opnfv.org/meetings/opnfv-meeting/2016/opnfv-meeting.2016-02-16-14.59.html' - type: 'promotion' name: 'Mei Mei' link: 'http://lists.opnfv.org/pipermail/opnfv-tsc/2016-March/002228.html' - type: 'removal' name: 'Peter Banzi' link: '' - type: 'promotion' name: 'Trevor Bramwell' link: 'http://lists.opnfv.org/pipermail/opnfv-tech-discuss/2016-July/011659.html' - type: 'promotion' name: 'Serena Feng' link: '' - type: 'promotion' name: 'Yolanda Robla Mota' link: '' - type: 'promotion' name: 'Markos' link: '' - type: 'promotion' name: 'Luke Hinds' link: '' - type: 'promotion' name: 'Alexandru Avadanii' link: 'https://gerrit.opnfv.org/gerrit/#/c/64499/'