Please pull hmm changes
Subsystems (5)
Hi Linus,
Here is this batch of hmm updates, I think we are nearing the end of this project for now, although I suspect there will be some more patches related to hmm_range_fault() in the next cycle.
You will probably be most interested in the patch "mm/mmu_notifier: add an interval tree notifier". The approach here largely pre-exists in the various drivers, but is honestly kind of complex/ugly. No better idea was found, I'm hoping putting it all in one place will help improve this over the long term. At least many bugs were squashed and lines of code eliminated while consolidating.
Already i915 GPU has posted a series for the next window that also needs this same approach.
There are two small conflicts I know of, the first is RDMA related with -rc, the second is a one liner updating a deleted comment in GPU. Both can be solved by using the hmm.git side of the conflict.
All the big driver changes have been acked and/or tested by their respective maintainers.
Regards,
Jason
The following changes since commit d6d5df1db6e9d7f8f76d2911707f7d5877251b02:
Linux 5.4-rc5 (2019-10-27 13:19:19 -0400)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git tags/for-linus-hmm
for you to fetch changes up to 93f4e735b6d98ee4b7a1252d81e815a983e359f2:
mm/hmm: remove hmm_range_dma_map and hmm_range_dma_unmap (2019-11-23 19:56:45 -0400)
----------------------------------------------------------------
hmm related patches for 5.5
This is another round of bug fixing and cleanup. This time the focus is on the driver pattern to use mmu notifiers to monitor a VA range. This code is lifted out of many drivers and hmm_mirror directly into the mmu_notifier core and written using the best ideas from all the driver implementations.
This removes many bugs from the drivers and has a very pleasing diffstat. More drivers can still be converted, but that is for another cycle.
- A shared branch with RDMA reworking the RDMA ODP implementation
- New mmu_interval_notifier API. This is focused on the use case of monitoring a VA and simplifies the process for drivers
- A common seq-count locking scheme built into the mmu_interval_notifier API usable by drivers that call get_user_pages() or hmm_range_fault() with the VA range
- Conversion of mlx5 ODP, hfi1, radeon, nouveau, AMD GPU, and Xen GntDev drivers to the new API. This deletes a lot of wonky driver code.
- Two improvements for hmm_range_fault(), from testing done by Ralph
----------------------------------------------------------------
Christoph Hellwig (1):
mm/hmm: remove hmm_range_dma_map and hmm_range_dma_unmap
Jason Gunthorpe (30):
RDMA/mlx5: Use SRCU properly in ODP prefetch
RDMA/mlx5: Split sig_err MR data into its own xarray
RDMA/mlx5: Use a dedicated mkey xarray for ODP
RDMA/mlx5: Delete struct mlx5_priv->mkey_table
RDMA/mlx5: Rework implicit_mr_get_data
RDMA/mlx5: Lift implicit_mr_alloc() into the two routines that call it RDMA/mlx5: Set the HW IOVA of the child MRs to their place in the tree RDMA/mlx5: Split implicit handling from pagefault_mr
RDMA/mlx5: Use an xarray for the children of an implicit ODP RDMA/mlx5: Reduce locking in implicit_mr_get_data()
RDMA/mlx5: Avoid double lookups on the pagefault path
RDMA/mlx5: Rework implicit ODP destroy
RDMA/mlx5: Do not store implicit children in the odp_mkeys xarray RDMA/mlx5: Do not race with mlx5_ib_invalidate_range during create and destroy RDMA/odp: Remove broken debugging call to invalidate_range
Merge branch 'odp_rework' into hmm.git
mm/mmu_notifier: define the header pre-processor parts even if disabled mm/mmu_notifier: add an interval tree notifier
mm/hmm: allow hmm_range to be used with a mmu_interval_notifier or hmm_mirror mm/hmm: define the pre-processor related parts of hmm.h even if disabled RDMA/odp: Use mmu_interval_notifier_insert()
RDMA/hfi1: Use mmu_interval_notifier_insert for user_exp_rcv drm/radeon: use mmu_interval_notifier_insert
nouveau: use mmu_notifier directly for invalidate_range_start
nouveau: use mmu_interval_notifier instead of hmm_mirror drm/amdgpu: Call find_vma under mmap_sem
drm/amdgpu: Use mmu_interval_insert instead of hmm_mirror drm/amdgpu: Use mmu_interval_notifier instead of hmm_mirror mm/hmm: remove hmm_mirror and related
xen/gntdev: use mmu_interval_notifier_insert
Ralph Campbell (2):
mm/hmm: allow snapshot of the special zero page mm/hmm: make full use of walk_page_range()
Documentation/vm/hmm.rst | 105 +-- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 9 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 14 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 443 ++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_mn.h | 53 -- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 13 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 145 ++-- drivers/gpu/drm/nouveau/nouveau_svm.c | 230 +++-- drivers/gpu/drm/radeon/radeon.h | 9 +- drivers/gpu/drm/radeon/radeon_mn.c | 218 +---- drivers/infiniband/core/device.c | 1 - drivers/infiniband/core/umem_odp.c | 341 ++------ drivers/infiniband/hw/hfi1/file_ops.c | 2 +- drivers/infiniband/hw/hfi1/hfi.h | 2 +- drivers/infiniband/hw/hfi1/user_exp_rcv.c | 146 ++-- drivers/infiniband/hw/hfi1/user_exp_rcv.h | 3 +- drivers/infiniband/hw/mlx5/cq.c | 33 +- drivers/infiniband/hw/mlx5/devx.c | 8 +- drivers/infiniband/hw/mlx5/main.c | 17 +- drivers/infiniband/hw/mlx5/mlx5_ib.h | 29 +- drivers/infiniband/hw/mlx5/mr.c | 142 ++- drivers/infiniband/hw/mlx5/odp.c | 1004 +++++++++++----------- drivers/net/ethernet/mellanox/mlx5/core/main.c | 4 - drivers/net/ethernet/mellanox/mlx5/core/mr.c | 28 +- drivers/xen/gntdev-common.h | 8 +- drivers/xen/gntdev.c | 179 ++-- include/linux/hmm.h | 190 +--- include/linux/mlx5/driver.h | 4 - include/linux/mmu_notifier.h | 147 +++- include/rdma/ib_umem_odp.h | 86 +- include/rdma/ib_verbs.h | 2 - kernel/fork.c | 1 - mm/Kconfig | 2 +- mm/hmm.c | 523 ++--------- mm/mmu_notifier.c | 557 +++++++++++- 37 files changed, 1912 insertions(+), 2789 deletions(-)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 3 lines · Jason Gunthorpe
You will probably be most interested in the patch "
mm/mmu_notifier: add an interval tree notifier".
I'm trying to read that patch, and I'm completely unable to by the absolutely *horrid* variable names.
There are zero excuses for names like "mmn_mm". WTF?
I'll try to figure the code out, but my initial reaction was "yeah, not in my VM".
Linus
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 3 lines · Linus Torvalds
I'll try to figure the code out, but my initial reaction was "yeah, not in my VM".
Why is it ok to sometimes do
WRITE_ONCE(mni->invalidate_seq, cur_seq);
(to pair with the unlocked READ_ONCE), and sometimes then do
mni->invalidate_seq = mmn_mm->invalidate_seq;
My initial guess was that latter is only done at initialization time, but at least in one case it's done *after* the mni has been added to the mmn_mm (oh, how I despise those names - I can only repeat: WTF?).
See __mmu_interval_notifier_insert() in themmn_mm->active_invalidate_ranges case.
I'm guessing that it doesn't matter, because when inserting the notifier the sequence number is presumably not used until after the insertion (and any use though mmn_mm is protected by the mmn_mm->lock), but it still looks odd to me.
Linus
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Jason Gunthorpe
Here is this batch of hmm updates, I think we are nearing the end of this project for now, although I suspect there will be some more patches related to
hmm_range_fault()in the next cycle.
I've ended up pulling this, but I'm not entirely happy with the code. You've already seen the comments on it in the earlier replies.
Linus
Quoted 10 lines · Linus Torvalds
Quoted 3 lines · Linus Torvalds
I'll try to figure the code out, but my initial reaction was "yeah, not in my VM".
Why is it ok to sometimes do
WRITE_ONCE(mni->invalidate_seq, cur_seq);
Quoted 7 lines
(to pair with the unlocked
READ_ONCE), and sometimes then domni->invalidate_seq = mmn_mm->invalidate_seq;My initial guess was that latter is only done at initialization time, but at least in one case it's done *after* the mni has been added to the
mmn_mm(oh, how I despise those names - I can only repeat: WTF?).
Yes, the only occurrences are in the notifier_insert, under the spinlock. The one case where it is out of the natural order was to make the manipulation of seq a bit saner, but in all cases since the spinlock is held there is no way for another thread to get the pointer to the 'mmu_interval_notifier *' to do the unlocked read.
Regarding the ugly names.. Naming has been really hard here because currently everything is a 'mmu notifier' and the natural abberviations from there are crummy. Here is the basic summary:
struct mmu_notifier_mm (ie the mm->mmu_notifier_mm)
-> mmn_mm
struct mm_struct
-> mm
struct mmu_notifier (ie the user subscription to the mm_struct)
-> mn
struct mmu_interval_notifier (the other kind of user subscription)
-> mni
struct mmu_notifier_range (ie the args to invalidate_range)
-> range
I can send a patch to switch mmn_mm to mmu_notifier_mm, which is the only pre-existing name for this value. But IIRC, it is a somewhat ugly with long line wrapping. 'mni' is a pain, I have to reflect on that. (honesly, I dislike mmu_notififer_mm quite a lot too)
I think it would be overall nicer with better names for the original structs. Perhaps:
mmn_* - MMU notifier prefix
mmn_state <- struct mmu_notifier_mm
mmn_subscription (mmn_sub) <- struct mmu_notifier mmn_range_subscription (mmn_range_sub) <- struct mmu_interval_notifier mmn_invalidate_desc <- struct mmu_notifier_range
At least this is how I describe them in my mind.. This is a lot of churn, and spreads through many drivers. This is why I kept the names as-is and we ended up with the also quite bad 'mmu_interval_notifier'
Maybe just switch mmu_notifier_mm for mmn_state and leave the drivers alone?
Anyone on the CC list have advice?
Jason
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 29 lines · Jason Gunthorpe
Quoted 10 lines · Linus Torvalds
Quoted 3 lines · Linus Torvalds
I'll try to figure the code out, but my initial reaction was "yeah, not in my VM".
Why is it ok to sometimes do
WRITE_ONCE(mni->invalidate_seq, cur_seq);Quoted 7 lines
(to pair with the unlocked
READ_ONCE), and sometimes then domni->invalidate_seq = mmn_mm->invalidate_seq;My initial guess was that latter is only done at initialization time, but at least in one case it's done *after* the mni has been added to the
mmn_mm(oh, how I despise those names - I can only repeat: WTF?).Yes, the only occurrences are in the
notifier_insert, under the spinlock. The one case where it is out of the natural order was to make the manipulation of seq a bit saner, but in all cases since the spinlock is held there is no way for another thread to get the pointer to the 'mmu_interval_notifier*' to do the unlocked read.Regarding the ugly names.. Naming has been really hard here because currently everything is a 'mmu notifier' and the natural abberviations from there are crummy. Here is the basic summary:
Quoted 8 lines
struct
mmu_notifier_mm(ie themm->mmu_notifier_mm)
->mmn_mm
structmm_struct
-> mm
structmmu_notifier(ie the user subscription to themm_struct)
-> mn
structmmu_interval_notifier(the other kind of user subscription)
-> mni
What about "interval" the context should already tell people it is related to mmu notifier and thus a notifier. I would just remove the notifier suffix, this would match the below range.
Quoted 2 lines
struct
mmu_notifier_range(ie the args toinvalidate_range)
-> range
Yeah range as context should tell you it is related to mmu notifier.
Quoted 6 lines
I can send a patch to switch
mmn_mmtommu_notifier_mm, which is the only pre-existing name for this value. But IIRC, it is a somewhat ugly with long line wrapping. 'mni' is a pain, I have to reflect on that. (honesly, I dislikemmu_notififer_mmquite a lot too)
Quoted 8 lines
I think it would be overall nicer with better names for the original structs. Perhaps:
mmn_* - MMU notifier prefix
mmn_state<- structmmu_notifier_mm
mmn_subscription(mmn_sub) <- structmmu_notifiermmn_range_subscription(mmn_range_sub) <- structmmu_interval_notifiermmn_invalidate_desc<- structmmu_notifier_range
This looks good.
Quoted 9 lines
At least this is how I describe them in my mind.. This is a lot of churn, and spreads through many drivers. This is why I kept the names as-is and we ended up with the also quite bad '
mmu_interval_notifier'Maybe just switch
mmu_notifier_mmformmn_stateand leave the drivers alone?Anyone on the CC list have advice?
Maybe we can do a semantic patch to do convertion and then Linus can easily apply the patch by just re-running the coccinelle.
Cheers,
Jérôme
On 12/2/19 6:42 PM, Jason Gunthorpe wrote:
...
Quoted 33 lines
Regarding the ugly names.. Naming has been really hard here because currently everything is a 'mmu notifier' and the natural abberviations from there are crummy. Here is the basic summary:
struct
mmu_notifier_mm(ie themm->mmu_notifier_mm)
->mmn_mm
structmm_struct
-> mm
structmmu_notifier(ie the user subscription to themm_struct)
-> mn
structmmu_interval_notifier(the other kind of user subscription)
-> mni
structmmu_notifier_range(ie the args toinvalidate_range)
-> rangeI can send a patch to switch
mmn_mmtommu_notifier_mm, which is the only pre-existing name for this value. But IIRC, it is a somewhat ugly with long line wrapping. 'mni' is a pain, I have to reflect on that. (honesly, I dislikemmu_notififer_mmquite a lot too)I think it would be overall nicer with better names for the original structs. Perhaps:
mmn_* - MMU notifier prefix
mmn_state<- structmmu_notifier_mm
mmn_subscription(mmn_sub) <- structmmu_notifiermmn_range_subscription(mmn_range_sub) <- structmmu_interval_notifiermmn_invalidate_desc<- structmmu_notifier_rangeAt least this is how I describe them in my mind.. This is a lot of churn, and spreads through many drivers. This is why I kept the names as-is and we ended up with the also quite bad '
mmu_interval_notifier'
Quoted 6 lines
Maybe just switch
mmu_notifier_mmformmn_stateand leave the drivers alone?Anyone on the CC list have advice?
Jason
No advice, just a naming idea similar in spirit to Jerome's suggestion (use a longer descriptive word, and don't try to capture the entire phrase):
use "notif" in place of the unloved "mmn". So partially, approximately like this:
notif_* <- MMU notifier prefix notif_state <- struct mmu_notifier_mm notif_subscription (notif_sub) <- struct mmu_notifier notif_invalidate_desc <- struct mmu_notifier_range*
notif_range_subscription (notif_range_sub) <- struct mmu_interval_notifier
thanks,
Signature · 2 lines
John Hubbard NVIDIA
Quoted 10 lines · John Hubbard
No advice, just a naming idea similar in spirit to Jerome's suggestion (use a longer descriptive word, and don't try to capture the entire phrase):
use "notif" in place of the unloved "mmn". So partially, approximately like this:notif_* <- MMU notifier prefix notif_state <- struct mmu_notifier_mm notif_subscription (notif_sub) <- struct mmu_notifier notif_invalidate_desc <- struct mmu_notifier_range*
notif_range_subscription(notif_range_sub) <- structmmu_interval_notifier
To me 'notif' suggests this belongs to the stuff in notifier.h - ie the naked word notififer is already taken
Jason
Quoted 9 lines · Jerome Glisse
Quoted 8 lines
struct
mmu_notifier_mm(ie themm->mmu_notifier_mm)
->mmn_mm
structmm_struct
-> mm
structmmu_notifier(ie the user subscription to themm_struct)
-> mn
structmmu_interval_notifier(the other kind of user subscription)
-> mni
Quoted 4 lines
What about "interval" the context should already tell people it is related to mmu notifier and thus a notifier. I would just remove the notifier suffix, this would match the below range.
Interval could be a good replacement for mni in the mm/mmu_notififer file if we don't do the wholesale rename
Quoted 10 lines
Quoted 8 lines
I think it would be overall nicer with better names for the original structs. Perhaps:
mmn_* - MMU notifier prefix
mmn_state<- structmmu_notifier_mm
mmn_subscription(mmn_sub) <- structmmu_notifiermmn_range_subscription(mmn_range_sub) <- structmmu_interval_notifiermmn_invalidate_desc<- structmmu_notifier_rangeThis looks good.
Well, lets just bite the bullet then and switch it. Do you like 'state'? I thought that was the weakest one
We could use mmnotif as the prefix, this makes the longest:
struct mmnotif_range_subscription
Which is reasonable enough
Quoted 2 lines
Maybe we can do a semantic patch to do convertion and then Linus can easily apply the patch by just re-running the coccinelle.
I tried this last time I renamed everything, it was OK, but it missed updating the comments. So it still needs some by-hand helping.
I'll make some patches next week when I get back.
Jason
Quoted 28 lines · Jason Gunthorpe
Quoted 9 lines · Jerome Glisse
Quoted 8 lines
struct
mmu_notifier_mm(ie themm->mmu_notifier_mm)
->mmn_mm
structmm_struct
-> mm
structmmu_notifier(ie the user subscription to themm_struct)
-> mn
structmmu_interval_notifier(the other kind of user subscription)
-> mniQuoted 4 lines
What about "interval" the context should already tell people it is related to mmu notifier and thus a notifier. I would just remove the notifier suffix, this would match the below range.
Interval could be a good replacement for mni in the
mm/mmu_notififerfile if we don't do the wholesale renameQuoted 9 lines
Quoted 8 lines
I think it would be overall nicer with better names for the original structs. Perhaps:
mmn_* - MMU notifier prefix
mmn_state<- structmmu_notifier_mm
mmn_subscription(mmn_sub) <- structmmu_notifiermmn_range_subscription(mmn_range_sub) <- structmmu_interval_notifiermmn_invalidate_desc<- structmmu_notifier_range
Quoted 4 lines
Quoted 1 line
This looks good.
Well, lets just bite the bullet then and switch it. Do you like 'state'? I thought that was the weakest one
Since you're asking, here's my bikeshed. I kinda agree _state looks a bit strange for this, what about a _link suffix in the spirit of
struct list_head link;
The other common name is "node", but I think that's confusing in the context of mm code. The purpose of this struct is to link everything together (and yes it carries also some state, but the main job is to link a mm_struct to a mmu_notifier). At least for me a _state is configuration state for a specific object, not something that links a bunch of things together. But I'm biased on this, since we use that pattern in drm for all the display state tracking.
Also feel free to ignore my bikeshed :-)
Aside from this I think the proposed names are a solid improvement. -Daniel
Quoted 20 lines
We could use mmnotif as the prefix, this makes the longest:
struct
mmnotif_range_subscriptionWhich is reasonable enough
Quoted 2 lines
Maybe we can do a semantic patch to do convertion and then Linus can easily apply the patch by just re-running the coccinelle.
I tried this last time I renamed everything, it was OK, but it missed updating the comments. So it still needs some by-hand helping.
I'll make some patches next week when I get back.
Jason
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 29 lines · Daniel Vetter
Quoted 28 lines · Jason Gunthorpe
Quoted 9 lines · Jerome Glisse
Quoted 8 lines
struct
mmu_notifier_mm(ie themm->mmu_notifier_mm)
->mmn_mm
structmm_struct
-> mm
structmmu_notifier(ie the user subscription to themm_struct)
-> mn
structmmu_interval_notifier(the other kind of user subscription)
-> mniQuoted 4 lines
What about "interval" the context should already tell people it is related to mmu notifier and thus a notifier. I would just remove the notifier suffix, this would match the below range.
Interval could be a good replacement for mni in the
mm/mmu_notififerfile if we don't do the wholesale renameQuoted 9 lines
Quoted 8 lines
I think it would be overall nicer with better names for the original structs. Perhaps:
mmn_* - MMU notifier prefix
mmn_state<- structmmu_notifier_mm
mmn_subscription(mmn_sub) <- structmmu_notifiermmn_range_subscription(mmn_range_sub) <- structmmu_interval_notifiermmn_invalidate_desc<- structmmu_notifier_range
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
This looks good.
Well, lets just bite the bullet then and switch it. Do you like 'state'? I thought that was the weakest one
Since you're asking, here's my bikeshed. I kinda agree
_statelooks a bit strange for this, what about a_linksuffix in the spirit of
Do you think calling it 'mmn_subscriptions' is clear?
Ie a struct mmn_subscriptions holds the lists of struct mmn_subscription and struct mmn_range_subscription?
Jason
Quoted 2 lines · Jason Gunthorpe
Do you think calling it '
mmn_subscriptions' is clear?
Why do you want that "mmn"?
Guys, the "mmn" part is clear from the _context_. The function name is
When the function name is something like "mmu_interval_read_begin()", and the filename is "mm/mmu_notifier.c", you do NOT NEED silly prefixes like "mmn" for local variables.
They add NOTHING.
And they make the code an illegible mess.
Yes, global function names need to be unique, and if they aren't really core, they want some prefix that explains the context, because global functions are called from _outside_ the context that explains them.
But if it's a "struct mmu_interval_notifier" pointer, and it's inside a file that is all about these pointers, it shouldn't be called "mmn_xyz". That's not a name. That's line noise.
So call it a "notifier". Maybe even an "interval_notifier" if you don't mind the typing. Name it by something _descriptive_. And if you want.
And "subscriptions" is a lovely name. What does the "mmn" buy you?
Just to clarify: the names I really hated were the local variable names (and the argument names) that were all entirely within the context of mm/mmu_notifier.c. Calling something "mmn_mm" is a random jumble of letters that looks more like you're humming than you're speaking.
Don't mumble. Speak _clearly_.
The other side of "short names" is that some non-local conventions exist because they are _so_ global. So if it's just a mm pointer, call it "mm". We do have some very core concepts in the kernel that permeate _everything_, and those core things we tend to have very short names for. So whenever you're working with VM code, you'll see lots of small names like "mm", "vma", "pte" etc. They aren't exactly clear, but they are _globally_ something you read and learn when you work on the Linux VM code.
That's very diofferent from "mmn" - the "mmn" thing isn't some global shorthand, it is just a local abomination.
So "notifier_mm" makes sense - it's the mm for a notifier. But "mmn_notifier" does not, because "mmn" only makes sense in a local context, and in that local context it's not any new information at all.
See the difference? Two shorthands, but one makes sense and adds information, while the other is just unnecessary and pointless and doesn't add anything at all.
Linus
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Linus Torvalds
On Wed, Dec 18, 2019 at 6:59 AM Jason Gunthorpe <[email protected]> wrote:
Yes, global function names need to be unique, and if they aren't really core, they want some prefix that explains the context, because global functions are called from _outside_ the context that explains them.
Yes, in this thread I have mostly talked about changing the global struct names, and for that mmn_ is the context explaining prefix.
Quoted 9 lines
But if it's a "struct
mmu_interval_notifier" pointer, and it's inside a file that is all about these pointers, it shouldn't be called "mmn_xyz". That's not a name. That's line noise.So call it a "notifier". Maybe even an "
interval_notifier" if you don't mind the typing. Name it by something _descriptive_. And if you want.And "subscriptions" is a lovely name. What does the "mmn" buy you?
To be clear, I was proposing this as the struct name:
'struct mmu_notifier_mm' becomes 'struct mmn_subscriptions'
(and similar for other mmu_notifier_x* and mmu_x_notifier patterns)
From there we now have a natural and readable local variable name like 'subscriptions' within mm/mmu_notifier.c
I've just started looking at this in detail, but it seems sticking with 'mmu_notifier_' as the global prefix will avoid a fair amount of churn. So lets not try to shorten it to mmn_ as the global prefix.
Quoted 5 lines
Just to clarify: the names I really hated were the local variable names (and the argument names) that were all entirely within the context of
mm/mmu_notifier.c. Calling something "mmn_mm" is a random jumble of letters that looks more like you're humming than you're speaking.
Yes, I understood - I've approached trying to have good names for the variables via having good names for their struct's.
Below is what I'm suggesting for the first patch. I am intending a patch series to make the naming better across mmu_notifier.h, this would be the first.
Next patches would probably replace 'mn' with 'list_sub' (struct mmu_notifier_subscription) and 'mni' with 'range_sub' (struct mmu_notifier_range_subscription).
Thus we have code working on a 'list_sub/range_sub' and storing it in a 'subscriptions'.
I think this is what you are looking for?
From c656d0862dedcc2f5f4beda129a2ac51c892be7e Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <[email protected]>
Date: Wed, 18 Dec 2019 13:40:35 -0400
Subject: [PATCH] mm/mmu_notifier: Rename struct mmu_notifier_mm to
mmu_notifier_subscriptions
The name mmu_notifier_mm implies that the thing is a mm_struct pointer, and is difficult to abbreviate. The struct is actually holding the interval tree and hlist containing the notifiers subscribed to a mm.
Use 'subscriptions' as the variable name for this struct instead of the really terrible and misleading 'mmn_mm'.
--- include/linux/mm_types.h | 2 +- include/linux/mmu_notifier.h | 18 +- kernel/fork.c | 4 +- mm/debug.c | 4 +- mm/mmu_notifier.c | 322 ++++++++++++++++++----------------- 5 files changed, 182 insertions(+), 168 deletions(-)
include/linux/mm_types.h +1 -1
@@ -490,7 +490,7 @@ struct mm_struct {/* store ref to file /proc/<pid>/exe symlink points to */ struct file __rcu *exe_file;#ifdef CONFIG_MMU_NOTIFIER -struct mmu_notifier_mm *mmu_notifier_mm; +struct mmu_notifier_subscriptions *notifier_subscriptions;#endif #if defined(CONFIG_TRANSPARENT_HUGEPAGE ) && !USE_SPLIT_PMD_PTLOCKS pgtable_t pmd_huge_pte;/* protected by page_table_lock */
include/linux/mmu_notifier.h +9 -9
@@ -8,7 +8,7 @@#include <linux/srcu.h> #include <linux/interval_tree.h> -struct mmu_notifier_mm ; +struct mmu_notifier_subscriptions ;struct mmu_notifier ;struct mmu_notifier_range ;struct mmu_interval_notifier ;
@@ -265,7 +265,7 @@ struct mmu_notifier_range {static inline int mm_has_notifiers (struct mm_struct *mm) { -return unlikely (mm->mmu_notifier_mm); +return unlikely (mm->notifier_subscriptions); } struct mmu_notifier *mmu_notifier_get_locked(const struct mmu_notifier_ops *ops,
@@ -364,7 +364,7 @@ static inline bool mmu_interval_check_retry(struct mmu_interval_notifier *mni,return READ_ONCE (mni->invalidate_seq) != seq; } -extern void __mmu_notifier_mm_destroy (struct mm_struct *mm); +extern void __mmu_notifier_subscriptions_destroy (struct mm_struct *mm);extern void __mmu_notifier_release (struct mm_struct *mm); extern int __mmu_notifier_clear_flush_young(struct mm_struct *mm, unsigned long start,
@@ -480,15 +480,15 @@ static inline void mmu_notifier_invalidate_range(struct mm_struct *mm,__mmu_notifier_invalidate_range (mm, start, end); } -static inline void mmu_notifier_mm_init (struct mm_struct *mm) +static inline void mmu_notifier_subscriptions_init (struct mm_struct *mm) { - mm->mmu_notifier_mm =NULL ; + mm->notifier_subscriptions =NULL ; } -static inline void mmu_notifier_mm_destroy (struct mm_struct *mm) +static inline void mmu_notifier_subscriptions_destroy (struct mm_struct *mm) {if (mm_has_notifiers (mm)) -__mmu_notifier_mm_destroy (mm); +__mmu_notifier_subscriptions_destroy (mm); }
@@ -692,11 +692,11 @@ static inline void mmu_notifier_invalidate_range(struct mm_struct *mm, { } -static inline void mmu_notifier_mm_init (struct mm_struct *mm) +static inline void mmu_notifier_subscriptions_init (struct mm_struct *mm) { } -static inline void mmu_notifier_mm_destroy (struct mm_struct *mm) +static inline void mmu_notifier_subscriptions_destroy (struct mm_struct *mm) { }
kernel/fork.c +2 -2
@@ -692,7 +692,7 @@ void __mmdrop(struct mm_struct *mm)WARN_ON_ONCE (mm == current->active_mm);mm_free_pgd (mm);destroy_context (mm); -mmu_notifier_mm_destroy (mm); +mmu_notifier_subscriptions_destroy (mm);check_mm (mm);put_user_ns (mm->user_ns);free_mm (mm);
@@ -1025,7 +1025,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,mm_init_aio (mm);mm_init_owner (mm, p);RCU_INIT_POINTER (mm->exe_file,NULL ); -mmu_notifier_mm_init (mm); +mmu_notifier_subscriptions_init (mm);init_tlb_flush_pending (mm);#if defined(CONFIG_TRANSPARENT_HUGEPAGE ) && !USE_SPLIT_PMD_PTLOCKS mm->pmd_huge_pte =NULL ;
mm/debug.c +2 -2
@@ -153,7 +153,7 @@ void dump_mm(const struct mm_struct *mm)#endif "exe_file %px\n" #ifdef CONFIG_MMU_NOTIFIER - "mmu_notifier_mm %px\n" + "notifier_subscriptions %px\n" #endif#ifdef CONFIG_NUMA_BALANCING "numa_next_scan %lu numa_scan_offset %lu numa_scan_seq %d\n"
@@ -185,7 +185,7 @@ void dump_mm(const struct mm_struct *mm)#endif mm->exe_file,#ifdef CONFIG_MMU_NOTIFIER - mm->mmu_notifier_mm, + mm->notifier_subscriptions,#endif #ifdef CONFIG_NUMA_BALANCING mm->numa_next_scan, mm->numa_scan_offset, mm->numa_scan_seq,
mm/mmu_notifier.c +168 -154
738 lines not on this page · raw message
Signature · 1 line
2.24.1
Quoted 2 lines · Jason Gunthorpe
I think this is what you are looking for?
I think that with these names, I would have had an easier time reading the original patch that made me go "Eww", yes.
Of course, now that it's just a rename patch, it's not like the patch is all that legible, but yeah, I think the naming is saner.
Linus