#include #include #include #include #include "rnd.h" #include "die.h" #include "ioexact.h" #include "ioops.h" static int fdw = -1; static void randombytes_weak(unsigned char *x, unsigned long long xlen) { int ret; if (fdw == -1) { for (;;) { fdw = open(LOW_ENTROPY_SOURCE, O_RDONLY); if (fdw != -1) break; sleep(1); } } while (xlen > 0) { if (xlen < 1048576) ret = xlen; else ret = 1048576; ret = read(fdw, x, ret); if (ret < 1) { sleep(1); continue; } x += ret; xlen -= ret; } } static void randombytes_strong(unsigned char *x, unsigned long long xlen) { int fds, ret; fds = open_or_die(HIG_ENTROPY_SOURCE, O_RDONLY); ret = read_exact(fds, x, xlen, 0); if (ret != xlen) panic("Error reading from entropy source!\n"); close(fds); } int secrand(void) { int ret; randombytes_weak((void *) &ret, sizeof(ret)); return ret; } void gen_key_bytes(unsigned char *area, size_t len) { randombytes_strong(area, len); } 'emaclite-cleanup'>emaclite-cleanup net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlastimil Babka <vbabka@suse.cz>2016-05-19 17:11:51 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-19 19:12:14 -0700
commita34753d275576896b06af9baa6f54bee258368c2 (patch)
tree6cdb6beec24ff70f83c08515b5ad2b9ccf5c5580
parent06b6640a3902d6d50c1bb4fb1f29a46b207dbf08 (diff)
mm, compaction: reduce spurious pcplist drains
Compaction drains the local pcplists each time migration scanner moves away from a cc->order aligned block where it isolated pages for migration, so that the pages freed by migrations can merge into higher orders. The detection is currently coarser than it could be. The cc->last_migrated_pfn variable should track the lowest pfn that was isolated for migration. But it is set to the pfn where isolate_migratepages_block() starts scanning, which is typically the first pfn of the pageblock. There, the scanner might fail to isolate several order-aligned blocks, and then isolate COMPACT_CLUSTER_MAX in another block. This would cause the pcplists drain to be performed, although the scanner didn't yet finish the block where it isolated from. This patch thus makes cc->last_migrated_pfn handling more accurate by setting it to the pfn of an actually isolated page in isolate_migratepages_block(). Although practical effects of this patch are likely low, it arguably makes the intent of the code more obvious. Also the next patch will make async direct compaction skip blocks more aggressively, and draining pcplists due to skipped blocks is wasteful. Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Rik van Riel <riel@redhat.com> Cc: David Rientjes <rientjes@google.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/compaction.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/mm/compaction.c b/mm/compaction.c