From: Anshuman Khandual <anshuman.khandual@arm.com>
To: Mike Rapoport <rppt@linux.ibm.com>, lsf-pc@lists.linux-foundation.org
Cc: linux-mm@kvack.org
Subject: Re: [LSF/MM TOPIC]: memory management bits in arch/*
Date: Thu, 14 Feb 2019 14:07:10 +0530 [thread overview]
Message-ID: <2d0a7cd1-fdbf-b679-6692-440121e45a86@arm.com> (raw)
In-Reply-To: <20190128070705.GB2470@rapoport-lnx>
On 01/28/2019 12:37 PM, Mike Rapoport wrote:
> Hi,
>
> There is a lot of similar and duplicated code in architecture specific
> bits of memory management.
>
> For instance, as it was recently discussed at [1], most architectures
> have
>
> #define GFP_KERNEL | __GFP_ZERO
>
> for allocating page table pages and many of them use similar, if not
> identical, implementation of pte_alloc_one*().
As concluded earlier on that thread [1] apart from unifying allocation flags
as GFP_PGTABLE there is also a need for generic implementation for standard
page table page allocation/free functions like pte_alloc_one_[kernel]()/
pte_free_[kernel]() which can ensure that all page allocation/free goes
through pgtable_page_ctor/dtor constructs and user page table allocation
is accounted for it's memcg with __GFP_ACCOUNT.
IMHO zone stats for NR_PAGETABLE and memcg accounting for user page tables
should not be arch specific and the semantics should be same for all.
>
> But that's only the tip of the iceberg.
>
> I've seen several early_alloc() or similarly called routines that do
>
> if (slab_is_available())
> return kazalloc()
> else
> return memblock_alloc()
>
> Some other trivial examples are free_initmem(), free_initrd_mem() and,
> to some extent, mem_init(), but more generally there are a lot of
> similarities in arch/*/mm/.
Agreed.
>
> More complex cases are per-cpu initialization, passing of memory topology
> to the generic MM, reservation of crash kernel, mmap of vdso etc. They
> are not really duplicated, but still are very similar in at least
> several architectures.
>
> While factoring out the common code is an obvious step to take, I
> believe there is also room for refining arch <-> mm interface to avoid
> adding extra HAVE_ARCH_NO_BOOTMEM^w^wWHAT_NOT and then searching for
> ways to get rid of them.
>
> This is particularly true for mm initialization. It evolved the way
> it's evolved, but now we can step back to black/white board and
> consider design that hopefully will avoid problems like [2].
Factoring out common code one specific function at a time would be the
right approach. As suggested during GFP_PGTABLE thread, first define
a generic function and switch one arch at a time to use the generic
one. This will give enough time for each platform to evaluate before
subscribing to the new generic function. I would like to participate
in this discussion.
prev parent reply other threads:[~2019-02-14 8:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-28 7:07 Mike Rapoport
2019-02-14 8:37 ` Anshuman Khandual [this message]
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=2d0a7cd1-fdbf-b679-6692-440121e45a86@arm.com \
--to=anshuman.khandual@arm.com \
--cc=linux-mm@kvack.org \
--cc=lsf-pc@lists.linux-foundation.org \
--cc=rppt@linux.ibm.com \
/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