qcow2-cache.c (59c58f96b270f5edd4ad10954c3a96556cb3a728) | qcow2-cache.c (038adc2f5850e32019bda06c559d0301be436eae) |
---|---|
1/* 2 * L2/refcount table cache for the QCOW2 format 3 * 4 * Copyright (c) 2010 Kevin Wolf <kwolf@redhat.com> 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 60 unchanged lines hidden (view full) --- 69 } 70} 71 72static void qcow2_cache_table_release(Qcow2Cache *c, int i, int num_tables) 73{ 74/* Using MADV_DONTNEED to discard memory is a Linux-specific feature */ 75#ifdef CONFIG_LINUX 76 void *t = qcow2_cache_get_table_addr(c, i); | 1/* 2 * L2/refcount table cache for the QCOW2 format 3 * 4 * Copyright (c) 2010 Kevin Wolf <kwolf@redhat.com> 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 60 unchanged lines hidden (view full) --- 69 } 70} 71 72static void qcow2_cache_table_release(Qcow2Cache *c, int i, int num_tables) 73{ 74/* Using MADV_DONTNEED to discard memory is a Linux-specific feature */ 75#ifdef CONFIG_LINUX 76 void *t = qcow2_cache_get_table_addr(c, i); |
77 int align = getpagesize(); | 77 int align = qemu_real_host_page_size; |
78 size_t mem_size = (size_t) c->table_size * num_tables; 79 size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t; 80 size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align); 81 if (mem_size > offset && length > 0) { 82 madvise((uint8_t *) t + offset, length, MADV_DONTNEED); 83 } 84#endif 85} --- 373 unchanged lines hidden --- | 78 size_t mem_size = (size_t) c->table_size * num_tables; 79 size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t; 80 size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align); 81 if (mem_size > offset && length > 0) { 82 madvise((uint8_t *) t + offset, length, MADV_DONTNEED); 83 } 84#endif 85} --- 373 unchanged lines hidden --- |