mem-cache, configs, arch-arm: Handle partitioning policies through a PartitionManager (#966)

This PR is offloading some of the partitioning logic to the partitioning
manager, effectively changing
the partitioning interface. Rather than always relying on the
PartitionFieldExtention data structure to
convey partition IDs, we make it implementation defined by introducing
the partitioning manager abstraction.
We want user to be able to extract the partitionId more flexibly and
this requires using a SimObject.

Users can extend the PartitioningManager, overriding the
readPacketPartitionId, therefore providing their
own mean of injecting/extracting partitioning data from a packet
This commit is contained in:
Bobby R. Bruce
2024-04-08 16:05:17 -07:00
committed by GitHub
24 changed files with 438 additions and 90 deletions

View File

@@ -93,6 +93,7 @@ Source('fs_workload.cc', tags='arm isa')
Source('regs/int.cc', tags='arm isa')
Source('regs/misc.cc', tags='arm isa')
Source('mmu.cc', tags='arm isa')
Source('mpam.cc', tags='arm isa')
Source('nativetrace.cc', tags='arm isa')
Source('pagetable.cc', tags='arm isa')
Source('pauth_helpers.cc', tags='arm isa')

View File

@@ -35,55 +35,39 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "partition_fields_extension.hh"
#include "arch/arm/mpam.hh"
namespace gem5
{
namespace partitioning_policy
namespace gem5::ArmISA::mpam
{
std::unique_ptr<ExtensionBase>
PartitionFieldExtention::clone() const
PartitionFieldExtension::clone() const
{
return std::make_unique<PartitionFieldExtention>(*this);
return std::make_unique<PartitionFieldExtension>(*this);
}
uint64_t
PartitionFieldExtention::getPartitionID() const
PartitionFieldExtension::getPartitionID() const
{
return this->_partitionID;
}
uint64_t
PartitionFieldExtention::getPartitionMonitoringID() const
PartitionFieldExtension::getPartitionMonitoringID() const
{
return this->_partitionMonitoringID;
}
void
PartitionFieldExtention::setPartitionID(uint64_t id)
PartitionFieldExtension::setPartitionID(uint64_t id)
{
this->_partitionID = id;
}
void
PartitionFieldExtention::setPartitionMonitoringID(uint64_t id)
PartitionFieldExtension::setPartitionMonitoringID(uint64_t id)
{
this->_partitionMonitoringID = id;
}
uint64_t
readPacketPartitionID (PacketPtr pkt)
{
// get partition_id from PartitionFieldExtention
std::shared_ptr<PartitionFieldExtention> ext =
pkt->req->getExtension<PartitionFieldExtention>();
// use default value if extension is not set
return (ext != nullptr) ? ext->getPartitionID() : DEFAULT_PARTITION_ID;
}
} // namespace partitioning_policy
} // namespace gem5
} // namespace gem5::ArmISA::mpam

View File

@@ -35,28 +35,25 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __MEM_CACHE_TAGS_PARTITIONING_POLICIES_FIELD_EXTENTION_HH__
#define __MEM_CACHE_TAGS_PARTITIONING_POLICIES_FIELD_EXTENTION_HH__
#ifndef __ARCH_ARM_MPAM_HH__
#define __ARCH_ARM_MPAM_HH__
#include "base/extensible.hh"
#include "mem/packet.hh"
#include "mem/request.hh"
namespace gem5
{
namespace partitioning_policy
namespace gem5::ArmISA::mpam
{
const uint64_t DEFAULT_PARTITION_ID = 0;
const uint64_t DEFAULT_PARTITION_MONITORING_ID = 0;
class PartitionFieldExtention : public Extension<Request,
PartitionFieldExtention>
class PartitionFieldExtension : public Extension<Request,
PartitionFieldExtension>
{
public:
std::unique_ptr<ExtensionBase> clone() const override;
PartitionFieldExtention() = default;
PartitionFieldExtension() = default;
/**
* _partitionID getter
@@ -87,16 +84,6 @@ class PartitionFieldExtention : public Extension<Request,
uint64_t _partitionMonitoringID = DEFAULT_PARTITION_MONITORING_ID;
};
/**
* Helper function to retrieve PartitionID from a packet; Returns packet
* PartitionID if available or DEFAULT_PARTITION_ID if extention is not set
* @param pkt pointer to packet (PacketPtr)
* @return packet PartitionID.
*/
uint64_t readPacketPartitionID (PacketPtr pkt);
} // namespace gem5::ArmISA::mpam
} // namespace partitioning_policy
} // namespace gem5
#endif // __MEM_CACHE_TAGS_PARTITIONING_POLICIES_FIELD_EXTENTION_HH__
#endif // __ARCH_ARM_MPAM_HH__

43
src/dev/arm/Mpam.py Normal file
View File

@@ -0,0 +1,43 @@
# Copyright (c) 2024 Arm Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
# not be construed as granting a license to any other intellectual
# property including but not limited to intellectual property relating
# to a hardware implementation of the functionality of the software
# licensed hereunder. You may use the software subject to the license
# terms below provided that you ensure that this notice is replicated
# unmodified and in its entirety in all distributions of the software,
# modified or unmodified, in source code or in binary form.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer;
# redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution;
# neither the name of the copyright holders nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from m5.objects.PartitioningPolicies import PartitionManager
class MpamMSC(PartitionManager):
type = "MpamMSC"
abstract = True
cxx_header = "dev/arm/mpam.hh"
cxx_class = "gem5::mpam::MSC"

View File

@@ -49,6 +49,7 @@ SimObject('Gic.py', sim_objects=[
'BaseGic', 'ArmInterruptPin', 'ArmSPI', 'ArmPPI', 'ArmSigInterruptPin',
'GicV2', 'Gicv2mFrame', 'Gicv2m', 'VGic', 'Gicv3Its', 'Gicv3'],
enums=['ArmInterruptType'], tags='arm isa')
SimObject('Mpam.py', sim_objects=['MpamMSC'], tags='arm isa')
SimObject('RealView.py', sim_objects=[
'AmbaPioDevice', 'AmbaIntDevice', 'AmbaDmaDevice', 'A9SCU',
'GenericArmPciHost', 'RealViewCtrl', 'RealViewOsc',
@@ -80,6 +81,7 @@ Source('gic_v3_cpu_interface.cc', tags='arm isa')
Source('gic_v3_distributor.cc', tags='arm isa')
Source('gic_v3_redistributor.cc', tags='arm isa')
Source('gic_v3_its.cc', tags='arm isa')
Source('mpam.cc', tags='arm isa')
Source('pl011.cc', tags='arm isa')
Source('pl111.cc', tags='arm isa')
Source('hdlcd.cc', tags='arm isa')

54
src/dev/arm/mpam.cc Normal file
View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2024 Arm Limited
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
* not be construed as granting a license to any other intellectual
* property including but not limited to intellectual property relating
* to a hardware implementation of the functionality of the software
* licensed hereunder. You may use the software subject to the license
* terms below provided that you ensure that this notice is replicated
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "arch/arm/mpam.hh"
#include "dev/arm/mpam.hh"
namespace gem5::mpam
{
uint64_t
MSC::readPacketPartitionID(PacketPtr pkt) const
{
// get partition_id from PartitionFieldExtension
auto ext = pkt->req->getExtension<ArmISA::mpam::PartitionFieldExtension>();
// use default value if extension is not set
return (ext != nullptr) ? ext->getPartitionID() :
ArmISA::mpam::DEFAULT_PARTITION_ID;
}
} // namespace gem5::mpam

67
src/dev/arm/mpam.hh Normal file
View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2024 Arm Limited
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
* not be construed as granting a license to any other intellectual
* property including but not limited to intellectual property relating
* to a hardware implementation of the functionality of the software
* licensed hereunder. You may use the software subject to the license
* terms below provided that you ensure that this notice is replicated
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DEV_ARM_MPAM_HH__
#define __DEV_ARM_MPAM_HH__
#include "mem/cache/tags/partitioning_policies/partition_manager.hh"
namespace gem5::mpam
{
/**
* This class implements a simple MPAM Memory System Component (MSC)
* partitioning controller. For further info refer to:
* https://developer.arm.com/documentation/ddi0598/latest/
*/
class MSC : public partitioning_policy::PartitionManager
{
public:
using partitioning_policy::PartitionManager::PartitionManager;
/**
* Helper function to retrieve PartitionID from a packet; Returns packet
* PartitionID if available or DEFAULT_PARTITION_ID if extention is not set
* @param pkt pointer to packet (PacketPtr)
* @return packet PartitionID.
*/
uint64_t readPacketPartitionID(PacketPtr pkt) const override;
};
} // namespace gem5::mpam
#endif // __DEV_ARM_MPAM_HH__

View File

@@ -111,11 +111,8 @@ class BaseCache(ClockedObject):
replacement_policy = Param.BaseReplacementPolicy(
LRURP(), "Replacement policy"
)
partitioning_policies = VectorParam.BasePartitioningPolicy(
[],
"Partitioning policies "
"Setting multiple policies will enforce all of them individually "
"in order",
partitioning_manager = Param.PartitionManager(
NULL, "Cache partitioning manager"
)
compressor = Param.BaseCacheCompressor(NULL, "Cache compressor.")

View File

@@ -58,7 +58,7 @@
#include "mem/cache/prefetch/base.hh"
#include "mem/cache/queue_entry.hh"
#include "mem/cache/tags/compressed_tags.hh"
#include "mem/cache/tags/partitioning_policies/partition_fields_extension.hh"
#include "mem/cache/tags/partitioning_policies/partition_manager.hh"
#include "mem/cache/tags/super_blk.hh"
#include "params/BaseCache.hh"
#include "params/WriteAllocator.hh"
@@ -87,6 +87,7 @@ BaseCache::BaseCache(const BaseCacheParams &p, unsigned blk_size)
writeBuffer("write buffer", p.write_buffers, p.mshrs, p.name),
tags(p.tags),
compressor(p.compressor),
partitionManager(p.partitioning_manager),
prefetcher(p.prefetcher),
writeAllocator(p.write_allocator),
writebackClean(p.writeback_clean),
@@ -1642,7 +1643,8 @@ BaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks)
}
// get partitionId from Packet
const auto partition_id = partitioning_policy::readPacketPartitionID(pkt);
const auto partition_id = partitionManager ?
partitionManager->readPacketPartitionID(pkt) : 0;
// Find replacement victim
std::vector<CacheBlk*> evict_blks;
CacheBlk *victim = tags->findVictim(addr, is_secure, blk_size_bits,

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2013, 2015-2016, 2018-2019, 2023 ARM Limited
* Copyright (c) 2012-2013, 2015-2016, 2018-2019, 2023-2024 Arm Limited
* All rights reserved.
*
* The license below extends only to copyright in the software and shall
@@ -84,6 +84,10 @@ namespace prefetch
{
class Base;
}
namespace partitioning_policy
{
class PartitionManager;
}
class MSHR;
class RequestPort;
class QueueEntry;
@@ -351,6 +355,9 @@ class BaseCache : public ClockedObject
/** Compression method being used. */
compression::Base* compressor;
/** Partitioning manager */
partitioning_policy::PartitionManager* partitionManager;
/** Prefetcher */
prefetch::Base *prefetcher;

View File

@@ -75,8 +75,8 @@ class BaseTags(ClockedObject):
SetAssociative(), "Indexing policy"
)
partitioning_policies = VectorParam.BasePartitioningPolicy(
Parent.partitioning_policies, "Partitioning policies"
partitioning_manager = Param.PartitionManager(
Parent.partitioning_manager, "Cache partitioning manager"
)
# Set the indexing entry size as the block size

View File

@@ -50,7 +50,7 @@
#include "base/types.hh"
#include "mem/cache/replacement_policies/replaceable_entry.hh"
#include "mem/cache/tags/indexing_policies/base.hh"
#include "mem/cache/tags/partitioning_policies/partition_fields_extension.hh"
#include "mem/cache/tags/partitioning_policies/partition_manager.hh"
#include "mem/request.hh"
#include "sim/core.hh"
#include "sim/sim_exit.hh"
@@ -63,7 +63,7 @@ BaseTags::BaseTags(const Params &p)
: ClockedObject(p), blkSize(p.block_size), blkMask(blkSize - 1),
size(p.size), lookupLatency(p.tag_latency),
system(p.system), indexingPolicy(p.indexing_policy),
partitioningPolicies(p.partitioning_policies),
partitionManager(p.partitioning_manager),
warmupBound((p.warmup_percentage/100.0) * (p.size / p.block_size)),
warmedUp(false), numBlocks(p.size / p.block_size),
dataBlks(new uint8_t[p.size]), // Allocate data storage in one big chunk
@@ -114,7 +114,8 @@ BaseTags::insertBlock(const PacketPtr pkt, CacheBlk *blk)
stats.occupancies[requestor_id]++;
// Insert block with tag, src requestor id, task id and PartitionId
const auto partition_id = partitioning_policy::readPacketPartitionID(pkt);
const auto partition_id = partitionManager ?
partitionManager->readPacketPartitionID(pkt) : 0;
blk->insert(extractTag(pkt->getAddr()), pkt->isSecure(), requestor_id,
pkt->req->taskId(), partition_id);

View File

@@ -56,7 +56,6 @@
#include "base/statistics.hh"
#include "base/types.hh"
#include "mem/cache/cache_blk.hh"
#include "mem/cache/tags/partitioning_policies/base_pp.hh"
#include "mem/packet.hh"
#include "params/BaseTags.hh"
#include "sim/clocked_object.hh"
@@ -89,9 +88,8 @@ class BaseTags : public ClockedObject
/** Indexing policy */
BaseIndexingPolicy *indexingPolicy;
/** Partitioning policies */
std::vector<partitioning_policy::BasePartitioningPolicy *>
partitioningPolicies;
/** Partitioning manager */
partitioning_policy::PartitionManager *partitionManager;
/**
* The number of tags that need to be touched to meet the warmup

View File

@@ -89,8 +89,9 @@ void
BaseSetAssoc::invalidate(CacheBlk *blk)
{
// Notify partitioning policies of release of ownership
for (auto partitioning_policy : partitioningPolicies)
partitioning_policy->notifyRelease(blk->getPartitionId());
if (partitionManager) {
partitionManager->notifyRelease(blk->getPartitionId());
}
BaseTags::invalidate(blk);

View File

@@ -59,7 +59,7 @@
#include "mem/cache/replacement_policies/replaceable_entry.hh"
#include "mem/cache/tags/base.hh"
#include "mem/cache/tags/indexing_policies/base.hh"
#include "mem/cache/tags/partitioning_policies/partition_fields_extension.hh"
#include "mem/cache/tags/partitioning_policies/partition_manager.hh"
#include "mem/packet.hh"
#include "params/BaseSetAssoc.hh"
@@ -177,8 +177,9 @@ class BaseSetAssoc : public BaseTags
indexingPolicy->getPossibleEntries(addr);
// Filter entries based on PartitionID
for (auto partitioning_policy : partitioningPolicies)
partitioning_policy->filterByPartition(entries, partition_id);
if (partitionManager) {
partitionManager->filterByPartition(entries, partition_id);
}
// Choose replacement victim from replacement candidates
CacheBlk* victim = entries.empty() ? nullptr :
@@ -204,12 +205,9 @@ class BaseSetAssoc : public BaseTags
// Increment tag counter
stats.tagsInUse++;
// Notify partitioning policies of acquisition of ownership
for (auto & partitioning_policy : partitioningPolicies) {
// get partitionId from Packet
const auto partitionId =
partitioning_policy::readPacketPartitionID(pkt);
partitioning_policy->notifyAcquire(partitionId);
if (partitionManager) {
auto partition_id = partitionManager->readPacketPartitionID(pkt);
partitionManager->notifyAcquire(partition_id);
}
// Update replacement policy

View File

@@ -50,6 +50,7 @@
#include "mem/cache/replacement_policies/base.hh"
#include "mem/cache/replacement_policies/replaceable_entry.hh"
#include "mem/cache/tags/indexing_policies/base.hh"
#include "mem/cache/tags/partitioning_policies/partition_manager.hh"
#include "mem/packet.hh"
#include "params/CompressedTags.hh"
@@ -124,8 +125,8 @@ CompressedTags::findVictim(Addr addr, const bool is_secure,
indexingPolicy->getPossibleEntries(addr);
// Filter entries based on PartitionID
for (auto partitioning_policy : partitioningPolicies){
partitioning_policy->filterByPartition(superblock_entries,
if (partitionManager){
partitionManager->filterByPartition(superblock_entries,
partition_id);
}

View File

@@ -75,7 +75,7 @@ FALRU::FALRU(const Params &p)
blkSize);
if (!isPowerOf2(size))
fatal("Cache Size must be power of 2 for now");
if (this->partitioningPolicies.size() != 0)
if (partitionManager)
fatal("Cannot use Cache Partitioning Policies with FALRU");
blks = new FALRUBlk[numBlocks];

View File

@@ -1,5 +1,14 @@
# Copyright (c) 2024 ARM Limited
# All rights reserved.
# Copyright (c) 2024 Arm Limited
# All rights reserved
#
# The license below extends only to copyright in the software and shall
# not be construed as granting a license to any other intellectual
# property including but not limited to intellectual property relating
# to a hardware implementation of the functionality of the software
# licensed hereunder. You may use the software subject to the license
# terms below provided that you ensure that this notice is replicated
# unmodified and in its entirety in all distributions of the software,
# modified or unmodified, in source code or in binary form.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -32,6 +41,19 @@ from m5.proxy import Parent
from m5.SimObject import SimObject
class PartitionManager(SimObject):
type = "PartitionManager"
cxx_header = "mem/cache/tags/partitioning_policies/partition_manager.hh"
cxx_class = "gem5::partitioning_policy::PartitionManager"
partitioning_policies = VectorParam.BasePartitioningPolicy(
[],
"Partitioning policies "
"Setting multiple policies will enforce all of them individually "
"in order",
)
class BasePartitioningPolicy(SimObject):
type = "BasePartitioningPolicy"
cxx_header = "mem/cache/tags/partitioning_policies/base_pp.hh"

View File

@@ -38,6 +38,7 @@
Import('*')
SimObject('PartitioningPolicies.py', sim_objects=[
'PartitionManager',
'BasePartitioningPolicy',
'MaxCapacityPartitioningPolicy',
'WayPolicyAllocation',
@@ -48,4 +49,4 @@ Source('base_pp.cc')
Source('max_capacity_pp.cc')
Source('way_allocation.cc')
Source('way_pp.cc')
Source('partition_fields_extension.cc')
Source('partition_manager.cc')

View File

@@ -54,12 +54,11 @@ namespace partitioning_policy
/**
* A Partitioning Policy is a cache partitioning mechanism that limits the
* cache block allocations in a cache based on a PartitionID identifier. This
* identifier may be set to any upstream memory request by attaching a
* PartitionFieldExtention to it as so:
* identifier may be set to any upstream memory request by attaching the
* PartitionID to it. The way the partition ID is attached/extracted
* from the request depends on the partitioning manager.
*
* std::shared_ptr<PartitionFieldExtention> ext(PartitionFieldExtention);
* ext->setPartitionID(PartitionID);
* req->setExtension(ext);
* See the use of the PartitionFieldExtension in Arm as an example.
*
* When partitioning policies are in place, the allocatable cache blocks for
* this memory request will be filtered based on its PartitionID.

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 2024 Arm Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* not be construed as granting a license to any other intellectual
* property including but not limited to intellectual property relating
* to a hardware implementation of the functionality of the software
* licensed hereunder. You may use the software subject to the license
* terms below provided that you ensure that this notice is replicated
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "mem/cache/tags/partitioning_policies/partition_manager.hh"
#include "mem/cache/tags/partitioning_policies/base_pp.hh"
namespace gem5
{
namespace partitioning_policy
{
PartitionManager::PartitionManager(const Params &p)
: SimObject(p),
partitioningPolicies(p.partitioning_policies)
{}
void
PartitionManager::notifyAcquire(uint64_t partition_id)
{
// Notify partitioning policies of acquisition of ownership
for (auto & partitioning_policy : partitioningPolicies) {
// get partitionId from Packet
partitioning_policy->notifyAcquire(partition_id);
}
}
void
PartitionManager::notifyRelease(uint64_t partition_id)
{
// Notify partitioning policies of release of ownership
for (auto partitioning_policy : partitioningPolicies) {
partitioning_policy->notifyRelease(partition_id);
}
}
void
PartitionManager::filterByPartition(
std::vector<ReplaceableEntry *> &entries,
const uint64_t partition_id) const
{
// Filter entries based on PartitionID
for (auto partitioning_policy : partitioningPolicies) {
partitioning_policy->filterByPartition(entries, partition_id);
}
}
} // namespace partitioning_policy
} // namespace gem5

View File

@@ -0,0 +1,95 @@
/*
* Copyright (c) 2024 Arm Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* not be construed as granting a license to any other intellectual
* property including but not limited to intellectual property relating
* to a hardware implementation of the functionality of the software
* licensed hereunder. You may use the software subject to the license
* terms below provided that you ensure that this notice is replicated
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __MEM_CACHE_TAGS_PARTITIONING_MANAGER_HH__
#define __MEM_CACHE_TAGS_PARTITIONING_MANAGER_HH__
#include "mem/packet.hh"
#include "params/PartitionManager.hh"
#include "sim/sim_object.hh"
namespace gem5
{
class ReplaceableEntry;
namespace partitioning_policy
{
class BasePartitioningPolicy;
class PartitionManager : public SimObject
{
public:
PARAMS(PartitionManager);
PartitionManager(const Params &p);
/**
* PartitionManager interface to retrieve PartitionID from a packet;
* This base implementation returns zero by default.
*
* @param pkt pointer to packet (PacketPtr)
* @return packet PartitionID.
*/
virtual uint64_t
readPacketPartitionID(PacketPtr pkt) const
{
return 0;
};
/**
* Notify of acquisition of ownership of a cache line
* @param partition_id PartitionID of the upstream memory request
*/
void notifyAcquire(uint64_t partition_id);
void notifyRelease(uint64_t partition_id);
void filterByPartition(std::vector<ReplaceableEntry *> &entries,
const uint64_t partition_id) const;
protected:
/** Partitioning policies */
std::vector<partitioning_policy::BasePartitioningPolicy *>
partitioningPolicies;
};
} // namespace partitioning_policy
} // namespace gem5
#endif // __MEM_CACHE_TAGS_PARTITIONING_MANAGER_HH__

View File

@@ -55,6 +55,7 @@
#include "mem/cache/replacement_policies/base.hh"
#include "mem/cache/replacement_policies/replaceable_entry.hh"
#include "mem/cache/tags/indexing_policies/base.hh"
#include "mem/cache/tags/partitioning_policies/partition_manager.hh"
namespace gem5
{
@@ -76,7 +77,7 @@ SectorTags::SectorTags(const SectorTagsParams &p)
"Block size must be at least 4 and a power of 2");
fatal_if(!isPowerOf2(numBlocksPerSector),
"# of blocks per sector must be non-zero and a power of 2");
warn_if((p.partitioning_policies.size() > 0),
warn_if(partitionManager,
"Using cache partitioning policies with sector and/or compressed "
"tags is not fully tested.");
}
@@ -296,8 +297,8 @@ SectorTags::findVictim(Addr addr, const bool is_secure, const std::size_t size,
indexingPolicy->getPossibleEntries(addr);
// Filter entries based on PartitionID
for (auto partitioning_policy : partitioningPolicies)
partitioning_policy->filterByPartition(sector_entries, partition_id);
if (partitionManager)
partitionManager->filterByPartition(sector_entries, partition_id);
// Check if the sector this address belongs to has been allocated
Addr tag = extractTag(addr);