Re: [tip: x86/mm] x86/mm/pat: Rename pat_rbtree.c to pat_interval.c

Ingo Molnar
2019-11-21T17:08:56Z

* Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Wed, Nov 20, 2019, 22:03 tip-bot2 for Davidlohr Bueso <
> tip-bot2@linutronix.de> wrote:
>
> >
> > x86/mm/pat: Rename pat_rbtree.c to pat_interval.c
> >
> > Considering that we don't use an rbtree but an interval tree,
> > rename the main file accordingly.
> >
>
> Wouldn't it be even better to not make the same mistake all over again, and
> instead of naming the file by an implementation detail, it should be named
> by what it does?
>
> Maybe pat_memtype.c or just pat_manage.c or something?
>
> Or even just pat.c?

Yeah, so incidentally, just before you made this suggestion yesterday, I
rearranged the files quite a bit in tip:WIP.x86/mm, and the latest naming
scheme is:

dagon:~/tip> ls -l arch/x86/mm/pat/
total 112
-rw-r--r-- 1 mingo mingo 5782 Nov 21 06:41 cpa-test.c
-rw-r--r-- 1 mingo mingo 117 Nov 21 06:41 Makefile
-rw-r--r-- 1 mingo mingo 32026 Nov 21 06:41 memtype.c
-rw-r--r-- 1 mingo mingo 1470 Nov 21 06:41 memtype.h
-rw-r--r-- 1 mingo mingo 5003 Nov 21 06:41 memtype_interval.c
-rw-r--r-- 1 mingo mingo 56668 Nov 21 06:41 set_memory.c

I named most of the files based on the API families they are
implementing:

- memtype*.c for the <asm/memtype.h> APIs
- set_memory.c for the <asm/set_memory.h> APIs.

Is this close to what you had in mind?

( Note: cpa-test.c is a leftover that should probably be renamed to
set_memory_test.c, with a few explicit set_memory() API tests added as
well, not just the internal change_page_attribute() tests. )

I also started the process of tidying up the API namespace which is a bit
of a historical accident as well, and I'm done with most of the memtype
funtions, which are now:

reserve_memtype() => memtype_reserve()
free_memtype() => memtype_free()
kernel_map_sync_memtype() => memtype_kernel_map_sync()
io_reserve_memtype() => memtype_reserve_io()
io_free_memtype() => memtype_free_io()

memtype_check_insert() => memtype_check_insert()
memtype_erase() => memtype_erase()
memtype_lookup() => memtype_lookup()
memtype_copy_nth_element() => memtype_copy_nth_element()

This work is in WIP.x86/mm:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.x86/mm

f53ee099dfac: x86/mm: Tabulate the page table encoding definitions
2ab1a9a197f7: x86/mm/pat: Fix typo in the Kconfig help text
0d2a9498e4db: x86/mm/pat: Clean up <asm/memtype.h> externs
2e2ee215db87: x86/mm/pat: Rename <asm/pat.h> => <asm/memtype.h>
84285e92bb7a: x86/mm/pat: Standardize on memtype_*() prefix for APIs
b2c61e70ccca: x86/mm/pat: Move the memtype related files to arch/x86/mm/pat/
f54b639ad101: x86/mm/pat: Clean up PAT initialization flags
bca867e88012: x86/mm/pat: Harmonize 'struct memtype *' local variable and function parameter use
35459848e92f: x86/mm/pat: Simplify the free_memtype() control flow
a71fbb6061dc: x86/mm/pat: Create fixed width output in /sys/kernel/debug/x86/pat_memtype_list, similar to the E820 debug printouts
a252a95b6b91: x86/mm/pat: Disambiguate PAT-disabled boot messages
83d743db88c5: x86/mm/pat: Update the comments in pat.c and pat_interval.c and refresh the code a bit

820cac65197c: x86/mm/pat: Rename pat_rbtree.c to pat_interval.c
010ca1041da3: x86/mm/pat: Drop the rbt_ prefix from external memtype calls
a2cb4c9af315: x86/mm/pat: Do not pass 'rb_root' down the memtype tree helper functions
2418ac70a9c1: x86/mm/pat: Convert the PAT tree to a generic interval tree

But there's still quite some work left. I'll send out a series once I
think the end result is a coherent whole.

Davidlohr's four patches are intended for v5.5, the remaining patches
from me on top of his work will probably need a bit more testing.

Thanks,

Ingo