1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-13 03:08:58 +00:00

Hardware Monitor: Add support for GPU device utilization readings from sysfs (AMD on Linux)

This commit is contained in:
Jens Steube 2021-06-07 09:34:34 +02:00
parent 1697bcd809
commit e8ad343153
2 changed files with 67 additions and 0 deletions

View File

@ -42,6 +42,7 @@
- AES Crypt Plugin: Reduced max password length from 256 to 128 which improved performance by 22%
- CUDA Backend: Do not warn about missing CUDA SDK installation if --stdout is used
- Folder Management: Add support for XDG Base Directory specification if hashcat was installed using make install
- Hardware Monitor: Add support for GPU device utilization readings from sysfs (AMD on Linux)
- OpenCL Backend: Use CL_DEVICE_BOARD_NAME_AMD instead of CL_DEVICE_NAME for device name in case OpenCL runtime supports this query
- Performance Monitor: Add -S as a user suggestion to improve cracking performance in specific attack configurations
- RAR3-p (Compressed): Fix workaround in unrar library in AES constant table generation to enable multi-threading support

View File

@ -394,6 +394,57 @@ static int hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx_t *hashcat_ctx, const int backe
return 0;
}
static int hm_SYSFS_get_gpu_busy_percent (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx, int *val)
{
char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx);
if (syspath == NULL) return -1;
char *path;
hc_asprintf (&path, "%s/gpu_busy_percent", syspath);
hcfree (syspath);
HCFILE fp;
if (hc_fopen (&fp, path, "r") == false)
{
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
hcfree (path);
return -1;
}
int util = 0;
while (!hc_feof (&fp))
{
char buf[HCBUFSIZ_TINY];
char *ptr = hc_fgets (buf, sizeof (buf), &fp);
if (ptr == NULL) continue;
size_t len = strlen (ptr);
if (len < 1) continue;
int rc = sscanf (ptr, "%d", &util);
if (rc == 1) break;
}
hc_fclose (&fp);
*val = util;
hcfree (path);
return 0;
}
// nvml functions
static int nvml_init (hashcat_ctx_t *hashcat_ctx)
@ -1896,6 +1947,20 @@ int hm_get_utilization_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int b
return PMActivity.iActivityPercent;
}
if (hwmon_ctx->hm_sysfs)
{
int util;
if (hm_SYSFS_get_gpu_busy_percent (hashcat_ctx, backend_device_idx, &util) == -1)
{
hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
return -1;
}
return util;
}
}
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
@ -2575,6 +2640,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
hm_adapters_sysfs[device_id].fanpolicy_get_supported = true;
hm_adapters_sysfs[device_id].memoryspeed_get_supported = true;
hm_adapters_sysfs[device_id].temperature_get_supported = true;
hm_adapters_sysfs[device_id].utilization_get_supported = true;
}
}
}