Re: [PATCH 11/19] vmw_balloon: rework the inflate and deflate loops
From: kbuild test robot
Date: Tue Sep 18 2018 - 05:56:08 EST
Hi Nadav,
I love your patch! Yet something to improve:
[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v4.19-rc4 next-20180913]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Nadav-Amit/vmw_balloon-compaction-shrinker-64-bit-etc/20180918-152302
config: i386-randconfig-s2-09171149 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
drivers/misc/vmw_balloon.o: In function `vmballoon_deflate':
>> drivers/misc/vmw_balloon.c:1073: undefined reference to `__divdi3'
drivers/misc/vmw_balloon.o: In function `vmballoon_inflate':
drivers/misc/vmw_balloon.c:966: undefined reference to `__divdi3'
vim +1073 drivers/misc/vmw_balloon.c
1018
1019 /**
1020 * vmballoon_deflate() - Decrease the size of the balloon.
1021 *
1022 * @b: pointer to the balloon
1023 * @n_frames: the number of frames to deflate. If zero, automatically
1024 * calculated according to the target size.
1025 * @coordinated: whether to coordinate with the host
1026 *
1027 * Decrease the size of the balloon allowing guest to use more memory.
1028 *
1029 * Return: The number of deflated frames (i.e., basic page size units)
1030 */
1031 static unsigned long vmballoon_deflate(struct vmballoon *b, uint64_t n_frames,
1032 bool coordinated)
1033 {
1034 unsigned long deflated_frames = 0;
1035 unsigned long tried_frames = 0;
1036 struct vmballoon_ctl ctl = {
1037 .pages = LIST_HEAD_INIT(ctl.pages),
1038 .refused_pages = LIST_HEAD_INIT(ctl.refused_pages),
1039 .page_size = VMW_BALLOON_4K_PAGE,
1040 .op = VMW_BALLOON_DEFLATE
1041 };
1042
1043 /* free pages to reach target */
1044 while (true) {
1045 unsigned int to_deflate_pages, n_unlocked_frames;
1046 unsigned int page_in_frames;
1047 int64_t to_deflate_frames;
1048 bool deflated_all;
1049
1050 page_in_frames = vmballoon_page_in_frames(ctl.page_size);
1051
1052 VM_BUG_ON(!list_empty(&ctl.pages));
1053 VM_BUG_ON(ctl.n_pages);
1054 VM_BUG_ON(!list_empty(&ctl.refused_pages));
1055 VM_BUG_ON(ctl.n_refused_pages);
1056
1057 /*
1058 * If we were requested a specific number of frames, we try to
1059 * deflate this number of frames. Otherwise, deflation is
1060 * performed according to the target and balloon size.
1061 */
1062 to_deflate_frames = n_frames ? n_frames - tried_frames :
1063 -vmballoon_change(b);
1064
1065 /* break if no work to do */
1066 if (to_deflate_frames <= 0)
1067 break;
1068
1069 /*
1070 * Calculate the number of frames based on current page size,
1071 * but limit the deflated frames to a single chunk
1072 */
> 1073 to_deflate_pages = min_t(unsigned long, b->batch_max_pages,
1074 DIV_ROUND_UP(to_deflate_frames,
1075 page_in_frames));
1076
1077 /* First take the pages from the balloon pages. */
1078 vmballoon_dequeue_page_list(b, &ctl.pages, &ctl.n_pages,
1079 ctl.page_size, to_deflate_pages);
1080
1081 /*
1082 * Before pages are moving to the refused list, count their
1083 * frames as frames that we tried to deflate.
1084 */
1085 tried_frames += ctl.n_pages * page_in_frames;
1086
1087 /*
1088 * Unlock the pages by communicating with the hypervisor if the
1089 * communication is coordinated (i.e., not pop). We ignore the
1090 * return code. Instead we check if all the pages we manage to
1091 * unlock all the pages. If we failed, we will move to the next
1092 * page size, and would eventually try again later.
1093 */
1094 if (coordinated)
1095 vmballoon_lock(b, &ctl);
1096
1097 /*
1098 * Check if we deflated enough. We will move to the next page
1099 * size if we did not manage to do so. This calculation takes
1100 * place now, as once the pages are released, the number of
1101 * pages is zeroed.
1102 */
1103 deflated_all = (ctl.n_pages == to_deflate_pages);
1104
1105 /* Update local and global counters */
1106 n_unlocked_frames = ctl.n_pages * page_in_frames;
1107 atomic64_sub(n_unlocked_frames, &b->size);
1108 deflated_frames += n_unlocked_frames;
1109
1110 vmballoon_stats_page_add(b, VMW_BALLOON_PAGE_STAT_FREE,
1111 ctl.page_size, ctl.n_pages);
1112
1113 /* free the ballooned pages */
1114 vmballoon_release_page_list(&ctl.pages, &ctl.n_pages,
1115 ctl.page_size);
1116
1117 /* Return the refused pages to the ballooned list. */
1118 vmballoon_enqueue_page_list(b, &ctl.refused_pages,
1119 &ctl.n_refused_pages,
1120 ctl.page_size);
1121
1122 /* If we failed to unlock all the pages, move to next size. */
1123 if (!deflated_all) {
1124 if (ctl.page_size == b->max_page_size)
1125 break;
1126 ctl.page_size++;
1127 }
1128
1129 cond_resched();
1130 }
1131
1132 return deflated_frames;
1133 }
1134
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Attachment:
.config.gz
Description: application/gzip