linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <peterz@infradead.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>
Subject: linux-next: manual merge of the akpm-current tree with the tip tree
Date: Fri, 27 Nov 2020 18:48:38 +1100	[thread overview]
Message-ID: <20201127184838.62efbb4c@canb.auug.org.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 10069 bytes --]

Hi all,

Today's linux-next merge of the akpm-current tree got a conflict in:

  mm/highmem.c

between commits:

  298fa1ad5571 ("highmem: Provide generic variant of kmap_atomic*")
  5fbda3ecd14a ("sched: highmem: Store local kmaps in task struct")

from the tip tree and commit:

  72d22a0d0e86 ("mm: support THPs in zero_user_segments")

from the akpm-current tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc mm/highmem.c
index 83f9660f168f,e2da8c9770e9..000000000000
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@@ -358,260 -367,68 +358,319 @@@ void kunmap_high(struct page *page
  	if (need_wakeup)
  		wake_up(pkmap_map_wait);
  }
 -
  EXPORT_SYMBOL(kunmap_high);
+ 
+ #ifdef CONFIG_TRANSPARENT_HUGEPAGE
+ void zero_user_segments(struct page *page, unsigned start1, unsigned end1,
+ 		unsigned start2, unsigned end2)
+ {
+ 	unsigned int i;
+ 
+ 	BUG_ON(end1 > page_size(page) || end2 > page_size(page));
+ 
+ 	for (i = 0; i < compound_nr(page); i++) {
+ 		void *kaddr;
+ 		unsigned this_end;
+ 
+ 		if (end1 == 0 && start2 >= PAGE_SIZE) {
+ 			start2 -= PAGE_SIZE;
+ 			end2 -= PAGE_SIZE;
+ 			continue;
+ 		}
+ 
+ 		if (start1 >= PAGE_SIZE) {
+ 			start1 -= PAGE_SIZE;
+ 			end1 -= PAGE_SIZE;
+ 			if (start2) {
+ 				start2 -= PAGE_SIZE;
+ 				end2 -= PAGE_SIZE;
+ 			}
+ 			continue;
+ 		}
+ 
+ 		kaddr = kmap_atomic(page + i);
+ 
+ 		this_end = min_t(unsigned, end1, PAGE_SIZE);
+ 		if (end1 > start1)
+ 			memset(kaddr + start1, 0, this_end - start1);
+ 		end1 -= this_end;
+ 		start1 = 0;
+ 
+ 		if (start2 >= PAGE_SIZE) {
+ 			start2 -= PAGE_SIZE;
+ 			end2 -= PAGE_SIZE;
+ 		} else {
+ 			this_end = min_t(unsigned, end2, PAGE_SIZE);
+ 			if (end2 > start2)
+ 				memset(kaddr + start2, 0, this_end - start2);
+ 			end2 -= this_end;
+ 			start2 = 0;
+ 		}
+ 
+ 		kunmap_atomic(kaddr);
+ 		flush_dcache_page(page + i);
+ 
+ 		if (!end1 && !end2)
+ 			break;
+ 	}
+ 
+ 	BUG_ON((start1 | start2 | end1 | end2) != 0);
+ }
+ EXPORT_SYMBOL(zero_user_segments);
+ #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 -#endif	/* CONFIG_HIGHMEM */
 +#endif /* CONFIG_HIGHMEM */
 +
 +#ifdef CONFIG_KMAP_LOCAL
 +
 +#include <asm/kmap_size.h>
 +
 +/*
 + * With DEBUG_KMAP_LOCAL the stack depth is doubled and every second
 + * slot is unused which acts as a guard page
 + */
 +#ifdef CONFIG_DEBUG_KMAP_LOCAL
 +# define KM_INCR	2
 +#else
 +# define KM_INCR	1
 +#endif
 +
 +static inline int kmap_local_idx_push(void)
 +{
 +	WARN_ON_ONCE(in_irq() && !irqs_disabled());
 +	current->kmap_ctrl.idx += KM_INCR;
 +	BUG_ON(current->kmap_ctrl.idx >= KM_MAX_IDX);
 +	return current->kmap_ctrl.idx - 1;
 +}
 +
 +static inline int kmap_local_idx(void)
 +{
 +	return current->kmap_ctrl.idx - 1;
 +}
 +
 +static inline void kmap_local_idx_pop(void)
 +{
 +	current->kmap_ctrl.idx -= KM_INCR;
 +	BUG_ON(current->kmap_ctrl.idx < 0);
 +}
 +
 +#ifndef arch_kmap_local_post_map
 +# define arch_kmap_local_post_map(vaddr, pteval)	do { } while (0)
 +#endif
 +
 +#ifndef arch_kmap_local_pre_unmap
 +# define arch_kmap_local_pre_unmap(vaddr)		do { } while (0)
 +#endif
 +
 +#ifndef arch_kmap_local_post_unmap
 +# define arch_kmap_local_post_unmap(vaddr)		do { } while (0)
 +#endif
 +
 +#ifndef arch_kmap_local_map_idx
 +#define arch_kmap_local_map_idx(idx, pfn)	kmap_local_calc_idx(idx)
 +#endif
 +
 +#ifndef arch_kmap_local_unmap_idx
 +#define arch_kmap_local_unmap_idx(idx, vaddr)	kmap_local_calc_idx(idx)
 +#endif
 +
 +#ifndef arch_kmap_local_high_get
 +static inline void *arch_kmap_local_high_get(struct page *page)
 +{
 +	return NULL;
 +}
 +#endif
 +
 +/* Unmap a local mapping which was obtained by kmap_high_get() */
 +static inline bool kmap_high_unmap_local(unsigned long vaddr)
 +{
 +#ifdef ARCH_NEEDS_KMAP_HIGH_GET
 +	if (vaddr >= PKMAP_ADDR(0) && vaddr < PKMAP_ADDR(LAST_PKMAP)) {
 +		kunmap_high(pte_page(pkmap_page_table[PKMAP_NR(vaddr)]));
 +		return true;
 +	}
 +#endif
 +	return false;
 +}
 +
 +static inline int kmap_local_calc_idx(int idx)
 +{
 +	return idx + KM_MAX_IDX * smp_processor_id();
 +}
 +
 +static pte_t *__kmap_pte;
 +
 +static pte_t *kmap_get_pte(void)
 +{
 +	if (!__kmap_pte)
 +		__kmap_pte = virt_to_kpte(__fix_to_virt(FIX_KMAP_BEGIN));
 +	return __kmap_pte;
 +}
 +
 +void *__kmap_local_pfn_prot(unsigned long pfn, pgprot_t prot)
 +{
 +	pte_t pteval, *kmap_pte = kmap_get_pte();
 +	unsigned long vaddr;
 +	int idx;
 +
 +	/*
 +	 * Disable migration so resulting virtual address is stable
 +	 * accross preemption.
 +	 */
 +	migrate_disable();
 +	preempt_disable();
 +	idx = arch_kmap_local_map_idx(kmap_local_idx_push(), pfn);
 +	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
 +	BUG_ON(!pte_none(*(kmap_pte - idx)));
 +	pteval = pfn_pte(pfn, prot);
 +	set_pte_at(&init_mm, vaddr, kmap_pte - idx, pteval);
 +	arch_kmap_local_post_map(vaddr, pteval);
 +	current->kmap_ctrl.pteval[kmap_local_idx()] = pteval;
 +	preempt_enable();
 +
 +	return (void *)vaddr;
 +}
 +EXPORT_SYMBOL_GPL(__kmap_local_pfn_prot);
 +
 +void *__kmap_local_page_prot(struct page *page, pgprot_t prot)
 +{
 +	void *kmap;
 +
 +	/*
 +	 * To broaden the usage of the actual kmap_local() machinery always map
 +	 * pages when debugging is enabled and the architecture has no problems
 +	 * with alias mappings.
 +	 */
 +	if (!IS_ENABLED(CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP) && !PageHighMem(page))
 +		return page_address(page);
 +
 +	/* Try kmap_high_get() if architecture has it enabled */
 +	kmap = arch_kmap_local_high_get(page);
 +	if (kmap)
 +		return kmap;
 +
 +	return __kmap_local_pfn_prot(page_to_pfn(page), prot);
 +}
 +EXPORT_SYMBOL(__kmap_local_page_prot);
 +
 +void kunmap_local_indexed(void *vaddr)
 +{
 +	unsigned long addr = (unsigned long) vaddr & PAGE_MASK;
 +	pte_t *kmap_pte = kmap_get_pte();
 +	int idx;
 +
 +	if (addr < __fix_to_virt(FIX_KMAP_END) ||
 +	    addr > __fix_to_virt(FIX_KMAP_BEGIN)) {
 +		if (IS_ENABLED(CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP)) {
 +			/* This _should_ never happen! See above. */
 +			WARN_ON_ONCE(1);
 +			return;
 +		}
 +		/*
 +		 * Handle mappings which were obtained by kmap_high_get()
 +		 * first as the virtual address of such mappings is below
 +		 * PAGE_OFFSET. Warn for all other addresses which are in
 +		 * the user space part of the virtual address space.
 +		 */
 +		if (!kmap_high_unmap_local(addr))
 +			WARN_ON_ONCE(addr < PAGE_OFFSET);
 +		return;
 +	}
 +
 +	preempt_disable();
 +	idx = arch_kmap_local_unmap_idx(kmap_local_idx(), addr);
 +	WARN_ON_ONCE(addr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
 +
 +	arch_kmap_local_pre_unmap(addr);
 +	pte_clear(&init_mm, addr, kmap_pte - idx);
 +	arch_kmap_local_post_unmap(addr);
 +	current->kmap_ctrl.pteval[kmap_local_idx()] = __pte(0);
 +	kmap_local_idx_pop();
 +	preempt_enable();
 +	migrate_enable();
 +}
 +EXPORT_SYMBOL(kunmap_local_indexed);
 +
 +/*
 + * Invoked before switch_to(). This is safe even when during or after
 + * clearing the maps an interrupt which needs a kmap_local happens because
 + * the task::kmap_ctrl.idx is not modified by the unmapping code so a
 + * nested kmap_local will use the next unused index and restore the index
 + * on unmap. The already cleared kmaps of the outgoing task are irrelevant
 + * because the interrupt context does not know about them. The same applies
 + * when scheduling back in for an interrupt which happens before the
 + * restore is complete.
 + */
 +void __kmap_local_sched_out(void)
 +{
 +	struct task_struct *tsk = current;
 +	pte_t *kmap_pte = kmap_get_pte();
 +	int i;
 +
 +	/* Clear kmaps */
 +	for (i = 0; i < tsk->kmap_ctrl.idx; i++) {
 +		pte_t pteval = tsk->kmap_ctrl.pteval[i];
 +		unsigned long addr;
 +		int idx;
 +
 +		/* With debug all even slots are unmapped and act as guard */
 +		if (IS_ENABLED(CONFIG_DEBUG_HIGHMEM) && !(i & 0x01)) {
 +			WARN_ON_ONCE(!pte_none(pteval));
 +			continue;
 +		}
 +		if (WARN_ON_ONCE(pte_none(pteval)))
 +			continue;
 +
 +		/*
 +		 * This is a horrible hack for XTENSA to calculate the
 +		 * coloured PTE index. Uses the PFN encoded into the pteval
 +		 * and the map index calculation because the actual mapped
 +		 * virtual address is not stored in task::kmap_ctrl.
 +		 * For any sane architecture this is optimized out.
 +		 */
 +		idx = arch_kmap_local_map_idx(i, pte_pfn(pteval));
 +
 +		addr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
 +		arch_kmap_local_pre_unmap(addr);
 +		pte_clear(&init_mm, addr, kmap_pte - idx);
 +		arch_kmap_local_post_unmap(addr);
 +	}
 +}
 +
 +void __kmap_local_sched_in(void)
 +{
 +	struct task_struct *tsk = current;
 +	pte_t *kmap_pte = kmap_get_pte();
 +	int i;
 +
 +	/* Restore kmaps */
 +	for (i = 0; i < tsk->kmap_ctrl.idx; i++) {
 +		pte_t pteval = tsk->kmap_ctrl.pteval[i];
 +		unsigned long addr;
 +		int idx;
 +
 +		/* With debug all even slots are unmapped and act as guard */
 +		if (IS_ENABLED(CONFIG_DEBUG_HIGHMEM) && !(i & 0x01)) {
 +			WARN_ON_ONCE(!pte_none(pteval));
 +			continue;
 +		}
 +		if (WARN_ON_ONCE(pte_none(pteval)))
 +			continue;
 +
 +		/* See comment in __kmap_local_sched_out() */
 +		idx = arch_kmap_local_map_idx(i, pte_pfn(pteval));
 +		addr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
 +		set_pte_at(&init_mm, addr, kmap_pte - idx, pteval);
 +		arch_kmap_local_post_map(addr, pteval);
 +	}
 +}
 +
 +void kmap_local_fork(struct task_struct *tsk)
 +{
 +	if (WARN_ON_ONCE(tsk->kmap_ctrl.idx))
 +		memset(&tsk->kmap_ctrl, 0, sizeof(tsk->kmap_ctrl));
 +}
 +
 +#endif
  
  #if defined(HASHED_PAGE_VIRTUAL)
  

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2020-11-27  7:48 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27  7:48 Stephen Rothwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-02-16  5:38 linux-next: manual merge of the akpm-current tree with the tip tree Stephen Rothwell
2021-10-07  6:27 Stephen Rothwell
2021-03-22  6:12 Stephen Rothwell
2020-12-11  8:56 Stephen Rothwell
2020-12-11 12:47 ` Jason Gunthorpe
2020-11-27  7:39 Stephen Rothwell
2020-11-27 11:54 ` Andy Shevchenko
2020-11-30  9:27   ` Thomas Gleixner
2020-11-23  8:05 Stephen Rothwell
2020-11-09  6:00 Stephen Rothwell
2020-10-13  6:59 Stephen Rothwell
2020-07-17 10:19 Stephen Rothwell
2020-05-29 11:05 Stephen Rothwell
2020-05-29 10:18 Stephen Rothwell
2020-05-29 10:05 Stephen Rothwell
2020-05-29  9:58 Stephen Rothwell
2020-05-25 11:04 Stephen Rothwell
2020-05-26  4:41 ` Singh, Balbir
2020-06-03  4:43 ` Stephen Rothwell
2020-05-19 16:18 Stephen Rothwell
2020-03-25  7:48 Stephen Rothwell
2020-03-19  6:42 Stephen Rothwell
2020-01-20  6:37 Stephen Rothwell
2020-01-20  6:30 Stephen Rothwell
2019-10-31  5:43 Stephen Rothwell
2019-06-24 10:24 Stephen Rothwell
2019-05-01 11:10 Stephen Rothwell
2019-01-31  4:31 Stephen Rothwell
2018-08-20  4:32 Stephen Rothwell
2018-08-20 19:52 ` Andrew Morton
2018-03-23  5:59 Stephen Rothwell
2017-12-18  5:04 Stephen Rothwell
2017-11-10  4:33 Stephen Rothwell
2017-11-02  7:19 Stephen Rothwell
2017-08-22  6:57 Stephen Rothwell
2017-08-23  6:39 ` Vlastimil Babka
2017-08-11  7:53 Stephen Rothwell
2017-08-11  9:34 ` Peter Zijlstra
2017-08-11 10:48   ` Peter Zijlstra
2017-08-11 11:45   ` Stephen Rothwell
2017-08-11 11:56     ` Ingo Molnar
2017-08-11 12:17       ` Peter Zijlstra
2017-08-11 12:44         ` Ingo Molnar
2017-08-11 13:49           ` Stephen Rothwell
2017-08-11 14:04       ` Peter Zijlstra
2017-08-13  6:06         ` Nadav Amit
2017-08-13 12:50           ` Peter Zijlstra
2017-08-14  3:16             ` Minchan Kim
2017-08-14  5:07               ` Nadav Amit
2017-08-14  5:23                 ` Minchan Kim
2017-08-14  8:38                 ` Minchan Kim
2017-08-14 19:57                   ` Peter Zijlstra
2017-08-16  4:14                     ` Minchan Kim
2017-08-14 19:38                 ` Peter Zijlstra
2017-08-15  7:51                   ` Nadav Amit
2017-08-14  3:09         ` Minchan Kim
2017-08-14 18:54           ` Peter Zijlstra
2017-04-12  6:46 Stephen Rothwell
2017-04-12 20:53 ` Vlastimil Babka
2017-04-20  2:17   ` NeilBrown
2017-03-24  5:25 Stephen Rothwell
2017-02-17  4:40 Stephen Rothwell
2016-11-14  6:08 Stephen Rothwell
2016-07-29  4:14 Stephen Rothwell
2016-06-15  5:23 Stephen Rothwell
2016-06-18 19:39 ` Manfred Spraul
2016-04-29  6:12 Stephen Rothwell
2016-04-29  6:26 ` Ingo Molnar
2016-03-02  5:40 Stephen Rothwell
2016-02-26  5:07 Stephen Rothwell
2016-02-26 21:35 ` Andrew Morton
2016-02-19  4:09 Stephen Rothwell
2016-02-19 15:26 ` Ard Biesheuvel
2015-12-07  8:06 Stephen Rothwell
2015-10-02  4:21 Stephen Rothwell
2015-07-28  6:00 Stephen Rothwell
2015-07-29 17:12 ` Andrea Arcangeli
2015-07-29 17:47   ` Andy Lutomirski
2015-07-29 18:46     ` Thomas Gleixner
2015-07-30 15:38       ` Andrea Arcangeli
2015-07-29 23:06   ` Stephen Rothwell
2015-07-29 23:07     ` Thomas Gleixner
2015-09-07 23:35   ` Stephen Rothwell
2015-09-08 18:11     ` Linus Torvalds
2015-09-08 22:56       ` Stephen Rothwell
2015-09-08 23:03         ` Linus Torvalds
2015-09-08 23:21           ` Andrew Morton
2015-09-16  6:58             ` Geert Uytterhoeven
2015-06-04 12:07 Stephen Rothwell
2015-04-08  8:28 Stephen Rothwell
2015-04-08  8:25 Stephen Rothwell
2014-03-17  9:31 Stephen Rothwell
2014-03-17  9:36 ` Peter Zijlstra
2014-03-19 23:27   ` Andrew Morton
2014-01-14  4:53 Stephen Rothwell
2014-01-14  5:04 ` Davidlohr Bueso
2014-01-14 12:51 ` Peter Zijlstra
2014-01-14 13:17   ` Geert Uytterhoeven
2014-01-14 13:33     ` Peter Zijlstra
2014-01-14 16:19     ` H. Peter Anvin
2014-01-14 15:15   ` H. Peter Anvin
2014-01-14 15:20     ` Geert Uytterhoeven
2014-01-14 15:41       ` Peter Zijlstra
2014-01-14 15:48         ` H. Peter Anvin
2014-01-07  6:00 Stephen Rothwell
2014-01-07  6:34 ` Tang Chen
2013-11-08  7:48 Stephen Rothwell
2013-11-08 18:58 ` Josh Triplett
2013-11-08 23:20   ` Stephen Rothwell
2013-11-09  0:19     ` Josh Triplett
2013-10-30  6:40 Stephen Rothwell

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=20201127184838.62efbb4c@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).