linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Song Liu <song@kernel.org>
Cc: "linux-modules@vger.kernel.org" <linux-modules@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"songliubraving@fb.com" <songliubraving@fb.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH/RFC] module: replace module_layout with module_memory
Date: Tue, 10 Jan 2023 06:31:41 +0000	[thread overview]
Message-ID: <154ed99c-5877-35f6-5e7d-9d7abada7d33@csgroup.eu> (raw)
In-Reply-To: <CAPhsuW7+BG9wYaoD6EYH-jnWqX30JdgNr5_733sO-++SzR5v3w@mail.gmail.com>



Le 09/01/2023 à 21:51, Song Liu a écrit :
> On Mon, Jan 9, 2023 at 10:24 AM Song Liu <song@kernel.org> wrote:
>>
>> On Mon, Jan 9, 2023 at 10:03 AM Christophe Leroy
>> <christophe.leroy@csgroup.eu> wrote:
>>>
>>>
>>>
>>> Le 06/01/2023 à 23:09, Song Liu a écrit :
>>>> module_layout manages different types of memory (text, data, rodata, etc.)
>>>> in one allocation, which is problematic for some reasons:
>>>>
>>>> 1. It is hard to enable CONFIG_STRICT_MODULE_RWX.
>>>> 2. It is hard to use huge pages in modules (and not break strict rwx).
>>>> 3. Many archs uses module_layout for arch-specific data, but it is not
>>>>      obvious how these data are used (are they RO, RX, or RW?)
>>>>
>>>> Improve the scenario by replacing 2 (or 3) module_layout per module with
>>>> up to 7 module_memory per module:
>>>>
>>>>           MOD_MEM_TYPE_TEXT,
>>>>           MOD_MEM_TYPE_DATA,
>>>>           MOD_MEM_TYPE_RODATA,
>>>>           MOD_MEM_TYPE_RO_AFTER_INIT,
>>>>           MOD_MEM_TYPE_INIT_TEXT,
>>>>           MOD_MEM_TYPE_INIT_DATA,
>>>>           MOD_MEM_TYPE_INIT_RODATA,
>>>>
>>>> and allocating them separately.
>>>>
>>>> Various archs use module_layout for different data. These data are put
>>>> into different module_memory based on their location in module_layout.
>>>> IOW, data that used to go with text is allocated with MOD_MEM_TYPE_TEXT;
>>>> data that used to go with data is allocated with MOD_MEM_TYPE_DATA, etc.
>>>
>>> I dislike how it looks with enums, things like
>>> mod->mod_mem[MOD_MEM_TYPE_INIT_TEXT] are odd and don't read nicely.
>>> Could we have something nicer like mod->mod_mem_init_text ?
>>> I know it will complicate your for_each_mod_mem_type() but it would look
>>> nicer.
>>
>> Hmm.. I am not sure whether we want 7 module_memory here. But if we
>> agree that it looks better like that, I am ok with it.
>>
>>>
>>> Also, can you explain how you switch from two trees to only one ?
>>> As far as I remember, the same question arised when I implemented
>>> CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC, and the conclusion was that
>>> we had to keep two independant trees, so I'm a bit puzzled that you have
>>> now merged everything into a single tree.
>>
>> AFAICT, we only need __module_address() to work? So one tree is enough.
>> Did I miss something?
> 
> Do you mean one tree will cause addr_[min|max] to be inaccurate?
> 

Yes at least. On powerpc you will have module text below kernel, 
somewhere between 0xb0000000 and 0xcfffffff, and you will have module 
data in vmalloc area, somewhere between 0xf0000000 and 0xffffffff.

If you have only one tree, any address between 0xc0000000 and 0xefffffff 
will trigger a tree search.

Christophe

  reply	other threads:[~2023-01-10  6:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 22:09 [PATCH/RFC] module: replace module_layout with module_memory Song Liu
2023-01-09 18:03 ` Christophe Leroy
2023-01-09 18:24   ` Song Liu
2023-01-09 20:51     ` Song Liu
2023-01-10  6:31       ` Christophe Leroy [this message]
2023-01-10  6:51         ` Song Liu
2023-01-18 15:07         ` Peter Zijlstra
2023-01-18 17:52           ` Song Liu
2023-01-10 18:31 ` Song Liu
2023-01-17 18:50   ` Song Liu
2023-01-18  7:40     ` Christoph Hellwig
2023-01-18 17:37       ` Song Liu
2023-01-18 21:52       ` Song Liu
2023-01-19  5:35         ` Christoph Hellwig
2023-01-19  8:29           ` Song Liu
2023-01-20 17:42             ` Song Liu
2023-01-23  6:57               ` Christoph Hellwig
2023-01-24 18:01                 ` Song Liu

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=154ed99c-5877-35f6-5e7d-9d7abada7d33@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=peterz@infradead.org \
    --cc=song@kernel.org \
    --cc=songliubraving@fb.com \
    --cc=tglx@linutronix.de \
    /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).