lkml.org 
[lkml]   [2021]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 2/4] cxl/mem: Fix synchronization mechanism for device removal vs ioctl operations
On Tue, Mar 30, 2021 at 04:36:37PM -0700, Dan Williams wrote:
> -static void cxlmdev_unregister(void *_cxlmd)
> +static void cxl_memdev_activate(struct cxl_memdev *cxlmd, struct cxl_mem *cxlm)
> {
> - struct cxl_memdev *cxlmd = _cxlmd;
> - struct device *dev = &cxlmd->dev;
> + cxlmd->cxlm = cxlm;
> + down_write(&cxl_memdev_rwsem);
> + up_write(&cxl_memdev_rwsem);
> +}

No reason not to put the assignment inside the lock. Though using the
lock at all is overkill as the pointer hasn't left the local stack
frame at this point.

> err_add:
> - ida_free(&cxl_memdev_ida, cxlmd->id);
> -err_id:
> /*
> - * Theoretically userspace could have already entered the fops,
> - * so flush ops_active.
> + * The cdev was briefly live, shutdown any ioctl operations that
> + * saw that state.
> */

Wow it is really subtle that cdev_device_add has this tiny hole where
it can fail but have already allowed open() :<

Other than the lock it looks OK

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason

\
 
 \ /
  Last update: 2021-03-31 15:08    [W:0.088 / U:0.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site