Re: [PATCH] iommu: arm-smmu-v3: Copy SMMU table for kdump kernel

2020-05-06 Thread Prabhakar Kushwaha
Thanks Robin for Review. Please find reply in-lined. On Tue, May 5, 2020 at 10:07 PM Robin Murphy wrote: > > [ fixed Will's address... ] > > On 2020-05-05 4:59 pm, Prabhakar Kushwaha wrote: > > An SMMU Stream table is created by the primary kernel. This table is > > used by the SMMU to perform a

Re: [PATCH] kernel: add panic_on_taint

2020-05-06 Thread Qian Cai
> On May 6, 2020, at 6:28 PM, Rafael Aquini wrote: > > Analogously to the introduction of panic_on_warn, this patch > introduces a kernel option named panic_on_taint in order to > provide a simple and generic way to stop execution and catch > a coredump when the kernel gets tainted by any give

[RFC 29/43] memblock: PKRAM: mark memblocks that contain preserved pages

2020-05-06 Thread Anthony Yznaga
To support deferred initialization of page structs for preserved pages, separate memblocks containing preserved pages by setting a new flag when adding them to the memblock reserved list. Signed-off-by: Anthony Yznaga --- include/linux/memblock.h | 7 +++ mm/memblock.c| 8 +++

[RFC 38/43] mm: implement splicing a list of pages to the LRU

2020-05-06 Thread Anthony Yznaga
Considerable contention on the LRU lock happens when multiple threads are used to insert pages into a shmem file in parallel. To alleviate this provide a way for pages to be added to the same LRU to be staged so that they can be added by splicing lists and updating stats once with the lock held. Fo

[RFC 41/43] XArray: add xas_export_node() and xas_import_node()

2020-05-06 Thread Anthony Yznaga
Contention on the xarray lock when multiple threads are adding to the same xarray can be mitigated by providing a way to add entries in bulk. Allow a caller to allocate and populate an xarray node outside of the target xarray and then only take the xarray lock long enough to import the node into i

[RFC 17/43] PKRAM: provide a way to check if a memory range has preserved pages

2020-05-06 Thread Anthony Yznaga
When a kernel is loaded for kexec the address ranges where the kexec segments will be copied to may conflict with pages already set to be preserved. Provide a way to determine if preserved pages exist in a specified range. Signed-off-by: Anthony Yznaga --- include/linux/pkram.h | 2 ++ mm/pkram

[RFC 39/43] shmem: optimize adding pages to the LRU in shmem_insert_pages()

2020-05-06 Thread Anthony Yznaga
Reduce LRU lock contention when inserting shmem pages by staging pages to be added to the same LRU and adding them en masse. Signed-off-by: Anthony Yznaga --- mm/shmem.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index ca5edf580f24..678a396

[RFC 15/43] PKRAM: provide a way to ban pages from use by PKRAM

2020-05-06 Thread Anthony Yznaga
Not all memory ranges can be used for saving preserved over-kexec data. For example, a kexec kernel may be loaded before pages are preserved. The memory regions where the kexec segments will be copied to on kexec must not contain preserved pages or else they will be clobbered. Originally-by: Vladi

[RFC 27/43] x86/mm/numa: add numa_isolate_memblocks()

2020-05-06 Thread Anthony Yznaga
Provide a way for a caller external to numa to ensure memblocks in the memblock reserved list do not cross node boundaries and have a node id assigned to them. This will be used by PKRAM to ensure initialization of page structs for preserved pages can be deferred and multithreaded efficiently. Si

[RFC 34/43] shmem: PKRAM: multithread preserving and restoring shmem pages

2020-05-06 Thread Anthony Yznaga
Improve performance by multithreading the work to preserve and restore shmem pages. Add 'pkram_max_threads=' kernel option to specify the maximum number of threads to use to preserve or restore the pages of a shmem file. The default is 16. When preserving pages each thread saves chunks of a file

[RFC 26/43] mm: shmem: when inserting, handle pages already charged to a memcg

2020-05-06 Thread Anthony Yznaga
If shmem_insert_page() is called to insert a page that was preserved using PKRAM on the current boot (i.e. preserved page is restored without an intervening kexec boot), the page will still be charged to a memory cgroup because it is never freed. Don't try to charge it again. Signed-off-by: Anthon

[RFC 23/43] mm: shmem: enable saving to PKRAM

2020-05-06 Thread Anthony Yznaga
This patch illustrates how the PKRAM API can be used for preserving tmpfs. Two options are added to tmpfs: The 'pkram=' option specifies the PKRAM node to load/save the filesystem tree from/to. The 'preserve' option initiates preservation of a read-only filesystem tree. If the 'pkr

[RFC 43/43] PKRAM: improve index alignment of pkram_link entries

2020-05-06 Thread Anthony Yznaga
To take advantage of optimizations when adding pages to the page cache via shmem_insert_pages(), improve the likelihood that the pages array passed to shmem_insert_pages() starts on an aligned index. Do this when preserving pages by starting a new pkram_link page when the current page is aligned a

[RFC 40/43] shmem: initial support for adding multiple pages to pagecache

2020-05-06 Thread Anthony Yznaga
shmem_insert_pages() currently loops over the array of pages passed to it and calls shmem_add_to_page_cache() for each one. Prepare for adding pages to the pagecache in bulk by adding and using a shmem_add_pages_to_cache() call. For now it just iterates over an array and adds pages individually, b

[RFC 12/43] mm: PKRAM: reserve preserved memory at boot

2020-05-06 Thread Anthony Yznaga
Keep preserved pages from being recycled during boot by adding them to the memblock reserved list during early boot. If memory reservation fails (e.g. a region has already been reserved), all preserved pages are dropped. For efficiency the preserved pages pagetable is used to identify and reserve

[RFC 42/43] shmem: reduce time holding xa_lock when inserting pages

2020-05-06 Thread Anthony Yznaga
Rather than adding one page at a time to the page cache and taking the page cache xarray lock each time, where possible add pages in bulk by first populating an xarray node outside of the page cache before taking the lock to insert it. When a group of pages to be inserted will fill an xarray node,

[RFC 33/43] PKRAM: atomically add and remove link pages

2020-05-06 Thread Anthony Yznaga
Add and remove pkram_link pages from a pkram_obj atomically to prepare for multithreading. Signed-off-by: Anthony Yznaga --- mm/pkram.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/mm/pkram.c b/mm/pkram.c index 5f4e4d12865f..042c14dedc25 100644

[RFC 05/43] mm: PKRAM: support preserving transparent hugepages

2020-05-06 Thread Anthony Yznaga
Support preserving a transparent hugepage by recording the page order and a flag indicating it is a THP. Use these values when the page is restored to reconstruct the THP. Signed-off-by: Anthony Yznaga --- include/linux/pkram.h | 2 ++ mm/pkram.c| 20 2 files c

[RFC 28/43] PKRAM: ensure memblocks with preserved pages init'd for numa

2020-05-06 Thread Anthony Yznaga
In order to facilitate fast initialization of page structs for preserved pages, memblocks with preserved pages must not cross numa node boundaries and must have a node id assigned to them. Signed-off-by: Anthony Yznaga --- mm/pkram.c | 10 ++ 1 file changed, 10 insertions(+) diff --git

[RFC 32/43] shmem: PKRAM: preserve shmem files a chunk at a time

2020-05-06 Thread Anthony Yznaga
To prepare for multithreading the work done to a preserve a file, divide the work into subranges of the total index range of the file. The chunk size is a rather arbitrary 256k indices. A new API call, pkram_prepare_save_chunk(), is added. It is called after calling pkram_prepare_save_obj(), and

[RFC 36/43] PKRAM: add support for loading pages in bulk

2020-05-06 Thread Anthony Yznaga
This patch adds three functions: pkram_prepare_load_pages() Called after calling pkram_prepare_load_obj() pkram_load_pages() Loads some number of pages that are contiguous by their original file index values. The index of the first page, an array of the page pointers, and the number of p

[RFC 37/43] shmem: PKRAM: enable bulk loading of preserved pages into shmem

2020-05-06 Thread Anthony Yznaga
Make use of new interfaces for loading and inserting preserved pages into a shmem file in bulk. Signed-off-by: Anthony Yznaga --- mm/shmem_pkram.c | 23 +-- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mm/shmem_pkram.c b/mm/shmem_pkram.c index 4992b6c3e54e..

[RFC 31/43] memblock, mm: defer initialization of preserved pages

2020-05-06 Thread Anthony Yznaga
Preserved pages are represented in the memblock reserved list, but page structs for pages in the reserved list are initialized early while boot is single threaded which means that a large number of preserved pages can impact boot time. To mitigate, defer initialization of preserved pages by skippin

[RFC 10/43] PKRAM: add code for walking the preserved pages pagetable

2020-05-06 Thread Anthony Yznaga
Add the ability to walk the pkram pagetable from high to low addresses and execute a callback for each contiguous range of preserved or not preserved memory found. The reason for walking high to low is to align with high to low memblock allocation when finding holes that memblocks can safely be al

[RFC 30/43] memblock: add for_each_reserved_mem_range()

2020-05-06 Thread Anthony Yznaga
To support deferred initialization of page structs for preserved pages, add an iterator of the memblock reserved list that can select or exclude ranges based on memblock flags. Signed-off-by: Anthony Yznaga --- include/linux/memblock.h | 10 ++ mm/memblock.c| 51 +

[RFC 35/43] shmem: introduce shmem_insert_pages()

2020-05-06 Thread Anthony Yznaga
Calling shmem_insert_page() to insert one page at a time does not scale well when multiple threads are inserting pages into the same shmem segment. This is primarily due to the locking needed when adding to the pagecache and LRU but also due to contention on the shmem_inode_info lock. To address t

[RFC 03/43] mm: PKRAM: implement object load and save functions

2020-05-06 Thread Anthony Yznaga
PKRAM nodes are further divided into a list of objects. After a save operation has been initiated for a node, a save operation for an object associated with the node is initiated by calling pkram_prepare_save_obj(). A new object is created and linked to the node. The save operation for the object

[RFC 04/43] mm: PKRAM: implement page stream operations

2020-05-06 Thread Anthony Yznaga
Using the pkram_save_page() function, one can populate PKRAM objects with memory pages which can later be loaded using the pkram_load_page() function. Saving a memory page to PKRAM is accomplished by recording its pfn and incrementing its refcount so that it will not be freed after the last user pu

[RFC 21/43] x86/KASLR: PKRAM: support physical kaslr

2020-05-06 Thread Anthony Yznaga
Avoid regions of memory that contain preserved pages when computing slots used to select where to put the decompressed kernel. Signed-off-by: Anthony Yznaga --- arch/x86/boot/compressed/Makefile | 3 + arch/x86/boot/compressed/kaslr.c | 67 ++ arch/x86/boot/compressed/misc.h | 19

[RFC 25/43] mm: shmem: specify the mm to use when inserting pages

2020-05-06 Thread Anthony Yznaga
Explicitly specify the mm to pass to shmem_insert_page() when the pkram_stream is initialized rather than use the mm of the current thread. This will allow for multiple kernel threads to target the same mm when inserting pages in parallel. Signed-off-by: Anthony Yznaga --- include/linux/pkram.h

[RFC 22/43] mm: shmem: introduce shmem_insert_page

2020-05-06 Thread Anthony Yznaga
The function inserts a page into a shmem file at a specified offset. The page can be a regular PAGE_SIZE page or a transparent huge page. If there is something at the offset (page or swap), the function fails. The function will be used by the next patch. Originally-by: Vladimir Davydov Signed-of

[RFC 20/43] PKRAM: disable feature when running the kdump kernel

2020-05-06 Thread Anthony Yznaga
The kdump kernel should not preserve or restore pages. Signed-off-by: Anthony Yznaga --- mm/pkram.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/pkram.c b/mm/pkram.c index 95e691382721..4d4d836fea53 100644 --- a/mm/pkram.c +++ b/mm/pkram.c @@ -1,4 +1,5 @@ // SP

[RFC 18/43] kexec: PKRAM: avoid clobbering already preserved pages

2020-05-06 Thread Anthony Yznaga
Ensure destination ranges of the kexec segments do not overlap with any kernel pages marked to be preserved across kexec. For kexec_load, return EADDRNOTAVAIL if overlap is detected. For kexec_file_load, skip ranges containing preserved pages when seaching for available ranges to use. Signed-off

[RFC 02/43] mm: PKRAM: implement node load and save functions

2020-05-06 Thread Anthony Yznaga
Preserved memory is divided into nodes which can be saved and loaded independently of each other. PKRAM nodes are kept on a list and identified by unique names. Whenever a save operation is initiated by calling pkram_prepare_save(), a new node is created and linked to the list. When the save operat

[RFC 24/43] mm: shmem: prevent swapping of PKRAM-enabled tmpfs pages

2020-05-06 Thread Anthony Yznaga
Workaround the limitation that shmem pages must be in memory in order to be preserved by preventing them from being swapped out in the first place. Do this by marking shmem pages associated with a PKRAM node as unevictable. Signed-off-by: Anthony Yznaga --- mm/shmem.c | 2 ++ 1 file changed, 2

[RFC 19/43] mm: PKRAM: allow preserved memory to be freed from userspace

2020-05-06 Thread Anthony Yznaga
To free all space utilized for preserved memory, one can write 0 to /sys/kernel/pkram. This will destroy all PKRAM nodes that are not currently being read or written. Originally-by: Vladimir Davydov Signed-off-by: Anthony Yznaga --- mm/pkram.c | 39 ++- 1 fil

[RFC 16/43] kexec: PKRAM: prevent kexec clobbering preserved pages in some cases

2020-05-06 Thread Anthony Yznaga
When loading a kernel for kexec, dynamically update the list of physical ranges that are not to be used for storing preserved pages with the ranges where kexec segments will be copied to on reboot. This ensures no pages preserved after the new kernel has been loaded will reside in these ranges on r

[RFC 00/43] PKRAM: Preserved-over-Kexec RAM

2020-05-06 Thread Anthony Yznaga
This patchset implements preserved-over-kexec memory storage or PKRAM as a method for saving memory pages of the currently executing kernel so that they may be restored after kexec into a new kernel. The patches are adapted from an RFC patchset sent out in 2013 by Vladimir Davydov [1]. They introdu

[RFC 14/43] mm: memblock: PKRAM: prevent memblock resize from clobbering preserved pages

2020-05-06 Thread Anthony Yznaga
The size of the memblock reserved array may be increased while preserved pages are being reserved. When this happens, preserved pages that have not yet been reserved are at risk for being clobbered when space for a larger array is allocated. When called from memblock_double_array(), a wrapper aroun

[RFC 06/43] mm: PKRAM: implement byte stream operations

2020-05-06 Thread Anthony Yznaga
This patch adds the ability to save arbitrary byte streams up to a total length of one page to a PKRAM object using pkram_write() to be restored later using pkram_read(). Originally-by: Vladimir Davydov Signed-off-by: Anthony Yznaga --- include/linux/pkram.h | 4 +++ mm/pkram.c| 84

[RFC 08/43] mm: PKRAM: introduce super block

2020-05-06 Thread Anthony Yznaga
The PKRAM super block is the starting point for restoring preserved memory. By providing the super block to the new kernel at boot time, preserved memory can be reserved and made available to be restored. To point the kernel to the location of the super block, one passes its pfn via the 'pkram' boo

[RFC 07/43] mm: PKRAM: link nodes by pfn before reboot

2020-05-06 Thread Anthony Yznaga
Since page structs are used for linking PKRAM nodes and cleared on boot, organize all PKRAM nodes into a list singly-linked by pfns before reboot to facilitate the node list restore in the new kernel. Originally-by: Vladimir Davydov Signed-off-by: Anthony Yznaga --- mm/pkram.c | 50

[RFC 01/43] mm: add PKRAM API stubs and Kconfig

2020-05-06 Thread Anthony Yznaga
Preserved-across-kexec memory or PKRAM is a method for saving memory pages of the currently executing kernel and restoring them after kexec boot into a new one. This can be utilized for preserving guest VM state, large in-memory databases, process memory, etc. across reboot. While DRAM-as-PMEM or a

[RFC 13/43] mm: PKRAM: free preserved pages pagetable

2020-05-06 Thread Anthony Yznaga
After the page ranges in the pagetable have been reserved the pagetable is no longer needed. Rather than free it during early boot by unreserving page-sized blocks which can be inefficient when dealing with a large number of blocks, wait until the page structs have been initialized and free them a

[RFC 11/43] PKRAM: pass the preserved pages pagetable to the next kernel

2020-05-06 Thread Anthony Yznaga
Add a pointer to the pagetable to the pkram_super_block page. Signed-off-by: Anthony Yznaga --- mm/pkram.c | 20 +--- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mm/pkram.c b/mm/pkram.c index 5a7b8f61a55d..54b2779d0813 100644 --- a/mm/pkram.c +++ b/mm/pkram.c @

[RFC 09/43] PKRAM: build a physical mapping pagetable of pages to be preserved

2020-05-06 Thread Anthony Yznaga
Future patches will need a way to efficiently identify physically contiguous ranges of preserved pages regardless of their virtual addresses as well as a way to identify ranges that do not contain preserved pages. To facilitate this all pages to be preserved across kexec are added to an identity ma

Re: [PATCH] kernel: add panic_on_taint

2020-05-06 Thread Randy Dunlap
On 5/6/20 3:28 PM, Rafael Aquini wrote: > diff --git a/Documentation/admin-guide/kernel-parameters.txt > b/Documentation/admin-guide/kernel-parameters.txt > index 7bc83f3d9bdf..75c02c1841b2 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-para

Re: [PATCH] kernel: add panic_on_taint

2020-05-06 Thread Rafael Aquini
On Wed, May 06, 2020 at 11:24:48PM +, Luis Chamberlain wrote: > On Wed, May 06, 2020 at 06:28:15PM -0400, Rafael Aquini wrote: > > Analogously to the introduction of panic_on_warn, this patch > > introduces a kernel option named panic_on_taint in order to > > provide a simple and generic way to

Re: [PATCH] kernel: add panic_on_taint

2020-05-06 Thread Luis Chamberlain
On Wed, May 06, 2020 at 06:28:15PM -0400, Rafael Aquini wrote: > Analogously to the introduction of panic_on_warn, this patch > introduces a kernel option named panic_on_taint in order to > provide a simple and generic way to stop execution and catch > a coredump when the kernel gets tainted by any

[PATCH] kernel: add panic_on_taint

2020-05-06 Thread Rafael Aquini
Analogously to the introduction of panic_on_warn, this patch introduces a kernel option named panic_on_taint in order to provide a simple and generic way to stop execution and catch a coredump when the kernel gets tainted by any given taint flag. This is useful for debugging sessions as it avoids

Re: [PATCH v2 3/3] printk: use the lockless ringbuffer

2020-05-06 Thread John Ogness
Hi, I discovered a bug while preparing my next series, which also made me realize I had never tested the extended mode feature of netconsole. :-/ The only other user of extended output is /dev/kmsg, and it is doing it correctly. Explanation and patch below. On 2020-05-01, John Ogness wrote: > d

Re: [PATCH v3 1/3] mm/memory_hotplug: Introduce add_memory_device_managed()

2020-05-06 Thread David Hildenbrand
Typo in $SUBJECT, should be "add_memory_driver_managed" ... -- Thanks, David / dhildenb ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec

Re: [PATCH v3 1/3] mm/memory_hotplug: Introduce add_memory_device_managed()

2020-05-06 Thread Pankaj Gupta
Looks good to me. Acked-by: Pankaj Gupta ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec

Re: [PATCH v3 3/3] device-dax: Add memory via add_memory_driver_managed()

2020-05-06 Thread Pankaj Gupta
> Currently, when adding memory, we create entries in /sys/firmware/memmap/ > as "System RAM". This will lead to kexec-tools to add that memory to the > fixed-up initial memmap for a kexec kernel (loaded via kexec_load()). The > memory will be considered initial System RAM by the kexec'd kernel and

Re: [PATCH v2 1/2] arm64/crash_core: Export KERNELPACMASK in vmcoreinfo

2020-05-06 Thread Amit Kachhap
Hi, On 5/6/20 6:01 PM, Will Deacon wrote: On Wed, May 06, 2020 at 05:32:56PM +0530, Amit Kachhap wrote: On 5/4/20 10:47 PM, Will Deacon wrote: On Mon, Apr 27, 2020 at 11:55:01AM +0530, Amit Daniel Kachhap wrote: diff --git a/arch/arm64/include/asm/compiler.h b/arch/arm64/include/asm/compiler

Re: [PATCH v2 1/2] arm64/crash_core: Export KERNELPACMASK in vmcoreinfo

2020-05-06 Thread Will Deacon
On Wed, May 06, 2020 at 05:32:56PM +0530, Amit Kachhap wrote: > On 5/4/20 10:47 PM, Will Deacon wrote: > > On Mon, Apr 27, 2020 at 11:55:01AM +0530, Amit Daniel Kachhap wrote: > > > diff --git a/arch/arm64/include/asm/compiler.h > > > b/arch/arm64/include/asm/compiler.h > > > index eece20d..32d590

Re: [PATCH v2 2/2] Documentation/vmcoreinfo: Add documentation for 'KERNELPACMASK'

2020-05-06 Thread Amit Kachhap
Hi, On 5/4/20 11:04 PM, Will Deacon wrote: On Mon, Apr 27, 2020 at 11:55:02AM +0530, Amit Daniel Kachhap wrote: Add documentation for KERNELPACMASK variable being added to the vmcoreinfo. It indicates the PAC bits mask information of signed kernel pointers if Armv8.3-A Pointer Authentication f

Re: [PATCH v2 1/2] arm64/crash_core: Export KERNELPACMASK in vmcoreinfo

2020-05-06 Thread Amit Kachhap
Hi Will, On 5/4/20 10:47 PM, Will Deacon wrote: On Mon, Apr 27, 2020 at 11:55:01AM +0530, Amit Daniel Kachhap wrote: Recently arm64 linux kernel added support for Armv8.3-A Pointer Authentication feature. If this feature is enabled in the kernel and the hardware supports address authentication

Re: [EXT] [PATCH 1/2] net: qed*: Reduce RX and TX default ring count when running inside kdump kernel

2020-05-06 Thread Bhupesh Sharma
Hello Igor, On Wed, May 6, 2020 at 12:21 PM Igor Russkikh wrote: > > > > > #include > > +#include > > #include > > #include > > #include > > @@ -574,13 +575,13 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, > > __be16 proto, > > #define RX_RING_SIZE ((u16)BIT(RX_RING_SIZE