aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaeseok Youn <daeseok.youn@gmail.com>2014-03-19 19:20:51 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-03-19 21:53:35 -0400
commit60140462904825f17766efd4edf996e888846c2d (patch)
tree4fc34ec0600f9b3fcfc6867ac09da0b8f09fd1c9
parent120ee599b5bf4273992ef9c6ac2a316cc3630969 (diff)
staging: unisys: replace kzalloc/kfree with UISMALLOC/UISFREE
It doesn't need to trace status of buffer when buffers are allocated/deallocated. So stuff of tracing memory status are removed. And also UISMALLOC/UISFREE macro are removed completetly. just use kzalloc/kfree. Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/unisys/include/uisutils.h6
-rw-r--r--drivers/staging/unisys/uislib/uislib.c107
-rw-r--r--drivers/staging/unisys/uislib/uisutils.c5
3 files changed, 13 insertions, 105 deletions
diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h
index effd8935e81b..5fdab3a3464a 100644
--- a/drivers/staging/unisys/include/uisutils.h
+++ b/drivers/staging/unisys/include/uisutils.h
@@ -333,12 +333,6 @@ static inline unsigned int Issue_VMCALL_FATAL_BYE_BYE(void)
333} 333}
334 334
335#define UIS_DAEMONIZE(nam) 335#define UIS_DAEMONIZE(nam)
336void *uislib_malloc(size_t siz, gfp_t gfp, U8 contiguous, char *fn, int ln);
337#define UISMALLOC(siz, gfp) uislib_malloc(siz, gfp, 1, __FILE__, __LINE__)
338#define UISVMALLOC(siz) uislib_malloc(siz, 0, 0, __FILE__, __LINE__)
339void uislib_free(void *p, size_t siz, U8 contiguous, char *fn, int ln);
340#define UISFREE(p, siz) uislib_free(p, siz, 1, __FILE__, __LINE__)
341#define UISVFREE(p, siz) uislib_free(p, siz, 0, __FILE__, __LINE__)
342void *uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln); 336void *uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln);
343#define UISCACHEALLOC(cur_pool) uislib_cache_alloc(cur_pool, __FILE__, __LINE__) 337#define UISCACHEALLOC(cur_pool) uislib_cache_alloc(cur_pool, __FILE__, __LINE__)
344void uislib_cache_free(struct kmem_cache *cur_pool, void *p, char *fn, int ln); 338void uislib_cache_free(struct kmem_cache *cur_pool, void *p, char *fn, int ln);
diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c
index 4f8a8081f8d0..8ea9c46e56ae 100644
--- a/drivers/staging/unisys/uislib/uislib.c
+++ b/drivers/staging/unisys/uislib/uislib.c
@@ -319,7 +319,7 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf)
319 size = 319 size =
320 sizeof(struct bus_info) + 320 sizeof(struct bus_info) +
321 (deviceCount * sizeof(struct device_info *)); 321 (deviceCount * sizeof(struct device_info *));
322 bus = UISMALLOC(size, GFP_ATOMIC); 322 bus = kzalloc(size, GFP_ATOMIC);
323 if (!bus) { 323 if (!bus) {
324 LOGERR("CONTROLVM_BUS_CREATE Failed: kmalloc for bus failed.\n"); 324 LOGERR("CONTROLVM_BUS_CREATE Failed: kmalloc for bus failed.\n");
325 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, 325 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo,
@@ -327,8 +327,6 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf)
327 return CONTROLVM_RESP_ERROR_KMALLOC_FAILED; 327 return CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
328 } 328 }
329 329
330 memset(bus, 0, size);
331
332 /* Currently by default, the bus Number is the GuestHandle. 330 /* Currently by default, the bus Number is the GuestHandle.
333 * Configure Bus message can override this. 331 * Configure Bus message can override this.
334 */ 332 */
@@ -362,7 +360,7 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf)
362 bus->busNo); 360 bus->busNo);
363 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo, 361 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo,
364 POSTCODE_SEVERITY_ERR); 362 POSTCODE_SEVERITY_ERR);
365 UISFREE(bus, size); 363 kfree(bus);
366 return CONTROLVM_RESP_ERROR_ALREADY_DONE; 364 return CONTROLVM_RESP_ERROR_ALREADY_DONE;
367 } 365 }
368 if ((msg->cmd.createBus.channelAddr != 0) 366 if ((msg->cmd.createBus.channelAddr != 0)
@@ -383,14 +381,14 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf)
383 cmd.add_vbus.busTypeGuid = msg->cmd.createBus.busDataTypeGuid; 381 cmd.add_vbus.busTypeGuid = msg->cmd.createBus.busDataTypeGuid;
384 cmd.add_vbus.busInstGuid = msg->cmd.createBus.busInstGuid; 382 cmd.add_vbus.busInstGuid = msg->cmd.createBus.busInstGuid;
385 if (!VirtControlChanFunc) { 383 if (!VirtControlChanFunc) {
386 UISFREE(bus, size); 384 kfree(bus);
387 LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci callback not registered."); 385 LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci callback not registered.");
388 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo, 386 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo,
389 POSTCODE_SEVERITY_ERR); 387 POSTCODE_SEVERITY_ERR);
390 return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE; 388 return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
391 } 389 }
392 if (!VirtControlChanFunc(&cmd)) { 390 if (!VirtControlChanFunc(&cmd)) {
393 UISFREE(bus, size); 391 kfree(bus);
394 LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci GUEST_ADD_VBUS returned error."); 392 LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci GUEST_ADD_VBUS returned error.");
395 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo, 393 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->busNo,
396 POSTCODE_SEVERITY_ERR); 394 POSTCODE_SEVERITY_ERR);
@@ -488,9 +486,7 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf)
488 bus->pBusChannel = NULL; 486 bus->pBusChannel = NULL;
489 } 487 }
490 488
491 UISFREE(bus, 489 kfree(bus);
492 sizeof(struct bus_info) +
493 (bus->deviceCount * sizeof(struct device_info *)));
494 return CONTROLVM_RESP_SUCCESS; 490 return CONTROLVM_RESP_SUCCESS;
495} 491}
496 492
@@ -510,7 +506,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
510 POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo, 506 POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo,
511 POSTCODE_SEVERITY_INFO); 507 POSTCODE_SEVERITY_INFO);
512 508
513 dev = UISMALLOC(sizeof(struct device_info), GFP_ATOMIC); 509 dev = kzalloc(sizeof(struct device_info), GFP_ATOMIC);
514 if (!dev) { 510 if (!dev) {
515 LOGERR("CONTROLVM_DEVICE_CREATE Failed: kmalloc for dev failed.\n"); 511 LOGERR("CONTROLVM_DEVICE_CREATE Failed: kmalloc for dev failed.\n");
516 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, 512 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo,
@@ -518,7 +514,6 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
518 return CONTROLVM_RESP_ERROR_KMALLOC_FAILED; 514 return CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
519 } 515 }
520 516
521 memset(dev, 0, sizeof(struct device_info));
522 dev->channelTypeGuid = msg->cmd.createDevice.dataTypeGuid; 517 dev->channelTypeGuid = msg->cmd.createDevice.dataTypeGuid;
523 dev->intr = msg->cmd.createDevice.intr; 518 dev->intr = msg->cmd.createDevice.intr;
524 dev->channelAddr = msg->cmd.createDevice.channelAddr; 519 dev->channelAddr = msg->cmd.createDevice.channelAddr;
@@ -691,7 +686,7 @@ Away:
691 dev->chanptr = NULL; 686 dev->chanptr = NULL;
692 } 687 }
693 688
694 UISFREE(dev, sizeof(struct device_info)); 689 kfree(dev);
695 return result; 690 return result;
696} 691}
697 692
@@ -920,7 +915,7 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf)
920 LOGINF("destroy_device, doing iounmap"); 915 LOGINF("destroy_device, doing iounmap");
921 uislib_iounmap(dev->chanptr); 916 uislib_iounmap(dev->chanptr);
922 } 917 }
923 UISFREE(dev, sizeof(struct device_info)); 918 kfree(dev);
924 bus->device[devNo] = NULL; 919 bus->device[devNo] = NULL;
925 break; 920 break;
926 } 921 }
@@ -1346,69 +1341,7 @@ uislib_client_delete_vnic(U32 busNo)
1346 return 1; 1341 return 1;
1347} 1342}
1348EXPORT_SYMBOL_GPL(uislib_client_delete_vnic); 1343EXPORT_SYMBOL_GPL(uislib_client_delete_vnic);
1349 1344/* end client_delete_vnic */
1350 /* end client_delete_vnic */
1351
1352static atomic_t Malloc_BytesInUse = ATOMIC_INIT(0);
1353static atomic_t Malloc_BuffersInUse = ATOMIC_INIT(0);
1354static atomic_t Malloc_FailuresAlloc = ATOMIC_INIT(0);
1355static atomic_t Malloc_FailuresFree = ATOMIC_INIT(0);
1356static atomic_t Malloc_TotalMallocs = ATOMIC_INIT(0);
1357static atomic_t Malloc_TotalFrees = ATOMIC_INIT(0);
1358
1359void *
1360uislib_malloc(size_t siz, gfp_t gfp, U8 contiguous, char *fn, int ln)
1361{
1362 void *p = NULL;
1363
1364 if (contiguous == 0) {
1365 /* Allocate non-contiguous memory, such as in the
1366 * add_vnic and add_vhba methods where we are rebooting
1367 * the guest, for example. Otherwise the contiguous
1368 * memory allocation attempt results in an
1369 * out-of-memory crash in the IOVM...
1370 */
1371 p = vmalloc(siz);
1372 } else {
1373 /* __GFP_NORETRY means "ok to fail", meaning kmalloc()
1374 * can return NULL. If you do NOT specify
1375 * __GFP_NORETRY, Linux will go to extreme measures to
1376 * get memory for you (like, invoke oom killer), which
1377 * will probably cripple the system.
1378 */
1379 p = kmalloc(siz, gfp | __GFP_NORETRY);
1380 }
1381 if (p == NULL) {
1382 LOGERR("uislib_malloc failed to alloc %d bytes @%s:%d",
1383 (int) siz, fn, ln);
1384 atomic_inc(&Malloc_FailuresAlloc);
1385 return NULL;
1386 }
1387 atomic_add((int) (siz), &Malloc_BytesInUse);
1388 atomic_inc(&Malloc_BuffersInUse);
1389 atomic_inc(&Malloc_TotalMallocs); /* will eventually overflow */
1390 return p;
1391}
1392EXPORT_SYMBOL_GPL(uislib_malloc);
1393
1394void
1395uislib_free(void *p, size_t siz, U8 contiguous, char *fn, int ln)
1396{
1397 if (p == NULL) {
1398 LOGERR("uislib_free NULL pointer @%s:%d", fn, ln);
1399 atomic_inc(&Malloc_FailuresFree);
1400 return;
1401 }
1402
1403 if (contiguous == 0)
1404 vfree(p);
1405 else
1406 kfree(p);
1407 atomic_sub((int) (siz), &Malloc_BytesInUse);
1408 atomic_dec(&Malloc_BuffersInUse);
1409 atomic_inc(&Malloc_TotalFrees); /* will eventually overflow */
1410}
1411EXPORT_SYMBOL_GPL(uislib_free);
1412 1345
1413void * 1346void *
1414uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln) 1347uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln)
@@ -1608,24 +1541,6 @@ info_proc_read_helper(char **buff, int *buff_len)
1608 } 1541 }
1609 read_unlock(&BusListLock); 1542 read_unlock(&BusListLock);
1610 1543
1611 if (PLINE("Malloc bytes in use: %d\n",
1612 atomic_read(&Malloc_BytesInUse)) < 0)
1613 goto err_done;
1614 if (PLINE("Malloc buffers in use: %d\n",
1615 atomic_read(&Malloc_BuffersInUse)) < 0)
1616 goto err_done;
1617 if (PLINE("Malloc allocation failures: %d\n",
1618 atomic_read(&Malloc_FailuresAlloc)) < 0)
1619 goto err_done;
1620 if (PLINE("Malloc free failures: %d\n",
1621 atomic_read(&Malloc_FailuresFree)) < 0)
1622 goto err_done;
1623 if (PLINE("Malloc total mallocs: %u (may overflow)\n",
1624 (unsigned) atomic_read(&Malloc_TotalMallocs)) < 0)
1625 goto err_done;
1626 if (PLINE("Malloc total frees: %u (may overflow)\n",
1627 (unsigned) atomic_read(&Malloc_TotalFrees)) < 0)
1628 goto err_done;
1629 if (PLINE("UisUtils_Registered_Services: %d\n", 1544 if (PLINE("UisUtils_Registered_Services: %d\n",
1630 atomic_read(&UisUtils_Registered_Services)) < 0) 1545 atomic_read(&UisUtils_Registered_Services)) < 0)
1631 goto err_done; 1546 goto err_done;
@@ -1658,7 +1573,7 @@ info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset)
1658/* *start = buf; */ 1573/* *start = buf; */
1659 if (ProcReadBuffer == NULL) { 1574 if (ProcReadBuffer == NULL) {
1660 DBGINF("ProcReadBuffer == NULL; allocating buffer.\n."); 1575 DBGINF("ProcReadBuffer == NULL; allocating buffer.\n.");
1661 ProcReadBuffer = UISVMALLOC(PROC_READ_BUFFER_SIZE); 1576 ProcReadBuffer = vmalloc(PROC_READ_BUFFER_SIZE);
1662 1577
1663 if (ProcReadBuffer == NULL) { 1578 if (ProcReadBuffer == NULL) {
1664 LOGERR("failed to allocate buffer to provide proc data.\n"); 1579 LOGERR("failed to allocate buffer to provide proc data.\n");
@@ -2489,7 +2404,7 @@ uislib_mod_exit(void)
2489 remove_proc_entry(DIR_PROC_ENTRY, NULL); 2404 remove_proc_entry(DIR_PROC_ENTRY, NULL);
2490 2405
2491 if (ProcReadBuffer) { 2406 if (ProcReadBuffer) {
2492 UISVFREE(ProcReadBuffer, PROC_READ_BUFFER_SIZE); 2407 vfree(ProcReadBuffer);
2493 ProcReadBuffer = NULL; 2408 ProcReadBuffer = NULL;
2494 } 2409 }
2495 2410
diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c
index 208b7eab9188..3178f75e1ebe 100644
--- a/drivers/staging/unisys/uislib/uisutils.c
+++ b/drivers/staging/unisys/uislib/uisutils.c
@@ -291,10 +291,9 @@ ReqHandlerAdd(GUID switchTypeGuid,
291{ 291{
292 ReqHandlerInfo_t *rc = NULL; 292 ReqHandlerInfo_t *rc = NULL;
293 293
294 rc = UISMALLOC(sizeof(*rc), GFP_ATOMIC); 294 rc = kzalloc(sizeof(*rc), GFP_ATOMIC);
295 if (!rc) 295 if (!rc)
296 return NULL; 296 return NULL;
297 memset(rc, 0, sizeof(*rc));
298 rc->switchTypeGuid = switchTypeGuid; 297 rc->switchTypeGuid = switchTypeGuid;
299 rc->controlfunc = controlfunc; 298 rc->controlfunc = controlfunc;
300 rc->min_channel_bytes = min_channel_bytes; 299 rc->min_channel_bytes = min_channel_bytes;
@@ -342,7 +341,7 @@ ReqHandlerDel(GUID switchTypeGuid)
342 (&entry->switchTypeGuid, &switchTypeGuid, 341 (&entry->switchTypeGuid, &switchTypeGuid,
343 sizeof(GUID)) == 0) { 342 sizeof(GUID)) == 0) {
344 list_del(lelt); 343 list_del(lelt);
345 UISFREE(entry, sizeof(*entry)); 344 kfree(entry);
346 rc++; 345 rc++;
347 } 346 }
348 } 347 }