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