mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-04 16:25:34 +00:00

When a resource group is pseudo-locked it is orphaned without a class of service associated with it. We thus do not want any monitoring in progress on a resource group that will be used for pseudo-locking. Introduce a test that can be used to determine if pseudo-locking in progress on a resource group. Temporarily mark it as unused to avoid compile warnings until it is used. Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: fenghua.yu@intel.com Cc: tony.luck@intel.com Cc: vikas.shivappa@linux.intel.com Cc: gavin.hindman@intel.com Cc: jithu.joseph@intel.com Cc: dave.hansen@intel.com Cc: hpa@zytor.com Link: https://lkml.kernel.org/r/14fd9494f87ca72a213b3a197d1172d4e66ae196.1529706536.git.reinette.chatre@intel.com
126 lines
3.1 KiB
C
126 lines
3.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Resource Director Technology (RDT)
|
|
*
|
|
* Pseudo-locking support built on top of Cache Allocation Technology (CAT)
|
|
*
|
|
* Copyright (C) 2018 Intel Corporation
|
|
*
|
|
* Author: Reinette Chatre <reinette.chatre@intel.com>
|
|
*/
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
#include "intel_rdt.h"
|
|
|
|
/**
|
|
* rdtgroup_monitor_in_progress - Test if monitoring in progress
|
|
* @r: resource group being queried
|
|
*
|
|
* Return: 1 if monitor groups have been created for this resource
|
|
* group, 0 otherwise.
|
|
*/
|
|
static int __attribute__ ((unused))
|
|
rdtgroup_monitor_in_progress(struct rdtgroup *rdtgrp)
|
|
{
|
|
return !list_empty(&rdtgrp->mon.crdtgrp_list);
|
|
}
|
|
|
|
/**
|
|
* rdtgroup_locksetup_user_restrict - Restrict user access to group
|
|
* @rdtgrp: resource group needing access restricted
|
|
*
|
|
* A resource group used for cache pseudo-locking cannot have cpus or tasks
|
|
* assigned to it. This is communicated to the user by restricting access
|
|
* to all the files that can be used to make such changes.
|
|
*
|
|
* Permissions restored with rdtgroup_locksetup_user_restore()
|
|
*
|
|
* Return: 0 on success, <0 on failure. If a failure occurs during the
|
|
* restriction of access an attempt will be made to restore permissions but
|
|
* the state of the mode of these files will be uncertain when a failure
|
|
* occurs.
|
|
*/
|
|
static int __attribute__ ((unused))
|
|
rdtgroup_locksetup_user_restrict(struct rdtgroup *rdtgrp)
|
|
{
|
|
int ret;
|
|
|
|
ret = rdtgroup_kn_mode_restrict(rdtgrp, "tasks");
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = rdtgroup_kn_mode_restrict(rdtgrp, "cpus");
|
|
if (ret)
|
|
goto err_tasks;
|
|
|
|
ret = rdtgroup_kn_mode_restrict(rdtgrp, "cpus_list");
|
|
if (ret)
|
|
goto err_cpus;
|
|
|
|
if (rdt_mon_capable) {
|
|
ret = rdtgroup_kn_mode_restrict(rdtgrp, "mon_groups");
|
|
if (ret)
|
|
goto err_cpus_list;
|
|
}
|
|
|
|
ret = 0;
|
|
goto out;
|
|
|
|
err_cpus_list:
|
|
rdtgroup_kn_mode_restore(rdtgrp, "cpus_list");
|
|
err_cpus:
|
|
rdtgroup_kn_mode_restore(rdtgrp, "cpus");
|
|
err_tasks:
|
|
rdtgroup_kn_mode_restore(rdtgrp, "tasks");
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* rdtgroup_locksetup_user_restore - Restore user access to group
|
|
* @rdtgrp: resource group needing access restored
|
|
*
|
|
* Restore all file access previously removed using
|
|
* rdtgroup_locksetup_user_restrict()
|
|
*
|
|
* Return: 0 on success, <0 on failure. If a failure occurs during the
|
|
* restoration of access an attempt will be made to restrict permissions
|
|
* again but the state of the mode of these files will be uncertain when
|
|
* a failure occurs.
|
|
*/
|
|
static int __attribute__ ((unused))
|
|
rdtgroup_locksetup_user_restore(struct rdtgroup *rdtgrp)
|
|
{
|
|
int ret;
|
|
|
|
ret = rdtgroup_kn_mode_restore(rdtgrp, "tasks");
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = rdtgroup_kn_mode_restore(rdtgrp, "cpus");
|
|
if (ret)
|
|
goto err_tasks;
|
|
|
|
ret = rdtgroup_kn_mode_restore(rdtgrp, "cpus_list");
|
|
if (ret)
|
|
goto err_cpus;
|
|
|
|
if (rdt_mon_capable) {
|
|
ret = rdtgroup_kn_mode_restore(rdtgrp, "mon_groups");
|
|
if (ret)
|
|
goto err_cpus_list;
|
|
}
|
|
|
|
ret = 0;
|
|
goto out;
|
|
|
|
err_cpus_list:
|
|
rdtgroup_kn_mode_restrict(rdtgrp, "cpus_list");
|
|
err_cpus:
|
|
rdtgroup_kn_mode_restrict(rdtgrp, "cpus");
|
|
err_tasks:
|
|
rdtgroup_kn_mode_restrict(rdtgrp, "tasks");
|
|
out:
|
|
return ret;
|
|
}
|