diff options
| author | Jason Gunthorpe <jgg@mellanox.com> | 2019-05-23 10:17:22 -0400 |
|---|---|---|
| committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-06-18 10:55:20 -0400 |
| commit | 378a60406415bd20ec6e845a3d6883d460656537 (patch) | |
| tree | 7aeef111174ad31e590e3564a01a5668be484db9 | |
| parent | 8a9320b7ec5d879884c547fb73c35ac411a0b977 (diff) | |
mm/hmm: Remove duplicate condition test before wait_event_timeout
The wait_event_timeout macro already tests the condition as its first
action, so there is no reason to open code another version of this, all
that does is skip the might_sleep() debugging in common cases, which is
not helpful.
Further, based on prior patches, we can now simplify the required condition
test:
- If range is valid memory then so is range->hmm
- If hmm_release() has run then range->valid is set to false
at the same time as dead, so no reason to check both.
- A valid hmm has a valid hmm->mm.
Allowing the return value of wait_event_timeout() (along with its internal
barriers) to compute the result of the function.
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Reviewed-by: Ralph Campbell <rcampbell@nvidia.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Philip Yang <Philip.Yang@amd.com>
| -rw-r--r-- | include/linux/hmm.h | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 1d97b6d62c5b..26e7c477490c 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h | |||
| @@ -209,17 +209,8 @@ static inline unsigned long hmm_range_page_size(const struct hmm_range *range) | |||
| 209 | static inline bool hmm_range_wait_until_valid(struct hmm_range *range, | 209 | static inline bool hmm_range_wait_until_valid(struct hmm_range *range, |
| 210 | unsigned long timeout) | 210 | unsigned long timeout) |
| 211 | { | 211 | { |
| 212 | /* Check if mm is dead ? */ | 212 | return wait_event_timeout(range->hmm->wq, range->valid, |
| 213 | if (range->hmm == NULL || range->hmm->dead || range->hmm->mm == NULL) { | 213 | msecs_to_jiffies(timeout)) != 0; |
| 214 | range->valid = false; | ||
| 215 | return false; | ||
| 216 | } | ||
| 217 | if (range->valid) | ||
| 218 | return true; | ||
| 219 | wait_event_timeout(range->hmm->wq, range->valid || range->hmm->dead, | ||
| 220 | msecs_to_jiffies(timeout)); | ||
| 221 | /* Return current valid status just in case we get lucky */ | ||
| 222 | return range->valid; | ||
| 223 | } | 214 | } |
| 224 | 215 | ||
| 225 | /* | 216 | /* |
