linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org,
	vishal.l.verma@intel.com, ira.weiny@intel.com,
	alison.schofield@intel.com
Subject: Re: [PATCH v2 2/4] cxl/mem: Fix synchronization mechanism for device removal vs ioctl operations
Date: Tue, 30 Mar 2021 08:16:20 -0300	[thread overview]
Message-ID: <20210330111620.GK2356281@nvidia.com> (raw)
In-Reply-To: <161707246948.2072157.2116502455691653472.stgit@dwillia2-desk3.amr.corp.intel.com>

On Mon, Mar 29, 2021 at 07:47:49PM -0700, Dan Williams wrote:

> @@ -1155,21 +1175,12 @@ static void cxlmdev_unregister(void *_cxlmd)
>  	struct cxl_memdev *cxlmd = _cxlmd;
>  	struct device *dev = &cxlmd->dev;
>  
> -	percpu_ref_kill(&cxlmd->ops_active);
>  	cdev_device_del(&cxlmd->cdev, dev);
> -	wait_for_completion(&cxlmd->ops_dead);
> +	synchronize_srcu(&cxl_memdev_srcu);

This needs some kind of rcu protected pointer for SRCU to to
work.. The write side has to null the pointer and the read side has to
copy the pointer to the stack and check for NULL. 

Otherwise the read side can't detect when the write side is shutting
down.

Basically you must use rcu_derference(), rcu_assign_pointer(), etc
when working with RCU.

Something like 'ops' is usually a reasonable choice

This really can't just be a simple rwsem?

Jason

  reply	other threads:[~2021-03-30 11:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-30  2:47 [PATCH v2 0/4] cxl/mem: Fix memdev device setup Dan Williams
2021-03-30  2:47 ` [PATCH v2 1/4] cxl/mem: Use sysfs_emit() for attribute show routines Dan Williams
2021-03-30  2:47 ` [PATCH v2 2/4] cxl/mem: Fix synchronization mechanism for device removal vs ioctl operations Dan Williams
2021-03-30 11:16   ` Jason Gunthorpe [this message]
2021-03-30 15:37     ` Dan Williams
2021-03-30 15:47       ` Jason Gunthorpe
2021-03-30 16:05         ` Dan Williams
2021-03-30 17:02           ` Jason Gunthorpe
2021-03-30 17:31             ` Dan Williams
2021-03-30 17:54               ` Jason Gunthorpe
2021-03-30 19:00                 ` Dan Williams
2021-03-30 19:26                   ` Jason Gunthorpe
2021-03-30 19:43                     ` Dan Williams
2021-03-30 19:51                       ` Jason Gunthorpe
2021-03-30 21:00                         ` Dan Williams
2021-03-30 22:09                           ` Jason Gunthorpe
2021-03-30  2:47 ` [PATCH v2 3/4] cxl/mem: Do not rely on device_add() side effects for dev_set_name() failures Dan Williams
2021-03-30  2:48 ` [PATCH v2 4/4] cxl/mem: Disable cxl device power management Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210330111620.GK2356281@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).