Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'pm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6

* 'pm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6:
PM / Hibernate: Avoid hitting OOM during preallocation of memory
PM QoS: Correct pr_debug() misuse and improve parameter checks
PM: Prevent waiting forever on asynchronous resume after failing suspend

+69 -21
+1
drivers/base/power/main.c
··· 59 59 { 60 60 dev->power.status = DPM_ON; 61 61 init_completion(&dev->power.completion); 62 + complete_all(&dev->power.completion); 62 63 dev->power.wakeup_count = 0; 63 64 pm_runtime_init(dev); 64 65 }
+3 -1
kernel/pm_qos_params.c
··· 389 389 } else if (count == 11) { /* len('0x12345678/0') */ 390 390 if (copy_from_user(ascii_value, buf, 11)) 391 391 return -EFAULT; 392 + if (strlen(ascii_value) != 10) 393 + return -EINVAL; 392 394 x = sscanf(ascii_value, "%x", &value); 393 395 if (x != 1) 394 396 return -EINVAL; 395 - pr_debug(KERN_ERR "%s, %d, 0x%x\n", ascii_value, x, value); 397 + pr_debug("%s, %d, 0x%x\n", ascii_value, x, value); 396 398 } else 397 399 return -EINVAL; 398 400
+65 -20
kernel/power/snapshot.c
··· 1121 1121 return nr_alloc; 1122 1122 } 1123 1123 1124 - static unsigned long preallocate_image_memory(unsigned long nr_pages) 1124 + static unsigned long preallocate_image_memory(unsigned long nr_pages, 1125 + unsigned long avail_normal) 1125 1126 { 1126 - return preallocate_image_pages(nr_pages, GFP_IMAGE); 1127 + unsigned long alloc; 1128 + 1129 + if (avail_normal <= alloc_normal) 1130 + return 0; 1131 + 1132 + alloc = avail_normal - alloc_normal; 1133 + if (nr_pages < alloc) 1134 + alloc = nr_pages; 1135 + 1136 + return preallocate_image_pages(alloc, GFP_IMAGE); 1127 1137 } 1128 1138 1129 1139 #ifdef CONFIG_HIGHMEM ··· 1179 1169 */ 1180 1170 static void free_unnecessary_pages(void) 1181 1171 { 1182 - unsigned long save_highmem, to_free_normal, to_free_highmem; 1172 + unsigned long save, to_free_normal, to_free_highmem; 1183 1173 1184 - to_free_normal = alloc_normal - count_data_pages(); 1185 - save_highmem = count_highmem_pages(); 1186 - if (alloc_highmem > save_highmem) { 1187 - to_free_highmem = alloc_highmem - save_highmem; 1174 + save = count_data_pages(); 1175 + if (alloc_normal >= save) { 1176 + to_free_normal = alloc_normal - save; 1177 + save = 0; 1178 + } else { 1179 + to_free_normal = 0; 1180 + save -= alloc_normal; 1181 + } 1182 + save += count_highmem_pages(); 1183 + if (alloc_highmem >= save) { 1184 + to_free_highmem = alloc_highmem - save; 1188 1185 } else { 1189 1186 to_free_highmem = 0; 1190 - to_free_normal -= save_highmem - alloc_highmem; 1187 + to_free_normal -= save - alloc_highmem; 1191 1188 } 1192 1189 1193 1190 memory_bm_position_reset(&copy_bm); ··· 1275 1258 { 1276 1259 struct zone *zone; 1277 1260 unsigned long saveable, size, max_size, count, highmem, pages = 0; 1278 - unsigned long alloc, save_highmem, pages_highmem; 1261 + unsigned long alloc, save_highmem, pages_highmem, avail_normal; 1279 1262 struct timeval start, stop; 1280 1263 int error; 1281 1264 ··· 1312 1295 else 1313 1296 count += zone_page_state(zone, NR_FREE_PAGES); 1314 1297 } 1298 + avail_normal = count; 1315 1299 count += highmem; 1316 1300 count -= totalreserve_pages; 1317 1301 ··· 1327 1309 */ 1328 1310 if (size >= saveable) { 1329 1311 pages = preallocate_image_highmem(save_highmem); 1330 - pages += preallocate_image_memory(saveable - pages); 1312 + pages += preallocate_image_memory(saveable - pages, avail_normal); 1331 1313 goto out; 1332 1314 } 1333 1315 1334 1316 /* Estimate the minimum size of the image. */ 1335 1317 pages = minimum_image_size(saveable); 1318 + /* 1319 + * To avoid excessive pressure on the normal zone, leave room in it to 1320 + * accommodate an image of the minimum size (unless it's already too 1321 + * small, in which case don't preallocate pages from it at all). 1322 + */ 1323 + if (avail_normal > pages) 1324 + avail_normal -= pages; 1325 + else 1326 + avail_normal = 0; 1336 1327 if (size < pages) 1337 1328 size = min_t(unsigned long, pages, max_size); 1338 1329 ··· 1362 1335 */ 1363 1336 pages_highmem = preallocate_image_highmem(highmem / 2); 1364 1337 alloc = (count - max_size) - pages_highmem; 1365 - pages = preallocate_image_memory(alloc); 1366 - if (pages < alloc) 1367 - goto err_out; 1368 - size = max_size - size; 1369 - alloc = size; 1370 - size = preallocate_highmem_fraction(size, highmem, count); 1371 - pages_highmem += size; 1372 - alloc -= size; 1373 - pages += preallocate_image_memory(alloc); 1374 - pages += pages_highmem; 1338 + pages = preallocate_image_memory(alloc, avail_normal); 1339 + if (pages < alloc) { 1340 + /* We have exhausted non-highmem pages, try highmem. */ 1341 + alloc -= pages; 1342 + pages += pages_highmem; 1343 + pages_highmem = preallocate_image_highmem(alloc); 1344 + if (pages_highmem < alloc) 1345 + goto err_out; 1346 + pages += pages_highmem; 1347 + /* 1348 + * size is the desired number of saveable pages to leave in 1349 + * memory, so try to preallocate (all memory - size) pages. 1350 + */ 1351 + alloc = (count - pages) - size; 1352 + pages += preallocate_image_highmem(alloc); 1353 + } else { 1354 + /* 1355 + * There are approximately max_size saveable pages at this point 1356 + * and we want to reduce this number down to size. 1357 + */ 1358 + alloc = max_size - size; 1359 + size = preallocate_highmem_fraction(alloc, highmem, count); 1360 + pages_highmem += size; 1361 + alloc -= size; 1362 + size = preallocate_image_memory(alloc, avail_normal); 1363 + pages_highmem += preallocate_image_highmem(alloc - size); 1364 + pages += pages_highmem + size; 1365 + } 1375 1366 1376 1367 /* 1377 1368 * We only need as many page frames for the image as there are saveable