From efcd79a883caddea4a20bfc771da31ecc6ce4ca2 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 3 Dec 2014 14:56:32 -0500 Subject: [PATCH] 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 --- include/sys/spa.h | 1 + include/sys/zfs_context.h | 2 +- module/nvpair/nvpair_alloc_spl.c | 4 ++-- module/zfs/ddt.c | 2 +- module/zfs/dmu.c | 3 +-- module/zfs/dnode.c | 3 +-- module/zfs/dsl_scan.c | 2 +- module/zfs/spa.c | 2 +- module/zfs/spa_config.c | 4 ++-- module/zfs/spa_misc.c | 2 +- module/zfs/vdev.c | 2 +- module/zfs/zfs_ioctl.c | 11 +++++------ module/zfs/zfs_vfsops.c | 2 +- module/zfs/zfs_znode.c | 2 +- module/zfs/zil.c | 5 ++--- module/zfs/zio.c | 5 ++--- module/zfs/zpl_file.c | 4 ++-- 17 files changed, 26 insertions(+), 30 deletions(-) diff --git a/include/sys/spa.h b/include/sys/spa.h index 1faf0420f2..c989c0b35c 100644 --- a/include/sys/spa.h +++ b/include/sys/spa.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index 1487a99f4a..dd02e6f1bc 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -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 diff --git a/module/nvpair/nvpair_alloc_spl.c b/module/nvpair/nvpair_alloc_spl.c index a75b4a6c7f..f9055b94f1 100644 --- a/module/nvpair/nvpair_alloc_spl.c +++ b/module/nvpair/nvpair_alloc_spl.c @@ -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 * diff --git a/module/zfs/ddt.c b/module/zfs/ddt.c index 0ce8ca1a98..3ecb539093 100644 --- a/module/zfs/ddt.c +++ b/module/zfs/ddt.c @@ -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); diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 98defa3bbf..607da887b0 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -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); diff --git a/module/zfs/dnode.c b/module/zfs/dnode.c index 0a87aa9b15..e5c212cc0b 100644 --- a/module/zfs/dnode.c +++ b/module/zfs/dnode.c @@ -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++) { diff --git a/module/zfs/dsl_scan.c b/module/zfs/dsl_scan.c index 0e16002b37..ebb6305eb1 100644 --- a/module/zfs/dsl_scan.c +++ b/module/zfs/dsl_scan.c @@ -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)); diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 776beda117..88641603ab 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -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) diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c index a08456d56f..818a4308f1 100644 --- a/module/zfs/spa_config.c +++ b/module/zfs/spa_config.c @@ -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, diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index 2a2e72d5a3..363f982feb 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -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); diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 37ce492973..18a246c333 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -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)); diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index 5fb407900a..7d443ecf18 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -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) { diff --git a/module/zfs/zfs_vfsops.c b/module/zfs/zfs_vfsops.c index d67f11eca0..d29fc6560a 100644 --- a/module/zfs/zfs_vfsops.c +++ b/module/zfs/zfs_vfsops.c @@ -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; diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c index f02c02184b..b51d780375 100644 --- a/module/zfs/zfs_znode.c +++ b/module/zfs/zfs_znode.c @@ -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; diff --git a/module/zfs/zil.c b/module/zfs/zil.c index 6ee6c9868e..1d8e7cb4d1 100644 --- a/module/zfs/zil.c +++ b/module/zfs/zil.c @@ -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); } /* diff --git a/module/zfs/zio.c b/module/zfs/zio.c index 7c0e6bf7e8..d7c8458f47 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -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 diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c index 61005dcd4f..1f4f219ed5 100644 --- a/module/zfs/zpl_file.c +++ b/module/zfs/zpl_file.c @@ -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);