From: Mike Rapoport <rppt@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Matthew Wilcox <willy@infradead.org>,
Karolina Drobnik <karolinadrobnik@gmail.com>,
Linux-MM <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <mike.rapoport@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH 07/16] tools/include: Add io.h stub
Date: Mon, 31 Jan 2022 17:18:07 +0200 [thread overview]
Message-ID: <Yff9r+NdshpNKRk8@kernel.org> (raw)
In-Reply-To: <CAK8P3a1UcY7Lkm0U5igQCq2K5kpqpjVi-sW3R=JzpciS-+c-gQ@mail.gmail.com>
On Mon, Jan 31, 2022 at 02:30:32PM +0100, Arnd Bergmann wrote:
> On Sun, Jan 30, 2022 at 6:53 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> > Thanks for doing the sweep, Mike.
> >
> > I think I found a deeper problem which is masked due to our maze of
> > header files:
> >
> > include/asm-generic/io.h:#ifndef virt_to_phys
> > include/asm-generic/io.h:#define virt_to_phys virt_to_phys
> >
> > so there's an assumption that <asm/io.h> defines virt_to_phys().
> > You can see that in a number of architectures, eg:
> >
> > arch/alpha/include/asm/io.h:static inline unsigned long virt_to_phys(volatile void *address)
> > arch/ia64/include/asm/io.h:#define virt_to_phys virt_to_phys
> > arch/mips/include/asm/io.h:#define virt_to_phys virt_to_phys
> > arch/nios2/include/asm/io.h:#define virt_to_phys(vaddr) \
> > arch/parisc/include/asm/io.h:#define virt_to_phys(a) ((unsigned long)__pa(a))
> > arch/powerpc/include/asm/io.h:#define virt_to_phys virt_to_phys
> > arch/sh/include/asm/io.h:#define virt_to_phys(address) ((unsigned long)(address))
> > arch/x86/include/asm/io.h:#define virt_to_phys virt_to_phys
> >
> > That's clearly not the right place to define it. Two architectures
> > put it in asm/memory.h:
> >
> > arch/arm/include/asm/memory.h:#define virt_to_phys virt_to_phys
> > arch/arm64/include/asm/memory.h:#define virt_to_phys virt_to_phys
> >
> > then:
> >
> > arch/m68k/include/asm/virtconvert.h:#define virt_to_phys virt_to_phys
> > arch/sparc/include/asm/page_32.h:#define virt_to_phys __pa
> > arch/sparc/include/asm/page_64.h:#define virt_to_phys __pa
> >
> > This needs to be properly sorted out, but I don't want to tell Karolina
> > that's now her job as a prerequisite for merging this patchset; that
> > would be unfair.
> >
> > Cc'ing Arnd. This is the kind of awful mess that he loves fixing ;-)
>
> Adding Ingo as well. I'm in the middle of getting his fast-headers tree
> to work well on a couple of other architectures, and the memory.h/page.h/io.h
> mess is one of the tricky bits in there, both in his series and in my
> follow-ups.
>
> What makes this bit even worse is that the architectures also not just
> inconsistent about where they put __va/__pa and
> virt_to_phys/phys_to_virt, they are also inconsistent about which of the
> two pairs is based on the other, so any way you touch it means you
> will break something, and changing it now will likely require a tricky
> rebase of Ingo's patches.
Hmm, whatever we'll do with these conversions, it will be tricky for Ingo's
tree...
> Ingo, do you happen to have patches already that could be isolated
> from your series to address this? Maybe we can add the
> linux/mm_page_address.h header first and require that each
> architecture puts these macros into asm/page_address.h.
> We need to isolate these anyway, because the page addresses
> are used in a lot of places that don't need to include any of the
> remaining headers (page.h, mm.h, memory.h, io.h) that pull in
> hundreds more.
I peeked at Ingo's tree and there is this:
commit 3426911a3f83 (headers/deps: io/arch: Move the address translation
APIs from <asm/io.h> to <asm/io_extra.h>)
(https://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git/commit/?id=3426911a3f833930d92f3aebe349f09a513375d9)
It moves virt_to_phys and phys_to_virt on x86 to a new header.
I actually liked m68k's name for a header with virt_to_phys/phys_to_virt
definitions - virtconvert.h.
As an experiment I pulled out address translations from
arch/arm/include/memory.h to arch/arm/include/virtconvert.h, it wasn't that
bad:
arch/arm/include/asm/dma-mapping.h | 2 +
arch/arm/include/asm/io.h | 1 +
arch/arm/include/asm/memory.h | 244 ----------------------------------
arch/arm/include/asm/pgtable.h | 1 +
arch/arm/include/asm/virtconvert.h | 264 +++++++++++++++++++++++++++++++++++++
arch/arm/kernel/psci_smp.c | 1 +
6 files changed, 269 insertions(+), 244 deletions(-)
(https://git.kernel.org/rppt/linux/c/4c34ec16319fc85280aad89d7a74df845c1614fc)
> Arnd
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2022-01-31 15:18 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 13:21 [PATCH 00/16] Introduce memblock simulator Karolina Drobnik
2022-01-27 13:21 ` [PATCH 01/16] tools: Move gfp.h and slab.h from radix-tree to lib Karolina Drobnik
2022-01-27 13:28 ` Matthew Wilcox
2022-01-28 11:00 ` Karolina Drobnik
2022-01-27 13:36 ` Matthew Wilcox
2022-01-28 11:02 ` Karolina Drobnik
2022-01-28 17:30 ` Karolina Drobnik
2022-01-27 13:21 ` [PATCH 02/16] tools/include: Add phys_addr_t to types.h Karolina Drobnik
2022-01-27 13:21 ` [PATCH 03/16] tools/include: Add _RET_IP_ and math definitions to kernel.h Karolina Drobnik
2022-01-27 13:54 ` Matthew Wilcox
2022-01-28 11:05 ` Karolina Drobnik
2022-01-27 13:21 ` [PATCH 04/16] tools/include: Update atomic.h header Karolina Drobnik
2022-01-27 13:56 ` Matthew Wilcox
2022-01-28 11:08 ` Karolina Drobnik
2022-01-27 13:21 ` [PATCH 05/16] tools/include: Add mm.h file Karolina Drobnik
2022-01-27 13:21 ` [PATCH 06/16] tools/include: Add cache.h stub Karolina Drobnik
2022-01-27 14:00 ` Matthew Wilcox
2022-01-28 11:13 ` Karolina Drobnik
2022-01-28 13:10 ` Matthew Wilcox
2022-01-27 13:21 ` [PATCH 07/16] tools/include: Add io.h stub Karolina Drobnik
2022-01-27 14:09 ` Matthew Wilcox
2022-01-28 11:21 ` Karolina Drobnik
2022-01-30 16:10 ` Mike Rapoport
2022-01-30 17:53 ` Matthew Wilcox
2022-01-30 19:00 ` Mike Rapoport
2022-01-31 10:55 ` Karolina Drobnik
2022-01-31 13:30 ` Arnd Bergmann
2022-01-31 15:18 ` Mike Rapoport [this message]
2022-01-31 16:26 ` Arnd Bergmann
2022-01-31 10:54 ` Karolina Drobnik
2022-01-27 13:21 ` [PATCH 08/16] tools/include: Add pfn.h stub Karolina Drobnik
2022-01-27 13:21 ` [PATCH 09/16] tools/include: Add debugfs.h stub Karolina Drobnik
2022-01-27 13:21 ` [PATCH 10/16] memblock tests: Add skeleton of the memblock simulator Karolina Drobnik
2022-01-27 14:02 ` Matthew Wilcox
2022-01-27 14:06 ` Matthew Wilcox
2022-01-28 11:25 ` Karolina Drobnik
2022-01-28 13:11 ` Matthew Wilcox
2022-01-27 13:21 ` [PATCH 11/16] memblock tests: Add memblock reset function Karolina Drobnik
2022-01-27 13:21 ` [PATCH 12/16] memblock tests: Add memblock_add tests Karolina Drobnik
2022-01-27 13:21 ` [PATCH 13/16] memblock tests: Add memblock_reserve tests Karolina Drobnik
2022-01-27 13:21 ` [PATCH 14/16] memblock tests: Add memblock_remove tests Karolina Drobnik
2022-01-27 13:21 ` [PATCH 15/16] memblock tests: Add memblock_add_node test Karolina Drobnik
2022-01-27 13:21 ` [PATCH 16/16] memblock tests: Add memblock_free tests Karolina Drobnik
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=Yff9r+NdshpNKRk8@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=karolinadrobnik@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.rapoport@gmail.com \
--cc=mingo@redhat.com \
--cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).