resctrlfs.c (a3611fbc6e58c147bdd409b356baf15ddf57271e) | resctrlfs.c (ee0415681eb661efa1eb2db7acc263f2c7df1e23) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Basic resctrl file system operations 4 * 5 * Copyright (C) 2018 Intel Corporation 6 * 7 * Authors: 8 * Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>, --- 592 unchanged lines hidden (view full) --- 601 602 return NULL; 603} 604 605/* 606 * validate_resctrl_feature_request - Check if requested feature is valid. 607 * @resctrl_val: Requested feature 608 * | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Basic resctrl file system operations 4 * 5 * Copyright (C) 2018 Intel Corporation 6 * 7 * Authors: 8 * Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>, --- 592 unchanged lines hidden (view full) --- 601 602 return NULL; 603} 604 605/* 606 * validate_resctrl_feature_request - Check if requested feature is valid. 607 * @resctrl_val: Requested feature 608 * |
609 * Return: 0 on success, non-zero on failure | 609 * Return: True if the feature is supported, else false |
610 */ | 610 */ |
611bool validate_resctrl_feature_request(char *resctrl_val) | 611bool validate_resctrl_feature_request(const char *resctrl_val) |
612{ | 612{ |
613 FILE *inf = fopen("/proc/cpuinfo", "r"); | 613 struct stat statbuf; |
614 bool found = false; 615 char *res; | 614 bool found = false; 615 char *res; |
616 FILE *inf; |
|
616 | 617 |
617 if (!inf) | 618 if (!resctrl_val) |
618 return false; 619 | 619 return false; 620 |
620 res = fgrep(inf, "flags"); | 621 if (remount_resctrlfs(false)) 622 return false; |
621 | 623 |
622 if (res) { 623 char *s = strchr(res, ':'); | 624 if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) { 625 if (!stat(L3_PATH, &statbuf)) 626 return true; 627 } else if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { 628 if (!stat(MB_PATH, &statbuf)) 629 return true; 630 } else if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || 631 !strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { 632 if (!stat(L3_MON_PATH, &statbuf)) { 633 inf = fopen(L3_MON_FEATURES_PATH, "r"); 634 if (!inf) 635 return false; |
624 | 636 |
625 found = s && !strstr(s, resctrl_val); 626 free(res); | 637 if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { 638 res = fgrep(inf, "llc_occupancy"); 639 if (res) { 640 found = true; 641 free(res); 642 } 643 } 644 645 if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { 646 res = fgrep(inf, "mbm_total_bytes"); 647 if (res) { 648 free(res); 649 res = fgrep(inf, "mbm_local_bytes"); 650 if (res) { 651 found = true; 652 free(res); 653 } 654 } 655 } 656 fclose(inf); 657 } |
627 } | 658 } |
628 fclose(inf); | |
629 630 return found; 631} 632 633int filter_dmesg(void) 634{ 635 char line[1024]; 636 FILE *fp; --- 77 unchanged lines hidden --- | 659 660 return found; 661} 662 663int filter_dmesg(void) 664{ 665 char line[1024]; 666 FILE *fp; --- 77 unchanged lines hidden --- |