linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: afzal mohammed <afzal.mohd.ma@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: ARM: static kernel in vmalloc space
Date: Thu, 14 May 2020 17:32:41 +0200	[thread overview]
Message-ID: <CAK8P3a1PVwkAi8ycUAB-7EMk4nQ_qOu0rC5vJAQk_q9j5xvOJw@mail.gmail.com> (raw)
In-Reply-To: <20200514133545.GA5020@afzalpc>

On Thu, May 14, 2020 at 3:35 PM afzal mohammed <afzal.mohd.ma@gmail.com> wrote:
> On Thu, May 14, 2020 at 02:41:11PM +0200, Arnd Bergmann wrote:
> > On Thu, May 14, 2020 at 1:18 PM afzal mohammed <afzal.mohd.ma@gmail.com> wrote:
> > > 4. for user space to/from copy
> > >  a. pin user pages
> > >  b. kmap user page (can't corresponding lowmem be used instead ?)
>
> > - In the long run, there is no need for kmap()/kmap_atomic() after
> >   highmem gets removed from the kernel, but for the next few years
> >   we should still assume that highmem can be used, in order to support
> >   systems like the 8GB highbank, armadaxp, keystone2 or virtual
> >   machines. For lowmem pages (i.e. all pages when highmem is
> >   disabled), kmap_atomic() falls back to page_address() anyway,
> >   so there is no much overhead.
>
> Here i have some confusion - iiuc, VMSPLIT_4G_4G is meant to help
> platforms having RAM > 768M and <= 4GB disable high memory and still
> be able to access full RAM, so high memory shouldn't come into picture,
> right ?. And for the above platforms it can continue current VMPSLIT
> option (the default 3G/1G), no ?, as VMSPLIT_4G_4G can't help complete
> 8G to be accessible from lowmem.
>
> So if we make VMSPLIT_4G_4G, depends on !HIGH_MEMORY (w/ mention of
> caveat in Kconfig help that this is meant for platforms w/ <=4GB), then
> we can do copy_{from,to}_user the same way currently do, and no need to
> do the user page pinning & kmap, right ?

No, that doesn't work: the current copy_from_user() relies on the user
address space being a subset of the kernel address space, so it doesn't
have to walk the page tables but just access the pointer and use
the .text.fixup/__ex_table trick to trap any accesses to pages with the
wrong permission or no backing.

> ...
> i think user page pinning is still required, but kmap can be avoided
> by using lowmem corresponding to that page, right ?, or am i
> completely wrong ?

As long as one does not actually use highmem on a particular
machine, kmap_atomic() is much cheaper than the get_user_pages()
that is needed anyway:

static inline void *kmap_atomic_prot(struct page *page, pgprot_t prot)
{
        preempt_disable();
        pagefault_disable();
        if (!PageHighMem(page))
                return page_address(page);
        return kmap_atomic_high_prot(page, prot);
}
#define kmap_atomic(page)       kmap_atomic_prot(page, kmap_prot)

The preempt_disable()/pagefault_disable() are just adding to
variables that are usually on the local L1 cache, and the
page_address() is another multiply+add that you need in any
case. In kernels that disable highmem, the expensive code path
(kmap_atomic_high_prot) goes away entirely.

As a micro-optimization, one could use page_address() directly
instead of kmap_atomic() when highmem is disabled, but
I doubt it makes much of a difference.

> Only problem i see is Kernel compiled w/ VMSPLIT_4G_4G not suitable
> for >4GB machines, but anyway iiuc, it is was not meant for those
> machines. And it is not going to affect our current multiplatform
> setup as LPAE is not defined in multi_v7.

That was what I original thought as well, but I'd now prefer to
allow highmem to coexist with vmsplit-4g-4g:

Typical distros currently offer two kernels, with and without LPAE,
and they probably don't want to add a third one for LPAE with
either highmem or vmsplit-4g-4g. Having extra user address
space and more lowmem is both going to help users that
still have 8GB configurations.

If we want to limit the number of combinations, I'd prefer making
vmsplit-4g-4g mandatory for all LPAE kernels and it is stable
enough.

       Arnd

  parent reply	other threads:[~2020-05-14 15:33 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31  9:32 [PATCH 0/3] Highmem support for 32-bit RISC-V Eric Lin
2020-03-31  9:32 ` [PATCH 1/3] riscv/mm: Add pkmap region and CONFIG_HIGHMEM Eric Lin
2020-03-31  9:32 ` [PATCH 2/3] riscv/mm: Implement kmap() and kmap_atomic() Eric Lin
2020-03-31  9:32 ` [PATCH 3/3] riscv/mm: Add pkmap in print_vm_layout() Eric Lin
2020-04-02  9:31 ` [PATCH 0/3] Highmem support for 32-bit RISC-V Arnd Bergmann
2020-04-08  3:51   ` Alan Kao
2020-04-08 14:40     ` Arnd Bergmann
2020-04-14 15:17       ` afzal mohammed
2020-04-14 19:29         ` Arnd Bergmann
2020-04-15 13:54           ` afzal mohammed
2020-05-03 14:50             ` afzal mohammed
2020-05-03 20:20               ` Arnd Bergmann
2020-05-04  9:10                 ` afzal mohammed
2020-05-04 11:27                   ` Arnd Bergmann
2020-05-11 14:21                     ` ARM: static kernel in vmalloc space (was Re: [PATCH 0/3] Highmem support for 32-bit RISC-V) afzal mohammed
2020-05-11 15:29                       ` Arnd Bergmann
2020-05-12 10:47                         ` ARM: static kernel in vmalloc space afzal mohammed
2020-05-12 19:49                           ` Arnd Bergmann
2020-05-14 11:17                             ` afzal mohammed
2020-05-14 12:41                               ` Arnd Bergmann
2020-05-14 13:35                                 ` afzal mohammed
2020-05-14 14:44                                   ` afzal mohammed
2020-05-14 15:32                                   ` Arnd Bergmann [this message]
2020-05-16  6:06                                     ` afzal mohammed
2020-05-16  7:35                                       ` Arnd Bergmann
2020-06-07 12:59                                         ` ARM: vmsplit 4g/4g afzal mohammed
2020-06-07 16:11                                           ` Russell King - ARM Linux admin
2020-06-08 11:09                                             ` afzal mohammed
2020-06-10 10:10                                               ` Linus Walleij
2020-06-12 10:25                                                 ` afzal mohammed
2020-06-15  9:11                                                   ` Linus Walleij
2020-06-15 10:01                                                     ` afzal mohammed
2020-06-07 19:26                                           ` Arnd Bergmann
2020-06-08 11:18                                             ` afzal mohammed
2020-06-08 14:43                                               ` Arnd Bergmann
2020-06-08 15:17                                                 ` afzal mohammed
2020-06-09 12:15                                                   ` afzal mohammed
2020-06-09 14:22                                                     ` Arnd Bergmann
2020-05-14 16:25                                 ` ARM: static kernel in vmalloc space Russell King - ARM Linux admin
2020-05-14 21:12                                   ` Arnd Bergmann
2020-05-14 23:40                                     ` Russell King - ARM Linux admin
2020-05-15 15:41                                       ` Arnd Bergmann
2020-07-30  9:33                                         ` Linus Walleij
2020-07-30 10:17                                           ` Arnd Bergmann

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=CAK8P3a1PVwkAi8ycUAB-7EMk4nQ_qOu0rC5vJAQk_q9j5xvOJw@mail.gmail.com \
    --to=arnd@arndb.de \
    --cc=afzal.mohd.ma@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    /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).