aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mps
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2018-01-21 15:42:36 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2018-01-21 15:42:36 +0000
commitac2fffa4b74cd83963f0d462c379c7f50eeabf20 (patch)
tree1f8fc635121499d467998c99ece5983a2d563840 /sys/dev/mps
parente09304d8f33887be9cc37817885061ccbb770d50 (diff)
downloadsrc-ac2fffa4b74cd83963f0d462c379c7f50eeabf20.tar.gz
src-ac2fffa4b74cd83963f0d462c379c7f50eeabf20.zip
Revert r327828, r327949, r327953, r328016-r328026, r328041:
Uses of mallocarray(9). The use of mallocarray(9) has rocketed the required swap to build FreeBSD. This is likely caused by the allocation size attributes which put extra pressure on the compiler. Given that most of these checks are superfluous we have to choose better where to use mallocarray(9). We still have more uses of mallocarray(9) but hopefully this is enough to bring swap usage to a reasonable level. Reported by: wosch PR: 225197
Notes
Notes: svn path=/head/; revision=328218
Diffstat (limited to 'sys/dev/mps')
-rw-r--r--sys/dev/mps/mps.c4
-rw-r--r--sys/dev/mps/mps_mapping.c20
2 files changed, 12 insertions, 12 deletions
diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c
index ee26c84c2ac1..2f684bdd3c6e 100644
--- a/sys/dev/mps/mps.c
+++ b/sys/dev/mps/mps.c
@@ -1164,12 +1164,12 @@ static int
mps_alloc_queues(struct mps_softc *sc)
{
struct mps_queue *q;
- u_int nq, i;
+ int nq, i;
nq = sc->msi_msgs;
mps_dprint(sc, MPS_INIT|MPS_XINFO, "Allocating %d I/O queues\n", nq);
- sc->queues = mallocarray(nq, sizeof(struct mps_queue), M_MPT2,
+ sc->queues = malloc(sizeof(struct mps_queue) * nq, M_MPT2,
M_NOWAIT|M_ZERO);
if (sc->queues == NULL)
return (ENOMEM);
diff --git a/sys/dev/mps/mps_mapping.c b/sys/dev/mps/mps_mapping.c
index cda8ee2cce18..9330288acd06 100644
--- a/sys/dev/mps/mps_mapping.c
+++ b/sys/dev/mps/mps_mapping.c
@@ -1694,27 +1694,27 @@ mps_mapping_allocate_memory(struct mps_softc *sc)
{
uint32_t dpm_pg0_sz;
- sc->mapping_table = mallocarray(sc->max_devices,
- sizeof(struct dev_mapping_table), M_MPT2, M_ZERO|M_NOWAIT);
+ sc->mapping_table = malloc((sizeof(struct dev_mapping_table) *
+ sc->max_devices), M_MPT2, M_ZERO|M_NOWAIT);
if (!sc->mapping_table)
goto free_resources;
- sc->removal_table = mallocarray(sc->max_devices,
- sizeof(struct map_removal_table), M_MPT2, M_ZERO|M_NOWAIT);
+ sc->removal_table = malloc((sizeof(struct map_removal_table) *
+ sc->max_devices), M_MPT2, M_ZERO|M_NOWAIT);
if (!sc->removal_table)
goto free_resources;
- sc->enclosure_table = mallocarray(sc->max_enclosures,
- sizeof(struct enc_mapping_table), M_MPT2, M_ZERO|M_NOWAIT);
+ sc->enclosure_table = malloc((sizeof(struct enc_mapping_table) *
+ sc->max_enclosures), M_MPT2, M_ZERO|M_NOWAIT);
if (!sc->enclosure_table)
goto free_resources;
- sc->dpm_entry_used = mallocarray(sc->max_dpm_entries, sizeof(u8),
+ sc->dpm_entry_used = malloc((sizeof(u8) * sc->max_dpm_entries),
M_MPT2, M_ZERO|M_NOWAIT);
if (!sc->dpm_entry_used)
goto free_resources;
- sc->dpm_flush_entry = mallocarray(sc->max_dpm_entries, sizeof(u8),
+ sc->dpm_flush_entry = malloc((sizeof(u8) * sc->max_dpm_entries),
M_MPT2, M_ZERO|M_NOWAIT);
if (!sc->dpm_flush_entry)
goto free_resources;
@@ -2451,7 +2451,7 @@ mps_mapping_topology_change_event(struct mps_softc *sc,
if (!num_entries)
goto out;
- phy_change = mallocarray(num_entries, sizeof(struct _map_phy_change),
+ phy_change = malloc(sizeof(struct _map_phy_change) * num_entries,
M_MPT2, M_NOWAIT|M_ZERO);
topo_change.phy_details = phy_change;
if (!phy_change)
@@ -2492,7 +2492,7 @@ mps_mapping_ir_config_change_event(struct mps_softc *sc,
struct dev_mapping_table *mt_entry;
u16 element_flags;
- wwid_table = mallocarray(event_data->NumElements, sizeof(u64), M_MPT2,
+ wwid_table = malloc(sizeof(u64) * event_data->NumElements, M_MPT2,
M_NOWAIT | M_ZERO);
if (!wwid_table)
goto out;