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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-5.5b-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull more xen updates from Juergen Gross:

- a patch to fix a build warning

- a cleanup of no longer needed code in the Xen event handling

- a small series for the Xen grant driver avoiding high order
allocations and replacing an insane global limit by a per-call one

- a small series fixing Xen frontend/backend module referencing

* tag 'for-linus-5.5b-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
xen-blkback: allow module to be cleanly unloaded
xen/xenbus: reference count registered modules
xen/gntdev: switch from kcalloc() to kvcalloc()
xen/gntdev: replace global limit of mapped pages by limit per call
xen/gntdev: remove redundant non-zero check on ret
xen/events: remove event handling recursion detection

+66 -62
+8
drivers/block/xen-blkback/blkback.c
··· 1506 1506 1507 1507 module_init(xen_blkif_init); 1508 1508 1509 + static void __exit xen_blkif_fini(void) 1510 + { 1511 + xen_blkif_xenbus_fini(); 1512 + xen_blkif_interface_fini(); 1513 + } 1514 + 1515 + module_exit(xen_blkif_fini); 1516 + 1509 1517 MODULE_LICENSE("Dual BSD/GPL"); 1510 1518 MODULE_ALIAS("xen-backend:vbd");
+3
drivers/block/xen-blkback/common.h
··· 375 375 struct block_device *bdev; 376 376 blkif_sector_t sector_number; 377 377 }; 378 + 378 379 int xen_blkif_interface_init(void); 380 + void xen_blkif_interface_fini(void); 379 381 380 382 int xen_blkif_xenbus_init(void); 383 + void xen_blkif_xenbus_fini(void); 381 384 382 385 irqreturn_t xen_blkif_be_int(int irq, void *dev_id); 383 386 int xen_blkif_schedule(void *arg);
+11
drivers/block/xen-blkback/xenbus.c
··· 333 333 return 0; 334 334 } 335 335 336 + void xen_blkif_interface_fini(void) 337 + { 338 + kmem_cache_destroy(xen_blkif_cachep); 339 + xen_blkif_cachep = NULL; 340 + } 341 + 336 342 /* 337 343 * sysfs interface for VBD I/O requests 338 344 */ ··· 1127 1121 int xen_blkif_xenbus_init(void) 1128 1122 { 1129 1123 return xenbus_register_backend(&xen_blkbk_driver); 1124 + } 1125 + 1126 + void xen_blkif_xenbus_fini(void) 1127 + { 1128 + xenbus_unregister_driver(&xen_blkbk_driver); 1130 1129 }
+3 -13
drivers/xen/events/events_base.c
··· 1213 1213 notify_remote_via_irq(irq); 1214 1214 } 1215 1215 1216 - static DEFINE_PER_CPU(unsigned, xed_nesting_count); 1217 - 1218 1216 static void __xen_evtchn_do_upcall(void) 1219 1217 { 1220 1218 struct vcpu_info *vcpu_info = __this_cpu_read(xen_vcpu); 1221 - int cpu = get_cpu(); 1222 - unsigned count; 1219 + int cpu = smp_processor_id(); 1223 1220 1224 1221 do { 1225 1222 vcpu_info->evtchn_upcall_pending = 0; 1226 - 1227 - if (__this_cpu_inc_return(xed_nesting_count) - 1) 1228 - goto out; 1229 1223 1230 1224 xen_evtchn_handle_events(cpu); 1231 1225 1232 1226 BUG_ON(!irqs_disabled()); 1233 1227 1234 - count = __this_cpu_read(xed_nesting_count); 1235 - __this_cpu_write(xed_nesting_count, 0); 1236 - } while (count != 1 || vcpu_info->evtchn_upcall_pending); 1228 + virt_rmb(); /* Hypervisor can set upcall pending. */ 1237 1229 1238 - out: 1239 - 1240 - put_cpu(); 1230 + } while (vcpu_info->evtchn_upcall_pending); 1241 1231 } 1242 1232 1243 1233 void xen_evtchn_do_upcall(struct pt_regs *regs)
+1 -1
drivers/xen/gntdev-common.h
··· 81 81 82 82 void gntdev_put_map(struct gntdev_priv *priv, struct gntdev_grant_map *map); 83 83 84 - bool gntdev_account_mapped_pages(int count); 84 + bool gntdev_test_page_count(unsigned int count); 85 85 86 86 int gntdev_map_grant_pages(struct gntdev_grant_map *map); 87 87
+3 -8
drivers/xen/gntdev-dmabuf.c
··· 446 446 { 447 447 struct gntdev_grant_map *map; 448 448 449 - if (unlikely(count <= 0)) 449 + if (unlikely(gntdev_test_page_count(count))) 450 450 return ERR_PTR(-EINVAL); 451 451 452 452 if ((dmabuf_flags & GNTDEV_DMA_FLAG_WC) && ··· 459 459 if (!map) 460 460 return ERR_PTR(-ENOMEM); 461 461 462 - if (unlikely(gntdev_account_mapped_pages(count))) { 463 - pr_debug("can't map %d pages: over limit\n", count); 464 - gntdev_put_map(NULL, map); 465 - return ERR_PTR(-ENOMEM); 466 - } 467 462 return map; 468 463 } 469 464 ··· 766 771 if (copy_from_user(&op, u, sizeof(op)) != 0) 767 772 return -EFAULT; 768 773 769 - if (unlikely(op.count <= 0)) 774 + if (unlikely(gntdev_test_page_count(op.count))) 770 775 return -EINVAL; 771 776 772 777 refs = kcalloc(op.count, sizeof(*refs), GFP_KERNEL); ··· 813 818 if (copy_from_user(&op, u, sizeof(op)) != 0) 814 819 return -EFAULT; 815 820 816 - if (unlikely(op.count <= 0)) 821 + if (unlikely(gntdev_test_page_count(op.count))) 817 822 return -EINVAL; 818 823 819 824 gntdev_dmabuf = dmabuf_imp_to_refs(priv->dmabuf_priv,
+25 -39
drivers/xen/gntdev.c
··· 55 55 "Gerd Hoffmann <kraxel@redhat.com>"); 56 56 MODULE_DESCRIPTION("User-space granted page access driver"); 57 57 58 - static int limit = 1024*1024; 59 - module_param(limit, int, 0644); 60 - MODULE_PARM_DESC(limit, "Maximum number of grants that may be mapped by " 61 - "the gntdev device"); 62 - 63 - static atomic_t pages_mapped = ATOMIC_INIT(0); 58 + static unsigned int limit = 64*1024; 59 + module_param(limit, uint, 0644); 60 + MODULE_PARM_DESC(limit, 61 + "Maximum number of grants that may be mapped by one mapping request"); 64 62 65 63 static int use_ptemod; 66 64 ··· 69 71 70 72 /* ------------------------------------------------------------------ */ 71 73 72 - bool gntdev_account_mapped_pages(int count) 74 + bool gntdev_test_page_count(unsigned int count) 73 75 { 74 - return atomic_add_return(count, &pages_mapped) > limit; 76 + return !count || count > limit; 75 77 } 76 78 77 79 static void gntdev_print_maps(struct gntdev_priv *priv, ··· 112 114 gnttab_free_pages(map->count, map->pages); 113 115 114 116 #ifdef CONFIG_XEN_GRANT_DMA_ALLOC 115 - kfree(map->frames); 117 + kvfree(map->frames); 116 118 #endif 117 - kfree(map->pages); 118 - kfree(map->grants); 119 - kfree(map->map_ops); 120 - kfree(map->unmap_ops); 121 - kfree(map->kmap_ops); 122 - kfree(map->kunmap_ops); 119 + kvfree(map->pages); 120 + kvfree(map->grants); 121 + kvfree(map->map_ops); 122 + kvfree(map->unmap_ops); 123 + kvfree(map->kmap_ops); 124 + kvfree(map->kunmap_ops); 123 125 kfree(map); 124 126 } 125 127 ··· 133 135 if (NULL == add) 134 136 return NULL; 135 137 136 - add->grants = kcalloc(count, sizeof(add->grants[0]), GFP_KERNEL); 137 - add->map_ops = kcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL); 138 - add->unmap_ops = kcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL); 139 - add->kmap_ops = kcalloc(count, sizeof(add->kmap_ops[0]), GFP_KERNEL); 140 - add->kunmap_ops = kcalloc(count, sizeof(add->kunmap_ops[0]), GFP_KERNEL); 141 - add->pages = kcalloc(count, sizeof(add->pages[0]), GFP_KERNEL); 138 + add->grants = kvcalloc(count, sizeof(add->grants[0]), GFP_KERNEL); 139 + add->map_ops = kvcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL); 140 + add->unmap_ops = kvcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL); 141 + add->kmap_ops = kvcalloc(count, sizeof(add->kmap_ops[0]), GFP_KERNEL); 142 + add->kunmap_ops = kvcalloc(count, 143 + sizeof(add->kunmap_ops[0]), GFP_KERNEL); 144 + add->pages = kvcalloc(count, sizeof(add->pages[0]), GFP_KERNEL); 142 145 if (NULL == add->grants || 143 146 NULL == add->map_ops || 144 147 NULL == add->unmap_ops || ··· 158 159 if (dma_flags & (GNTDEV_DMA_FLAG_WC | GNTDEV_DMA_FLAG_COHERENT)) { 159 160 struct gnttab_dma_alloc_args args; 160 161 161 - add->frames = kcalloc(count, sizeof(add->frames[0]), 162 - GFP_KERNEL); 162 + add->frames = kvcalloc(count, sizeof(add->frames[0]), 163 + GFP_KERNEL); 163 164 if (!add->frames) 164 165 goto err; 165 166 ··· 239 240 240 241 if (!refcount_dec_and_test(&map->users)) 241 242 return; 242 - 243 - atomic_sub(map->count, &pages_mapped); 244 243 245 244 if (map->notify.flags & UNMAP_NOTIFY_SEND_EVENT) { 246 245 notify_remote_via_evtchn(map->notify.event); ··· 503 506 static int gntdev_open(struct inode *inode, struct file *flip) 504 507 { 505 508 struct gntdev_priv *priv; 506 - int ret = 0; 507 509 508 510 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 509 511 if (!priv) ··· 514 518 #ifdef CONFIG_XEN_GNTDEV_DMABUF 515 519 priv->dmabuf_priv = gntdev_dmabuf_init(flip); 516 520 if (IS_ERR(priv->dmabuf_priv)) { 517 - ret = PTR_ERR(priv->dmabuf_priv); 521 + int ret = PTR_ERR(priv->dmabuf_priv); 522 + 518 523 kfree(priv); 519 524 return ret; 520 525 } 521 526 #endif 522 - 523 - if (ret) { 524 - kfree(priv); 525 - return ret; 526 - } 527 527 528 528 flip->private_data = priv; 529 529 #ifdef CONFIG_XEN_GRANT_DMA_ALLOC ··· 565 573 if (copy_from_user(&op, u, sizeof(op)) != 0) 566 574 return -EFAULT; 567 575 pr_debug("priv %p, add %d\n", priv, op.count); 568 - if (unlikely(op.count <= 0)) 576 + if (unlikely(gntdev_test_page_count(op.count))) 569 577 return -EINVAL; 570 578 571 579 err = -ENOMEM; 572 580 map = gntdev_alloc_map(priv, op.count, 0 /* This is not a dma-buf. */); 573 581 if (!map) 574 582 return err; 575 - 576 - if (unlikely(gntdev_account_mapped_pages(op.count))) { 577 - pr_debug("can't map: over limit\n"); 578 - gntdev_put_map(NULL, map); 579 - return err; 580 - } 581 583 582 584 if (copy_from_user(map->grants, &u->refs, 583 585 sizeof(map->grants[0]) * op.count) != 0) {
+12 -1
drivers/xen/xenbus/xenbus_probe.c
··· 232 232 return err; 233 233 } 234 234 235 + if (!try_module_get(drv->driver.owner)) { 236 + dev_warn(&dev->dev, "failed to acquire module reference on '%s'\n", 237 + drv->driver.name); 238 + err = -ESRCH; 239 + goto fail; 240 + } 241 + 235 242 err = drv->probe(dev, id); 236 243 if (err) 237 - goto fail; 244 + goto fail_put; 238 245 239 246 err = watch_otherend(dev); 240 247 if (err) { ··· 251 244 } 252 245 253 246 return 0; 247 + fail_put: 248 + module_put(drv->driver.owner); 254 249 fail: 255 250 xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename); 256 251 xenbus_switch_state(dev, XenbusStateClosed); ··· 271 262 272 263 if (drv->remove) 273 264 drv->remove(dev); 265 + 266 + module_put(drv->driver.owner); 274 267 275 268 free_otherend_details(dev); 276 269