Lines Matching refs:sbm

203 		} sbm;  member
365 return (addr - mb_addr) / vm->sbm.sb_size; in virtio_mem_phys_to_sb_id()
441 const unsigned long idx = mb_id - vm->sbm.first_mb_id; in virtio_mem_sbm_set_mb_state()
444 old_state = vm->sbm.mb_states[idx]; in virtio_mem_sbm_set_mb_state()
445 vm->sbm.mb_states[idx] = state; in virtio_mem_sbm_set_mb_state()
447 BUG_ON(vm->sbm.mb_count[old_state] == 0); in virtio_mem_sbm_set_mb_state()
448 vm->sbm.mb_count[old_state]--; in virtio_mem_sbm_set_mb_state()
449 vm->sbm.mb_count[state]++; in virtio_mem_sbm_set_mb_state()
458 const unsigned long idx = mb_id - vm->sbm.first_mb_id; in virtio_mem_sbm_get_mb_state()
460 return vm->sbm.mb_states[idx]; in virtio_mem_sbm_get_mb_state()
468 int old_pages = PFN_UP(vm->sbm.next_mb_id - vm->sbm.first_mb_id); in virtio_mem_sbm_mb_states_prepare_next_mb()
469 int new_pages = PFN_UP(vm->sbm.next_mb_id - vm->sbm.first_mb_id + 1); in virtio_mem_sbm_mb_states_prepare_next_mb()
472 if (vm->sbm.mb_states && old_pages == new_pages) in virtio_mem_sbm_mb_states_prepare_next_mb()
480 if (vm->sbm.mb_states) in virtio_mem_sbm_mb_states_prepare_next_mb()
481 memcpy(new_array, vm->sbm.mb_states, old_pages * PAGE_SIZE); in virtio_mem_sbm_mb_states_prepare_next_mb()
482 vfree(vm->sbm.mb_states); in virtio_mem_sbm_mb_states_prepare_next_mb()
483 vm->sbm.mb_states = new_array; in virtio_mem_sbm_mb_states_prepare_next_mb()
490 for (_mb_id = _vm->sbm.first_mb_id; \
491 _mb_id < _vm->sbm.next_mb_id && _vm->sbm.mb_count[_state]; \
496 for (_mb_id = _vm->sbm.next_mb_id - 1; \
497 _mb_id >= _vm->sbm.first_mb_id && _vm->sbm.mb_count[_state]; \
508 return (mb_id - vm->sbm.first_mb_id) * vm->sbm.sbs_per_mb + sb_id; in virtio_mem_sbm_sb_state_bit_nr()
522 __bitmap_set(vm->sbm.sb_states, bit, count); in virtio_mem_sbm_set_sb_plugged()
536 __bitmap_clear(vm->sbm.sb_states, bit, count); in virtio_mem_sbm_set_sb_unplugged()
549 return test_bit(bit, vm->sbm.sb_states); in virtio_mem_sbm_test_sb_plugged()
552 return find_next_zero_bit(vm->sbm.sb_states, bit + count, bit) >= in virtio_mem_sbm_test_sb_plugged()
566 return find_next_bit(vm->sbm.sb_states, bit + count, bit) >= in virtio_mem_sbm_test_sb_unplugged()
579 return find_next_zero_bit(vm->sbm.sb_states, in virtio_mem_sbm_first_unplugged_sb()
580 bit + vm->sbm.sbs_per_mb, bit) - bit; in virtio_mem_sbm_first_unplugged_sb()
588 const unsigned long old_nb_mb = vm->sbm.next_mb_id - vm->sbm.first_mb_id; in virtio_mem_sbm_sb_states_prepare_next_mb()
589 const unsigned long old_nb_bits = old_nb_mb * vm->sbm.sbs_per_mb; in virtio_mem_sbm_sb_states_prepare_next_mb()
590 const unsigned long new_nb_bits = (old_nb_mb + 1) * vm->sbm.sbs_per_mb; in virtio_mem_sbm_sb_states_prepare_next_mb()
595 if (vm->sbm.sb_states && old_pages == new_pages) in virtio_mem_sbm_sb_states_prepare_next_mb()
603 if (vm->sbm.sb_states) in virtio_mem_sbm_sb_states_prepare_next_mb()
604 memcpy(new_bitmap, vm->sbm.sb_states, old_pages * PAGE_SIZE); in virtio_mem_sbm_sb_states_prepare_next_mb()
606 old_bitmap = vm->sbm.sb_states; in virtio_mem_sbm_sb_states_prepare_next_mb()
607 vm->sbm.sb_states = new_bitmap; in virtio_mem_sbm_sb_states_prepare_next_mb()
795 if (!virtio_mem_sbm_test_sb_unplugged(vm, mb_id, 0, vm->sbm.sbs_per_mb)) in virtio_mem_sbm_try_remove_unplugged_mb()
928 const unsigned long nr_pages = PFN_DOWN(vm->sbm.sb_size); in virtio_mem_sbm_notify_going_offline()
932 for (sb_id = 0; sb_id < vm->sbm.sbs_per_mb; sb_id++) { in virtio_mem_sbm_notify_going_offline()
936 sb_id * vm->sbm.sb_size); in virtio_mem_sbm_notify_going_offline()
944 const unsigned long nr_pages = PFN_DOWN(vm->sbm.sb_size); in virtio_mem_sbm_notify_cancel_offline()
948 for (sb_id = 0; sb_id < vm->sbm.sbs_per_mb; sb_id++) { in virtio_mem_sbm_notify_cancel_offline()
952 sb_id * vm->sbm.sb_size); in virtio_mem_sbm_notify_cancel_offline()
1333 order = ilog2(vm->sbm.sb_size) - PAGE_SHIFT; in virtio_mem_online_page()
1525 sb_id * vm->sbm.sb_size; in virtio_mem_sbm_plug_sb()
1526 const uint64_t size = count * vm->sbm.sb_size; in virtio_mem_sbm_plug_sb()
1543 sb_id * vm->sbm.sb_size; in virtio_mem_sbm_unplug_sb()
1544 const uint64_t size = count * vm->sbm.sb_size; in virtio_mem_sbm_unplug_sb()
1594 sb_id = vm->sbm.sbs_per_mb - 1; in virtio_mem_sbm_unplug_any_sb_raw()
1629 uint64_t nb_sb = vm->sbm.sbs_per_mb; in virtio_mem_sbm_unplug_mb()
1642 if (vm->sbm.next_mb_id > vm->sbm.last_usable_mb_id) in virtio_mem_sbm_prepare_next_mb()
1655 vm->sbm.mb_count[VIRTIO_MEM_SBM_MB_UNUSED]++; in virtio_mem_sbm_prepare_next_mb()
1656 *mb_id = vm->sbm.next_mb_id++; in virtio_mem_sbm_prepare_next_mb()
1669 const int count = min_t(int, *nb_sb, vm->sbm.sbs_per_mb); in virtio_mem_sbm_plug_and_add_mb()
1687 if (count == vm->sbm.sbs_per_mb) in virtio_mem_sbm_plug_and_add_mb()
1730 if (sb_id >= vm->sbm.sbs_per_mb) in virtio_mem_sbm_plug_any_sb()
1734 sb_id + count < vm->sbm.sbs_per_mb && in virtio_mem_sbm_plug_any_sb()
1747 sb_id * vm->sbm.sb_size); in virtio_mem_sbm_plug_any_sb()
1748 nr_pages = PFN_DOWN(count * vm->sbm.sb_size); in virtio_mem_sbm_plug_any_sb()
1752 if (virtio_mem_sbm_test_sb_plugged(vm, mb_id, 0, vm->sbm.sbs_per_mb)) in virtio_mem_sbm_plug_any_sb()
1765 uint64_t nb_sb = diff / vm->sbm.sb_size; in virtio_mem_sbm_plug_request()
1945 if (!virtio_mem_sbm_test_sb_plugged(vm, mb_id, 0, vm->sbm.sbs_per_mb)) in virtio_mem_sbm_unplug_any_sb_offline()
1951 if (virtio_mem_sbm_test_sb_unplugged(vm, mb_id, 0, vm->sbm.sbs_per_mb)) { in virtio_mem_sbm_unplug_any_sb_offline()
1978 const unsigned long nr_pages = PFN_DOWN(vm->sbm.sb_size) * count; in virtio_mem_sbm_unplug_sb_online()
1984 sb_id * vm->sbm.sb_size); in virtio_mem_sbm_unplug_sb_online()
2029 if (*nb_sb >= vm->sbm.sbs_per_mb && in virtio_mem_sbm_unplug_any_sb_online()
2030 virtio_mem_sbm_test_sb_plugged(vm, mb_id, 0, vm->sbm.sbs_per_mb)) { in virtio_mem_sbm_unplug_any_sb_online()
2032 vm->sbm.sbs_per_mb); in virtio_mem_sbm_unplug_any_sb_online()
2034 *nb_sb -= vm->sbm.sbs_per_mb; in virtio_mem_sbm_unplug_any_sb_online()
2041 for (sb_id = vm->sbm.sbs_per_mb - 1; sb_id >= 0 && *nb_sb; sb_id--) { in virtio_mem_sbm_unplug_any_sb_online()
2060 vm->sbm.have_unplugged_mb = 1; in virtio_mem_sbm_unplug_any_sb_online()
2106 uint64_t nb_sb = diff / vm->sbm.sb_size; in virtio_mem_sbm_unplug_request()
2341 if (!vm->sbm.have_unplugged_mb) in virtio_mem_cleanup_pending_mb()
2348 vm->sbm.have_unplugged_mb = false; in virtio_mem_cleanup_pending_mb()
2360 vm->sbm.have_unplugged_mb = true; in virtio_mem_cleanup_pending_mb()
2386 vm->sbm.last_usable_mb_id = virtio_mem_phys_to_mb_id(end_addr); in virtio_mem_refresh_config()
2388 vm->sbm.last_usable_mb_id--; in virtio_mem_refresh_config()
2461 if (!rc && vm->in_sbm && vm->sbm.have_unplugged_mb) in virtio_mem_run_wq()
2565 vm->sbm.sb_size = sb_size; in virtio_mem_init_hotplug()
2566 vm->sbm.sbs_per_mb = memory_block_size_bytes() / in virtio_mem_init_hotplug()
2567 vm->sbm.sb_size; in virtio_mem_init_hotplug()
2572 vm->sbm.first_mb_id = virtio_mem_phys_to_mb_id(addr); in virtio_mem_init_hotplug()
2573 vm->sbm.next_mb_id = vm->sbm.first_mb_id; in virtio_mem_init_hotplug()
2606 (unsigned long long)vm->sbm.sb_size); in virtio_mem_init_hotplug()
2950 vfree(vm->sbm.mb_states); in virtio_mem_deinit_hotplug()
2951 vfree(vm->sbm.sb_states); in virtio_mem_deinit_hotplug()