From: Thomas Gleixner <tglx@linutronix.de>
To: ira.weiny@intel.com, Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Cc: linux-aio@kvack.org, linux-efi@vger.kernel.org,
kvm@vger.kernel.org, linux-doc@vger.kernel.org,
linux-mmc@vger.kernel.org,
Dave Hansen <dave.hansen@linux.intel.com>,
dri-devel@lists.freedesktop.org, linux-mm@kvack.org,
target-devel@vger.kernel.org, linux-mtd@lists.infradead.org,
linux-kselftest@vger.kernel.org, samba-technical@lists.samba.org,
Ira Weiny <ira.weiny@intel.com>,
ceph-devel@vger.kernel.org, drbd-dev@lists.linbit.com,
devel@driverdev.osuosl.org, linux-cifs@vger.kernel.org,
linux-nilfs@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-nvdimm@lists.01.org, linux-rdma@vger.kernel.org,
x86@kernel.org, amd-gfx@lists.freedesktop.org,
linux-afs@lists.infradead.org, cluster-devel@redhat.com,
linux-cachefs@redhat.com, intel-wired-lan@lists.osuosl.org,
xen-devel@lists.xenproject.org, linux-ext4@vger.kernel.org,
Fenghua Yu <fenghua.yu@intel.com>,
linux-um@lists.infradead.org, intel-gfx@lists.freedesktop.org,
ecryptfs@vger.kernel.org, linux-erofs@lists.ozlabs.org,
reiserfs-devel@vger.kernel.org, linux-block@vger.kernel.org,
linux-bcache@vger.kernel.org,
Dan Williams <dan.j.williams@intel.com>,
io-uring@vger.kernel.org, linux-nfs@vger.kernel.org,
linux-ntfs-dev@lists.sourceforge.net, netdev@vger.kernel.org,
Randy Dunlap <rdunlap@infradead.org>,
kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, bpf@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, linux-btrfs@vger.kernel.org
Subject: Re: [Drbd-dev] [PATCH RFC PKS/PMEM 05/58] kmap: Introduce k[un]map_thread
Date: Tue, 10 Nov 2020 02:13:56 +0100 [thread overview]
Message-ID: <87h7pyhv3f.fsf@nanos.tec.linutronix.de> (raw)
In-Reply-To: <20201009195033.3208459-6-ira.weiny@intel.com>
Ira,
On Fri, Oct 09 2020 at 12:49, ira weiny wrote:
> From: Ira Weiny <ira.weiny@intel.com>
>
> To correctly support the semantics of kmap() with Kernel protection keys
> (PKS), kmap() may be required to set the protections on multiple
> processors (globally). Enabling PKS globally can be very expensive
> depending on the requested operation. Furthermore, enabling a domain
> globally reduces the protection afforded by PKS.
>
> Most kmap() (Aprox 209 of 229) callers use the map within a single thread and
> have no need for the protection domain to be enabled globally. However, the
> remaining callers do not follow this pattern and, as best I can tell, expect
> the mapping to be 'global' and available to any thread who may access the
> mapping.[1]
>
> We don't anticipate global mappings to pmem, however in general there is a
> danger in changing the semantics of kmap(). Effectively, this would cause an
> unresolved page fault with little to no information about why the failure
> occurred.
>
> To resolve this a number of options were considered.
>
> 1) Attempt to change all the thread local kmap() calls to kmap_atomic()[2]
> 2) Introduce a flags parameter to kmap() to indicate if the mapping should be
> global or not
> 3) Change ~20 call sites to 'kmap_global()' to indicate that they require a
> global enablement of the pages.
> 4) Change ~209 call sites to 'kmap_thread()' to indicate that the mapping is to
> be used within that thread of execution only
>
> Option 1 is simply not feasible. Option 2 would require all of the call sites
> of kmap() to change. Option 3 seems like a good minimal change but there is a
> danger that new code may miss the semantic change of kmap() and not get the
> behavior the developer intended. Therefore, #4 was chosen.
There is Option #5:
Convert the thread local kmap() invocations to the proposed kmap_local()
interface which is coming along [1].
That solves a couple of issues:
1) It relieves the current kmap_atomic() usage sites from the implict
pagefault/preempt disable semantics which apply even when
CONFIG_HIGHMEM is disabled. kmap_local() still can be invoked from
atomic context.
2) Due to #1 it allows to replace the conditional usage of kmap() and
kmap_atomic() for purely thread local mappings.
3) It puts the burden on the HIGHMEM inflicted systems
4) It is actually more efficient for most of the pure thread local use
cases on HIGHMEM inflicted systems because it avoids the overhead of
the global lock and the potential kmap slot exhaustion. A potential
preemption will be more expensive, but that's not really the case we
want to optimize for.
5) It solves the RT issue vs. kmap_atomic()
So instead of creating yet another variety of kmap() which is just
scratching the particular PKRS itch, can we please consolidate all of
that on the wider reaching kmap_local() approach?
Thanks,
tglx
[1] https://lore.kernel.org/lkml/20201103092712.714480842@linutronix.de/
next prev parent reply other threads:[~2020-11-10 1:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 19:49 [Drbd-dev] [PATCH RFC PKS/PMEM 00/58] PMEM: Introduce stray write protection for PMEM ira.weiny
2020-10-09 19:49 ` [Drbd-dev] [PATCH RFC PKS/PMEM 04/58] kmap: Add stray access protection for device pages ira.weiny
2020-10-09 19:49 ` [Drbd-dev] [PATCH RFC PKS/PMEM 05/58] kmap: Introduce k[un]map_thread ira.weiny
2020-11-10 1:13 ` Thomas Gleixner [this message]
2020-11-10 4:59 ` Ira Weiny
2020-11-10 8:48 ` Thomas Gleixner
2020-10-09 19:49 ` [Drbd-dev] [PATCH RFC PKS/PMEM 07/58] drivers/drbd: Utilize new kmap_thread() ira.weiny
[not found] ` <20201009195033.3208459-25-ira.weiny@intel.com>
2020-10-13 11:25 ` [Drbd-dev] [PATCH RFC PKS/PMEM 24/58] fs/freevxfs: " Christoph Hellwig
2020-10-13 20:52 ` Ira Weiny
[not found] ` <20201009195033.3208459-34-ira.weiny@intel.com>
2020-10-13 18:36 ` [Drbd-dev] [PATCH RFC PKS/PMEM 33/58] fs/cramfs: " Nicolas Pitre
2020-10-13 18:44 ` Dan Williams
2020-10-13 19:36 ` Matthew Wilcox
2020-10-13 19:41 ` Dan Williams
2020-10-13 20:01 ` Al Viro
2020-10-13 20:50 ` Ira Weiny
2020-10-13 20:45 ` Ira Weiny
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=87h7pyhv3f.fsf@nanos.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=akpm@linux-foundation.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=bp@alien8.de \
--cc=bpf@vger.kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=cluster-devel@redhat.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=drbd-dev@lists.linbit.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecryptfs@vger.kernel.org \
--cc=fenghua.yu@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=io-uring@vger.kernel.org \
--cc=ira.weiny@intel.com \
--cc=kexec@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-afs@lists.infradead.org \
--cc=linux-aio@kvack.org \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-cachefs@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.org \
--cc=linux-ntfs-dev@lists.sourceforge.net \
--cc=linux-nvdimm@lists.01.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=reiserfs-devel@vger.kernel.org \
--cc=samba-technical@lists.samba.org \
--cc=target-devel@vger.kernel.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/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