[openeuler:OLK-5.10 3386/3386] fs/proc/task_mmu.c:192:23: warning: variable 'last_vma_start' set but not used
tree: https://gitee.com/openeuler/kernel.git OLK-5.10 head: 69d9543977fd7abe8b555406c7a3e5d64d8292f8 commit: 094a76ab06c367065280f8760d2100db0c8a0b6a [3386/3386] mm: proc: use per_vma mmap_lock for vma traversal. config: x86_64-allnoconfig-bpf (https://download.01.org/0day-ci/archive/20251209/202512090552.wjNONK6W-lkp@i...) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251209/202512090552.wjNONK6W-lkp@i...) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202512090552.wjNONK6W-lkp@intel.com/ All warnings (new ones prefixed by >>): fs/proc/task_mmu.c: In function 'numa_maps_next':
fs/proc/task_mmu.c:192:23: warning: variable 'last_vma_start' set but not used [-Wunused-but-set-variable] 192 | unsigned long last_vma_start; | ^~~~~~~~~~~~~~
Kconfig warnings: (for reference only) WARNING: unmet direct dependencies detected for PTP_1588_CLOCK Depends on [n]: NET [=y] && POSIX_TIMERS [=n] Selected by [m]: - SXE [=m] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_LINKDATA [=y] && (X86 [=y] || ARM64) && PCI [=y] - SXE_VF [=m] && NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_LINKDATA [=y] && (X86 [=y] || ARM64) && PCI [=y] vim +/last_vma_start +192 fs/proc/task_mmu.c 184 185 static void *numa_maps_next(struct seq_file *m, void *v, loff_t *ppos) 186 { 187 struct proc_maps_private *priv = m->private; 188 struct vm_area_struct *next = NULL; 189 struct vm_area_struct *vma = v; 190 struct mm_struct *mm = priv->mm; 191 unsigned long last_vma_end;
192 unsigned long last_vma_start; 193 int ret; 194 195 if (!mm) 196 goto out; 197 198 if (vma == priv->tail_vma) 199 goto out; 200 201 if (vma->vm_next) 202 next = vma->vm_next; 203 else 204 next = priv->tail_vma; 205 206 last_vma_end = vma->vm_end; 207 last_vma_start = vma->vm_start; 208 if (mmap_lock_is_contended(mm)) { 209 mmap_read_unlock(mm); 210 ret = mmap_read_lock_killable(mm); 211 if (ret) { 212 mmput(mm); 213 put_task_struct(priv->task); 214 priv->task = NULL; 215 return ERR_PTR(ret); 216 } 217 218 /* 219 * After dropping the lock, there are four cases to 220 * consider. See the following example for explanation. 221 * 222 * +------+------+-----------+ 223 * | VMA1 | VMA2 | VMA3 | 224 * +------+------+-----------+ 225 * | | | | 226 * 4k 8k 16k 400k 227 * 228 * Suppose we drop the lock after reading VMA2 due to 229 * contention, then we get: 230 * 231 * last_vma_end = 16k 232 * 233 * 1) VMA2 is freed, but VMA3 exists: 234 * 235 * find_vma(mm, 16k - 1) will return VMA3. 236 * In this case, just continue from VMA3. 237 * 238 * 2) VMA2 still exists: 239 * 240 * find_vma(mm, 16k - 1) will return VMA2. 241 * Iterate the loop like the original one. 242 * 243 * 3) No more VMAs can be found: 244 * 245 * find_vma(mm, 16k - 1) will return NULL. 246 * No more things to do, just break. 247 * 248 * 4) (last_vma_end - 1) is the middle of a vma (VMA'): 249 * 250 * find_vma(mm, 16k - 1) will return VMA' whose range 251 * contains last_vma_end. 252 * Iterate VMA' from last_vma_end. 253 */ 254 next = find_vma(mm, last_vma_end - 1); 255 256 /* Case 3 above */ 257 if (!next) 258 goto out; 259 260 /* Case 1 above */ 261 if (next->vm_start >= last_vma_end) 262 goto out; 263 264 /* Case 4 above */ 265 if (next->vm_end > last_vma_end) { 266 *ppos = last_vma_end; 267 return next; 268 } 269 270 /* Case 2 above */ 271 if (next->vm_next) 272 next = next->vm_next; 273 else 274 next = priv->tail_vma; 275 } 276 out: 277 *ppos = next ? next->vm_start : -1UL; 278 return next; 279 } 280
-- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
participants (1)
-
kernel test robot