Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/vas: Limit open window failure messages in log bufffer

The VAS open window call prints error message and returns -EBUSY
after the migration suspend event initiated and until the resume
event completed on the destination system. It can cause the log
buffer filled with these error messages if the user space issues
continuous open window calls. Similar case even for DLPAR CPU
remove event when no credits are available until the credits are
freed or with the other DLPAR CPU add event.

So changes in the patch to use pr_err_ratelimited() instead of
pr_err() to display open window failure and not-available credits
error messages.

Use pr_fmt() and make the corresponding changes to have the
consistencein prefix all pr_*() messages (vas-api.c).

Fixes: 37e6764895ef ("powerpc/pseries/vas: Add VAS migration handler")
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
[mpe: Use "vas-api" as the prefix to match the file name.]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231019215033.1335251-1-haren@linux.ibm.com

authored by

Haren Myneni and committed by
Michael Ellerman
73b25505 3bf983e4

+18 -20
+16 -18
arch/powerpc/platforms/book3s/vas-api.c
··· 4 4 * Copyright (C) 2019 Haren Myneni, IBM Corp 5 5 */ 6 6 7 + #define pr_fmt(fmt) "vas-api: " fmt 8 + 7 9 #include <linux/kernel.h> 8 10 #include <linux/device.h> 9 11 #include <linux/cdev.h> ··· 80 78 task_ref->mm = get_task_mm(current); 81 79 if (!task_ref->mm) { 82 80 put_pid(task_ref->pid); 83 - pr_err("VAS: pid(%d): mm_struct is not found\n", 81 + pr_err("pid(%d): mm_struct is not found\n", 84 82 current->pid); 85 83 return -EPERM; 86 84 } ··· 237 235 rc = kill_pid_info(SIGSEGV, &info, pid); 238 236 rcu_read_unlock(); 239 237 240 - pr_devel("%s(): pid %d kill_proc_info() rc %d\n", __func__, 241 - pid_vnr(pid), rc); 238 + pr_devel("pid %d kill_proc_info() rc %d\n", pid_vnr(pid), rc); 242 239 } 243 240 244 241 void vas_dump_crb(struct coprocessor_request_block *crb) ··· 295 294 296 295 rc = copy_from_user(&uattr, uptr, sizeof(uattr)); 297 296 if (rc) { 298 - pr_err("%s(): copy_from_user() returns %d\n", __func__, rc); 297 + pr_err("copy_from_user() returns %d\n", rc); 299 298 return -EFAULT; 300 299 } 301 300 ··· 312 311 txwin = cp_inst->coproc->vops->open_win(uattr.vas_id, uattr.flags, 313 312 cp_inst->coproc->cop_type); 314 313 if (IS_ERR(txwin)) { 315 - pr_err("%s() VAS window open failed, %ld\n", __func__, 314 + pr_err_ratelimited("VAS window open failed rc=%ld\n", 316 315 PTR_ERR(txwin)); 317 316 return PTR_ERR(txwin); 318 317 } ··· 406 405 * window is not opened. Shouldn't expect this error. 407 406 */ 408 407 if (!cp_inst || !cp_inst->txwin) { 409 - pr_err("%s(): Unexpected fault on paste address with TX window closed\n", 410 - __func__); 408 + pr_err("Unexpected fault on paste address with TX window closed\n"); 411 409 return VM_FAULT_SIGBUS; 412 410 } 413 411 ··· 421 421 * issue NX request. 422 422 */ 423 423 if (txwin->task_ref.vma != vmf->vma) { 424 - pr_err("%s(): No previous mapping with paste address\n", 425 - __func__); 424 + pr_err("No previous mapping with paste address\n"); 426 425 return VM_FAULT_SIGBUS; 427 426 } 428 427 ··· 480 481 txwin = cp_inst->txwin; 481 482 482 483 if ((vma->vm_end - vma->vm_start) > PAGE_SIZE) { 483 - pr_debug("%s(): size 0x%zx, PAGE_SIZE 0x%zx\n", __func__, 484 + pr_debug("size 0x%zx, PAGE_SIZE 0x%zx\n", 484 485 (vma->vm_end - vma->vm_start), PAGE_SIZE); 485 486 return -EINVAL; 486 487 } 487 488 488 489 /* Ensure instance has an open send window */ 489 490 if (!txwin) { 490 - pr_err("%s(): No send window open?\n", __func__); 491 + pr_err("No send window open?\n"); 491 492 return -EINVAL; 492 493 } 493 494 494 495 if (!cp_inst->coproc->vops || !cp_inst->coproc->vops->paste_addr) { 495 - pr_err("%s(): VAS API is not registered\n", __func__); 496 + pr_err("VAS API is not registered\n"); 496 497 return -EACCES; 497 498 } 498 499 ··· 509 510 */ 510 511 mutex_lock(&txwin->task_ref.mmap_mutex); 511 512 if (txwin->status != VAS_WIN_ACTIVE) { 512 - pr_err("%s(): Window is not active\n", __func__); 513 + pr_err("Window is not active\n"); 513 514 rc = -EACCES; 514 515 goto out; 515 516 } 516 517 517 518 paste_addr = cp_inst->coproc->vops->paste_addr(txwin); 518 519 if (!paste_addr) { 519 - pr_err("%s(): Window paste address failed\n", __func__); 520 + pr_err("Window paste address failed\n"); 520 521 rc = -EINVAL; 521 522 goto out; 522 523 } ··· 532 533 rc = remap_pfn_range(vma, vma->vm_start, pfn + vma->vm_pgoff, 533 534 vma->vm_end - vma->vm_start, prot); 534 535 535 - pr_devel("%s(): paste addr %llx at %lx, rc %d\n", __func__, 536 - paste_addr, vma->vm_start, rc); 536 + pr_devel("paste addr %llx at %lx, rc %d\n", paste_addr, 537 + vma->vm_start, rc); 537 538 538 539 txwin->task_ref.vma = vma; 539 540 vma->vm_ops = &vas_vm_ops; ··· 608 609 goto err; 609 610 } 610 611 611 - pr_devel("%s: Added dev [%d,%d]\n", __func__, MAJOR(devno), 612 - MINOR(devno)); 612 + pr_devel("Added dev [%d,%d]\n", MAJOR(devno), MINOR(devno)); 613 613 614 614 return 0; 615 615
+2 -2
arch/powerpc/platforms/pseries/vas.c
··· 341 341 342 342 if (atomic_inc_return(&cop_feat_caps->nr_used_credits) > 343 343 atomic_read(&cop_feat_caps->nr_total_credits)) { 344 - pr_err("Credits are not available to allocate window\n"); 344 + pr_err_ratelimited("Credits are not available to allocate window\n"); 345 345 rc = -EINVAL; 346 346 goto out; 347 347 } ··· 424 424 425 425 put_vas_user_win_ref(&txwin->vas_win.task_ref); 426 426 rc = -EBUSY; 427 - pr_err("No credit is available to allocate window\n"); 427 + pr_err_ratelimited("No credit is available to allocate window\n"); 428 428 429 429 out_free: 430 430 /*