mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-10 01:16:18 +00:00
lib: add intel_get_total_swap_mb
Test that try to exercise the swap paths need to check whether swap is available, otherwise they'll just oom. Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
7132d0f977
commit
1a9fa8fd12
@ -106,3 +106,24 @@ intel_get_total_ram_mb(void)
|
||||
|
||||
return retval / (1024*1024);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
intel_get_total_swap_mb(void)
|
||||
{
|
||||
uint64_t retval;
|
||||
|
||||
#ifdef HAVE_STRUCT_SYSINFO_TOTALRAM /* Linux */
|
||||
struct sysinfo sysinf;
|
||||
int ret;
|
||||
|
||||
ret = sysinfo(&sysinf);
|
||||
assert(ret == 0);
|
||||
|
||||
retval = sysinf.totalswap;
|
||||
retval *= sysinf.mem_unit;
|
||||
#else
|
||||
#error "Unknown how to get swap size for this OS"
|
||||
#endif
|
||||
|
||||
return retval / (1024*1024);
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ struct pci_device *intel_get_pci_device(void);
|
||||
uint32_t intel_get_drm_devid(int fd);
|
||||
int intel_gen(uint32_t devid);
|
||||
uint64_t intel_get_total_ram_mb(void);
|
||||
uint64_t intel_get_total_swap_mb(void);
|
||||
|
||||
void intel_map_file(char *);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user