#define OBD_FAIL_ONCE CFS_FAIL_ONCE
#define OBD_FAILED CFS_FAILED
-void obd_update_maxusage(void);
-
-#define obd_memory_add(size) \
- lprocfs_counter_add(obd_memory, OBD_MEMORY_STAT, (long)(size))
-#define obd_memory_sub(size) \
- lprocfs_counter_sub(obd_memory, OBD_MEMORY_STAT, (long)(size))
-#define obd_memory_sum() \
- lprocfs_stats_collector(obd_memory, OBD_MEMORY_STAT, \
- LPROCFS_FIELDS_FLAGS_SUM)
-#define obd_pages_add(order) \
- lprocfs_counter_add(obd_memory, OBD_MEMORY_PAGES_STAT, \
- (long)(1 << (order)))
-#define obd_pages_sub(order) \
- lprocfs_counter_sub(obd_memory, OBD_MEMORY_PAGES_STAT, \
- (long)(1 << (order)))
-#define obd_pages_sum() \
- lprocfs_stats_collector(obd_memory, OBD_MEMORY_PAGES_STAT, \
- LPROCFS_FIELDS_FLAGS_SUM)
-
-__u64 obd_memory_max(void);
-__u64 obd_pages_max(void);
-
-#define OBD_DEBUG_MEMUSAGE (1)
-
-#if OBD_DEBUG_MEMUSAGE
-#define OBD_ALLOC_POST(ptr, size, name) \
- obd_memory_add(size); \
- CDEBUG(D_MALLOC, name " '" #ptr "': %d at %p.\n", \
- (int)(size), ptr)
-
-#define OBD_FREE_PRE(ptr, size, name) \
- LASSERT(ptr); \
- obd_memory_sub(size); \
- CDEBUG(D_MALLOC, name " '" #ptr "': %d at %p.\n", \
- (int)(size), ptr); \
- POISON(ptr, 0x5a, size)
-
-#else /* !OBD_DEBUG_MEMUSAGE */
-
-#define OBD_ALLOC_POST(ptr, size, name) ((void)0)
-#define OBD_FREE_PRE(ptr, size, name) ((void)0)
-
-#endif /* !OBD_DEBUG_MEMUSAGE */
-
#ifdef CONFIG_DEBUG_SLAB
#define POISON(ptr, c, s) do {} while (0)
#define POISON_PTR(ptr) ((void)0)
kmem_cache_alloc(slab, type | __GFP_ZERO) : \
kmem_cache_alloc_node(slab, type | __GFP_ZERO, \
cfs_cpt_spread_node(cptab, cpt)); \
- if (likely(ptr)) \
- OBD_ALLOC_POST(ptr, size, "slab-alloced"); \
} while (0)
#define OBD_SLAB_ALLOC_GFP(ptr, slab, size, flags) \
#define OBD_SLAB_FREE(ptr, slab, size) \
do { \
- OBD_FREE_PRE(ptr, size, "slab-freed"); \
kmem_cache_free(slab, ptr); \
POISON_PTR(ptr); \
} while (0)
(ptr) = (cptab) == NULL ? \
alloc_page(gfp_mask) : \
alloc_pages_node(cfs_cpt_spread_node(cptab, cpt), gfp_mask, 0);\
- if (unlikely((ptr) == NULL)) { \
- CERROR("alloc_pages of '" #ptr "' %d page(s) / %llu bytes "\
- "failed\n", (int)1, \
- (__u64)(1 << PAGE_CACHE_SHIFT)); \
- CERROR("%llu total bytes and %llu total pages " \
- "(%llu bytes) allocated by Lustre\n", \
- obd_memory_sum(), \
- obd_pages_sum() << PAGE_CACHE_SHIFT, \
- obd_pages_sum()); \
- } else { \
- obd_pages_add(0); \
+ if (ptr) { \
CDEBUG(D_MALLOC, "alloc_pages '" #ptr "': %d page(s) / " \
"%llu bytes at %p.\n", \
(int)1, \
#define OBD_PAGE_FREE(ptr) \
do { \
LASSERT(ptr); \
- obd_pages_sub(0); \
CDEBUG(D_MALLOC, "free_pages '" #ptr "': %d page(s) / %llu bytes " \
"at %p.\n", \
(int)1, (__u64)(1 << PAGE_CACHE_SHIFT), \
struct list_head obd_types;
DEFINE_RWLOCK(obd_dev_lock);
-__u64 obd_max_pages;
-EXPORT_SYMBOL(obd_max_pages);
-__u64 obd_max_alloc;
-EXPORT_SYMBOL(obd_max_alloc);
-__u64 obd_alloc;
-EXPORT_SYMBOL(obd_alloc);
-__u64 obd_pages;
-EXPORT_SYMBOL(obd_pages);
-static DEFINE_SPINLOCK(obd_updatemax_lock);
-
/* The following are visible and mutable through /proc/sys/lustre/. */
unsigned int obd_debug_peer_on_timeout;
EXPORT_SYMBOL(obd_debug_peer_on_timeout);
return err;
}
-void obd_update_maxusage(void)
-{
- __u64 max1, max2;
-
- max1 = obd_pages_sum();
- max2 = obd_memory_sum();
-
- spin_lock(&obd_updatemax_lock);
- if (max1 > obd_max_pages)
- obd_max_pages = max1;
- if (max2 > obd_max_alloc)
- obd_max_alloc = max2;
- spin_unlock(&obd_updatemax_lock);
-}
-EXPORT_SYMBOL(obd_update_maxusage);
-
-__u64 obd_memory_max(void)
-{
- __u64 ret;
-
- spin_lock(&obd_updatemax_lock);
- ret = obd_max_alloc;
- spin_unlock(&obd_updatemax_lock);
-
- return ret;
-}
-EXPORT_SYMBOL(obd_memory_max);
-
-__u64 obd_pages_max(void)
-{
- __u64 ret;
-
- spin_lock(&obd_updatemax_lock);
- ret = obd_max_pages;
- spin_unlock(&obd_updatemax_lock);
-
- return ret;
-}
-EXPORT_SYMBOL(obd_pages_max);
-
/* liblustre doesn't call cleanup_obdclass, apparently. we carry on in this
* ifdef to the end of the file to cover module and versioning goo.*/
static void cleanup_obdclass(void)
{
int i;
int lustre_unregister_fs(void);
- __u64 memory_leaked, pages_leaked;
- __u64 memory_max, pages_max;
lustre_unregister_fs();
class_exit_uuidlist();
obd_zombie_impexp_stop();
- memory_leaked = obd_memory_sum();
- pages_leaked = obd_pages_sum();
-
- memory_max = obd_memory_max();
- pages_max = obd_pages_max();
-
lprocfs_free_stats(&obd_memory);
- CDEBUG((memory_leaked) ? D_ERROR : D_INFO,
- "obd_memory max: %llu, leaked: %llu\n",
- memory_max, memory_leaked);
- CDEBUG((pages_leaked) ? D_ERROR : D_INFO,
- "obd_memory_pages max: %llu, leaked: %llu\n",
- pages_max, pages_leaked);
}
MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");