Re: [PATCH 2/5] mm/hmm: Clean up some coding style and comments

From: Ralph Campbell
Date: Thu Jun 06 2019 - 20:48:28 EST



On 6/6/19 8:57 AM, Jason Gunthorpe wrote:
On Mon, May 06, 2019 at 04:29:39PM -0700, rcampbell@xxxxxxxxxx wrote:
@@ -924,6 +922,7 @@ int hmm_range_register(struct hmm_range *range,
unsigned page_shift)
{
unsigned long mask = ((1UL << page_shift) - 1UL);
+ struct hmm *hmm;
range->valid = false;
range->hmm = NULL;

I was finishing these patches off and noticed that 'hmm' above is
never initialized.

I added the below to this patch:

diff --git a/mm/hmm.c b/mm/hmm.c
index 678873eb21930a..8e7403f081f44a 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -932,19 +932,20 @@ int hmm_range_register(struct hmm_range *range,
range->start = start;
range->end = end;
- range->hmm = hmm_get_or_create(mm);
- if (!range->hmm)
+ hmm = hmm_get_or_create(mm);
+ if (!hmm)
return -EFAULT;
/* Check if hmm_mm_destroy() was call. */
- if (range->hmm->mm == NULL || range->hmm->dead) {
- hmm_put(range->hmm);
+ if (hmm->mm == NULL || hmm->dead) {
+ hmm_put(hmm);
return -EFAULT;
}
/* Initialize range to track CPU page table updates. */
- mutex_lock(&range->hmm->lock);
+ mutex_lock(&hmm->lock);
+ range->hmm = hmm;
list_add_rcu(&range->list, &hmm->ranges);
/*

Which I think was the intent of adding the 'struct hmm *'. I prefer
this arrangement as it does not set an leave an invalid hmm pointer in
the range if there is a failure..

Most probably the later patches fixed this up?

Please confirm, thanks

Regards,
Jason


Yes, you understand correctly. That was the intended clean up.
I must have split my original patch set incorrectly.