[PATCH v2 1/3] mm/mmu_notifier: use structure for invalidate_range_start/end callback

Kuehling, Felix Felix.Kuehling at amd.com
Wed Dec 5 23:15:20 UTC 2018


On 2018-12-05 6:04 p.m., Jerome Glisse wrote:
> On Wed, Dec 05, 2018 at 09:42:45PM +0000, Kuehling, Felix wrote:
>> The amdgpu part looks good to me.
>>
>> A minor nit-pick in mmu_notifier.c (inline).
>>
>> Either way, the series is Acked-by: Felix Kuehling <Felix.Kuehling at amd.com>
>>
>> On 2018-12-05 12:36 a.m., jglisse at redhat.com wrote:
>>> From: Jérôme Glisse <jglisse at redhat.com>
>>>
>>> To avoid having to change many callback definition everytime we want
>>> to add a parameter use a structure to group all parameters for the
>>> mmu_notifier invalidate_range_start/end callback. No functional changes
>>> with this patch.
>>>
>>> Signed-off-by: Jérôme Glisse <jglisse at redhat.com>
>>> Cc: Andrew Morton <akpm at linux-foundation.org>
>>> Cc: Matthew Wilcox <mawilcox at microsoft.com>
>>> Cc: Ross Zwisler <zwisler at kernel.org>
>>> Cc: Jan Kara <jack at suse.cz>
>>> Cc: Dan Williams <dan.j.williams at intel.com>
>>> Cc: Paolo Bonzini <pbonzini at redhat.com>
>>> Cc: Radim Krčmář <rkrcmar at redhat.com>
>>> Cc: Michal Hocko <mhocko at kernel.org>
>>> Cc: Christian Koenig <christian.koenig at amd.com>
>>> Cc: Felix Kuehling <felix.kuehling at amd.com>
>>> Cc: Ralph Campbell <rcampbell at nvidia.com>
>>> Cc: John Hubbard <jhubbard at nvidia.com>
>>> Cc: kvm at vger.kernel.org
>>> Cc: dri-devel at lists.freedesktop.org
>>> Cc: linux-rdma at vger.kernel.org
>>> Cc: linux-fsdevel at vger.kernel.org
>>> ---
>>>  drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c  | 43 +++++++++++--------------
>>>  drivers/gpu/drm/i915/i915_gem_userptr.c | 14 ++++----
>>>  drivers/gpu/drm/radeon/radeon_mn.c      | 16 ++++-----
>>>  drivers/infiniband/core/umem_odp.c      | 20 +++++-------
>>>  drivers/infiniband/hw/hfi1/mmu_rb.c     | 13 +++-----
>>>  drivers/misc/mic/scif/scif_dma.c        | 11 ++-----
>>>  drivers/misc/sgi-gru/grutlbpurge.c      | 14 ++++----
>>>  drivers/xen/gntdev.c                    | 12 +++----
>>>  include/linux/mmu_notifier.h            | 14 +++++---
>>>  mm/hmm.c                                | 23 ++++++-------
>>>  mm/mmu_notifier.c                       | 21 ++++++++++--
>>>  virt/kvm/kvm_main.c                     | 14 +++-----
>>>  12 files changed, 102 insertions(+), 113 deletions(-)
>>>
>> [snip]
>>> diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
>>> index 5119ff846769..5f6665ae3ee2 100644
>>> --- a/mm/mmu_notifier.c
>>> +++ b/mm/mmu_notifier.c
>>> @@ -178,14 +178,20 @@ int __mmu_notifier_invalidate_range_start(struct mm_struct *mm,
>>>  				  unsigned long start, unsigned long end,
>>>  				  bool blockable)
>>>  {
>>> +	struct mmu_notifier_range _range, *range = &_range;
>> I'm not sure why you need to access _range indirectly through a pointer.
>> See below.
>>
>>
>>>  	struct mmu_notifier *mn;
>>>  	int ret = 0;
>>>  	int id;
>>>  
>>> +	range->blockable = blockable;
>>> +	range->start = start;
>>> +	range->end = end;
>>> +	range->mm = mm;
>> This could just assign _range.blockable, _range.start, etc. without the
>> indirection. Or you could even use an initializer instead:
>>
>> struct mmu_notifier_range range = {
>>     .blockable = blockable,
>>     .start = start,
>>     ...
>> };
>>
>>
>>> +
>>>  	id = srcu_read_lock(&srcu);
>>>  	hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist) {
>>>  		if (mn->ops->invalidate_range_start) {
>>> -			int _ret = mn->ops->invalidate_range_start(mn, mm, start, end, blockable);
>>> +			int _ret = mn->ops->invalidate_range_start(mn, range);
>> This could just use &_range without the indirection.
>>
>> Same in ..._invalidate_range_end below.
> So explaination is that this is a temporary step all this code is
> remove in the second patch. It was done this way in this patch to
> minimize the diff within the next patch.

I was actually looking for that because I suspected that this would make
more sense in the context of the other patches. But then I missed the
mmu_notifier.c change in patch 2 in the noise of all the other mm
changes. Never mind.


> I did this because i wanted to do the convertion in 2 steps the
> first step i convert all the listener of mmu notifier and in the
> second step i convert all the call site that trigger a mmu notifer.

That part makes sense and I appreciate that it keeps the patches
reasonably separate for different audiences.

Thanks,
  Felix


> I did that to help people reviewing only the part they care about.
>
> Apparently it end up confusing people more than it helped :)
>
> Do people have strong feeling about getting this code that is
> deleted in the second patch fix in the first patch anyway ?
>
> I can respin if so but i don't see much value in formating code
> that is deleted in the serie.
>
> Thank you for reviewing
>
> Cheers,
> Jérôme


More information about the dri-devel mailing list