All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Jonathan Corbet <corbet@lwn.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ira Weiny <ira.weiny@intel.com>, Mike Rapoport <rppt@kernel.org>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, Mike Rapoport <rppt@linux.ibm.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] mm/highmem: Add notes about conversions from kmap{,_atomic}()
Date: Wed, 07 Dec 2022 14:01:50 +0100	[thread overview]
Message-ID: <2130641.irdbgypaU6@suse> (raw)
In-Reply-To: <Y5BIHdnP4yeJ8svL@linutronix.de>

On mercoledì 7 dicembre 2022 09:00:29 CET Sebastian Andrzej Siewior wrote:
> On 2022-12-06 20:12:13 [+0100], Fabio M. De Francesco wrote:
> > >   Furthermore, code between the kmap_atomic() and kunmap_atomic()
> > >   functions may implicitly depended
> > 
> > I suppose it should be "depend"? Shouldn't it?
> 
> Ehm, yes, correct.
> 
> > >   on the side effects of kmap_atomic()
> > >   namely disabling pagefaults or preemption or both.
> > 
> > I agree with you for rephrasing, mainly because it is
> > written in poor English.
> > 
> > However, I still have doubts about why you deleted "migration".
> > AFAIK, __kmap_local_pfn_prot() always takes care of disabling migration 
for
> > HIGHMEM enabled kernels.
> 
> That is correct. Historically kmap_atomic() never had a
> migrate_disable() statement - only preempt_disable(). With disabled
> preemption the task migration is implicitly disabled.

Sure, I understand this mechanism: task migration is implicitly disabled with 
disabled preemption.

> 
> > How about !HIGHMEM, where kmap_local_page() is an indirect call to
> > page_address()? Did you mean that, if the code between kmap_atomic() and
> > kunmap_atomic() depended on migrate_disable() (in PREEMPT_RT) we should
> > always just stay safe and call preempt_disable() together with conversion
> > to kmap_local_page()?
> 
> Even in the !HIGHMEM case it always uses preempt_disable().

With the only exception of PREEMPT_RT kernels, which instead use 
migrate_disable().

> With
> PREEMPT_RT it is different as it never disabled preemption and always
> did a migrate_disable() instead.

OK, I see that I'm recalling correctly :-) 

> If you talk about what needs to be
> considered while migrating away from kmap_atomic()

Yes, I'm trying to explain what needs to be considered while converting from 
kmap_atomic() by looking at all the different cases.

> then I wouldn't add
> the PREEMPT_RT bits to it since it was never in the picture while the
> code (using kmap_atomic()) was originally written.

Ah, OK. Now I understand why you changed my last phrase.
I agree with you, so I won't add anything about the special PREEMPT_RT case.

> > If so, I understand and I again agree with you. If not, I'm missing
> > something; so please let me understand properly.
> > 
> > Aside from the above, I'm not sure whether you deleted the last phrase
> > before
> > your suggestion. What about making it to become "For the above-mentioned
> > cases, conversions should also explicitly disable page-faults and/or
> > preemption"?
> 
> They need to disable preemption or page-faults or both if it is needed
> (not unconditionally) and where it is needed. This means not
> unconditionally over the whole kmap-ed section.

I never meant to suggest to _unconditionally_ disable page-faults 
and/or preemption. I was only trying to say that developers must carefully 
check whether or not the whole kmap-ed section depended on those side effects.

If so, they must _explicitly_ disable preemption or page-faults or both 
together with the use of kmap_local_page(). Instead, if the section doesn't 
depend on preemption and/or page-faults disabling, they must only replace 
kmap_atomic() with kmap_local_page().

I had probably used a bad wording when trying to say the same things that you 
wrote much more clearly.

Thanks,

Fabio

> 
> > Thanks again for noticing my mistakes.
> > 
> > Fabio
> 
> Sebastian





  reply	other threads:[~2022-12-07 13:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06  7:00 [PATCH] mm/highmem: Add notes about conversions from kmap{,_atomic}() Fabio M. De Francesco
2022-12-06  8:00 ` Sebastian Andrzej Siewior
2022-12-06 19:12   ` Fabio M. De Francesco
2022-12-07  8:00     ` Sebastian Andrzej Siewior
2022-12-07 13:01       ` Fabio M. De Francesco [this message]
2022-12-07 13:51         ` Sebastian Andrzej Siewior
2022-12-07 23:03           ` Fabio M. De Francesco
2022-12-06 19:14   ` Fabio M. De Francesco

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=2130641.irdbgypaU6@suse \
    --to=fmdefrancesco@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=corbet@lwn.net \
    --cc=ira.weiny@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@kernel.org \
    --cc=rppt@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.