int obd_alloc_fail(const void *ptr, const char *name, const char *type, size_t size, const char *file, int line) { if (ptr == NULL || (cfs_rand() & OBD_ALLOC_FAIL_MASK) < obd_alloc_fail_rate) { CERROR("%s%salloc of %s ("LPU64" bytes) failed at %s:%d\n", ptr ? "force " :"", type, name, (__u64)size, file, line); CERROR(LPU64" total bytes and "LPU64" total pages " "("LPU64" bytes) allocated by Lustre, " "%d total bytes by LNET\n", obd_memory_sum(), obd_pages_sum() << CFS_PAGE_SHIFT, obd_pages_sum(), cfs_atomic_read(&libcfs_kmemory)); return 1; } return 0; }
void obd_update_maxusage() { __u64 max1, max2; max1 = obd_pages_sum(); max2 = obd_memory_sum(); cfs_spin_lock(&obd_updatemax_lock); if (max1 > obd_max_pages) obd_max_pages = max1; if (max2 > obd_max_alloc) obd_max_alloc = max2; cfs_spin_unlock(&obd_updatemax_lock); }
int LL_PROC_PROTO(proc_pages_alloc) { char buf[22]; int len; if (!*lenp || (*ppos && !write)) { *lenp = 0; return 0; } if (write) return -EINVAL; len = snprintf(buf, sizeof(buf), LPU64"\n", obd_pages_sum()); if (len > *lenp) len = *lenp; buf[len] = '\0'; if (copy_to_user(buffer, buf, len)) return -EFAULT; *lenp = len; *ppos += *lenp; return 0; }
static int proc_pages_alloc(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { char buf[22]; int len; if (!*lenp || (*ppos && !write)) { *lenp = 0; return 0; } if (write) return -EINVAL; len = snprintf(buf, sizeof(buf), "%llu\n", obd_pages_sum()); if (len > *lenp) len = *lenp; buf[len] = '\0'; if (copy_to_user(buffer, buf, len)) return -EFAULT; *lenp = len; *ppos += *lenp; return 0; }