OSDN Git Service

misc/sgi-gru: use mmu_notifier_get/put for struct gru_mm_struct
authorJason Gunthorpe <jgg@mellanox.com>
Tue, 6 Aug 2019 23:15:41 +0000 (20:15 -0300)
committerJason Gunthorpe <jgg@mellanox.com>
Fri, 16 Aug 2019 15:02:59 +0000 (12:02 -0300)
commite4c057d02c9ef0b39bb88544b0c3c0a0a4d55ed6
treeb1840936690813e3898520822b8f73cf1ce8d6b7
parent2c7933f53f6bff7656e3324ca1a04e478bdc57c1
misc/sgi-gru: use mmu_notifier_get/put for struct gru_mm_struct

GRU is already using almost the same algorithm as get/put, it even
helpfully has a 10 year old comment to make this algorithm common, which
is finally happening.

There are a few differences and fixes from this conversion:
- GRU used rcu not srcu to read the hlist
- Unclear how the locking worked to prevent gru_register_mmu_notifier()
  from running concurrently with gru_drop_mmu_notifier() - this version is
  safe
- GRU had a release function which only set a variable without any locking
  that skiped the synchronize_srcu during unregister which looks racey,
  but this makes it reliable via the integrated call_srcu().
- It is unclear if the mmap_sem is actually held when
  __mmu_notifier_register() was called, lockdep will now warn if this is
  wrong

Link: https://lore.kernel.org/r/20190806231548.25242-5-jgg@ziepe.ca
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dimitri Sivanich <sivanich@hpe.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/misc/sgi-gru/grufile.c
drivers/misc/sgi-gru/grutables.h
drivers/misc/sgi-gru/grutlbpurge.c