Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5d14ed6 authored by Chris Metcalf's avatar Chris Metcalf
Browse files

arch/tile: Allow tilegx to build with either 16K or 64K page size



This change introduces new flags for the hv_install_context()
API that passes a page table pointer to the hypervisor.  Clients
can explicitly request 4K, 16K, or 64K small pages when they
install a new context.  In practice, the page size is fixed at
kernel compile time and the same size is always requested every
time a new page table is installed.

The <hv/hypervisor.h> header changes so that it provides more abstract
macros for managing "page" things like PFNs and page tables.  For
example there is now a HV_DEFAULT_PAGE_SIZE_SMALL instead of the old
HV_PAGE_SIZE_SMALL.  The various PFN routines have been eliminated and
only PA- or PTFN-based ones remain (since PTFNs are always expressed
in fixed 2KB "page" size).  The page-table management macros are
renamed with a leading underscore and take page-size arguments with
the presumption that clients will use those macros in some single
place to provide the "real" macros they will use themselves.

I happened to notice the old hv_set_caching() API was totally broken
(it assumed 4KB pages) so I changed it so it would nominally work
correctly with other page sizes.

Tag modules with the page size so you can't load a module built with
a conflicting page size.  (And add a test for SMP while we're at it.)

Signed-off-by: default avatarChris Metcalf <cmetcalf@tilera.com>
parent 47d632f9
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -139,6 +139,31 @@ config NR_CPUS
	  smaller kernel memory footprint results from using a smaller
	  value on chips with fewer tiles.

if TILEGX

choice
	prompt "Kernel page size"
	default PAGE_SIZE_64KB
	help
	  This lets you select the page size of the kernel.  For best
	  performance on memory-intensive applications, a page size of 64KB
	  is recommended.  For workloads involving many small files, many
	  connections, etc., it may be better to select 16KB, which uses
	  memory more efficiently at some cost in TLB performance.

	  Note that this option is TILE-Gx specific; currently
	  TILEPro page size is set by rebuilding the hypervisor.

config PAGE_SIZE_16KB
	bool "16KB"

config PAGE_SIZE_64KB
	bool "64KB"

endchoice

endif

source "kernel/time/Kconfig"

source "kernel/Kconfig.hz"
+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ generic-y += ipcbuf.h
generic-y += irq_regs.h
generic-y += kdebug.h
generic-y += local.h
generic-y += module.h
generic-y += msgbuf.h
generic-y += mutex.h
generic-y += param.h
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ struct mm_context {
	 * Written under the mmap_sem semaphore; read without the
	 * semaphore but atomically, but it is conservatively set.
	 */
	unsigned int priority_cached;
	unsigned long priority_cached;
};

typedef struct mm_context mm_context_t;
+6 −2
Original line number Diff line number Diff line
@@ -30,11 +30,15 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
	return 0;
}

/* Note that arch/tile/kernel/head.S also calls hv_install_context() */
/*
 * Note that arch/tile/kernel/head_NN.S and arch/tile/mm/migrate_NN.S
 * also call hv_install_context().
 */
static inline void __install_page_table(pgd_t *pgdir, int asid, pgprot_t prot)
{
	/* FIXME: DIRECTIO should not always be set. FIXME. */
	int rc = hv_install_context(__pa(pgdir), prot, asid, HV_CTX_DIRECTIO);
	int rc = hv_install_context(__pa(pgdir), prot, asid,
				    HV_CTX_DIRECTIO | CTX_PAGE_FLAG);
	if (rc < 0)
		panic("hv_install_context failed: %d", rc);
}
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright 2011 Tilera Corporation. All Rights Reserved.
 *
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation, version 2.
 *
 *   This program is distributed in the hope that it will be useful, but
 *   WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 *   NON INFRINGEMENT.  See the GNU General Public License for
 *   more details.
 */

#ifndef _ASM_TILE_MODULE_H
#define _ASM_TILE_MODULE_H

#include <arch/chip.h>

#include <asm-generic/module.h>

/* We can't use modules built with different page sizes. */
#if defined(CONFIG_PAGE_SIZE_16KB)
# define MODULE_PGSZ " 16KB"
#elif defined(CONFIG_PAGE_SIZE_64KB)
# define MODULE_PGSZ " 64KB"
#else
# define MODULE_PGSZ ""
#endif

/* We don't really support no-SMP so tag if someone tries. */
#ifdef CONFIG_SMP
#define MODULE_NOSMP ""
#else
#define MODULE_NOSMP " nosmp"
#endif

#define MODULE_ARCH_VERMAGIC CHIP_ARCH_NAME MODULE_PGSZ MODULE_NOSMP

#endif /* _ASM_TILE_MODULE_H */
Loading