All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qi Zheng <qi.zheng@linux.dev>
To: Alistair Popple <apopple@nvidia.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	robin.murphy@arm.com, will@kernel.org, nicolinc@nvidia.com,
	linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
	jgg@nvidia.com, John Hubbard <jhubbard@nvidia.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] mmu_notifiers: Notify on pte permission upgrades
Date: Mon, 22 May 2023 16:28:54 +0800	[thread overview]
Message-ID: <05ab340a-d500-e742-fd59-5ef2e4ea86e0@linux.dev> (raw)
In-Reply-To: <87a5xwajn4.fsf@nvidia.com>



On 2023/5/22 15:45, Alistair Popple wrote:
> 
> Qi Zheng <qi.zheng@linux.dev> writes:
> 
>> Hi Alistair,
>>
>> On 2023/5/22 14:37, Alistair Popple wrote:
> 
> [...]
> 
>>> +	if (changed) {
>>> +		struct mmu_notifier_range range;
>>> +
>>> +		mmu_notifier_range_init(&range, MMU_NOTIFY_PROTECTION_UPGRADE,
>>> +					0, vmf->vma, vmf->vma->vm_mm,
>>> +					vmf->address & PAGE_MASK,
>>> +					(vmf->address & PAGE_MASK) + PAGE_SIZE);
>>> +		mmu_notifier_invalidate_range_start(&range);
>>> +		mmu_notifier_invalidate_range_end(&range);
>>> +	}
>>
>> There are four similar patterns, can we introduce a helper function to
>> deduplicate them?
> 
> For sure. How about something like this?
> 
> void mmu_notifier_range_start_end(enum mmu_notifier_event event,
>                                    struct vm_area_struct *vma,
>                                    struct mm_struct *mm,
>                                    unsigned long start,
>                                    unsigned long end)

LGTM. :)

> 
> As an aside I didn't just use mmu_notifier_invalidate_range() as that
> doesn't allow an event type to be set for interval notifiers which may
> want to filter this.
> 
>>> +
>>>    	return 0;
>>>    }
>>>    
> 

-- 
Thanks,
Qi

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Qi Zheng <qi.zheng@linux.dev>
To: Alistair Popple <apopple@nvidia.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	robin.murphy@arm.com, will@kernel.org, nicolinc@nvidia.com,
	linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
	jgg@nvidia.com, John Hubbard <jhubbard@nvidia.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] mmu_notifiers: Notify on pte permission upgrades
Date: Mon, 22 May 2023 16:28:54 +0800	[thread overview]
Message-ID: <05ab340a-d500-e742-fd59-5ef2e4ea86e0@linux.dev> (raw)
In-Reply-To: <87a5xwajn4.fsf@nvidia.com>



On 2023/5/22 15:45, Alistair Popple wrote:
> 
> Qi Zheng <qi.zheng@linux.dev> writes:
> 
>> Hi Alistair,
>>
>> On 2023/5/22 14:37, Alistair Popple wrote:
> 
> [...]
> 
>>> +	if (changed) {
>>> +		struct mmu_notifier_range range;
>>> +
>>> +		mmu_notifier_range_init(&range, MMU_NOTIFY_PROTECTION_UPGRADE,
>>> +					0, vmf->vma, vmf->vma->vm_mm,
>>> +					vmf->address & PAGE_MASK,
>>> +					(vmf->address & PAGE_MASK) + PAGE_SIZE);
>>> +		mmu_notifier_invalidate_range_start(&range);
>>> +		mmu_notifier_invalidate_range_end(&range);
>>> +	}
>>
>> There are four similar patterns, can we introduce a helper function to
>> deduplicate them?
> 
> For sure. How about something like this?
> 
> void mmu_notifier_range_start_end(enum mmu_notifier_event event,
>                                    struct vm_area_struct *vma,
>                                    struct mm_struct *mm,
>                                    unsigned long start,
>                                    unsigned long end)

LGTM. :)

> 
> As an aside I didn't just use mmu_notifier_invalidate_range() as that
> doesn't allow an event type to be set for interval notifiers which may
> want to filter this.
> 
>>> +
>>>    	return 0;
>>>    }
>>>    
> 

-- 
Thanks,
Qi

  reply	other threads:[~2023-05-22  8:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22  6:37 [PATCH] mmu_notifiers: Notify on pte permission upgrades Alistair Popple
2023-05-22  6:37 ` Alistair Popple
2023-05-22  7:15 ` Qi Zheng
2023-05-22  7:15   ` Qi Zheng
2023-05-22  7:45   ` Alistair Popple
2023-05-22  7:45     ` Alistair Popple
2023-05-22  8:28     ` Qi Zheng [this message]
2023-05-22  8:28       ` Qi Zheng
2023-05-22 15:09 ` Catalin Marinas
2023-05-22 15:09   ` Catalin Marinas
2023-05-22 23:52   ` Alistair Popple
2023-05-22 23:52     ` Alistair Popple
2023-05-22 18:34 ` Sean Christopherson
2023-05-22 18:34   ` Sean Christopherson
2023-05-22 23:50   ` Alistair Popple
2023-05-22 23:50     ` Alistair Popple
2023-05-23  0:06     ` Sean Christopherson
2023-05-23  0:06       ` Sean Christopherson
2023-05-23  0:43       ` Alistair Popple
2023-05-23  0:43         ` Alistair Popple
2023-05-23  1:13     ` John Hubbard
2023-05-23  1:13       ` John Hubbard
2023-05-23  4:35       ` Alistair Popple
2023-05-23  4:35         ` Alistair Popple
2023-05-23  0:55 ` John Hubbard
2023-05-23  0:55   ` John Hubbard
2023-05-23  1:12   ` Alistair Popple
2023-05-23  1:12     ` Alistair Popple
2023-05-23  6:45 ` Christoph Hellwig
2023-05-23  6:45   ` Christoph Hellwig

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=05ab340a-d500-e742-fd59-5ef2e4ea86e0@linux.dev \
    --to=qi.zheng@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=jgg@nvidia.com \
    --cc=jhubbard@nvidia.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.