CC: [email protected] TO: David Hildenbrand <[email protected]> CC: Andrew Morton <[email protected]> CC: Linux Memory Management List <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: b36c969764ab12faebb74711c942fa3e6eaf1e96 commit: f2995d0dd75eafd7b6188155f3cb2315e480f911 [3147/3958] virtio-mem: don't special-case ZONE_MOVABLE :::::: branch date: 13 hours ago :::::: commit date: 3 days ago config: x86_64-randconfig-m001-20200828 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> smatch warnings: drivers/virtio/virtio_mem.c:723 virtio_mem_memory_notifier_cb() warn: inconsistent returns 'vm->hotplug_mutex'. # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=f2995d0dd75eafd7b6188155f3cb2315e480f911 git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git fetch --no-tags linux-next master git checkout f2995d0dd75eafd7b6188155f3cb2315e480f911 vim +723 drivers/virtio/virtio_mem.c 8e5c921ca0cd9aa David Hildenbrand 2020-05-07 636 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 637 /* 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 638 * This callback will either be called synchronously from add_memory() or 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 639 * asynchronously (e.g., triggered via user space). We have to be careful 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 640 * with locking when calling add_memory(). 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 641 */ 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 642 static int virtio_mem_memory_notifier_cb(struct notifier_block *nb, 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 643 unsigned long action, void *arg) 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 644 { 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 645 struct virtio_mem *vm = container_of(nb, struct virtio_mem, 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 646 memory_notifier); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 647 struct memory_notify *mhp = arg; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 648 const unsigned long start = PFN_PHYS(mhp->start_pfn); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 649 const unsigned long size = PFN_PHYS(mhp->nr_pages); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 650 const unsigned long mb_id = virtio_mem_phys_to_mb_id(start); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 651 int rc = NOTIFY_OK; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 652 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 653 if (!virtio_mem_overlaps_range(vm, start, size)) 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 654 return NOTIFY_DONE; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 655 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 656 /* 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 657 * Memory is onlined/offlined in memory block granularity. We cannot 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 658 * cross virtio-mem device boundaries and memory block boundaries. Bail 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 659 * out if this ever changes. 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 660 */ 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 661 if (WARN_ON_ONCE(size != memory_block_size_bytes() || 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 662 !IS_ALIGNED(start, memory_block_size_bytes()))) 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 663 return NOTIFY_BAD; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 664 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 665 /* 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 666 * Avoid circular locking lockdep warnings. We lock the mutex 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 667 * e.g., in MEM_GOING_ONLINE and unlock it in MEM_ONLINE. The 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 668 * blocking_notifier_call_chain() has it's own lock, which gets unlocked 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 669 * between both notifier calls and will bail out. False positive. 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 670 */ 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 671 lockdep_off(); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 672 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 673 switch (action) { 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 674 case MEM_GOING_OFFLINE: 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 675 mutex_lock(&vm->hotplug_mutex); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 676 if (vm->removing) { 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 677 rc = notifier_from_errno(-EBUSY); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 678 mutex_unlock(&vm->hotplug_mutex); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 679 break; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 680 } 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 681 vm->hotplug_active = true; 8e5c921ca0cd9aa David Hildenbrand 2020-05-07 682 virtio_mem_notify_going_offline(vm, mb_id); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 683 break; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 684 case MEM_GOING_ONLINE: 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 685 mutex_lock(&vm->hotplug_mutex); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 686 if (vm->removing) { 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 687 rc = notifier_from_errno(-EBUSY); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 688 mutex_unlock(&vm->hotplug_mutex); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 689 break; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 690 } 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 691 vm->hotplug_active = true; f2995d0dd75eafd David Hildenbrand 2020-08-26 692 rc = virtio_mem_notify_going_online(vm, mb_id); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 693 break; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 694 case MEM_OFFLINE: 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 695 virtio_mem_notify_offline(vm, mb_id); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 696 vm->hotplug_active = false; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 697 mutex_unlock(&vm->hotplug_mutex); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 698 break; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 699 case MEM_ONLINE: f2995d0dd75eafd David Hildenbrand 2020-08-26 700 virtio_mem_notify_online(vm, mb_id); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 701 vm->hotplug_active = false; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 702 mutex_unlock(&vm->hotplug_mutex); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 703 break; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 704 case MEM_CANCEL_OFFLINE: 8e5c921ca0cd9aa David Hildenbrand 2020-05-07 705 if (!vm->hotplug_active) 8e5c921ca0cd9aa David Hildenbrand 2020-05-07 706 break; 8e5c921ca0cd9aa David Hildenbrand 2020-05-07 707 virtio_mem_notify_cancel_offline(vm, mb_id); 8e5c921ca0cd9aa David Hildenbrand 2020-05-07 708 vm->hotplug_active = false; 8e5c921ca0cd9aa David Hildenbrand 2020-05-07 709 mutex_unlock(&vm->hotplug_mutex); 8e5c921ca0cd9aa David Hildenbrand 2020-05-07 710 break; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 711 case MEM_CANCEL_ONLINE: 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 712 if (!vm->hotplug_active) 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 713 break; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 714 vm->hotplug_active = false; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 715 mutex_unlock(&vm->hotplug_mutex); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 716 break; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 717 default: 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 718 break; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 719 } 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 720 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 721 lockdep_on(); 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 722 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 @723 return rc; 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 724 } 5f1f79bbc9e26fa David Hildenbrand 2020-05-07 725 :::::: The code at line 723 was first introduced by commit :::::: 5f1f79bbc9e26fa9412fa9522f957bb8f030c442 virtio-mem: Paravirtualized memory hotplug :::::: TO: David Hildenbrand <[email protected]> :::::: CC: Michael S. Tsirkin <[email protected]> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/[email protected]
.config.gz
Description: application/gzip
_______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
