@@ -1327,7 +1327,6 @@ static void * __init memblock_virt_alloc_internal(
1327
1327
return NULL ;
1328
1328
done :
1329
1329
ptr = phys_to_virt (alloc );
1330
- memset (ptr , 0 , size );
1331
1330
1332
1331
/*
1333
1332
* The min_count is set to 0 so that bootmem allocated blocks
@@ -1340,6 +1339,45 @@ static void * __init memblock_virt_alloc_internal(
1340
1339
return ptr ;
1341
1340
}
1342
1341
1342
+ /**
1343
+ * memblock_virt_alloc_try_nid_raw - allocate boot memory block without zeroing
1344
+ * memory and without panicking
1345
+ * @size: size of memory block to be allocated in bytes
1346
+ * @align: alignment of the region and block's size
1347
+ * @min_addr: the lower bound of the memory region from where the allocation
1348
+ * is preferred (phys address)
1349
+ * @max_addr: the upper bound of the memory region from where the allocation
1350
+ * is preferred (phys address), or %BOOTMEM_ALLOC_ACCESSIBLE to
1351
+ * allocate only from memory limited by memblock.current_limit value
1352
+ * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
1353
+ *
1354
+ * Public function, provides additional debug information (including caller
1355
+ * info), if enabled. Does not zero allocated memory, does not panic if request
1356
+ * cannot be satisfied.
1357
+ *
1358
+ * RETURNS:
1359
+ * Virtual address of allocated memory block on success, NULL on failure.
1360
+ */
1361
+ void * __init memblock_virt_alloc_try_nid_raw (
1362
+ phys_addr_t size , phys_addr_t align ,
1363
+ phys_addr_t min_addr , phys_addr_t max_addr ,
1364
+ int nid )
1365
+ {
1366
+ void * ptr ;
1367
+
1368
+ memblock_dbg ("%s: %llu bytes align=0x%llx nid=%d from=0x%llx max_addr=0x%llx %pF\n" ,
1369
+ __func__ , (u64 )size , (u64 )align , nid , (u64 )min_addr ,
1370
+ (u64 )max_addr , (void * )_RET_IP_ );
1371
+
1372
+ ptr = memblock_virt_alloc_internal (size , align ,
1373
+ min_addr , max_addr , nid );
1374
+ #ifdef CONFIG_DEBUG_VM
1375
+ if (ptr && size > 0 )
1376
+ memset (ptr , 0xff , size );
1377
+ #endif
1378
+ return ptr ;
1379
+ }
1380
+
1343
1381
/**
1344
1382
* memblock_virt_alloc_try_nid_nopanic - allocate boot memory block
1345
1383
* @size: size of memory block to be allocated in bytes
@@ -1351,8 +1389,8 @@ static void * __init memblock_virt_alloc_internal(
1351
1389
* allocate only from memory limited by memblock.current_limit value
1352
1390
* @nid: nid of the free area to find, %NUMA_NO_NODE for any node
1353
1391
*
1354
- * Public version of _memblock_virt_alloc_try_nid_nopanic() which provides
1355
- * additional debug information (including caller info), if enabled.
1392
+ * Public function, provides additional debug information (including caller
1393
+ * info), if enabled. This function zeroes the allocated memory .
1356
1394
*
1357
1395
* RETURNS:
1358
1396
* Virtual address of allocated memory block on success, NULL on failure.
@@ -1362,11 +1400,17 @@ void * __init memblock_virt_alloc_try_nid_nopanic(
1362
1400
phys_addr_t min_addr , phys_addr_t max_addr ,
1363
1401
int nid )
1364
1402
{
1403
+ void * ptr ;
1404
+
1365
1405
memblock_dbg ("%s: %llu bytes align=0x%llx nid=%d from=0x%llx max_addr=0x%llx %pF\n" ,
1366
1406
__func__ , (u64 )size , (u64 )align , nid , (u64 )min_addr ,
1367
1407
(u64 )max_addr , (void * )_RET_IP_ );
1368
- return memblock_virt_alloc_internal (size , align , min_addr ,
1369
- max_addr , nid );
1408
+
1409
+ ptr = memblock_virt_alloc_internal (size , align ,
1410
+ min_addr , max_addr , nid );
1411
+ if (ptr )
1412
+ memset (ptr , 0 , size );
1413
+ return ptr ;
1370
1414
}
1371
1415
1372
1416
/**
@@ -1380,7 +1424,7 @@ void * __init memblock_virt_alloc_try_nid_nopanic(
1380
1424
* allocate only from memory limited by memblock.current_limit value
1381
1425
* @nid: nid of the free area to find, %NUMA_NO_NODE for any node
1382
1426
*
1383
- * Public panicking version of _memblock_virt_alloc_try_nid_nopanic ()
1427
+ * Public panicking version of memblock_virt_alloc_try_nid_nopanic ()
1384
1428
* which provides debug information (including caller info), if enabled,
1385
1429
* and panics if the request can not be satisfied.
1386
1430
*
@@ -1399,8 +1443,10 @@ void * __init memblock_virt_alloc_try_nid(
1399
1443
(u64 )max_addr , (void * )_RET_IP_ );
1400
1444
ptr = memblock_virt_alloc_internal (size , align ,
1401
1445
min_addr , max_addr , nid );
1402
- if (ptr )
1446
+ if (ptr ) {
1447
+ memset (ptr , 0 , size );
1403
1448
return ptr ;
1449
+ }
1404
1450
1405
1451
panic ("%s: Failed to allocate %llu bytes align=0x%llx nid=%d from=0x%llx max_addr=0x%llx\n" ,
1406
1452
__func__ , (u64 )size , (u64 )align , nid , (u64 )min_addr ,
0 commit comments