From: Vlastimil Babka <vbabka@suse.cz>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] highmem: Don't disable preemption on RT in kmap_atomic()
Date: Tue, 10 Aug 2021 12:33:38 +0200 [thread overview]
Message-ID: <1458fa2b-d46c-98e9-510a-31e37469914a@suse.cz> (raw)
In-Reply-To: <20210810091116.pocdmaatdcogvdso@linutronix.de>
On 8/10/21 11:11 AM, Sebastian Andrzej Siewior wrote:
> kmap_atomic() disables preemption and pagefaults for historical
> reasons. The conversion to kmap_local(), which only disables
> migration, cannot be done wholesale because quite some call sites need
> to be updated to accommodate with the changed semantics.
>
> On PREEMPT_RT enabled kernels the kmap_atomic() semantics are
> problematic due to the implicit disabling of preemption which makes it
> impossible to acquire 'sleeping' spinlocks within the kmap atomic
> sections.
>
> PREEMPT_RT replaces the preempt_disable() with a migrate_disable() for
> more than a decade. It could be argued that this is a justification to
> do this unconditionally, but PREEMPT_RT covers only a limited number of
> architectures and it disables some functionality which limits the
> coverage further.
>
> Limit the replacement to PREEMPT_RT for now.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Note I use the same pattern in my SLUB series, but for performance reasons
(migrate_disable() is an unconditional function call etc). But I can guess what
would be the answer if I suggested this pattern to get a common shared wrapper,
so I won't :P
> ---
> include/linux/highmem-internal.h | 27 ++++++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h
> index 7902c7d8b55f9..4aa1031d3e4c3 100644
> --- a/include/linux/highmem-internal.h
> +++ b/include/linux/highmem-internal.h
> @@ -90,7 +90,11 @@ static inline void __kunmap_local(void *vaddr)
>
> static inline void *kmap_atomic_prot(struct page *page, pgprot_t prot)
> {
> - preempt_disable();
> + if (IS_ENABLED(CONFIG_PREEMPT_RT))
> + migrate_disable();
> + else
> + preempt_disable();
> +
> pagefault_disable();
> return __kmap_local_page_prot(page, prot);
> }
> @@ -102,7 +106,11 @@ static inline void *kmap_atomic(struct page *page)
>
> static inline void *kmap_atomic_pfn(unsigned long pfn)
> {
> - preempt_disable();
> + if (IS_ENABLED(CONFIG_PREEMPT_RT))
> + migrate_disable();
> + else
> + preempt_disable();
> +
> pagefault_disable();
> return __kmap_local_pfn_prot(pfn, kmap_prot);
> }
> @@ -111,7 +119,10 @@ static inline void __kunmap_atomic(void *addr)
> {
> kunmap_local_indexed(addr);
> pagefault_enable();
> - preempt_enable();
> + if (IS_ENABLED(CONFIG_PREEMPT_RT))
> + migrate_enable();
> + else
> + preempt_enable();
> }
>
> unsigned int __nr_free_highpages(void);
> @@ -179,7 +190,10 @@ static inline void __kunmap_local(void *addr)
>
> static inline void *kmap_atomic(struct page *page)
> {
> - preempt_disable();
> + if (IS_ENABLED(CONFIG_PREEMPT_RT))
> + migrate_disable();
> + else
> + preempt_disable();
> pagefault_disable();
> return page_address(page);
> }
> @@ -200,7 +214,10 @@ static inline void __kunmap_atomic(void *addr)
> kunmap_flush_on_unmap(addr);
> #endif
> pagefault_enable();
> - preempt_enable();
> + if (IS_ENABLED(CONFIG_PREEMPT_RT))
> + migrate_enable();
> + else
> + preempt_enable();
> }
>
> static inline unsigned int nr_free_highpages(void) { return 0; }
>
prev parent reply other threads:[~2021-08-10 10:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-10 9:11 Sebastian Andrzej Siewior
2021-08-10 10:33 ` Vlastimil Babka [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=1458fa2b-d46c-98e9-510a-31e37469914a@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterz@infradead.org \
--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