├── .gitignore ├── rpm └── README ├── .travis.yml ├── LICENSE ├── examples ├── perl │ ├── README │ ├── hello_world.pl │ └── Makefile └── c │ ├── CMT_MBM │ ├── README │ └── Makefile │ ├── CAT │ ├── README │ └── Makefile │ └── PSEUDO_LOCK │ ├── tsc.c │ ├── dlock.h │ ├── Makefile │ └── README ├── lib ├── perl │ ├── MANIFEST │ ├── README │ └── Makefile.PL ├── api.h ├── utils.h ├── types.h ├── README ├── cpuinfo.h ├── cap.h ├── perf.h ├── perf_monitoring.h ├── machine.h ├── perf.c ├── resctrl.h ├── log.h ├── log.c ├── resctrl_monitoring.h └── os_monitoring.h ├── pqos ├── configs │ ├── alloc_reset_cat.cfg │ ├── alloc_select_clos.cfg │ ├── alloc_show_verbose.cfg │ ├── mon_llc_core_text.cfg │ ├── mon_mbl_core_text.cfg │ ├── alloc_set_clos_11LLC_ways.cfg │ ├── alloc_set_clos_12LLC_ways.cfg │ ├── alloc_config_cdp.cfg │ ├── alloc_set_clos_20LLC_ways.cfg │ ├── mon_llc_pid_text.cfg │ ├── mon_mbr_core_interval.cfg │ ├── alloc_set_clos_11LLC_ways_cdp.cfg │ ├── alloc_set_clos_12LLC_ways_cdp.cfg │ ├── alloc_set_clos_20LLC_ways_cdp.cfg │ ├── alloc_set_core_assoc.cfg │ ├── mon_llc_core_xml_file.cfg │ ├── mon_llc_pid_xml_file.cfg │ └── README ├── pqos-msr ├── pqos-os ├── cap.h ├── profiles.h ├── alloc.h ├── monitor.h ├── main.h ├── Makefile └── README ├── rdtset ├── cpu.h ├── cpu.c ├── rdt.h ├── Makefile └── rdtset.8 ├── Makefile ├── snmp ├── Makefile └── README └── INSTALL /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | *.a 4 | *.xml 5 | *.log 6 | *.d 7 | pqos/pqos 8 | rdtset/rdtset 9 | -------------------------------------------------------------------------------- /rpm/README: -------------------------------------------------------------------------------- 1 | To build a RPM using our spec file please follow the instructions outlined on the following wiki: 2 | https://github.com/01org/intel-cmt-cat/wiki/FAQ#how-do-i-build-and-install-from-a-rpm-spec-file 3 | 4 | 5 | Public location of our Fedora RPMs: 6 | https://admin.fedoraproject.org/pkgdb/package/rpms/intel-cmt-cat/ 7 | 8 | 9 | Other locations of where to find our RPMs: 10 | https://www.rpmfind.net/ (Search for "intel-cmt-cat") 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | before_script: 4 | - sudo apt-get -q update 5 | - sudo apt-get install -y swig cppcheck wget 6 | - wget -P /tmp/ https://raw.githubusercontent.com/torvalds/linux/879be4f378cb412af3a3fe107d35835c99099add/scripts/checkpatch.pl && chmod a+x /tmp/checkpatch.pl 7 | - wget -P /tmp/ https://raw.githubusercontent.com/torvalds/linux/879be4f378cb412af3a3fe107d35835c99099add/scripts/spelling.txt 8 | script: make cppcheck && make style CHECKPATCH=/tmp/checkpatch.pl && make && sudo make install && (cd lib/perl && perl Makefile.PL && make && sudo make install) 9 | language: c 10 | compiler: 11 | - gcc 12 | # - clang 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD LICENSE 2 | 3 | Copyright(c) 2014-2016 Intel Corporation. All rights reserved. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in 14 | the documentation and/or other materials provided with the 15 | distribution. 16 | * Neither the name of Intel Corporation nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /examples/perl/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | ======================================================================== 4 | README for hello_world.pl Perl script 5 | 6 | April 2016 7 | ======================================================================== 8 | 9 | 10 | Contents 11 | ======== 12 | 13 | - Overview 14 | - Requirements 15 | - Usage 16 | - Legal Disclaimer 17 | 18 | 19 | Overview 20 | ======== 21 | 22 | hello_world.pl is a simple Perl script to demonstrate the use of the 23 | PQoS/Intel(R) RDT library Perl wrapper API. This script shows how to 24 | initialize the library, read COS bitmasks and associations and shutdown 25 | the library. 26 | 27 | Requirements 28 | ============ 29 | 30 | Tested with SWIG Version 3.0.5 and Perl v5.18.4. 31 | 32 | The hello_world.pl script depends on the pqos.pm Perl module generated 33 | by SWIG. For more information about this module and how to build it, 34 | please refer to the README found in the "lib/perl" directory. 35 | 36 | Usage 37 | ===== 38 | 39 | To run the hello_world.pl script: 40 | "sudo ./hello_world.pl" 41 | 42 | Legal Disclaimer 43 | ================ 44 | 45 | THIS SOFTWARE IS PROVIDED BY INTEL"AS IS". NO LICENSE, EXPRESS OR 46 | IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS 47 | ARE GRANTED THROUGH USE. EXCEPT AS PROVIDED IN INTEL'S TERMS AND 48 | CONDITIONS OF SALE, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL 49 | DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR 50 | USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO 51 | FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT 52 | OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. -------------------------------------------------------------------------------- /lib/perl/MANIFEST: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # MANIFEST for PQoS library SWIG Perl interface 3 | # 4 | # @par 5 | # BSD LICENSE 6 | # 7 | # Copyright(c) 2016 Intel Corporation. All rights reserved. 8 | # All rights reserved. 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions 12 | # are met: 13 | # 14 | # * Redistributions of source code must retain the above copyright 15 | # notice, this list of conditions and the following disclaimer. 16 | # * Redistributions in binary form must reproduce the above copyright 17 | # notice, this list of conditions and the following disclaimer in 18 | # the documentation and/or other materials provided with the 19 | # distribution. 20 | # * Neither the name of Intel Corporation nor the names of its 21 | # contributors may be used to endorse or promote products derived 22 | # from this software without specific prior written permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | ############################################################################### 36 | 37 | Makefile.PL 38 | MANIFEST 39 | pqos.i 40 | README 41 | test.pl 42 | -------------------------------------------------------------------------------- /pqos/configs/alloc_reset_cat.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Resets CAT class(es) of service to default values 5 | # 6 | # @par 7 | # BSD LICENSE 8 | # 9 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 10 | # All rights reserved. 11 | # 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions 14 | # are met: 15 | # 16 | # * Redistributions of source code must retain the above copyright 17 | # notice, this list of conditions and the following disclaimer. 18 | # * Redistributions in binary form must reproduce the above copyright 19 | # notice, this list of conditions and the following disclaimer in 20 | # the documentation and/or other materials provided with the 21 | # distribution. 22 | # * Neither the name of Intel Corporation nor the names of its 23 | # contributors may be used to endorse or promote products derived 24 | # from this software without specific prior written permission. 25 | # 26 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 37 | # 38 | ################################################################################ 39 | 40 | # Reset CAT 41 | reset-cat: 42 | -------------------------------------------------------------------------------- /pqos/configs/alloc_select_clos.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets CAT class(es) of service from profile 5 | # 6 | # @par 7 | # BSD LICENSE 8 | # 9 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 10 | # All rights reserved. 11 | # 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions 14 | # are met: 15 | # 16 | # * Redistributions of source code must retain the above copyright 17 | # notice, this list of conditions and the following disclaimer. 18 | # * Redistributions in binary form must reproduce the above copyright 19 | # notice, this list of conditions and the following disclaimer in 20 | # the documentation and/or other materials provided with the 21 | # distribution. 22 | # * Neither the name of Intel Corporation nor the names of its 23 | # contributors may be used to endorse or promote products derived 24 | # from this software without specific prior written permission. 25 | # 26 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 37 | # 38 | ################################################################################ 39 | 40 | # Define CLOS from profile 41 | alloc-class-select: CFG0 42 | -------------------------------------------------------------------------------- /lib/api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2017 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | #ifndef API_H 36 | #define API_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** 43 | * @brief Initializes api module 44 | * 45 | * @param interface option, MSR or OS 46 | * 47 | * @return Operational status 48 | * @retval PQOS_RETVAL_OK success 49 | */ 50 | int api_init(int interface); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif /* API_H */ 57 | 58 | -------------------------------------------------------------------------------- /pqos/pqos-msr: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################### 4 | # BSD LICENSE 5 | # 6 | # Copyright(c) 2017 Intel Corporation. All rights reserved. 7 | # All rights reserved. 8 | # 9 | # Redistribution and use in source and binary forms, with or without 10 | # modification, are permitted provided that the following conditions 11 | # are met: 12 | # 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in 17 | # the documentation and/or other materials provided with the 18 | # distribution. 19 | # * Neither the name of Intel Corporation nor the names of its 20 | # contributors may be used to endorse or promote products derived 21 | # from this software without specific prior written permission. 22 | # 23 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | ############################################################################### 35 | 36 | # MSR interface wrapper script 37 | # ---------------------------- 38 | # 39 | # PQoS utilty wrapper script to use the library MSR interface. 40 | # This will cause the library to read/write directly to MSR's. 41 | 42 | # Run pqos utilty passing CL args 43 | pqos $@ 44 | -------------------------------------------------------------------------------- /pqos/pqos-os: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################### 4 | # BSD LICENSE 5 | # 6 | # Copyright(c) 2017 Intel Corporation. All rights reserved. 7 | # All rights reserved. 8 | # 9 | # Redistribution and use in source and binary forms, with or without 10 | # modification, are permitted provided that the following conditions 11 | # are met: 12 | # 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in 17 | # the documentation and/or other materials provided with the 18 | # distribution. 19 | # * Neither the name of Intel Corporation nor the names of its 20 | # contributors may be used to endorse or promote products derived 21 | # from this software without specific prior written permission. 22 | # 23 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | ############################################################################### 35 | 36 | # OS interface wrapper script 37 | # ---------------------------- 38 | # 39 | # PQoS utilty wrapper script to use the library OS/Kernel interface. 40 | # This will cause the library to read/write to the resctrl filesystem. 41 | 42 | # Run pqos utilty passing CL args 43 | pqos -I $@ 44 | -------------------------------------------------------------------------------- /pqos/configs/alloc_show_verbose.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets the utility to display the current allocation settings in 5 | # verbose mode 6 | # 7 | # @par 8 | # BSD LICENSE 9 | # 10 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 11 | # All rights reserved. 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions 15 | # are met: 16 | # 17 | # * Redistributions of source code must retain the above copyright 18 | # notice, this list of conditions and the following disclaimer. 19 | # * Redistributions in binary form must reproduce the above copyright 20 | # notice, this list of conditions and the following disclaimer in 21 | # the documentation and/or other materials provided with the 22 | # distribution. 23 | # * Neither the name of Intel Corporation nor the names of its 24 | # contributors may be used to endorse or promote products derived 25 | # from this software without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 38 | # 39 | ################################################################################ 40 | 41 | # Show current allocation settings 42 | show-alloc: 43 | 44 | # Select verbose mode 45 | verbose-mode: 46 | -------------------------------------------------------------------------------- /pqos/configs/mon_llc_core_text.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets ultility to monitor LLC occupancy on cores 0-5 for a 5 | # duration of 5 seconds 6 | # 7 | # @par 8 | # BSD LICENSE 9 | # 10 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 11 | # All rights reserved. 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions 15 | # are met: 16 | # 17 | # * Redistributions of source code must retain the above copyright 18 | # notice, this list of conditions and the following disclaimer. 19 | # * Redistributions in binary form must reproduce the above copyright 20 | # notice, this list of conditions and the following disclaimer in 21 | # the documentation and/or other materials provided with the 22 | # distribution. 23 | # * Neither the name of Intel Corporation nor the names of its 24 | # contributors may be used to endorse or promote products derived 25 | # from this software without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 38 | # 39 | ################################################################################ 40 | 41 | # Monitor LLC occupancy on cores 0-5 42 | monitor-cores: llc:0-5 43 | 44 | # Stop monitoring after 5 seconds 45 | monitor-time: 5 46 | -------------------------------------------------------------------------------- /pqos/configs/mon_mbl_core_text.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets ultility to monitor local memory bandwidth on cores 0-5 for 5 | # a duration of 5 seconds 6 | # 7 | # @par 8 | # BSD LICENSE 9 | # 10 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 11 | # All rights reserved. 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions 15 | # are met: 16 | # 17 | # * Redistributions of source code must retain the above copyright 18 | # notice, this list of conditions and the following disclaimer. 19 | # * Redistributions in binary form must reproduce the above copyright 20 | # notice, this list of conditions and the following disclaimer in 21 | # the documentation and/or other materials provided with the 22 | # distribution. 23 | # * Neither the name of Intel Corporation nor the names of its 24 | # contributors may be used to endorse or promote products derived 25 | # from this software without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 38 | # 39 | ################################################################################ 40 | 41 | # Monitor MBL occupancy on cores 0-5 42 | monitor-cores: mbl:0-5 43 | 44 | # Stop monitoring after 5 seconds 45 | monitor-time: 5 46 | -------------------------------------------------------------------------------- /examples/c/CMT_MBM/README: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | README for CMT MBM Sample Code 3 | 4 | April 2016 5 | ================================================================================ 6 | 7 | CONTENTS 8 | ======== 9 | 10 | - Overview 11 | - Compilation 12 | - Usage 13 | - Legal Disclaimer 14 | 15 | 16 | OVERVIEW 17 | ======== 18 | 19 | This is example code to demonstrate the use of PQoS/Intel(R) Resource Director 20 | Technology (Intel(R) RDT) library APIs to manage Cache Monitoring Technology 21 | (CMT), Memory Bandwidth Monitoring (MBM). Refer to 22 | https://github.com/01org/intel-cmt-cat/blob/master/README table 1 for a list 23 | of processors supporting CMT and MBM. 24 | CMT_MBM sample application build will create one target as follows: 25 | 1. monitor_app - Demonstrates usage of PQoS/Intel(R) RDT library APIs related 26 | to monitoring events like cache occupancy, local memory bandwidth usage and 27 | remote memory bandwidth usage. It operates in user space and uses PQoS/Intel(R) 28 | RDT and C libraries only. 29 | Note: Monitor events are hardware dependant. Only supported event will be shown. 30 | 31 | 32 | COMPILATION 33 | =========== 34 | 35 | Note: The PQoS/Intel(R) RDT library should be installed before compilation. 36 | 37 | Run "make all" or "make" to compile the program. If compilation is successful 38 | "monitor_app" binary should be present in the directory. 39 | 40 | Run "make clean" to clean the build files. 41 | 42 | 43 | USAGE 44 | ===== 45 | 46 | To run: 47 | $ sudo ./monitor_app 48 | 49 | For more usage options: 50 | $ sudo ./monitor_app -h 51 | 52 | 53 | LEGAL DISCLAIMER 54 | ================ 55 | 56 | THIS SOFTWARE IS PROVIDED BY INTEL"AS IS". NO LICENSE, EXPRESS OR 57 | IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS 58 | ARE GRANTED THROUGH USE. EXCEPT AS PROVIDED IN INTEL'S TERMS AND 59 | CONDITIONS OF SALE, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL 60 | DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR 61 | USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO 62 | FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT 63 | OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. 64 | -------------------------------------------------------------------------------- /pqos/configs/alloc_set_clos_11LLC_ways.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets CAT class(es) of service (11LLC ways) 5 | # 6 | # @par 7 | # BSD LICENSE 8 | # 9 | # Copyright(c) 2017 Intel Corporation. All rights reserved. 10 | # All rights reserved. 11 | # 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions 14 | # are met: 15 | # 16 | # * Redistributions of source code must retain the above copyright 17 | # notice, this list of conditions and the following disclaimer. 18 | # * Redistributions in binary form must reproduce the above copyright 19 | # notice, this list of conditions and the following disclaimer in 20 | # the documentation and/or other materials provided with the 21 | # distribution. 22 | # * Neither the name of Intel Corporation nor the names of its 23 | # contributors may be used to endorse or promote products derived 24 | # from this software without specific prior written permission. 25 | # 26 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 37 | # 38 | ################################################################################ 39 | 40 | # Set allocation CLOS 41 | # 42 | # Class 0 mask = 0x7ff 43 | # Class 1 mask = 0x0ff 44 | # Class 2 mask = 0x00f 45 | # Class 3 mask = 0x003 46 | alloc-class-set: llc:0=0x7ff;llc:1=0x0ff;llc:2=0x00f;llc:3=0x003; 47 | -------------------------------------------------------------------------------- /pqos/configs/alloc_set_clos_12LLC_ways.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets CAT class(es) of service (12LLC ways) 5 | # 6 | # @par 7 | # BSD LICENSE 8 | # 9 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 10 | # All rights reserved. 11 | # 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions 14 | # are met: 15 | # 16 | # * Redistributions of source code must retain the above copyright 17 | # notice, this list of conditions and the following disclaimer. 18 | # * Redistributions in binary form must reproduce the above copyright 19 | # notice, this list of conditions and the following disclaimer in 20 | # the documentation and/or other materials provided with the 21 | # distribution. 22 | # * Neither the name of Intel Corporation nor the names of its 23 | # contributors may be used to endorse or promote products derived 24 | # from this software without specific prior written permission. 25 | # 26 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 37 | # 38 | ################################################################################ 39 | 40 | # Set allocation CLOS 41 | # 42 | # Class 0 mask = 0xfff 43 | # Class 1 mask = 0x0ff 44 | # Class 2 mask = 0x00f 45 | # Class 3 mask = 0x003 46 | alloc-class-set: llc:0=0xfff;llc:1=0x0ff;llc:2=0x00f;llc:3=0x003; 47 | -------------------------------------------------------------------------------- /pqos/configs/alloc_config_cdp.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Resets CAT, enables CDP and prints current allocation settings 5 | # in verbose mode 6 | # 7 | # @par 8 | # BSD LICENSE 9 | # 10 | # Copyright(c) 2015-2016 Intel Corporation. All rights reserved. 11 | # All rights reserved. 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions 15 | # are met: 16 | # 17 | # * Redistributions of source code must retain the above copyright 18 | # notice, this list of conditions and the following disclaimer. 19 | # * Redistributions in binary form must reproduce the above copyright 20 | # notice, this list of conditions and the following disclaimer in 21 | # the documentation and/or other materials provided with the 22 | # distribution. 23 | # * Neither the name of Intel Corporation nor the names of its 24 | # contributors may be used to endorse or promote products derived 25 | # from this software without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | # 39 | ################################################################################ 40 | 41 | # Set configuration setting 42 | reset-cat: l3cdp-on 43 | 44 | # Show current allocation settings 45 | show-alloc: 46 | 47 | # Select verbose mode 48 | verbose-mode: 49 | 50 | -------------------------------------------------------------------------------- /pqos/configs/alloc_set_clos_20LLC_ways.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets CAT class(es) of service (20 LLC ways) 5 | # 6 | # @par 7 | # BSD LICENSE 8 | # 9 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 10 | # All rights reserved. 11 | # 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions 14 | # are met: 15 | # 16 | # * Redistributions of source code must retain the above copyright 17 | # notice, this list of conditions and the following disclaimer. 18 | # * Redistributions in binary form must reproduce the above copyright 19 | # notice, this list of conditions and the following disclaimer in 20 | # the documentation and/or other materials provided with the 21 | # distribution. 22 | # * Neither the name of Intel Corporation nor the names of its 23 | # contributors may be used to endorse or promote products derived 24 | # from this software without specific prior written permission. 25 | # 26 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 37 | # 38 | ################################################################################ 39 | 40 | # Set allocation CLOS 41 | # 42 | # Class 0 mask = 0xfffff 43 | # Class 1 mask = 0x00fff 44 | # Class 2 mask = 0x000ff 45 | # Class 3 mask = 0x0000f 46 | alloc-class-set: llc:0=0xfffff;llc:1=0x00fff;llc:2=0x000ff;llc:3=0x0000f; 47 | -------------------------------------------------------------------------------- /pqos/configs/mon_llc_pid_text.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets ultility to monitor LLC occupancy for PID 1 for a duration 5 | # of 5 seconds 6 | # 7 | # @par 8 | # BSD LICENSE 9 | # 10 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 11 | # All rights reserved. 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions 15 | # are met: 16 | # 17 | # * Redistributions of source code must retain the above copyright 18 | # notice, this list of conditions and the following disclaimer. 19 | # * Redistributions in binary form must reproduce the above copyright 20 | # notice, this list of conditions and the following disclaimer in 21 | # the documentation and/or other materials provided with the 22 | # distribution. 23 | # * Neither the name of Intel Corporation nor the names of its 24 | # contributors may be used to endorse or promote products derived 25 | # from this software without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 38 | # 39 | ################################################################################ 40 | 41 | # Select library OS interface 42 | iface-os: 43 | 44 | # Monitor LLC occupancy on for PID 1 45 | monitor-pids: llc:1 46 | 47 | # Stop monitoring after 5 seconds 48 | monitor-time: 5 49 | -------------------------------------------------------------------------------- /lib/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2017 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | /** 36 | * @brief Internal header file to PQoS utils initialization 37 | */ 38 | 39 | #ifndef __PQOS_UTILS_H__ 40 | #define __PQOS_UTILS_H__ 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | 47 | /** 48 | * @brief Initializes utils module 49 | * 50 | * @param interface option, MSR or OS 51 | * 52 | * @return Operational status 53 | * @retval PQOS_RETVAL_OK success 54 | */ 55 | int _pqos_utils_init(int interface); 56 | 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* __PQOS_UTULS_H__ */ 63 | 64 | -------------------------------------------------------------------------------- /pqos/configs/mon_mbr_core_interval.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets ultility to monitor remote memory bandwidth on cores 0-5 5 | # for a duration of 5 seconds at 500ms intervals 6 | # 7 | # @par 8 | # BSD LICENSE 9 | # 10 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 11 | # All rights reserved. 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions 15 | # are met: 16 | # 17 | # * Redistributions of source code must retain the above copyright 18 | # notice, this list of conditions and the following disclaimer. 19 | # * Redistributions in binary form must reproduce the above copyright 20 | # notice, this list of conditions and the following disclaimer in 21 | # the documentation and/or other materials provided with the 22 | # distribution. 23 | # * Neither the name of Intel Corporation nor the names of its 24 | # contributors may be used to endorse or promote products derived 25 | # from this software without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 38 | # 39 | ################################################################################ 40 | 41 | # Monitor MBR occupancy on cores 0-5 42 | monitor-cores: mbr:0-5 43 | 44 | # Stop monitoring after 5 seconds 45 | monitor-time: 5 46 | 47 | # Set intervals for 500ms 48 | monitor-interval: 5 49 | -------------------------------------------------------------------------------- /lib/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2014-2015 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 32 | * 33 | */ 34 | 35 | /** 36 | * @brief Miscellaneous data type definitions and macro definitions 37 | */ 38 | 39 | #ifndef __PQOS_TYPES_H__ 40 | #define __PQOS_TYPES_H__ 41 | 42 | #ifdef DEBUG 43 | #include 44 | #endif 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | #ifndef DIM 51 | #define DIM(x) (sizeof(x)/sizeof(x[0])) 52 | #endif 53 | 54 | #define UNUSED_PARAM(x) (void)(x) 55 | 56 | #ifdef DEBUG 57 | #define ASSERT assert 58 | #else 59 | #define ASSERT(x) 60 | #endif 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* __PQOS_TYPES_H__ */ 67 | -------------------------------------------------------------------------------- /pqos/configs/alloc_set_clos_11LLC_ways_cdp.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets CDP CAT class(es) of service (11LLC ways) 5 | # 6 | # @par 7 | # BSD LICENSE 8 | # 9 | # Copyright(c) 2017 Intel Corporation. All rights reserved. 10 | # All rights reserved. 11 | # 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions 14 | # are met: 15 | # 16 | # * Redistributions of source code must retain the above copyright 17 | # notice, this list of conditions and the following disclaimer. 18 | # * Redistributions in binary form must reproduce the above copyright 19 | # notice, this list of conditions and the following disclaimer in 20 | # the documentation and/or other materials provided with the 21 | # distribution. 22 | # * Neither the name of Intel Corporation nor the names of its 23 | # contributors may be used to endorse or promote products derived 24 | # from this software without specific prior written permission. 25 | # 26 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 37 | # 38 | ################################################################################ 39 | 40 | # Set code and data allocation CLOS 41 | # 42 | # Class 0 data mask = 0xff 43 | # code mask = 0x7f0 44 | # Class 1 both masks = 0x0ff 45 | # Class 2 both masks = 0x00f 46 | # Class 3 both masks = 0x003 47 | alloc-class-set: llc:0d=0xff;llc:0c=0x7f0;llc:1=0x0ff;llc:2=0x00f;llc:3=0x003; 48 | -------------------------------------------------------------------------------- /pqos/configs/alloc_set_clos_12LLC_ways_cdp.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets CDP CAT class(es) of service (12LLC ways) 5 | # 6 | # @par 7 | # BSD LICENSE 8 | # 9 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 10 | # All rights reserved. 11 | # 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions 14 | # are met: 15 | # 16 | # * Redistributions of source code must retain the above copyright 17 | # notice, this list of conditions and the following disclaimer. 18 | # * Redistributions in binary form must reproduce the above copyright 19 | # notice, this list of conditions and the following disclaimer in 20 | # the documentation and/or other materials provided with the 21 | # distribution. 22 | # * Neither the name of Intel Corporation nor the names of its 23 | # contributors may be used to endorse or promote products derived 24 | # from this software without specific prior written permission. 25 | # 26 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 37 | # 38 | ################################################################################ 39 | 40 | # Set code and data allocation CLOS 41 | # 42 | # Class 0 data mask = 0xff 43 | # code mask = 0xff0 44 | # Class 1 both masks = 0x0ff 45 | # Class 2 both masks = 0x00f 46 | # Class 3 both masks = 0x003 47 | alloc-class-set: llc:0d=0xff;llc:0c=0xff0;llc:1=0x0ff;llc:2=0x00f;llc:3=0x003; 48 | -------------------------------------------------------------------------------- /pqos/configs/alloc_set_clos_20LLC_ways_cdp.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets CDP CAT class(es) of service (20 LLC ways) 5 | # 6 | # @par 7 | # BSD LICENSE 8 | # 9 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 10 | # All rights reserved. 11 | # 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions 14 | # are met: 15 | # 16 | # * Redistributions of source code must retain the above copyright 17 | # notice, this list of conditions and the following disclaimer. 18 | # * Redistributions in binary form must reproduce the above copyright 19 | # notice, this list of conditions and the following disclaimer in 20 | # the documentation and/or other materials provided with the 21 | # distribution. 22 | # * Neither the name of Intel Corporation nor the names of its 23 | # contributors may be used to endorse or promote products derived 24 | # from this software without specific prior written permission. 25 | # 26 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 37 | # 38 | ################################################################################ 39 | 40 | # Set code and data allocation CLOS 41 | # 42 | # Class 0 data mask = 0xfff 43 | # code mask = 0xfff00 44 | # Class 1 both masks = 0x0fff 45 | # Class 2 both masks = 0x0ff 46 | # Class 3 both masks = 0x00f 47 | alloc-class-set: llc:0d=0xfff;llc:0c=0xfff00;llc:1=0x0fff;llc:2=0x0ff;llc:3=0x00f; 48 | -------------------------------------------------------------------------------- /lib/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | ======================================================================== 4 | README for PQoS/Intel(R) RDT library 5 | 6 | April 2016 7 | ======================================================================== 8 | 9 | 10 | Contents 11 | ======== 12 | 13 | - Overview 14 | - Installation 15 | - Legal Disclaimer 16 | 17 | 18 | Overview 19 | ======== 20 | 21 | PQoS library provides API to detect and configure Intel(R) RDT including: 22 | Cache Monitoring Technology (CMT), Memory Bandwidth Monitoring (MBM), 23 | Cache Allocation Technology (CAT), Code and Data Prioritization (CDP) Technology. 24 | For more information about Intel(R) RDT please see top level README. 25 | 26 | 27 | Installation 28 | ============ 29 | 30 | NOTE to FreeBSD users, remember to replace "make" with "gmake" in 31 | the steps described below. 32 | 33 | The following steps are required to compile and install library: 34 | $ make 35 | $ sudo make install 36 | 37 | By default make builds shared library. 38 | 39 | "make" accepts extra options e.g.: 40 | "SHARED=n" - for static library 41 | "DEBUG=y" - for library for debugging 42 | 43 | "sudo make install" installs compiled library into system directories. 44 | 45 | By default, library files are installed in "lib" directory below "/usr/local" 46 | but it can be changed with use of PREFIX to install files below "/some/where": 47 | $ sudo make install PREFIX=/some/where 48 | 49 | Library files can be removed but the same PREFIX has to be 50 | used for uninstall and install targets. 51 | 52 | To remove files from below default PREFIX: 53 | $ sudo make uninstall 54 | 55 | To remove from below /some/where: 56 | $ sudo make uninstall PREFIX=/some/where 57 | 58 | For more info about make targets, please run "make help" command. 59 | 60 | 61 | Legal Disclaimer 62 | ================ 63 | 64 | THIS SOFTWARE IS PROVIDED BY INTEL"AS IS". NO LICENSE, EXPRESS OR 65 | IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS 66 | ARE GRANTED THROUGH USE. EXCEPT AS PROVIDED IN INTEL'S TERMS AND 67 | CONDITIONS OF SALE, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL 68 | DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR 69 | USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO 70 | FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT 71 | OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. -------------------------------------------------------------------------------- /pqos/configs/alloc_set_core_assoc.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets association between core(s) and allocation class(es) of 5 | # service 6 | # 7 | # @par 8 | # BSD LICENSE 9 | # 10 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 11 | # All rights reserved. 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions 15 | # are met: 16 | # 17 | # * Redistributions of source code must retain the above copyright 18 | # notice, this list of conditions and the following disclaimer. 19 | # * Redistributions in binary form must reproduce the above copyright 20 | # notice, this list of conditions and the following disclaimer in 21 | # the documentation and/or other materials provided with the 22 | # distribution. 23 | # * Neither the name of Intel Corporation nor the names of its 24 | # contributors may be used to endorse or promote products derived 25 | # from this software without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 38 | # 39 | ################################################################################ 40 | 41 | # Set associations 42 | # 43 | # Cores 0-2 are associated with class 0 44 | # Core 3 is associated with class 1 45 | # Core 4 is associated with class 2 46 | # Core 5 is associated with class 3 47 | alloc-assoc-set: llc:0=0-2 48 | alloc-assoc-set: llc:1=3 49 | alloc-assoc-set: llc:2=4 50 | alloc-assoc-set: llc:3=5 51 | -------------------------------------------------------------------------------- /pqos/configs/mon_llc_core_xml_file.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets utility to monitor LLC occupancy on cores 0-5 for a 5 | # duration of 5 seconds and output is directed to a file in 6 | # XML format 7 | # 8 | # @par 9 | # BSD LICENSE 10 | # 11 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 12 | # All rights reserved. 13 | # 14 | # Redistribution and use in source and binary forms, with or without 15 | # modification, are permitted provided that the following conditions 16 | # are met: 17 | # 18 | # * Redistributions of source code must retain the above copyright 19 | # notice, this list of conditions and the following disclaimer. 20 | # * Redistributions in binary form must reproduce the above copyright 21 | # notice, this list of conditions and the following disclaimer in 22 | # the documentation and/or other materials provided with the 23 | # distribution. 24 | # * Neither the name of Intel Corporation nor the names of its 25 | # contributors may be used to endorse or promote products derived 26 | # from this software without specific prior written permission. 27 | # 28 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 39 | # 40 | ################################################################################ 41 | 42 | # Monitor LLC occupancy on cores 0-5 43 | monitor-cores: llc:0-5 44 | 45 | # Set output type to XML 46 | monitor-file-type: xml 47 | 48 | # Output to file 49 | monitor-file: /tmp/pqos_example.xml 50 | 51 | # Stop monitoring after 5 seconds 52 | monitor-time: 5 53 | -------------------------------------------------------------------------------- /pqos/configs/mon_llc_pid_xml_file.cfg: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Configuration file for PQoS Utility 3 | # 4 | # Description: Sets ultility to monitor LLC occupancy for PID 1 for a duration 5 | # of 5 seconds and the output is directed to a file in XML format 6 | # 7 | # @par 8 | # BSD LICENSE 9 | # 10 | # Copyright(c) 2015 Intel Corporation. All rights reserved. 11 | # All rights reserved. 12 | # 13 | # Redistribution and use in source and binary forms, with or without 14 | # modification, are permitted provided that the following conditions 15 | # are met: 16 | # 17 | # * Redistributions of source code must retain the above copyright 18 | # notice, this list of conditions and the following disclaimer. 19 | # * Redistributions in binary form must reproduce the above copyright 20 | # notice, this list of conditions and the following disclaimer in 21 | # the documentation and/or other materials provided with the 22 | # distribution. 23 | # * Neither the name of Intel Corporation nor the names of its 24 | # contributors may be used to endorse or promote products derived 25 | # from this software without specific prior written permission. 26 | # 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 38 | # 39 | ################################################################################ 40 | 41 | # Select library OS interface 42 | iface-os: 43 | 44 | # Monitor LLC occupancy for PID 1 45 | monitor-pids: llc:1 46 | 47 | # Set output type to XML 48 | monitor-file-type: xml 49 | 50 | # Output to file 51 | monitor-file: /tmp/pqos_example.xml 52 | 53 | # Stop monitoring after 5 seconds 54 | monitor-time: 5 55 | -------------------------------------------------------------------------------- /lib/perl/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | ======================================================================== 4 | README for libpqos SWIG interface 5 | 6 | March 2016 7 | ======================================================================== 8 | 9 | 10 | Contents 11 | ======== 12 | 13 | - Overview 14 | - Requirements, compilation and installation 15 | - Usage 16 | - Legal Disclaimer 17 | 18 | 19 | Overview 20 | ======== 21 | 22 | In this folder you'll find "pqos.i" a SWIG interface file 23 | that allow libpqos usage in scripting languages (e.g. in Perl). 24 | Currently the full API is exported but only CAT and CMT (LLC occupancy) related 25 | parts were tested. 26 | 27 | 28 | Requirements, compilation and installation 29 | ========================================== 30 | 31 | Requires SWIG and Perl (-devel). 32 | Tested Linux running SWIG Version 3.0.5 and Perl v5.18.4 33 | and FreeBSD running SWIG Version 3.0.8 and Perl v5.14.2 34 | 35 | To compile lipqos interface file: 36 | "perl Makefile.PL" to generate Makefile. 37 | "make" to build SWIG Perl interface (Perl module and shared lib). 38 | "make clean" for cleaning. 39 | "sudo make test" to test. 40 | "sudo make install" to install SWIG Perl interface. 41 | 42 | 43 | Usage 44 | ===== 45 | 46 | Add "use pqos;" to your Perl script. 47 | 48 | Note: 49 | In case of error while running "sudo make install" such as: 50 | "touch: cannot touch ‘pqos.bs’: Permission denied 51 | Makefile:442: recipe for target 'pqos.bs' failed 52 | make: *** [pqos.bs] Error 1" 53 | please rerun make 54 | 55 | In case of error while running script such as: 56 | "Can't locate pqos.pm in @INC ..." 57 | or 58 | "Can't locate loadable object for module pqos in @INC" 59 | make sure that you have installed SWIG Perl interface, 60 | if not, just run "sudo make install" 61 | 62 | 63 | Legal Disclaimer 64 | ================ 65 | 66 | THIS SOFTWARE IS PROVIDED BY INTEL"AS IS". NO LICENSE, EXPRESS OR 67 | IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS 68 | ARE GRANTED THROUGH USE. EXCEPT AS PROVIDED IN INTEL'S TERMS AND 69 | CONDITIONS OF SALE, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL 70 | DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR 71 | USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO 72 | FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT 73 | OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. 74 | -------------------------------------------------------------------------------- /pqos/cap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2017 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /** 35 | * @brief Capability module 36 | */ 37 | 38 | #include 39 | #include 40 | #include "pqos.h" 41 | 42 | #ifndef __CAP_H__ 43 | #define __CAP_H__ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * @brief Print information about supported RDT features 51 | * 52 | * @param [in] cap platform QoS capabilities structure 53 | * returned by \a pqos_cap_get 54 | * @param [in] cpu CPU information structure from \a pqos_cap_get 55 | * @param [in] verbose verbose mode 56 | */ 57 | void cap_print_features(const struct pqos_cap *cap, 58 | const struct pqos_cpuinfo *cpu, 59 | const int verbose); 60 | 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* __CAP_H__ */ 67 | -------------------------------------------------------------------------------- /examples/c/CAT/README: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | README for CAT Sample Code 3 | 4 | April 2016 5 | ================================================================================ 6 | 7 | CONTENTS 8 | ======== 9 | 10 | - Overview 11 | - Compilation 12 | - Usage 13 | - Legal Disclaimer 14 | 15 | 16 | OVERVIEW 17 | ======== 18 | 19 | This is example code to demonstrate the use of PQoS/Intel(R) Resource Director 20 | Technology (Intel(R) RDT) library APIs to manage Cache Allocation Technology 21 | (CAT). Refer to https://github.com/01org/intel-cmt-cat/blob/master/README table 22 | 1 for a list of processors supporting CAT. CAT sample application build will 23 | create three targets as follows: 24 | 1. allocation_app - Demonstrates usage of PQoS/Intel(R) RDT library APIs 25 | related to set bit mask for class of service (CLOS) and displaying 26 | class of service (CLOS) and associated bit mask. 27 | 2. association_app - Demonstrates usage of PQoS/Intel(R) RDT library APIs 28 | related to association of class of service (CLOS) to cores and displaying 29 | class of service (CLOS) and core association. 30 | 3. reset_app - Demonstrates usage of PQoS/Intel(R) RDT library APIs related to 31 | resetting all classes of service to system default bit mask. 32 | All apps operate in user space and use PQoS/Intel(R) RDT and C libraries only. 33 | 34 | 35 | COMPILATION 36 | =========== 37 | 38 | Note: The PQoS/Intel(R) RDT library should be installed before compilation. 39 | 40 | Run "make all" or "make" to compile the programs. If compilation is successful 41 | "allocation_app", "association_app" and "reset_app" binaries should be present 42 | in the directory. 43 | 44 | Run "make clean" to clean the build files. 45 | 46 | 47 | USAGE 48 | ===== 49 | 50 | To run: 51 | $ sudo ./allocation_app 52 | $ sudo ./association_app 53 | $ sudo ./reset_app 54 | 55 | For more usage options: 56 | Run the app as stated up above with the "-h" option. 57 | 58 | 59 | LEGAL DISCLAIMER 60 | ================ 61 | 62 | THIS SOFTWARE IS PROVIDED BY INTEL"AS IS". NO LICENSE, EXPRESS OR 63 | IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS 64 | ARE GRANTED THROUGH USE. EXCEPT AS PROVIDED IN INTEL'S TERMS AND 65 | CONDITIONS OF SALE, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL 66 | DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR 67 | USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO 68 | FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT 69 | OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. 70 | -------------------------------------------------------------------------------- /pqos/profiles.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2014-2015 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /** 35 | * Allocation profiles API 36 | */ 37 | 38 | #include 39 | #include 40 | #include "pqos.h" 41 | 42 | #ifndef __PROFILES_H__ 43 | #define __PROFILES_H__ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * @brief Prints list of supported L3CA profiles to STDOUT 51 | * 52 | * @param [in] fp file stream to write profile descriptions to 53 | */ 54 | void profile_l3ca_list(FILE *fp); 55 | 56 | /** 57 | * @brief Applies selected profile via selfn_allocation_class() 58 | * 59 | * @param [in] name of the profile 60 | * @param [in] l3ca L3CA capability structure 61 | * 62 | * @return Operations status 63 | * @retval 0 OK 64 | * @retval -1 error 65 | */ 66 | int profile_l3ca_apply(const char *name, 67 | const struct pqos_capability *cap_l3ca); 68 | 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif /* __PROFILES_H__ */ 75 | -------------------------------------------------------------------------------- /lib/cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2014-2016 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | */ 34 | 35 | /** 36 | * @brief CPU sockets and cores enumeration module. 37 | */ 38 | 39 | #ifndef __PQOS_CPUINFO_H__ 40 | #define __PQOS_CPUINFO_H__ 41 | 42 | #include 43 | #include "pqos.h" 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * @brief Initializes CPU information module 51 | * 52 | * CPU topology detection method is OS dependant. 53 | * 54 | * @param [out] topology place to store pointer to CPU topology data 55 | * 56 | * @return Operation status 57 | * @retval 0 success 58 | * @retval -EINVAL invalid argument 59 | * @retval -EPERM cpuinfo already initialized 60 | * @retval -EFAULT error building & discovering the topology 61 | */ 62 | int cpuinfo_init(const struct pqos_cpuinfo **topology); 63 | 64 | /** 65 | * @brief Shuts down CPU information module 66 | * 67 | * @return Operation status 68 | * @retval 0 success 69 | * @retval -EPERM cpuinfo not initialized 70 | */ 71 | int cpuinfo_fini(void); 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif /* __PQOS_CPUINFO_H__ */ 78 | -------------------------------------------------------------------------------- /examples/c/PSEUDO_LOCK/tsc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2016 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #include /* vsnprintf() */ 35 | #include /* va_start(), va_end() */ 36 | #include /* ULONG_MAX */ 37 | #include /* memset() */ 38 | #include "tsc.h" 39 | 40 | static const double __measurement_cost = 0; 41 | 42 | void tsc_init(struct tsc_prof *p, const char *name, ...) 43 | { 44 | va_list ap; 45 | 46 | va_start(ap, name); 47 | memset(p->name, 0, sizeof(p->name)); 48 | vsnprintf(p->name, sizeof(p->name) - 1, name, ap); 49 | va_end(ap); 50 | 51 | p->clk_avg = 0; 52 | p->clk_avgc = 0; 53 | p->clk_result = 0.0; 54 | p->clk_max = 0.0; 55 | p->clk_min = (double) ULONG_MAX; 56 | p->cost = __measurement_cost; 57 | } 58 | 59 | void tsc_print(struct tsc_prof *p) 60 | { 61 | tsc_get_avg(p); 62 | 63 | printf("[%s] work items %llu; cycles per work item: " 64 | "avg=%.3f min=%.3f max=%.3f jitter=%.3f\n", 65 | p->name, (unsigned long long)p->clk_avgc, 66 | p->clk_result, p->clk_min, p->clk_max, p->clk_max - p->clk_min); 67 | } 68 | -------------------------------------------------------------------------------- /rdtset/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2016 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef _CPU_H 35 | #define _CPU_H 36 | 37 | #ifdef __linux__ 38 | #include 39 | #endif 40 | #ifdef __FreeBSD__ 41 | #include 42 | #include 43 | #endif 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | #ifdef __FreeBSD__ 50 | typedef cpuset_t cpu_set_t; 51 | #ifndef CPU_COUNT 52 | static inline int 53 | CPU_COUNT(const cpu_set_t *set) 54 | { 55 | int i = 0, count = 0; 56 | 57 | for (i = 0; i < CPU_SETSIZE; i++) 58 | if (CPU_ISSET(i, set)) 59 | count++; 60 | 61 | return count; 62 | } 63 | #endif /* !CPU_COUNT */ 64 | #endif /* __FreeBSD__ */ 65 | 66 | /** 67 | * @brief Parse -c/--cpu params 68 | * 69 | * @param [in] cpu params string 70 | * 71 | * @return status 72 | * @retval 0 on success 73 | * @retval negative on error (-errno) 74 | */ 75 | int parse_cpu(const char *cpu); 76 | 77 | /** 78 | * @brief Set process CPU affinity 79 | * 80 | * @param [in] pid pid of process (0 for current) 81 | * 82 | * @return status 83 | * @retval 0 on success 84 | * @retval -1 on error 85 | */ 86 | int set_affinity(pid_t pid); 87 | 88 | /** 89 | * @brief Print parsed -c/--cpu config 90 | */ 91 | void print_cmd_line_cpu_config(void); 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* _CPU_H */ 98 | -------------------------------------------------------------------------------- /rdtset/cpu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2016 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #include "cpu.h" 41 | #include "common.h" 42 | 43 | int 44 | parse_cpu(const char *cpustr) 45 | { 46 | unsigned cpustr_len = strlen(cpustr); 47 | int ret = 0; 48 | 49 | ret = str_to_cpuset(cpustr, cpustr_len, &g_cfg.cpu_aff_cpuset); 50 | return ret > 0 ? 0 : -EINVAL; 51 | } 52 | 53 | int 54 | set_affinity(pid_t pid) 55 | { 56 | int ret = 0; 57 | 58 | /* Set affinity */ 59 | #ifdef __linux__ 60 | ret = sched_setaffinity(pid, sizeof(g_cfg.cpu_aff_cpuset), 61 | &g_cfg.cpu_aff_cpuset); 62 | #endif 63 | #ifdef __FreeBSD__ 64 | /* Current thread */ 65 | if (0 == pid) 66 | ret = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, 67 | sizeof(g_cfg.cpu_aff_cpuset), &g_cfg.cpu_aff_cpuset); 68 | /* Process via PID */ 69 | else 70 | ret = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, pid, 71 | sizeof(g_cfg.cpu_aff_cpuset), &g_cfg.cpu_aff_cpuset); 72 | #endif 73 | 74 | return ret; 75 | } 76 | 77 | void 78 | print_cmd_line_cpu_config(void) 79 | { 80 | char cpustr[CPU_SETSIZE * 3] = { 0 }; 81 | 82 | if (0 != CPU_COUNT(&g_cfg.cpu_aff_cpuset)) { 83 | cpuset_to_str(cpustr, sizeof(cpustr), &g_cfg.cpu_aff_cpuset); 84 | printf("Core Affinity: CPUs: %s\n", cpustr); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /examples/perl/hello_world.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | ################################################################################ 4 | # BSD LICENSE 5 | # 6 | # Copyright(c) 2016 Intel Corporation. All rights reserved. 7 | # All rights reserved. 8 | # 9 | # Redistribution and use in source and binary forms, with or without 10 | # modification, are permitted provided that the following conditions 11 | # are met: 12 | # 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in 17 | # the documentation and/or other materials provided with the 18 | # distribution. 19 | # * Neither the name of Intel Corporation nor the names of its 20 | # contributors may be used to endorse or promote products derived 21 | # from this software without specific prior written permission. 22 | # 23 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | ################################################################################ 35 | 36 | use strict; 37 | use warnings; 38 | use pqos; 39 | 40 | =begin 41 | Script to test PQoS Perl interface 42 | =cut 43 | 44 | my $cfg = pqos::pqos_config->new(); 45 | my $l3ca = pqos::pqos_l3ca->new(); 46 | 47 | # Setup config 48 | $cfg->{verbose} = 0; 49 | $cfg->{fd_log} = 1; 50 | 51 | # Initialize the library 52 | if (0 != pqos::pqos_init($cfg)) { 53 | print "Error initializing PQoS library!\n"; 54 | exit 0; 55 | } 56 | print "Hello, World!\n"; 57 | print "\t\t\t\tAssociation\tWay Mask\n"; 58 | 59 | # Get number of cores 60 | my $cpuinfo_p = pqos::get_cpuinfo(); 61 | my $cpu_num = pqos::cpuinfo_p_value($cpuinfo_p)->{num_cores}; 62 | 63 | # Print L3CA info for each core 64 | for (my $i = 0; $i < $cpu_num; $i++) { 65 | 66 | # Get core association 67 | (my $result, my $cos) = pqos::pqos_alloc_assoc_get($i); 68 | if (0 != $result) { 69 | next; 70 | } 71 | 72 | # Get socket ID for this core 73 | ($result, my $socket_id) = pqos::pqos_cpu_get_socketid($cpuinfo_p, $i); 74 | if (0 != $result) { 75 | next; 76 | } 77 | 78 | # Get way mask info 79 | if (0 != pqos::get_l3ca($l3ca, $socket_id, $cos)) { 80 | next; 81 | } 82 | 83 | # Print info 84 | printf("Hello from core %d on socket %d\tCOS %d \t\t0x%x\n", 85 | $i, $socket_id, $cos, $l3ca->{u}->{ways_mask}); 86 | } 87 | 88 | # Shutdown the library 89 | pqos::pqos_fini(); 90 | -------------------------------------------------------------------------------- /examples/c/PSEUDO_LOCK/dlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2016 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /** 35 | * @brief Data pseudo locking module 36 | */ 37 | 38 | #ifndef __DLOCK_H__ 39 | #define __DLOCK_H__ 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * @brief Initializes data pseudo lock module 47 | * 48 | * @note It is assumed that \a clos is not associated to any CPU. 49 | * @note It is assumed PQoS library is already initialized. 50 | * @note Function modifies CAT classes on all sockets. 51 | * This configuration is restored at dlock_exit(). 52 | * @note Data will be locked in ways corresponding to least significant bits of 53 | * the bit mask. 54 | * @note It is not allowed to initialize the module multiple times for 55 | * different memory blocks. 56 | * 57 | * @param ptr pointer to memory block to be locked. 58 | * If NULL then memory block is allocated. 59 | * @param size size of memory block to be locked 60 | * @param clos CAT class of service to be used for data locking 61 | * @param cpuid CPU ID to be used for data locking 62 | * 63 | * @return Operation status 64 | * @retval 0 OK 65 | * @retval <0 error 66 | */ 67 | int dlock_init(void *ptr, const size_t size, const int clos, const int cpuid); 68 | 69 | /** 70 | * @brief Shuts down data pseudo lock module 71 | * 72 | * @note CAT configuration modified at dlock_init() is restored here. 73 | * 74 | * @return Operation status 75 | * @retval 0 OK 76 | * @retval <0 error 77 | */ 78 | int dlock_exit(void); 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif /* __DLOCK_H__ */ 85 | -------------------------------------------------------------------------------- /examples/c/CMT_MBM/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Makefile script for PQoS sample application 3 | # 4 | # @par 5 | # BSD LICENSE 6 | # 7 | # Copyright(c) 2014-2016 Intel Corporation. All rights reserved. 8 | # All rights reserved. 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions 12 | # are met: 13 | # 14 | # * Redistributions of source code must retain the above copyright 15 | # notice, this list of conditions and the following disclaimer. 16 | # * Redistributions in binary form must reproduce the above copyright 17 | # notice, this list of conditions and the following disclaimer in 18 | # the documentation and/or other materials provided with the 19 | # distribution. 20 | # * Neither the name of Intel Corporation nor the names of its 21 | # contributors may be used to endorse or promote products derived 22 | # from this software without specific prior written permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | # 36 | ############################################################################### 37 | 38 | LIBDIR ?= ../../../lib 39 | CFLAGS =-I$(LIBDIR) -pthread \ 40 | -W -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes \ 41 | -Wmissing-declarations -Wold-style-definition -Wpointer-arith \ 42 | -Wcast-qual -Wundef -Wwrite-strings \ 43 | -Wformat -Wformat-security -fstack-protector -fPIE -D_FORTIFY_SOURCE=2 \ 44 | -Wunreachable-code -Wsign-compare -Wno-endif-labels \ 45 | -g -O2 46 | ifneq ($(EXTRA_CFLAGS),) 47 | CFLAGS += $(EXTRA_CFLAGS) 48 | endif 49 | LDFLAGS=-L$(LIBDIR) -pie -z noexecstack -z relro -z now 50 | LDLIBS=-lpqos -lpthread 51 | 52 | # ICC and GCC options 53 | ifeq ($(CC),icc) 54 | else 55 | CFLAGS += -Wcast-align \ 56 | -Wnested-externs \ 57 | -Wmissing-noreturn 58 | endif 59 | 60 | # Build targets and dependencies 61 | MONITORAPP = monitor_app 62 | 63 | all: $(MONITORAPP) 64 | 65 | $(MONITORAPP): $(MONITORAPP).o 66 | 67 | .PHONY: clean 68 | clean: 69 | -rm -f $(MONITORAPP) ./*.o 70 | 71 | CHECKPATCH?=checkpatch.pl 72 | .PHONY: style 73 | style: 74 | $(CHECKPATCH) --no-tree --no-signoff --emacs \ 75 | --ignore CODE_INDENT,INITIALISED_STATIC,LEADING_SPACE,SPLIT_STRING,UNSPECIFIED_INT \ 76 | -f monitor_app.c 77 | 78 | CPPCHECK?=cppcheck 79 | .PHONY: cppcheck 80 | cppcheck: 81 | $(CPPCHECK) --enable=warning,portability,performance,unusedFunction,missingInclude \ 82 | --std=c99 -I$(LIBDIR) --template=gcc \ 83 | monitor_app.c 84 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Makefile script for PQoS sample application 3 | # 4 | # @par 5 | # BSD LICENSE 6 | # 7 | # Copyright(c) 2014-2016 Intel Corporation. All rights reserved. 8 | # All rights reserved. 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions 12 | # are met: 13 | # 14 | # * Redistributions of source code must retain the above copyright 15 | # notice, this list of conditions and the following disclaimer. 16 | # * Redistributions in binary form must reproduce the above copyright 17 | # notice, this list of conditions and the following disclaimer in 18 | # the documentation and/or other materials provided with the 19 | # distribution. 20 | # * Neither the name of Intel Corporation nor the names of its 21 | # contributors may be used to endorse or promote products derived 22 | # from this software without specific prior written permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | # 36 | ############################################################################### 37 | 38 | # XXX: modify as desired 39 | PREFIX ?= /usr/local 40 | export PREFIX 41 | 42 | ifdef DEBUG 43 | export DEBUG 44 | endif 45 | 46 | ifdef SHARED 47 | export SHARED 48 | endif 49 | 50 | .PHONY: all clean TAGS install uninstall style cppcheck 51 | 52 | all: 53 | $(MAKE) -C lib 54 | $(MAKE) -C pqos 55 | $(MAKE) -C rdtset 56 | $(MAKE) -C examples/c/CAT 57 | $(MAKE) -C examples/c/CMT_MBM 58 | $(MAKE) -C examples/c/PSEUDO_LOCK 59 | 60 | clean: 61 | $(MAKE) -C lib clean 62 | $(MAKE) -C pqos clean 63 | $(MAKE) -C rdtset clean 64 | $(MAKE) -C examples/c/CAT clean 65 | $(MAKE) -C examples/c/CMT_MBM clean 66 | $(MAKE) -C examples/c/PSEUDO_LOCK clean 67 | 68 | style: 69 | $(MAKE) -C lib style 70 | $(MAKE) -C pqos style 71 | $(MAKE) -C rdtset style 72 | $(MAKE) -C examples/c/CAT style 73 | $(MAKE) -C examples/c/CMT_MBM style 74 | $(MAKE) -C examples/c/PSEUDO_LOCK style 75 | 76 | cppcheck: 77 | $(MAKE) -C lib cppcheck 78 | $(MAKE) -C pqos cppcheck 79 | $(MAKE) -C rdtset cppcheck 80 | $(MAKE) -C examples/c/CAT cppcheck 81 | $(MAKE) -C examples/c/CMT_MBM cppcheck 82 | $(MAKE) -C examples/c/PSEUDO_LOCK cppcheck 83 | 84 | install: 85 | $(MAKE) -C lib install 86 | $(MAKE) -C pqos install 87 | $(MAKE) -C rdtset install 88 | 89 | uninstall: 90 | $(MAKE) -C lib uninstall 91 | $(MAKE) -C pqos uninstall 92 | $(MAKE) -C rdtset uninstall 93 | 94 | TAGS: 95 | find ./ -name "*.[ch]" -print | etags - 96 | -------------------------------------------------------------------------------- /examples/perl/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Makefile script for PQoS hello_world.pl Perl script 3 | # 4 | # @par 5 | # BSD LICENSE 6 | # 7 | # Copyright(c) 2016 Intel Corporation. All rights reserved. 8 | # All rights reserved. 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions 12 | # are met: 13 | # 14 | # * Redistributions of source code must retain the above copyright 15 | # notice, this list of conditions and the following disclaimer. 16 | # * Redistributions in binary form must reproduce the above copyright 17 | # notice, this list of conditions and the following disclaimer in 18 | # the documentation and/or other materials provided with the 19 | # distribution. 20 | # * Neither the name of Intel Corporation nor the names of its 21 | # contributors may be used to endorse or promote products derived 22 | # from this software without specific prior written permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | ############################################################################### 36 | 37 | PERLTIDY?=perltidy 38 | 39 | PERLTIDY_STYLE=-bar -ce -pt=2 -sbt=2 -bt=2 -bbt=2 -et=4 -baao -nsfs 40 | # http://perltidy.sourceforge.net/stylekey.html 41 | # http://perltidy.sourceforge.net/perltidy.html 42 | # -bar - keep the brace on the right even for multiple-line test expressions 43 | # -ce - Cuddled Else 44 | # -pt=2 - parentheses horizontal tightness - space is never used 45 | # -sbt=2 - square brackets horizontal tightness - space is never used 46 | # -bbt=2 - code block curly braces horizontal tightness - space is never used 47 | # -et=4 - entab leading whitespace with one tab character for each 4 spaces 48 | # -baao - "break after all operators" 49 | # -nsfs - no space before a semicolon in a for statement 50 | 51 | # List of Perl scripts to be processed, space separated list 52 | PERL_SCRIPTS_LIST=hello_world.pl 53 | 54 | # To check if required style is followed, perltidy is called and 55 | # formatted output is compared to actual file, 56 | # if there are no differences, it means that file meets the requirements 57 | .PHONY: style 58 | style: 59 | @bash -c 'for i in $(PERL_SCRIPTS_LIST); do \ 60 | $(PERLTIDY) $(PERLTIDY_STYLE) ./$${i} -st |\ 61 | diff - ./$${i} && echo "$${i} style OK" ||\ 62 | { echo "$${i} style check failed!"; exit 1; }; \ 63 | done' 64 | 65 | .PHONY: style-fix 66 | style-fix: 67 | @bash -c 'for i in $(PERL_SCRIPTS_LIST); do \ 68 | $(PERLTIDY) $(PERLTIDY_STYLE) -b ./$${i}; \ 69 | done' 70 | -------------------------------------------------------------------------------- /examples/c/PSEUDO_LOCK/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Makefile script for CAT PQoS sample applications 3 | # 4 | # @par 5 | # BSD LICENSE 6 | # 7 | # Copyright(c) 2016 Intel Corporation. All rights reserved. 8 | # All rights reserved. 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions 12 | # are met: 13 | # 14 | # * Redistributions of source code must retain the above copyright 15 | # notice, this list of conditions and the following disclaimer. 16 | # * Redistributions in binary form must reproduce the above copyright 17 | # notice, this list of conditions and the following disclaimer in 18 | # the documentation and/or other materials provided with the 19 | # distribution. 20 | # * Neither the name of Intel Corporation nor the names of its 21 | # contributors may be used to endorse or promote products derived 22 | # from this software without specific prior written permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | # 36 | ############################################################################### 37 | 38 | LIBDIR ?= ../../../lib 39 | LDFLAGS = -L$(LIBDIR) -pie -z noexecstack -z relro -z now 40 | LDLIBS = -lpqos -lrt -lpthread 41 | CFLAGS = -I$(LIBDIR) \ 42 | -W -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes \ 43 | -Wmissing-declarations -Wold-style-definition -Wpointer-arith \ 44 | -Wcast-qual -Wundef -Wwrite-strings \ 45 | -Wformat -Wformat-security -fstack-protector -fPIE -D_FORTIFY_SOURCE=2 \ 46 | -Wunreachable-code -Wsign-compare -Wno-endif-labels \ 47 | -g -O2 48 | ifneq ($(EXTRA_CFLAGS),) 49 | CFLAGS += $(EXTRA_CFLAGS) 50 | endif 51 | 52 | # ICC and GCC options 53 | ifeq ($(CC),icc) 54 | else 55 | CFLAGS += -Wcast-align \ 56 | -Wnested-externs \ 57 | -Wmissing-noreturn 58 | endif 59 | 60 | # Build targets and dependencies 61 | APP = pseudo_lock 62 | OBJS = pseudo_lock.o dlock.o tsc.o 63 | 64 | all: $(APP) 65 | 66 | $(APP): $(OBJS) 67 | 68 | .PHONY: clean 69 | clean: 70 | -rm -f $(APP) $(OBJS) *.o 71 | 72 | CHECKPATCH?=checkpatch.pl 73 | .PHONY: style 74 | style: 75 | $(CHECKPATCH) --no-tree --no-signoff --emacs \ 76 | --ignore CODE_INDENT,INITIALISED_STATIC,LEADING_SPACE,SPLIT_STRING,UNSPECIFIED_INT,\ 77 | ARRAY_SIZE,BLOCK_COMMENT_STYLE \ 78 | -f pseudo_lock.c -f tsc.c -f tsc.h -f dlock.c -f dlock.h 79 | 80 | CPPCHECK?=cppcheck 81 | .PHONY: cppcheck 82 | cppcheck: 83 | $(CPPCHECK) --enable=warning,portability,performance,unusedFunction,missingInclude \ 84 | --std=c99 -I$(LIBDIR) --template=gcc \ 85 | pseudo_lock.c dlock.c dlock.h tsc.c tsc.h 86 | -------------------------------------------------------------------------------- /lib/cap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2014-2017 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /** 35 | * @brief Internal header file to share PQoS API lock mechanism 36 | * and library initialization status. 37 | */ 38 | 39 | #ifndef __PQOS_HOSTCAP_H__ 40 | #define __PQOS_HOSTCAP_H__ 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** 47 | * @brief Modifies L3 CAT capability structure upon CDP config change 48 | * 49 | * Limited error checks done in this function and no errors reported. 50 | * It is up to caller to check for L3 CAT & CDP support. 51 | * 52 | * @param [in] cdp L3 cdp configuration 53 | */ 54 | void _pqos_cap_l3cdp_change(const enum pqos_cdp_config cdp); 55 | 56 | /** 57 | * @brief Modifies L2 CAT capability structure upon CDP config change 58 | * 59 | * Limited error checks done in this function and no errors reported. 60 | * It is up to caller to check for L2 CAT & CDP support. 61 | * 62 | * @param [in] cdp L2 cdp configuration 63 | */ 64 | void _pqos_cap_l2cdp_change(const enum pqos_cdp_config cdp); 65 | 66 | /** 67 | * @brief Aquires lock for PQoS API use 68 | * 69 | * Only one thread at a time is allowed to use the API. 70 | * Each PQoS API need to use api_lock and api_unlock functions. 71 | */ 72 | void _pqos_api_lock(void); 73 | 74 | /** 75 | * @brief Symmetric operation to \a _pqos_api_lock to release the lock 76 | */ 77 | void _pqos_api_unlock(void); 78 | 79 | /** 80 | * @brief Checks library initialization state 81 | * 82 | * @param expect expected stated of library initialization state 83 | * 84 | * @return Check status 85 | * @retval PQOS_RETVAL_OK state as expected 86 | * @retval PQOS_RETVA_ERROR state different than expected 87 | */ 88 | int _pqos_check_init(const int expect); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* __PQOS_HOSTCAP_H__ */ 95 | -------------------------------------------------------------------------------- /examples/c/CAT/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Makefile script for CAT PQoS sample applications 3 | # 4 | # @par 5 | # BSD LICENSE 6 | # 7 | # Copyright(c) 2014-2016 Intel Corporation. All rights reserved. 8 | # All rights reserved. 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions 12 | # are met: 13 | # 14 | # * Redistributions of source code must retain the above copyright 15 | # notice, this list of conditions and the following disclaimer. 16 | # * Redistributions in binary form must reproduce the above copyright 17 | # notice, this list of conditions and the following disclaimer in 18 | # the documentation and/or other materials provided with the 19 | # distribution. 20 | # * Neither the name of Intel Corporation nor the names of its 21 | # contributors may be used to endorse or promote products derived 22 | # from this software without specific prior written permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | # 36 | ############################################################################### 37 | 38 | LIBDIR ?= ../../../lib 39 | CFLAGS =-I$(LIBDIR) \ 40 | -W -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes \ 41 | -Wmissing-declarations -Wold-style-definition -Wpointer-arith \ 42 | -Wcast-qual -Wundef -Wwrite-strings \ 43 | -Wformat -Wformat-security -fstack-protector -fPIE -D_FORTIFY_SOURCE=2 \ 44 | -Wunreachable-code -Wsign-compare -Wno-endif-labels \ 45 | -g -O2 46 | ifneq ($(EXTRA_CFLAGS),) 47 | CFLAGS += $(EXTRA_CFLAGS) 48 | endif 49 | LDFLAGS=-L$(LIBDIR) -pie -z noexecstack -z relro -z now 50 | LDLIBS=-lpqos -lpthread 51 | 52 | # ICC and GCC options 53 | ifeq ($(CC),icc) 54 | else 55 | CFLAGS += -Wcast-align \ 56 | -Wnested-externs \ 57 | -Wmissing-noreturn 58 | endif 59 | 60 | # Build targets and dependencies 61 | ALLOCAPP = allocation_app 62 | ASSOCAPP = association_app 63 | RESETAPP = reset_app 64 | 65 | all: $(ALLOCAPP) $(ASSOCAPP) $(RESETAPP) 66 | 67 | $(ALLOCAPP): $(ALLOCAPP).o 68 | $(ASSOCAPP): $(ASSOCAPP).o 69 | $(RESETAPP): $(RESETAPP).o 70 | 71 | .PHONY: clean 72 | clean: 73 | -rm -f $(ALLOCAPP) $(ASSOCAPP) $(RESETAPP) *.o 74 | 75 | CHECKPATCH?=checkpatch.pl 76 | .PHONY: style 77 | style: 78 | $(CHECKPATCH) --no-tree --no-signoff --emacs \ 79 | --ignore CODE_INDENT,INITIALISED_STATIC,LEADING_SPACE,SPLIT_STRING,UNSPECIFIED_INT \ 80 | -f allocation_app.c -f association_app.c -f reset_app.c 81 | 82 | CPPCHECK?=cppcheck 83 | .PHONY: cppcheck 84 | cppcheck: 85 | $(CPPCHECK) --enable=warning,portability,performance,unusedFunction,missingInclude \ 86 | --std=c99 -I$(LIBDIR) --template=gcc \ 87 | allocation_app.c association_app.c reset_app.c 88 | -------------------------------------------------------------------------------- /snmp/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Makefile script for RDT SNMP Subagent Perl script 3 | # 4 | # @par 5 | # BSD LICENSE 6 | # 7 | # Copyright(c) 2016 Intel Corporation. All rights reserved. 8 | # All rights reserved. 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions 12 | # are met: 13 | # 14 | # * Redistributions of source code must retain the above copyright 15 | # notice, this list of conditions and the following disclaimer. 16 | # * Redistributions in binary form must reproduce the above copyright 17 | # notice, this list of conditions and the following disclaimer in 18 | # the documentation and/or other materials provided with the 19 | # distribution. 20 | # * Neither the name of Intel Corporation nor the names of its 21 | # contributors may be used to endorse or promote products derived 22 | # from this software without specific prior written permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | ############################################################################### 36 | 37 | PERLTIDY?=perltidy 38 | 39 | PERLTIDY_STYLE=-bar -ce -pt=2 -sbt=2 -bt=2 -bbt=2 -et=4 -baao -nsfs -vtc=1 -ci=4 40 | # http://perltidy.sourceforge.net/stylekey.html 41 | # http://perltidy.sourceforge.net/perltidy.html 42 | # -bar - keep the brace on the right even for multiple-line test expressions 43 | # -ce - cuddled else 44 | # -pt=2 - parentheses horizontal tightness - space is never used 45 | # -sbt=2 - square brackets horizontal tightness - space is never used 46 | # -bbt=2 - code block curly braces horizontal tightness - space is never used 47 | # -et=4 - entab leading whitespace with one tab character for each 4 spaces 48 | # -baao - "break after all operators" 49 | # -nsfs - no space before a semicolon in a for statement 50 | # -vtc=1 - do not break before a closing token which is followed by a semicolon 51 | # or another closing token, and is not in a list environment 52 | # -ci=4 - continuation indentation - extra indentation spaces applied when 53 | # a long line is broken, 4 spaces 54 | 55 | # List of Perl scripts to be processed, space separated list 56 | PERL_SCRIPTS_LIST=rdt-agentx.pl 57 | 58 | # To check if required style is followed, perltidy is called and 59 | # formatted output is compared to actual file, 60 | # if there are no differences, it means that file meets the requirements 61 | .PHONY: style 62 | style: 63 | @bash -c 'for i in $(PERL_SCRIPTS_LIST); do \ 64 | $(PERLTIDY) $(PERLTIDY_STYLE) ./$${i} -st |\ 65 | diff - ./$${i} && echo "$${i} style OK" ||\ 66 | { echo "$${i} style check failed!"; exit 1; }; \ 67 | done' 68 | 69 | .PHONY: style-fix 70 | style-fix: 71 | @bash -c 'for i in $(PERL_SCRIPTS_LIST); do \ 72 | $(PERLTIDY) $(PERLTIDY_STYLE) -b ./$${i}; \ 73 | done' 74 | -------------------------------------------------------------------------------- /lib/perf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2015 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef __PQOS_PERF_H__ 35 | #define __PQOS_PERF_H__ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | /** 46 | * @brief Function to setup perf event counters 47 | * 48 | * @param attr perf event attribute structure 49 | * @param pid pid to monitor 50 | * @param cpu cpu to monitor 51 | * @param group_fd fd of group leader (-1 for no leader) 52 | * @param flags perf event flags 53 | * @param counter_fd pointer to counter fd variable to be set 54 | * 55 | * @return fd used to read specified perf event counter 56 | * @retval positive number on success 57 | * @retval negative number on error 58 | */ 59 | int 60 | perf_setup_counter(struct perf_event_attr *attr, 61 | const pid_t pid, 62 | const int cpu, 63 | const int group_fd, 64 | const unsigned long flags, 65 | int *counter_fd); 66 | 67 | /** 68 | * @brief Function to shutdown a perf event counter 69 | * 70 | * @param counter_fd fd used to access the perf counters 71 | * 72 | * @return Operational status 73 | * @retval PQOS_RETVAL_OK on sucess 74 | */ 75 | int 76 | perf_shutdown_counter(int counter_fd); 77 | 78 | /** 79 | * @brief Function to start a perf counter 80 | * 81 | * @param counter_fd fd used to access the perf counter 82 | * 83 | * @return Operational status 84 | * @retval PQOS_RETVAL_OK on sucess 85 | */ 86 | int 87 | perf_start_counter(int counter_fd); 88 | 89 | /** 90 | * @brief Function to stop a perf counter 91 | * 92 | * @param counter_fd fd used to access the perf counter 93 | * 94 | * @return Operational status 95 | * @retval PQOS_RETVAL_OK on sucess 96 | */ 97 | int 98 | perf_stop_counter(int counter_fd); 99 | 100 | /** 101 | * @brief Function to read a perf counter 102 | * 103 | * @param counter_fd fd used to access the perf counter 104 | * @param value pointer to variable to store counter value 105 | * 106 | * @return Operational status 107 | * @retval PQOS_RETVAL_OK on sucess 108 | */ 109 | int 110 | perf_read_counter(int counter_fd, uint64_t *value); 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | #endif 116 | -------------------------------------------------------------------------------- /pqos/alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2014-2017 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /** 35 | * Allocation module 36 | */ 37 | 38 | #include 39 | #include 40 | #include "pqos.h" 41 | 42 | #ifndef __ALLOCATION_H__ 43 | #define __ALLOCATION_H__ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * @brief Defines allocation class of service 51 | * 52 | * @param [in] arg string passed to -e command line option 53 | */ 54 | void selfn_allocation_class(const char *arg); 55 | 56 | /** 57 | * @brief Associates cores with selected class of service 58 | * 59 | * @param [in] arg string passed to -a command line option 60 | */ 61 | void selfn_allocation_assoc(const char *arg); 62 | 63 | /** 64 | * @brief Prints information about cache allocation settings in the system 65 | * 66 | * @param [in] cap_mon monitoring capability structure 67 | * @param [in] cap_l3ca L3 CAT capability structures 68 | * @param [in] cap_l2ca L2 CAT capability structures 69 | * @param [in] cap_mba MBA capability structures 70 | * @param [in] sock_count number of detected CPU sockets 71 | * @param [in] sockets arrays with detected CPU socket id's 72 | * @param [in] cpu_info cpu information structure 73 | * @param [in] verbose verbose mode flag 74 | */ 75 | void alloc_print_config(const struct pqos_capability *cap_mon, 76 | const struct pqos_capability *cap_l3ca, 77 | const struct pqos_capability *cap_l2ca, 78 | const struct pqos_capability *cap_mba, 79 | const unsigned sock_count, 80 | const unsigned *sockets, 81 | const struct pqos_cpuinfo *cpu_info, 82 | const int verbose); 83 | 84 | /** 85 | * @brief Applies allocation settings previously selected via 86 | * selfn_xxxx() functions 87 | * 88 | * @param [in] cap_l3ca CAT capability structures 89 | * @param [in] cap_l2ca CAT capability structures 90 | * @param [in] cap_mba MBA capability structures 91 | * @param [in] cpu cpu information structure 92 | * 93 | * @return Operation status 94 | * @retval 0 there was no new config to apply 95 | * @retavl 1 there was new config to apply and it went smoothly 96 | * @retval -1 an error occurred when applying new config 97 | */ 98 | int alloc_apply(const struct pqos_capability *cap_l3ca, 99 | const struct pqos_capability *cap_l2ca, 100 | const struct pqos_capability *cap_mba, 101 | const struct pqos_cpuinfo *cpu); 102 | 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif /* __ALLOCATION_H__ */ 109 | -------------------------------------------------------------------------------- /lib/perf_monitoring.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2018 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 32 | * 33 | */ 34 | 35 | /** 36 | * @brief Internal header file for perf monitoring functions 37 | */ 38 | 39 | #ifndef __PQOS_PERF_MON_H__ 40 | #define __PQOS_PERF_MON_H__ 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #define PERF_MON_PATH "/sys/devices/intel_cqm/" 47 | 48 | /** 49 | * Local monitor event types 50 | */ 51 | enum perf_mon_event { 52 | PQOS_PERF_EVENT_INSTRUCTIONS = 0x1000, /**< Retired CPU Instructions */ 53 | PQOS_PERF_EVENT_CYCLES = 0x2000, /**< Unhalted CPU Clock Cycles */ 54 | }; 55 | 56 | /** 57 | * @brief Initializes Perf structures used for OS monitoring interface 58 | * 59 | * @param cpu cpu topology structure 60 | * @param cap capabilities structure 61 | * 62 | * @return Operational status 63 | * @retval PQOS_RETVAL_OK success 64 | */ 65 | int perf_mon_init(const struct pqos_cpuinfo *cpu, const struct pqos_cap *cap); 66 | 67 | /** 68 | * @brief Shuts down monitoring sub-module for perf monitoring 69 | * 70 | * @return Operation status 71 | * @retval PQOS_RETVAL_OK success 72 | */ 73 | int perf_mon_fini(void); 74 | 75 | /** 76 | * @brief This function starts Perf pqos event counters 77 | * 78 | * Used to start pqos counters and request file 79 | * descriptors used to read the counters 80 | * 81 | * @param group monitoring structure 82 | * @param event PQoS event type 83 | * 84 | * @return Operation status 85 | * @retval PQOS_RETVAL_OK on success 86 | */ 87 | int perf_mon_start(struct pqos_mon_data *group, 88 | const enum pqos_mon_event event); 89 | 90 | /** 91 | * @brief Function to stop Perf event counters 92 | * 93 | * @param group monitoring structure 94 | * @param event PQoS event type 95 | * 96 | * @return Operation status 97 | * @retval PQOS_RETVAL_OK on success 98 | */ 99 | int perf_mon_stop(struct pqos_mon_data *group, const enum pqos_mon_event event); 100 | 101 | /** 102 | * @brief This function polls all perf counters 103 | * 104 | * Reads counters for all events and stores values 105 | * 106 | * @param group monitoring structure 107 | * @param event PQoS event type 108 | * 109 | * @return Operation status 110 | * @retval PQOS_RETVAL_OK on success 111 | * @retval PQOS_RETVAL_ERROR if error occurs 112 | */ 113 | int perf_mon_poll(struct pqos_mon_data *group, const enum pqos_mon_event event); 114 | 115 | /** 116 | * @brief Check if event is supported by perf 117 | * 118 | * @param event PQoS event to check 119 | * 120 | * @retval 0 if not supported 121 | */ 122 | int perf_mon_is_event_supported(const enum pqos_mon_event event); 123 | 124 | 125 | #ifdef __cplusplus 126 | } 127 | #endif 128 | 129 | #endif /* __PQOS_PERF_MON_H__ */ 130 | -------------------------------------------------------------------------------- /rdtset/rdt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2016 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef _RDT_H 35 | #define _RDT_H 36 | 37 | #include "common.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** 44 | * @brief Initializes libpqos and configures allocation 45 | * 46 | * @return status 47 | * @retval 0 on success 48 | * @retval negative on error (-errno) 49 | */ 50 | int alloc_init(void); 51 | 52 | /** 53 | * @brief deinitializes libpqos 54 | */ 55 | void alloc_fini(void); 56 | 57 | /** 58 | * @brief Reverts allocation configuration and deinitializes libpqos 59 | */ 60 | void alloc_exit(void); 61 | 62 | /** 63 | * @brief Parses -r/--reset params 64 | * 65 | * @param [in] cpu params string 66 | * 67 | * @return parse status 68 | * @retval 0 on success 69 | * @retval negative on error (-errno) 70 | */ 71 | int parse_reset(const char *cpu); 72 | 73 | /** 74 | * @brief Parses -t/--rdt params and stores configuration in g_cfg 75 | * 76 | * @note The format pattern: 77 | * --rdt='l2=cbm;l3=cbm;cpu=cpulist' 78 | * Capacity bit mask (cbm) could be a single mask 79 | * or for a L3 CDP enabled system, a group of two masks 80 | * ("code cbm" and "data cbm") 81 | * cpus could be a single digit/range or a group. 82 | * 83 | * e.g. 'l3=0x00F00;cpu=1,3' 84 | * - CPUs 1 and 3 have 4 ways of L3 assigned; 85 | * 86 | * e.g. 'l2=0xF0000;l3=0x0FF00;cpu=4-6' 87 | * - CPUs 4,5 and 6 have 4 ways of L2 and 8 ways of L3 assigned; 88 | * 89 | * e.g. 'l3=0x00C00,0x00300;cpu=1,3' for a CDP enabled system 90 | * - cpus 1 and 3 have access to 2 ways of L3 for code 91 | * and 2 ways of L3 for data, code and data ways are not overlapping.; 92 | * 93 | * @param [in] rdtstr params string 94 | * 95 | * @return parse status 96 | * @retval 0 on success 97 | * @retval negative on error (-errno) 98 | */ 99 | int parse_rdt(char *rdtstr); 100 | 101 | /* 102 | * @brief Checks if it's possible to fulfill requested COS configuration 103 | * and then configures system. 104 | * 105 | * @return status 106 | * @retval 0 on success 107 | * @retval negative on error (-errno) 108 | */ 109 | int alloc_configure(void); 110 | 111 | /* 112 | * @brief Resets COS association (assign COS#0) on listed CPUs 113 | * 114 | * @return status 115 | * @retval 0 on success 116 | * @retval negative on error (-errno) 117 | */ 118 | int alloc_reset(void); 119 | 120 | /** 121 | * @brief This function dumps internal config structures 122 | * (updated by parse_rdt()) 123 | */ 124 | void print_cmd_line_rdt_config(void); 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | #endif /* _RDT_H */ 131 | -------------------------------------------------------------------------------- /lib/perl/Makefile.PL: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Makefile.PL script for PQoS library SWIG Perl interface 3 | # 4 | # @par 5 | # BSD LICENSE 6 | # 7 | # Copyright(c) 2016 Intel Corporation. All rights reserved. 8 | # All rights reserved. 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions 12 | # are met: 13 | # 14 | # * Redistributions of source code must retain the above copyright 15 | # notice, this list of conditions and the following disclaimer. 16 | # * Redistributions in binary form must reproduce the above copyright 17 | # notice, this list of conditions and the following disclaimer in 18 | # the documentation and/or other materials provided with the 19 | # distribution. 20 | # * Neither the name of Intel Corporation nor the names of its 21 | # contributors may be used to endorse or promote products derived 22 | # from this software without specific prior written permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | ############################################################################### 36 | 37 | use Config; 38 | use strict; 39 | use warnings; 40 | 41 | use ExtUtils::MakeMaker; 42 | 43 | WriteMakefile( 44 | 'NAME' => 'pqos', 45 | 'VERSION' => "0.1", 46 | 'CCFLAGS' => "$Config{ccflags} -Wno-unused-variable -Wno-unused-value", 47 | 'LIBS' => ['-lpqos', '-L/usr/local/lib -lpqos'], 48 | 'OBJECT' => 'pqos_wrap.o', 49 | 'clean' => {FILES => "pqos_wrap.c"}, 50 | ); 51 | 52 | sub MY::postamble { 53 | my $swig = "swig"; 54 | if ($^O eq "freebsd") { 55 | $swig = $swig . "3.0"; 56 | } 57 | 58 | my $swig_target = <<"SWIG_MAKEFILE"; 59 | pqos_wrap.c: 60 | $swig -perl -outdir \$(INST_LIB) -I/usr/local/include \$(EXTRA_SWIGFLAGS) pqos.i 61 | SWIG_MAKEFILE 62 | 63 | my $perltidy_targets = <<'PERLTIDY_MAKEFILE'; 64 | PERLTIDY?=perltidy 65 | 66 | PERLTIDY_STYLE=-bar -ce -pt=2 -sbt=2 -bt=2 -bbt=2 -et=4 -baao -nsfs -vtc=1 -ci=4 67 | # http://perltidy.sourceforge.net/stylekey.html 68 | # http://perltidy.sourceforge.net/perltidy.html 69 | # -bar - keep the brace on the right even for multiple-line test expressions 70 | # -ce - cuddled else 71 | # -pt=2 - parentheses horizontal tightness - space is never used 72 | # -sbt=2 - square brackets horizontal tightness - space is never used 73 | # -bbt=2 - code block curly braces horizontal tightness - space is never used 74 | # -et=4 - entab leading whitespace with one tab character for each 4 spaces 75 | # -baao - "break after all operators" 76 | # -nsfs - no space before a semicolon in a for statement 77 | # -vtc=1 - do not break before a closing token which is followed by a semicolon 78 | # or another closing token, and is not in a list environment 79 | # -ci=4 - continuation indentation - extra indentation spaces applied when 80 | # a long line is broken, 4 spaces 81 | 82 | # List of Perl scripts to be processed, space separated list 83 | PERL_SCRIPTS_LIST=test.pl 84 | 85 | # To check if required style is followed, perltidy is called and 86 | # formatted output is compared to actual file, 87 | # if there are no differences, it means that file meets the requirements 88 | .PHONY: style 89 | style: 90 | @bash -c 'for i in $(PERL_SCRIPTS_LIST); do \ 91 | $(PERLTIDY) $(PERLTIDY_STYLE) ./$${i} -st |\ 92 | diff - ./$${i} && echo "$${i} style OK" ||\ 93 | { echo "$${i} style check failed!"; exit 1; }; \ 94 | done' 95 | 96 | .PHONY: style-fix 97 | style-fix: 98 | @bash -c 'for i in $(PERL_SCRIPTS_LIST); do \ 99 | $(PERLTIDY) $(PERLTIDY_STYLE) -b ./$${i}; \ 100 | done' 101 | PERLTIDY_MAKEFILE 102 | 103 | return $swig_target . $perltidy_targets; 104 | } 105 | -------------------------------------------------------------------------------- /lib/machine.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2014-2016 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.O 32 | * 33 | */ 34 | 35 | /** 36 | * @brief Provides access to machine operations (CPUID, MSR read & write) 37 | */ 38 | 39 | #ifndef __PQOS_MACHINE_H__ 40 | #define __PQOS_MACHINE_H__ 41 | 42 | #include 43 | #include 44 | #include "types.h" 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | #define MACHINE_DEFAULT_MAX_COREID 255 /**< max core id */ 51 | 52 | #define MACHINE_RETVAL_OK 0 /**< everything OK */ 53 | #define MACHINE_RETVAL_ERROR 1 /**< generic error */ 54 | #define MACHINE_RETVAL_PARAM 2 /**< parameter error */ 55 | 56 | /** 57 | * Results of CPUID operation are stored in this structure. 58 | * It consists of 4x32bits IA registers: EAX, EBX, ECX and EDX. 59 | */ 60 | struct cpuid_out { 61 | uint32_t eax; 62 | uint32_t ebx; 63 | uint32_t ecx; 64 | uint32_t edx; 65 | }; 66 | 67 | /** 68 | * @brief Initializes machine module 69 | * 70 | * @param [in] max_core_id maximum logical core id to be handled by machine 71 | * module. If zero then default value assumed 72 | * \a MACHINE_DEFAULT_MAX_COREID 73 | * 74 | * @return Operation status 75 | * @retval MACHINE_RETVAL_OK on success 76 | */ 77 | int machine_init(const unsigned max_core_id); 78 | 79 | /** 80 | * @brief Shuts down machine module 81 | * 82 | * @return Operation status 83 | * @retval MACHINE_RETVAL_OK on success 84 | */ 85 | int machine_fini(void); 86 | 87 | /** 88 | * @brief Executes CPUID.leaf.sbuleaf on current core 89 | * 90 | * @param [in] leaf CPUID leaf number 91 | * @param [in] subleaf CPUID sub-leaf number 92 | * @param [out] out structure to write CPUID results into 93 | */ 94 | void 95 | lcpuid(const unsigned leaf, 96 | const unsigned subleaf, 97 | struct cpuid_out *out); 98 | 99 | /** 100 | * @brief Executes RDMSR on \a lcore logical core 101 | * 102 | * @param [in] lcore logical core id 103 | * @param [in] reg MSR to read from 104 | * @param [out] value place to store MSR value at 105 | * 106 | * @return Operation status 107 | * @retval MACHINE_RETVAL_OK on success 108 | */ 109 | int 110 | msr_read(const unsigned lcore, 111 | const uint32_t reg, 112 | uint64_t *value); 113 | 114 | /** 115 | * @brief Executes WRMSR on \a lcore logical core 116 | * 117 | * @param [in] lcore logical core id 118 | * @param [in] reg MSR to write to 119 | * @param [in] value to be written into \a reg 120 | * 121 | * @return Operation status 122 | * @retval MACHINE_RETVAL_OK on success 123 | */ 124 | int 125 | msr_write(const unsigned lcore, 126 | const uint32_t reg, 127 | const uint64_t value); 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | 133 | #endif /* __PQOS_MACHINE_H__ */ 134 | -------------------------------------------------------------------------------- /pqos/monitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2014-2017 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /** 35 | * Monitoring module 36 | */ 37 | 38 | #include 39 | #include 40 | #include "pqos.h" 41 | 42 | #ifndef __MONITOR_H__ 43 | #define __MONITOR_H__ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * @brief Verifies and translates multiple monitoring config strings into 51 | * internal PID monitoring configuration 52 | * 53 | * @param arg argument passed to -p command line option 54 | */ 55 | void selfn_monitor_pids(const char *arg); 56 | 57 | /** 58 | * @brief Looks for processes with highest CPU usage on the system and 59 | * starts monitoring for them. Processes are displayed and sorted 60 | * afterwards by LLC occupancy 61 | */ 62 | void selfn_monitor_top_pids(void); 63 | 64 | /** 65 | * @brief Selects top-like monitoring format 66 | * 67 | * @param arg not used 68 | */ 69 | void selfn_monitor_top_like(const char *arg); 70 | 71 | /** 72 | * @brief Selects monitoring interval 73 | * 74 | * @param arg string passed to -i command line option 75 | */ 76 | void selfn_monitor_interval(const char *arg); 77 | 78 | /** 79 | * @brief Selects monitoring time 80 | * 81 | * @param arg string passed to -t command line option 82 | */ 83 | void selfn_monitor_time(const char *arg); 84 | 85 | /** 86 | * @brief Selects type of monitoring output file 87 | * 88 | * @param arg string passed to -u command line option 89 | */ 90 | void selfn_monitor_file_type(const char *arg); 91 | 92 | /** 93 | * @brief Selects monitoring output file 94 | * 95 | * @param arg string passed to -o command line option 96 | */ 97 | void selfn_monitor_file(const char *arg); 98 | 99 | /** 100 | * @brief Translates multiple monitoring request strings into 101 | * internal monitoring request structures 102 | * 103 | * @param str string passed to -m command line option 104 | */ 105 | void selfn_monitor_cores(const char *arg); 106 | 107 | /** 108 | * @brief Stops monitoring on selected core(s)/pid(s) 109 | * 110 | */ 111 | void monitor_stop(void); 112 | 113 | /** 114 | * @brief Starts monitoring on selected core(s)/pid(s) 115 | * 116 | * @param [in] cpu_info cpu information structure 117 | * @param [in] cap_mon monitoring capability 118 | * 119 | * @return Operation status 120 | * @retval 0 OK 121 | * @retval -1 error 122 | */ 123 | int monitor_setup(const struct pqos_cpuinfo *cpu_info, 124 | const struct pqos_capability * const cap_mon); 125 | 126 | /** 127 | * @brief Frees any allocated memory during parameter selection and 128 | * monitoring setup. 129 | */ 130 | void monitor_cleanup(void); 131 | 132 | /** 133 | * @brief Monitors resources and writes data into selected stream. 134 | */ 135 | void monitor_loop(void); 136 | 137 | #ifdef __cplusplus 138 | } 139 | #endif 140 | 141 | #endif /* __MONITOR_H__ */ 142 | -------------------------------------------------------------------------------- /rdtset/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Makefile script for rdtset tool 3 | # 4 | # @par 5 | # BSD LICENSE 6 | # 7 | # Copyright(c) 2016 Intel Corporation. All rights reserved. 8 | # All rights reserved. 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions 12 | # are met: 13 | # 14 | # * Redistributions of source code must retain the above copyright 15 | # notice, this list of conditions and the following disclaimer. 16 | # * Redistributions in binary form must reproduce the above copyright 17 | # notice, this list of conditions and the following disclaimer in 18 | # the documentation and/or other materials provided with the 19 | # distribution. 20 | # * Neither the name of Intel Corporation nor the names of its 21 | # contributors may be used to endorse or promote products derived 22 | # from this software without specific prior written permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | # 36 | ############################################################################### 37 | 38 | LIBDIR ?= ../lib 39 | LDFLAGS = -L$(LIBDIR) -pie -z noexecstack -z relro -z now 40 | LDLIBS = -lpqos -lpthread 41 | CFLAGS = -I$(LIBDIR) \ 42 | -W -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes \ 43 | -Wmissing-declarations -Wold-style-definition -Wpointer-arith \ 44 | -Wcast-qual -Wundef -Wwrite-strings \ 45 | -Wformat -Wformat-security -fstack-protector -fPIE -D_FORTIFY_SOURCE=2 \ 46 | -Wunreachable-code -Wsign-compare -Wno-endif-labels \ 47 | -D_GNU_SOURCE 48 | ifneq ($(EXTRA_CFLAGS),) 49 | CFLAGS += $(EXTRA_CFLAGS) 50 | endif 51 | 52 | # ICC and GCC options 53 | ifeq ($(CC),icc) 54 | else 55 | CFLAGS += -Wcast-align \ 56 | -Wnested-externs \ 57 | -Wmissing-noreturn 58 | endif 59 | 60 | # DEBUG build 61 | ifeq ($(DEBUG),y) 62 | CFLAGS += -g -ggdb -O0 -DDEBUG 63 | else 64 | CFLAGS += -g -O2 65 | endif 66 | 67 | # Needed by initgroups() 68 | ifeq ($(shell uname), FreeBSD) 69 | CFLAGS += -D_BSD_SOURCE 70 | endif 71 | 72 | # Build targets and dependencies 73 | APP = rdtset 74 | MAN = rdtset.8 75 | 76 | # XXX: modify as desired 77 | PREFIX ?= /usr/local 78 | BIN_DIR = $(PREFIX)/bin 79 | MAN_DIR = $(PREFIX)/man/man8 80 | 81 | SRCS = $(sort $(wildcard *.c)) 82 | OBJS = $(SRCS:.c=.o) 83 | DEPFILES = $(SRCS:.c=.d) 84 | 85 | all: $(APP) 86 | 87 | $(APP): $(OBJS) 88 | $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ 89 | 90 | %.o: %.c %.d 91 | 92 | %.d: %.c 93 | $(CC) -MM -MP -MF $@ $(CFLAGS) $< 94 | cat $@ | sed 's/$(@:.d=.o)/$@/' >> $@ 95 | 96 | .PHONY: clean install uninstall 97 | 98 | install: $(APP) $(MAN) 99 | ifeq ($(shell uname), FreeBSD) 100 | install -d $(BIN_DIR) 101 | install -d $(MAN_DIR) 102 | install -s $(APP) $(BIN_DIR) 103 | install -m 0444 $(MAN) $(MAN_DIR) 104 | else 105 | install -D -s $(APP) $(BIN_DIR)/$(APP) 106 | install -m 0444 $(MAN) -D $(MAN_DIR)/$(MAN) 107 | endif 108 | 109 | uninstall: 110 | -rm $(BIN_DIR)/$(APP) 111 | -rm $(MAN_DIR)/$(MAN) 112 | 113 | clean: 114 | -rm -f $(APP) $(OBJS) $(DEPFILES) ./*~ 115 | 116 | CHECKPATCH?=checkpatch.pl 117 | .PHONY: style 118 | style: 119 | $(CHECKPATCH) --no-tree --no-signoff --emacs \ 120 | --ignore CODE_INDENT,INITIALISED_STATIC,LEADING_SPACE,SPLIT_STRING,NEW_TYPEDEFS,\ 121 | UNSPECIFIED_INT,ARRAY_SIZE,BLOCK_COMMENT_STYLE,CONSTANT_COMPARISON \ 122 | -f rdtset.c -f rdt.c -f rdt.h -f cpu.c -f cpu.h -f common.c -f common.h 123 | 124 | CPPCHECK?=cppcheck 125 | .PHONY: cppcheck 126 | cppcheck: 127 | $(CPPCHECK) --enable=warning,portability,performance,unusedFunction,missingInclude \ 128 | --std=c99 -I$(LIBDIR) --template=gcc --suppress=uninitvar \ 129 | rdtset.c rdt.c rdt.h cpu.c cpu.h common.c common.h 130 | 131 | # if target not clean then make dependencies 132 | ifneq ($(MAKECMDGOALS),clean) 133 | -include $(DEPFILES) 134 | endif 135 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | 2 | 3 | ======================================================================== 4 | INSTALLATION Instructions for Intel(R) RDT Software Package 5 | 6 | April 2016 7 | 8 | ======================================================================== 9 | 10 | 11 | Contents 12 | ======== 13 | 14 | - Overview 15 | - Installation Steps 16 | - Linux Requirements 17 | - FreeBSD Requirements (experimental) 18 | - Legal Disclaimer 19 | 20 | 21 | Installation Steps 22 | ================== 23 | 24 | For installation of the software package untar the gzip image and follow 25 | below instructions. As the results the following components will be built and 26 | installed: 27 | - PQoS DSO and its header file (libpqos.so and pqos.h) 28 | - PQoS utility executable (pqos) 29 | - PQoS utility MSR wrapper script 30 | - PQoS utility OS/Kernel wrapper script 31 | - PQoS man page (pqos.8) 32 | - rdtset tool executable (rdtset) 33 | - rdtset man page (rdtset.8) 34 | 35 | NOTE to FreeBSD users, remember to replace "make" with "gmake" in 36 | the steps described below. 37 | 38 | The following steps are required to compile and install the package: 39 | $ make 40 | $ sudo make install 41 | 42 | "make" compiles all software components of the package. 43 | "sudo make install" installs compiled files into system directories. 44 | 45 | By default, files are installed below /usr/local but it can be changed 46 | with use of PREFIX to install files below /some/where: 47 | $ sudo make install PREFIX=/some/where 48 | 49 | Software package files can be removed but the same PREFIX has to be 50 | used for uninstall and install targets. 51 | To remove files from below default PREFIX: 52 | $ sudo make uninstall 53 | To remove from below /some/where: 54 | $ sudo make uninstall PREFIX=/some/where 55 | 56 | Software package files can be cleaned with "make clean" command. 57 | 58 | NOTE 59 | If you require system wide interface enforcement you can do so by setting the 60 | "RDT_IFACE" environment variable. 61 | 62 | Linux 63 | ===== 64 | 65 | CMT, MBM and CAT are configured using Model Specific Registers (MSRs) 66 | to measure occupancy, set up the class of service masks and manage 67 | the association of the cores/logical threads to a class of service. 68 | The pqos software executes in user space, and access to the MSRs is 69 | obtained through a standard Linux* interface. The virtual file system 70 | structure /dev/cpu/CPUNUM/msr provides an interface to read and write 71 | the MSRs. The msr file interface is protected and requires root 72 | privileges. The msr driver might not be auto-loaded and on some 73 | modular kernels the driver may need to be loaded manually: 74 | 75 | $ modprobe msr 76 | 77 | For instructions on package installation please see "Installation Steps" 78 | section. 79 | 80 | 81 | FreeBSD (experimental) 82 | ====================== 83 | 84 | CMT, MBM and CAT are configured using Model Specific Registers (MSRs) 85 | to measure occupancy, set up the class of service masks and manage 86 | the association of the cores/logical threads to a class of service. 87 | The pqos software executes in user space, and access to the MSRs is 88 | obtained through a standard FreeBSD* cpuctl driver interface. The virtual 89 | file system structure /dev/cpuctlCPUNUM provides an interface to read 90 | and write the MSR registers. The MSR file interface is protected and 91 | requires root privileges. 92 | The cpuctl driver might not be auto-loaded on some systems. Please follow 93 | cpuctl (4) man page to load cpuctl driver on your system. 94 | 95 | $ man 4 cpuctl 96 | 97 | Please note that all project build scripts have been written for GNU Make so 98 | it is required to install GNU Make on FreeBSD in order to compile the project. 99 | 100 | $ pkg install gmake 101 | 102 | For instructions on package installation please see "Installation Steps" 103 | section. Remember to replace "make" with "gmake" on FreeBSD. 104 | 105 | Currently verified configuration is: 106 | - Intel(R) Xeon(R) processor D 107 | - FreeBSD 9.1 108 | - GNU Compiler Collection 5 (gcc 5.3.1) 109 | - GNU Make 4.1 110 | 111 | 112 | Legal Disclaimer 113 | ================ 114 | 115 | THIS SOFTWARE IS PROVIDED BY INTEL"AS IS". NO LICENSE, EXPRESS OR 116 | IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS 117 | ARE GRANTED THROUGH USE. EXCEPT AS PROVIDED IN INTEL'S TERMS AND 118 | CONDITIONS OF SALE, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL 119 | DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR 120 | USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO 121 | FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT 122 | OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. 123 | -------------------------------------------------------------------------------- /pqos/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD LICENSE 3 | * 4 | * Copyright(c) 2014-2017 Intel Corporation. All rights reserved. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * * Neither the name of Intel Corporation nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /** 35 | * @brief Platform QoS utility - main module 36 | */ 37 | 38 | #ifndef __MAIN_H__ 39 | #define __MAIN_H__ 40 | 41 | #ifdef DEBUG 42 | #include 43 | #endif 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * Macros 51 | */ 52 | #ifndef DIM 53 | #define DIM(x) (sizeof(x)/sizeof(x[0])) 54 | #endif 55 | #ifndef MAX 56 | /** 57 | * Macro to return the maximum of two numbers 58 | */ 59 | #define MAX(a, b) ({ \ 60 | typeof(a) _a = (a); \ 61 | typeof(b) _b = (b); \ 62 | _a > _b ? _a : _b; \ 63 | }) 64 | #endif /* !MAX */ 65 | 66 | #ifdef DEBUG 67 | #define ASSERT assert 68 | #else 69 | #define ASSERT(x) 70 | #endif 71 | 72 | #define UNUSED_ARG(_x) ((void)(_x)) 73 | 74 | #define PQOS_MAX_SOCKETS 8 75 | #define PQOS_MAX_L2IDS 32 76 | #define PQOS_MAX_SOCKET_CORES 64 77 | #define PQOS_MAX_CORES (PQOS_MAX_SOCKET_CORES*PQOS_MAX_SOCKETS) 78 | 79 | /** 80 | * Maintains alloc option - allocate cores or task id's 81 | */ 82 | extern int alloc_pid_flag; 83 | 84 | /** 85 | * Selected library interface 86 | */ 87 | extern enum pqos_interface sel_interface; 88 | 89 | /** 90 | * @brief Converts string into 64-bit unsigned number. 91 | * 92 | * Numbers can be in decimal or hexadecimal format. 93 | * 94 | * On error, this functions causes process to exit with FAILURE code. 95 | * 96 | * @param s string to be converted into 64-bit unsigned number 97 | * 98 | * @return Numeric value of the string representing the number 99 | */ 100 | uint64_t 101 | strtouint64(const char *s); 102 | 103 | /** 104 | * @brief Converts string of characters representing list of 105 | * numbers into table of numbers. 106 | * 107 | * Allowed formats are: 108 | * 0,1,2,3 109 | * 0-10,20-18 110 | * 1,3,5-8,10,0x10-12 111 | * 112 | * Numbers can be in decimal or hexadecimal format. 113 | * 114 | * On error, this functions causes process to exit with FAILURE code. 115 | * 116 | * @param s string representing list of unsigned numbers. 117 | * @param tab table to put converted numeric values into 118 | * @param max maximum number of elements that \a tab can accommodate 119 | * 120 | * @return Number of elements placed into \a tab 121 | */ 122 | unsigned 123 | strlisttotab(char *s, uint64_t *tab, const unsigned max); 124 | 125 | /** 126 | * @brief Common function to handle string parsing errors 127 | * 128 | * On error, this function causes process to exit with FAILURE code. 129 | * 130 | * @param arg string that caused error when parsing 131 | * @param note context and information about encountered error 132 | */ 133 | void parse_error(const char *arg, const char *note) __attribute__ ((noreturn)); 134 | 135 | /** 136 | * @brief Duplicates \a arg and stores at \a sel 137 | * 138 | * @param sel place to store duplicate of \a arg 139 | * @param arg string passed through command line option 140 | */ 141 | void selfn_strdup(char **sel, const char *arg); 142 | 143 | 144 | #ifdef __cplusplus 145 | } 146 | #endif 147 | 148 | #endif /* __MAIN_H__ */ 149 | -------------------------------------------------------------------------------- /pqos/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Makefile script for PQoS sample application 3 | # 4 | # @par 5 | # BSD LICENSE 6 | # 7 | # Copyright(c) 2014-2017 Intel Corporation. All rights reserved. 8 | # All rights reserved. 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions 12 | # are met: 13 | # 14 | # * Redistributions of source code must retain the above copyright 15 | # notice, this list of conditions and the following disclaimer. 16 | # * Redistributions in binary form must reproduce the above copyright 17 | # notice, this list of conditions and the following disclaimer in 18 | # the documentation and/or other materials provided with the 19 | # distribution. 20 | # * Neither the name of Intel Corporation nor the names of its 21 | # contributors may be used to endorse or promote products derived 22 | # from this software without specific prior written permission. 23 | # 24 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | # 36 | ############################################################################### 37 | 38 | LIBDIR ?= ../lib 39 | LDFLAGS = -L$(LIBDIR) -pie -z noexecstack -z relro -z now 40 | LDLIBS = -lpqos -lpthread 41 | CFLAGS = -I$(LIBDIR) \ 42 | -W -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes \ 43 | -Wmissing-declarations -Wold-style-definition -Wpointer-arith \ 44 | -Wcast-qual -Wundef -Wwrite-strings \ 45 | -Wformat -Wformat-security -fstack-protector -fPIE -D_FORTIFY_SOURCE=2 \ 46 | -Wunreachable-code -Wsign-compare -Wno-endif-labels 47 | ifneq ($(EXTRA_CFLAGS),) 48 | CFLAGS += $(EXTRA_CFLAGS) 49 | endif 50 | 51 | # ICC and GCC options 52 | ifeq ($(CC),icc) 53 | else 54 | CFLAGS += -Wcast-align \ 55 | -Wnested-externs \ 56 | -Wmissing-noreturn 57 | endif 58 | 59 | # DEBUG build 60 | ifeq ($(DEBUG),y) 61 | CFLAGS += -g -ggdb -O0 -DDEBUG 62 | else 63 | CFLAGS += -g -O2 64 | endif 65 | 66 | # Build targets and dependencies 67 | APP = pqos 68 | MAN = pqos.8 69 | 70 | # XXX: modify as desired 71 | PREFIX ?= /usr/local 72 | BIN_DIR = $(PREFIX)/bin 73 | MAN_DIR = $(PREFIX)/man/man8 74 | 75 | SRCS = $(sort $(wildcard *.c)) 76 | OBJS = $(SRCS:.c=.o) 77 | DEPFILES = $(SRCS:.c=.d) 78 | 79 | all: $(APP) 80 | 81 | $(APP): $(OBJS) 82 | $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ 83 | 84 | %.o: %.c %.d 85 | 86 | %.d: %.c 87 | $(CC) -MM -MP -MF $@ $(CFLAGS) $< 88 | cat $@ | sed 's/$(@:.d=.o)/$@/' >> $@ 89 | 90 | .PHONY: clean install uninstall 91 | 92 | install: $(APP) $(MAN) 93 | ifeq ($(shell uname), FreeBSD) 94 | install -d $(BIN_DIR) 95 | install -d $(MAN_DIR) 96 | install -s $(APP) $(BIN_DIR) 97 | install $(APP)-msr $(BIN_DIR) 98 | install -m 0444 $(MAN) $(MAN_DIR) 99 | ln -f -s $(MAN) $(MAN_DIR)/$(APP)-msr.8 100 | else 101 | install -D -s $(APP) $(BIN_DIR)/$(APP) 102 | install -D $(APP)-msr $(BIN_DIR)/$(APP)-msr 103 | install -D $(APP)-os $(BIN_DIR)/$(APP)-os 104 | install -m 0444 $(MAN) -D $(MAN_DIR)/$(MAN) 105 | ln -f -s $(MAN) $(MAN_DIR)/$(APP)-msr.8 106 | ln -f -s $(MAN) $(MAN_DIR)/$(APP)-os.8 107 | endif 108 | 109 | uninstall: 110 | -rm $(BIN_DIR)/$(APP) 111 | -rm $(MAN_DIR)/$(MAN) 112 | -rm $(BIN_DIR)/$(APP)-msr 113 | -rm $(MAN_DIR)/$(APP)-msr.8 114 | ifneq ($(shell uname), FreeBSD) 115 | -rm $(BIN_DIR)/$(APP)-os 116 | -rm $(MAN_DIR)/$(APP)-os.8 117 | endif 118 | 119 | clean: 120 | -rm -f $(APP) $(OBJS) $(DEPFILES) ./*~ 121 | 122 | CHECKPATCH?=checkpatch.pl 123 | .PHONY: style 124 | style: 125 | $(CHECKPATCH) --no-tree --no-signoff --emacs \ 126 | --ignore CODE_INDENT,INITIALISED_STATIC,LEADING_SPACE,SPLIT_STRING,UNSPECIFIED_INT,ARRAY_SIZE \ 127 | -f main.c -f main.h -f monitor.c -f monitor.h -f alloc.c -f alloc.h -f profiles.c -f profiles.h \ 128 | -f cap.h -f cap.c 129 | 130 | CPPCHECK?=cppcheck 131 | .PHONY: cppcheck 132 | cppcheck: 133 | $(CPPCHECK) --enable=warning,portability,performance,unusedFunction,missingInclude \ 134 | --std=c99 -I$(LIBDIR) --template=gcc \ 135 | main.c main.h alloc.c alloc.h monitor.c monitor.h profiles.c profiles.h \ 136 | cap.h cap.c 137 | 138 | # if target not clean then make dependencies 139 | ifneq ($(MAKECMDGOALS),clean) 140 | -include $(DEPFILES) 141 | endif 142 | -------------------------------------------------------------------------------- /pqos/configs/README: -------------------------------------------------------------------------------- 1 | 2 | ================================================================================ 3 | README for PQoS Utility Configuration files 4 | 5 | July 2016 6 | ================================================================================ 7 | 8 | Contents 9 | ======== 10 | - 1 Overview 11 | - 2 General Settings 12 | - 3 Allocation Settings 13 | - 4 Monitoring Settings 14 | 15 | 16 | ================================================================================ 17 | 1.0 Overview 18 | ================================================================================ 19 | 20 | Configuration files are used to set up the PQoS utility with pre-defined 21 | settings for custom use cases. The "./pqos -f" option is used to 22 | specify a config file to be parsed by the utility on startup. 23 | 24 | - E.g. "./pqos -f path/to/config/example.cfg" 25 | 26 | Found below are a list of settings that can be used to pass options to 27 | the utility. 28 | 29 | 30 | ================================================================================ 31 | 2.0 General Settings 32 | ================================================================================ 33 | 34 | Description: Selects showing current allocation settings 35 | Syntax: show-alloc: 36 | Example: 37 | show-alloc: 38 | 39 | 40 | Description: Selects verbose mode on 41 | Syntax: verbose-mode: 42 | Example: 43 | verbose-mode: 44 | 45 | 46 | Description: Selects log file 47 | Syntax: log-file: 48 | Exmaple: 49 | log-file: /tmp/example.log 50 | 51 | 52 | Description: Selects event monitoring time 53 | Syntax: monitor-time: