Re: [PATCH v2 2/2] mm: validate device_hotplug is held for memory hotplug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 16, 2017 at 01:53:58PM -0800, Dan Williams wrote:
> mem_hotplug_begin() assumes that it can set mem_hotplug.active_writer
> and run the hotplug process without racing another thread. Validate this
> assumption with a lockdep assertion.
> 
> Cc: Michal Hocko <mhocko@xxxxxxxx>
> Cc: Toshi Kani <toshi.kani@xxxxxxx>
> Cc: Vlastimil Babka <vbabka@xxxxxxx>
> Cc: Logan Gunthorpe <logang@xxxxxxxxxxxx>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Reported-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
> Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
> ---
>  drivers/base/core.c    |    5 +++++
>  include/linux/device.h |    1 +
>  mm/memory_hotplug.c    |    2 ++
>  3 files changed, 8 insertions(+)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 8c25e68e67d7..3050e6f99403 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -638,6 +638,11 @@ int lock_device_hotplug_sysfs(void)
>  	return restart_syscall();
>  }
>  
> +void assert_held_device_hotplug(void)
> +{
> +	lockdep_assert_held(&device_hotplug_lock);
> +}
> +
>  #ifdef CONFIG_BLOCK
>  static inline int device_is_not_partition(struct device *dev)
>  {
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 491b4c0ca633..815965ee55dd 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -1135,6 +1135,7 @@ static inline bool device_supports_offline(struct device *dev)
>  extern void lock_device_hotplug(void);
>  extern void unlock_device_hotplug(void);
>  extern int lock_device_hotplug_sysfs(void);
> +void assert_held_device_hotplug(void);
>  extern int device_offline(struct device *dev);
>  extern int device_online(struct device *dev);
>  extern void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index b8c11e063ff0..1635a2a085e5 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -126,6 +126,8 @@ void put_online_mems(void)
>  
>  void mem_hotplug_begin(void)
>  {
> +	assert_held_device_hotplug();

What's the benefit to defining assert_held_device_hotplug() as a one line
wrapper, instead of just calling lockdep_assert_held(&device_hotplug_lock)
directly?

> +
>  	mem_hotplug.active_writer = current;
>  
>  	memhp_lock_acquire();
> 
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@xxxxxxxxxxxx
> https://lists.01.org/mailman/listinfo/linux-nvdimm

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]
  Powered by Linux