Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1270234 > unrolled thread
| Started by | "Maciej W. Rozycki" <macro@imgtec.com> |
|---|---|
| First post | 2015-11-16 15:40 +0100 |
| Last post | 2015-11-16 15:40 +0100 |
| Articles | 3 — 1 participant |
Back to article view | Back to linux.kernel
[RFC PATCH 0/4] MIPS: IEEE Std 754 NaN interlinking support "Maciej W. Rozycki" <macro@imgtec.com> - 2015-11-16 15:40 +0100
[RFC PATCH 1/4] ELF: Add platform-specific AT_FLAGS initialisation support "Maciej W. Rozycki" <macro@imgtec.com> - 2015-11-16 15:40 +0100
[RFC PATCH 2/4] MIPS: Factor out FP context preemption "Maciej W. Rozycki" <macro@imgtec.com> - 2015-11-16 15:40 +0100
| From | "Maciej W. Rozycki" <macro@imgtec.com> |
|---|---|
| Date | 2015-11-16 15:40 +0100 |
| Subject | [RFC PATCH 0/4] MIPS: IEEE Std 754 NaN interlinking support |
| Message-ID | <qvt6N-8uH-7@gated-at.bofh.it> |
Hi, This implements the kernel part of IEEE Std 754 NaN interlinking support, as per "MIPS ABI Extension for IEEE Std 754 Non-Compliant Interlinking" <https://dmz-portal.mips.com/wiki/MIPS_ABI_-_NaN_Interlinking>. Four patches are included: a pair of preparatory changes, a generic one to allow ports to provide their own auxiliary vector's AT_FLAGS entry initialiser and one factoring out pieces of FP context maintenance code, respectively, and then a pair of actual changes, implementing the NaN interlinking feature proper and a prctl(2) interface to switch the compliance mode dynamically respectively. These patches rely on 2008-NaN support, recently posted, having been applied first. At this point this is a request for comments only rather than an actual patch submission for inclusion, as consensus about the specification has to be reached first. All feedback is welcome on the implementation and I'll be happy to address any questions, comments or concerns. Maciej -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | "Maciej W. Rozycki" <macro@imgtec.com> |
|---|---|
| Date | 2015-11-16 15:40 +0100 |
| Subject | [RFC PATCH 1/4] ELF: Add platform-specific AT_FLAGS initialisation support |
| Message-ID | <qvt6P-8uH-47@gated-at.bofh.it> |
| In reply to | #1270234 |
Signed-off-by: Maciej W. Rozycki <macro@imgtec.com>
---
linux-elf-at-flags.diff
Index: linux-sfr-test/fs/binfmt_elf.c
===================================================================
--- linux-sfr-test.orig/fs/binfmt_elf.c 2015-09-08 15:24:00.927208000 +0100
+++ linux-sfr-test/fs/binfmt_elf.c 2015-09-08 15:26:10.318310000 +0100
@@ -72,6 +72,10 @@ static int elf_core_dump(struct coredump
#define ELF_MIN_ALIGN PAGE_SIZE
#endif
+#ifndef ELF_FLAGS
+#define ELF_FLAGS 0
+#endif
+
#ifndef ELF_CORE_EFLAGS
#define ELF_CORE_EFLAGS 0
#endif
@@ -238,7 +242,7 @@ create_elf_tables(struct linux_binprm *b
NEW_AUX_ENT(AT_PHENT, sizeof(struct elf_phdr));
NEW_AUX_ENT(AT_PHNUM, exec->e_phnum);
NEW_AUX_ENT(AT_BASE, interp_load_addr);
- NEW_AUX_ENT(AT_FLAGS, 0);
+ NEW_AUX_ENT(AT_FLAGS, ELF_FLAGS);
NEW_AUX_ENT(AT_ENTRY, exec->e_entry);
NEW_AUX_ENT(AT_UID, from_kuid_munged(cred->user_ns, cred->uid));
NEW_AUX_ENT(AT_EUID, from_kuid_munged(cred->user_ns, cred->euid));
Index: linux-sfr-test/fs/binfmt_elf_fdpic.c
===================================================================
--- linux-sfr-test.orig/fs/binfmt_elf_fdpic.c 2015-09-08 15:24:00.950209000 +0100
+++ linux-sfr-test/fs/binfmt_elf_fdpic.c 2015-09-08 15:29:25.860980000 +0100
@@ -80,6 +80,10 @@ static int elf_fdpic_map_file_by_direct_
static int elf_fdpic_core_dump(struct coredump_params *cprm);
#endif
+#ifndef ELF_FLAGS
+#define ELF_FLAGS 0
+#endif
+
static struct linux_binfmt elf_fdpic_format = {
.module = THIS_MODULE,
.load_binary = load_elf_fdpic_binary,
@@ -616,7 +620,7 @@ static int create_elf_fdpic_tables(struc
NEW_AUX_ENT(AT_PHENT, sizeof(struct elf_phdr));
NEW_AUX_ENT(AT_PHNUM, exec_params->hdr.e_phnum);
NEW_AUX_ENT(AT_BASE, interp_params->elfhdr_addr);
- NEW_AUX_ENT(AT_FLAGS, 0);
+ NEW_AUX_ENT(AT_FLAGS, ELF_FLAGS);
NEW_AUX_ENT(AT_ENTRY, exec_params->entry_addr);
NEW_AUX_ENT(AT_UID, (elf_addr_t) from_kuid_munged(cred->user_ns, cred->uid));
NEW_AUX_ENT(AT_EUID, (elf_addr_t) from_kuid_munged(cred->user_ns, cred->euid));
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Maciej W. Rozycki" <macro@imgtec.com> |
|---|---|
| Date | 2015-11-16 15:40 +0100 |
| Subject | [RFC PATCH 2/4] MIPS: Factor out FP context preemption |
| Message-ID | <qvt6O-8uH-43@gated-at.bofh.it> |
| In reply to | #1270234 |
Signed-off-by: Maciej W. Rozycki <macro@imgtec.com>
---
Following the discussion around commit 9791554b [MIPS,prctl: add
PR_[GS]ET_FP_MODE prctl options for MIPS] or
<http://patchwork.linux-mips.org/patch/8899/> and Leonid's observation
<http://www.linux-mips.org/cgi-bin/mesg.cgi?a=linux-mips&i=54B02115.7090609%40imgtec.com>
in particular, I agree this would best be done with an IPI, however such
an improvement is independent of the changes made as a part of this series
so I took the minimal approach and left the solution implemented so far
unchanged. Especially as Leonid says he's got a patch already available.
linux-mips-process-fp-context.diff
Index: linux-sfr-test/arch/mips/kernel/process.c
===================================================================
--- linux-sfr-test.orig/arch/mips/kernel/process.c 2015-11-13 00:36:09.885716000 +0000
+++ linux-sfr-test/arch/mips/kernel/process.c 2015-11-16 13:50:18.962058000 +0000
@@ -570,6 +570,60 @@ void arch_trigger_all_cpu_backtrace(bool
smp_call_function(arch_dump_stack, NULL, 1);
}
+/*
+ * Make the FP context available for mode changes.
+ */
+static void mips_get_fp_context(struct task_struct *task)
+{
+ unsigned long switch_count;
+ struct task_struct *t;
+
+ /* Save FP & vector context, then disable FPU & MSA. */
+ if (task->signal == current->signal)
+ lose_fpu(1);
+
+ /* Prevent any threads from obtaining live FP context. */
+ atomic_set(&task->mm->context.fp_mode_switching, 1);
+ smp_mb__after_atomic();
+
+ /*
+ * If there are multiple online CPUs then wait until all threads
+ * whose FP mode is about to change have been context switched.
+ * This approach allows us to only worry about whether an FP mode
+ * switch is in progress when FP is first used in a tasks time
+ * slice. Pretty much all of the mode switch overhead can thus
+ * be confined to cases where mode switches are actually occurring.
+ * That is, to here. However for the thread performing the mode
+ * switch it may take a while...
+ */
+ if (num_online_cpus() > 1) {
+ spin_lock_irq(&task->sighand->siglock);
+
+ for_each_thread(task, t) {
+ if (t == current)
+ continue;
+
+ switch_count = t->nvcsw + t->nivcsw;
+
+ do {
+ spin_unlock_irq(&task->sighand->siglock);
+ cond_resched();
+ spin_lock_irq(&task->sighand->siglock);
+ } while ((t->nvcsw + t->nivcsw) == switch_count);
+ }
+
+ spin_unlock_irq(&task->sighand->siglock);
+ }
+}
+
+/*
+ * Allow threads to use FP again.
+ */
+static void mips_put_fp_context(struct task_struct *task)
+{
+ atomic_set(&task->mm->context.fp_mode_switching, 0);
+}
+
int mips_get_process_fp_mode(struct task_struct *task)
{
int value = 0;
@@ -585,7 +639,6 @@ int mips_get_process_fp_mode(struct task
int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
{
const unsigned int known_bits = PR_FP_MODE_FR | PR_FP_MODE_FRE;
- unsigned long switch_count;
struct task_struct *t;
/* Check the value is valid */
@@ -603,41 +656,7 @@ int mips_set_process_fp_mode(struct task
if (!(value & PR_FP_MODE_FR) && cpu_has_fpu && cpu_has_mips_r6)
return -EOPNOTSUPP;
- /* Save FP & vector context, then disable FPU & MSA */
- if (task->signal == current->signal)
- lose_fpu(1);
-
- /* Prevent any threads from obtaining live FP context */
- atomic_set(&task->mm->context.fp_mode_switching, 1);
- smp_mb__after_atomic();
-
- /*
- * If there are multiple online CPUs then wait until all threads whose
- * FP mode is about to change have been context switched. This approach
- * allows us to only worry about whether an FP mode switch is in
- * progress when FP is first used in a tasks time slice. Pretty much all
- * of the mode switch overhead can thus be confined to cases where mode
- * switches are actually occuring. That is, to here. However for the
- * thread performing the mode switch it may take a while...
- */
- if (num_online_cpus() > 1) {
- spin_lock_irq(&task->sighand->siglock);
-
- for_each_thread(task, t) {
- if (t == current)
- continue;
-
- switch_count = t->nvcsw + t->nivcsw;
-
- do {
- spin_unlock_irq(&task->sighand->siglock);
- cond_resched();
- spin_lock_irq(&task->sighand->siglock);
- } while ((t->nvcsw + t->nivcsw) == switch_count);
- }
-
- spin_unlock_irq(&task->sighand->siglock);
- }
+ mips_get_fp_context(task);
/*
* There are now no threads of the process with live FP context, so it
@@ -659,8 +678,7 @@ int mips_set_process_fp_mode(struct task
clear_tsk_thread_flag(t, TIF_HYBRID_FPREGS);
}
- /* Allow threads to use FP again */
- atomic_set(&task->mm->context.fp_mode_switching, 0);
+ mips_put_fp_context(task);
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web