Blame vdo/kernel/workQueueHandle.c

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