Retire KM_NODEBUG

Callers of kmem_alloc() which passed the KM_NODEBUG flag to suppress
the large allocation warning have been replaced by vmem_alloc() as
appropriate.  The updated vmem_alloc() call will not print a warning
regardless of the size of the allocation.

A careful reader will notice that not all callers have been changed
to vmem_alloc().  Some have only had the KM_NODEBUG flag removed.
This was possible because the default warning threshold has been
increased to 32k.  This is desirable because it minimizes the need
for Linux specific code changes.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf 2014-12-03 14:56:32 -05:00
parent 71f8548ea4
commit efcd79a883
17 changed files with 26 additions and 30 deletions

View File

@ -29,6 +29,7 @@
#include <sys/avl.h>
#include <sys/zfs_context.h>
#include <sys/kstat.h>
#include <sys/nvpair.h>
#include <sys/sysmacros.h>
#include <sys/types.h>

View File

@ -41,6 +41,7 @@
#include <sys/bitmap.h>
#include <sys/cmn_err.h>
#include <sys/kmem.h>
#include <sys/vmem.h>
#include <sys/taskq.h>
#include <sys/buf.h>
#include <sys/param.h>
@ -391,7 +392,6 @@ extern void kstat_set_raw_ops(kstat_t *ksp,
#define KM_SLEEP UMEM_NOFAIL
#define KM_PUSHPAGE KM_SLEEP
#define KM_NOSLEEP UMEM_DEFAULT
#define KM_NODEBUG 0x0
#define KMC_NODEBUG UMC_NODEBUG
#define KMC_KMEM 0x0
#define KMC_VMEM 0x0

View File

@ -30,13 +30,13 @@
static void *
nv_alloc_sleep_spl(nv_alloc_t *nva, size_t size)
{
return (kmem_alloc(size, KM_SLEEP | KM_NODEBUG));
return (kmem_alloc(size, KM_SLEEP));
}
static void *
nv_alloc_pushpage_spl(nv_alloc_t *nva, size_t size)
{
return (kmem_alloc(size, KM_PUSHPAGE | KM_NODEBUG));
return (kmem_alloc(size, KM_PUSHPAGE));
}
static void *

View File

@ -834,7 +834,7 @@ ddt_table_alloc(spa_t *spa, enum zio_checksum c)
{
ddt_t *ddt;
ddt = kmem_cache_alloc(ddt_cache, KM_PUSHPAGE | KM_NODEBUG);
ddt = kmem_cache_alloc(ddt_cache, KM_PUSHPAGE);
bzero(ddt, sizeof (ddt_t));
mutex_init(&ddt->ddt_lock, NULL, MUTEX_DEFAULT, NULL);

View File

@ -417,8 +417,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length,
}
nblks = 1;
}
dbp = kmem_zalloc(sizeof (dmu_buf_t *) * nblks,
KM_PUSHPAGE | KM_NODEBUG);
dbp = kmem_zalloc(sizeof (dmu_buf_t *) * nblks, KM_PUSHPAGE);
zio = zio_root(dn->dn_objset->os_spa, NULL, NULL, ZIO_FLAG_CANFAIL);
blkid = dbuf_whichblock(dn, offset);

View File

@ -1070,8 +1070,7 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag,
int i;
dnode_children_t *winner;
children_dnodes = kmem_alloc(sizeof (dnode_children_t) +
(epb - 1) * sizeof (dnode_handle_t),
KM_PUSHPAGE | KM_NODEBUG);
(epb - 1) * sizeof (dnode_handle_t), KM_PUSHPAGE);
children_dnodes->dnc_count = epb;
dnh = &children_dnodes->dnc_children[0];
for (i = 0; i < epb; i++) {

View File

@ -262,7 +262,7 @@ dsl_scan_setup_sync(void *arg, dmu_tx_t *tx)
if (dp->dp_blkstats == NULL) {
dp->dp_blkstats = kmem_alloc(sizeof (zfs_all_blkstats_t),
KM_PUSHPAGE | KM_NODEBUG);
KM_PUSHPAGE);
}
bzero(dp->dp_blkstats, sizeof (zfs_all_blkstats_t));

View File

@ -1586,7 +1586,7 @@ load_nvlist(spa_t *spa, uint64_t obj, nvlist_t **value)
nvsize = *(uint64_t *)db->db_data;
dmu_buf_rele(db, FTAG);
packed = kmem_alloc(nvsize, KM_PUSHPAGE | KM_NODEBUG);
packed = kmem_alloc(nvsize, KM_PUSHPAGE);
error = dmu_read(spa->spa_meta_objset, obj, 0, nvsize, packed,
DMU_READ_PREFETCH);
if (error == 0)

View File

@ -102,7 +102,7 @@ spa_config_load(void)
if (kobj_get_filesize(file, &fsize) != 0)
goto out;
buf = kmem_alloc(fsize, KM_PUSHPAGE | KM_NODEBUG);
buf = kmem_alloc(fsize, KM_PUSHPAGE);
/*
* Read the nvlist from the file.
@ -165,7 +165,7 @@ spa_config_write(spa_config_dirent_t *dp, nvlist_t *nvl)
*/
VERIFY(nvlist_size(nvl, &buflen, NV_ENCODE_XDR) == 0);
buf = kmem_alloc(buflen, KM_PUSHPAGE | KM_NODEBUG);
buf = kmem_alloc(buflen, KM_PUSHPAGE);
temp = kmem_zalloc(MAXPATHLEN, KM_PUSHPAGE);
VERIFY(nvlist_pack(nvl, &buf, &buflen, NV_ENCODE_XDR,

View File

@ -520,7 +520,7 @@ spa_add(const char *name, nvlist_t *config, const char *altroot)
ASSERT(MUTEX_HELD(&spa_namespace_lock));
spa = kmem_zalloc(sizeof (spa_t), KM_PUSHPAGE | KM_NODEBUG);
spa = kmem_zalloc(sizeof (spa_t), KM_PUSHPAGE);
mutex_init(&spa->spa_async_lock, NULL, MUTEX_DEFAULT, NULL);
mutex_init(&spa->spa_errlist_lock, NULL, MUTEX_DEFAULT, NULL);

View File

@ -856,7 +856,7 @@ vdev_metaslab_init(vdev_t *vd, uint64_t txg)
ASSERT(oldc <= newc);
mspp = kmem_zalloc(newc * sizeof (*mspp), KM_PUSHPAGE | KM_NODEBUG);
mspp = kmem_zalloc(newc * sizeof (*mspp), KM_PUSHPAGE);
if (oldc != 0) {
bcopy(vd->vdev_ms, mspp, oldc * sizeof (*mspp));

View File

@ -311,7 +311,7 @@ history_str_get(zfs_cmd_t *zc)
if (zc->zc_history == 0)
return (NULL);
buf = kmem_alloc(HIS_MAX_RECORD_LEN, KM_SLEEP | KM_NODEBUG);
buf = kmem_alloc(HIS_MAX_RECORD_LEN, KM_SLEEP);
if (copyinstr((void *)(uintptr_t)zc->zc_history,
buf, HIS_MAX_RECORD_LEN, NULL) != 0) {
history_str_free(buf);
@ -1328,7 +1328,7 @@ get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp)
if (size == 0)
return (SET_ERROR(EINVAL));
packed = kmem_alloc(size, KM_SLEEP | KM_NODEBUG);
packed = kmem_alloc(size, KM_SLEEP);
if ((error = ddi_copyin((void *)(uintptr_t)nvl, packed, size,
iflag)) != 0) {
@ -2443,8 +2443,7 @@ zfs_prop_set_special(const char *dsname, zprop_source_t source,
if (err == 0 && intval >= ZPL_VERSION_USERSPACE) {
zfs_cmd_t *zc;
zc = kmem_zalloc(sizeof (zfs_cmd_t),
KM_SLEEP | KM_NODEBUG);
zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
(void) strcpy(zc->zc_name, dsname);
(void) zfs_ioc_userspace_upgrade(zc);
kmem_free(zc, sizeof (zfs_cmd_t));
@ -3875,7 +3874,7 @@ zfs_check_clearable(char *dataset, nvlist_t *props, nvlist_t **errlist)
VERIFY(nvlist_alloc(&errors, NV_UNIQUE_NAME, KM_SLEEP) == 0);
zc = kmem_alloc(sizeof (zfs_cmd_t), KM_SLEEP | KM_NODEBUG);
zc = kmem_alloc(sizeof (zfs_cmd_t), KM_SLEEP);
(void) strcpy(zc->zc_name, dataset);
pair = nvlist_next_nvpair(props, NULL);
while (pair != NULL) {
@ -5748,7 +5747,7 @@ zfsdev_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
if (vec->zvec_func == NULL && vec->zvec_legacy_func == NULL)
return (-SET_ERROR(EINVAL));
zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP | KM_NODEBUG);
zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
error = ddi_copyin((void *)arg, zc, sizeof (zfs_cmd_t), flag);
if (error != 0) {

View File

@ -653,7 +653,7 @@ zfs_sb_create(const char *osname, zfs_sb_t **zsbp)
int i, error;
uint64_t sa_obj;
zsb = kmem_zalloc(sizeof (zfs_sb_t), KM_SLEEP | KM_NODEBUG);
zsb = kmem_zalloc(sizeof (zfs_sb_t), KM_SLEEP);
/*
* We claim to always be readonly so we can open snapshots;

View File

@ -1702,7 +1702,7 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
rootzp->z_atime_dirty = 0;
rootzp->z_is_sa = USE_SA(version, os);
zsb = kmem_zalloc(sizeof (zfs_sb_t), KM_PUSHPAGE | KM_NODEBUG);
zsb = kmem_zalloc(sizeof (zfs_sb_t), KM_PUSHPAGE);
zsb->z_os = os;
zsb->z_parent = zsb;
zsb->z_version = version;

View File

@ -1192,8 +1192,7 @@ zil_itx_create(uint64_t txtype, size_t lrsize)
lrsize = P2ROUNDUP_TYPED(lrsize, sizeof (uint64_t), size_t);
itx = kmem_alloc(offsetof(itx_t, itx_lr) + lrsize,
KM_PUSHPAGE | KM_NODEBUG);
itx = vmem_alloc(offsetof(itx_t, itx_lr) + lrsize, KM_PUSHPAGE);
itx->itx_lr.lrc_txtype = txtype;
itx->itx_lr.lrc_reclen = lrsize;
itx->itx_sod = lrsize; /* if write & WR_NEED_COPY will be increased */
@ -1208,7 +1207,7 @@ zil_itx_create(uint64_t txtype, size_t lrsize)
void
zil_itx_destroy(itx_t *itx)
{
kmem_free(itx, offsetof(itx_t, itx_lr) + itx->itx_lr.lrc_reclen);
vmem_free(itx, offsetof(itx_t, itx_lr) + itx->itx_lr.lrc_reclen);
}
/*

View File

@ -246,7 +246,7 @@ zio_buf_alloc(size_t size)
ASSERT3U(c, <, SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT);
return (kmem_cache_alloc(zio_buf_cache[c], KM_PUSHPAGE | KM_NODEBUG));
return (kmem_cache_alloc(zio_buf_cache[c], KM_PUSHPAGE));
}
/*
@ -262,8 +262,7 @@ zio_data_buf_alloc(size_t size)
ASSERT(c < SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT);
return (kmem_cache_alloc(zio_data_buf_cache[c],
KM_PUSHPAGE | KM_NODEBUG));
return (kmem_cache_alloc(zio_data_buf_cache[c], KM_PUSHPAGE));
}
void

View File

@ -248,7 +248,7 @@ zpl_aio_read(struct kiocb *kiocb, const struct iovec *iovp,
size_t count = kiocb->ki_nbytes;
ssize_t read;
size_t alloc_size = sizeof (struct iovec) * nr_segs;
struct iovec *iov_tmp = kmem_alloc(alloc_size, KM_SLEEP | KM_NODEBUG);
struct iovec *iov_tmp = kmem_alloc(alloc_size, KM_SLEEP);
bcopy(iovp, iov_tmp, alloc_size);
ASSERT(iovp);
@ -325,7 +325,7 @@ zpl_aio_write(struct kiocb *kiocb, const struct iovec *iovp,
size_t count = kiocb->ki_nbytes;
ssize_t wrote;
size_t alloc_size = sizeof (struct iovec) * nr_segs;
struct iovec *iov_tmp = kmem_alloc(alloc_size, KM_SLEEP | KM_NODEBUG);
struct iovec *iov_tmp = kmem_alloc(alloc_size, KM_SLEEP);
bcopy(iovp, iov_tmp, alloc_size);
ASSERT(iovp);