|
Packit Service |
d40955 |
/*
|
|
Packit Service |
d40955 |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
d40955 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
d40955 |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
d40955 |
* of the License, or (at your option) any later version.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
d40955 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
d40955 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
d40955 |
* GNU General Public License for more details.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
d40955 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
d40955 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
d40955 |
* 02110-1301, USA.
|
|
Packit Service |
d40955 |
*
|
|
Packit Service |
d40955 |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/kernel/workQueueHandle.c#2 $
|
|
Packit Service |
d40955 |
*/
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#include "workQueueHandle.h"
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
WorkQueueStackHandleGlobals workQueueStackHandleGlobals;
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**********************************************************************/
|
|
Packit Service |
d40955 |
void initializeWorkQueueStackHandle(WorkQueueStackHandle *handle,
|
|
Packit Service |
d40955 |
SimpleWorkQueue *queue)
|
|
Packit Service |
d40955 |
{
|
|
Packit Service |
d40955 |
handle->nonce = workQueueStackHandleGlobals.nonce;
|
|
Packit Service |
d40955 |
handle->queue = queue;
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
long offset = (char *) handle - (char *) task_stack_page(current);
|
|
Packit Service |
d40955 |
spin_lock(&workQueueStackHandleGlobals.offsetLock);
|
|
Packit Service |
d40955 |
if (workQueueStackHandleGlobals.offset == 0) {
|
|
Packit Service |
d40955 |
workQueueStackHandleGlobals.offset = offset;
|
|
Packit Service |
d40955 |
spin_unlock(&workQueueStackHandleGlobals.offsetLock);
|
|
Packit Service |
d40955 |
} else {
|
|
Packit Service |
d40955 |
long foundOffset = workQueueStackHandleGlobals.offset;
|
|
Packit Service |
d40955 |
spin_unlock(&workQueueStackHandleGlobals.offsetLock);
|
|
Packit Service |
d40955 |
BUG_ON(foundOffset != offset);
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**********************************************************************/
|
|
Packit Service |
d40955 |
void initWorkQueueStackHandleOnce(void)
|
|
Packit Service |
d40955 |
{
|
|
Packit Service |
d40955 |
spin_lock_init(&workQueueStackHandleGlobals.offsetLock);
|
|
Packit Service |
d40955 |
workQueueStackHandleGlobals.nonce = currentTime(CLOCK_MONOTONIC);
|
|
Packit Service |
d40955 |
}
|