linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: mikey@neuling.org, shuahkh@osg.samsung.com, anton@samba.org
Subject: [PATCH V2 05/12] documentation, powerpc: Add documentation for DSCR support
Date: Tue, 13 Jan 2015 15:52:33 +0530	[thread overview]
Message-ID: <1421144560-15901-6-git-send-email-khandual@linux.vnet.ibm.com> (raw)
In-Reply-To: <1421144560-15901-1-git-send-email-khandual@linux.vnet.ibm.com>

This patch adds a new documentation file explaining the DSCR
support on powerpc platforms. This explains DSCR related data
structure, code paths and also available user interfaces. Any
further functional changes to the DSCR support in the kernel
should definitely update the documentation here.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
 Documentation/powerpc/00-INDEX |  2 +
 Documentation/powerpc/dscr.txt | 83 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+)
 create mode 100644 Documentation/powerpc/dscr.txt

diff --git a/Documentation/powerpc/00-INDEX b/Documentation/powerpc/00-INDEX
index 6fd0e8b..9dc845c 100644
--- a/Documentation/powerpc/00-INDEX
+++ b/Documentation/powerpc/00-INDEX
@@ -30,3 +30,5 @@ ptrace.txt
 	- Information on the ptrace interfaces for hardware debug registers.
 transactional_memory.txt
 	- Overview of the Power8 transactional memory support.
+dscr.txt
+	- Overview DSCR (Data Stream Control Register) support.
diff --git a/Documentation/powerpc/dscr.txt b/Documentation/powerpc/dscr.txt
new file mode 100644
index 0000000..1ff4400
--- /dev/null
+++ b/Documentation/powerpc/dscr.txt
@@ -0,0 +1,83 @@
+			DSCR (Data Stream Control Register)
+		================================================
+
+DSCR register in powerpc allows user to have some control of prefetch of data
+stream in the processor. Please refer to the ISA documents or related manual
+for more detailed information regarding how to use this DSCR to attain this
+control of the pefetches . This document here provides an overview of kernel
+support for DSCR, related kernel objects, it's functionalities and exported
+user interface.
+
+(A) Data Structures:
+
+	(1) thread_struct:
+		dscr		/* Thread DSCR value */
+		dscr_inherit	/* Thread has changed default DSCR */
+
+	(2) PACA:
+		dscr_default	/* per-CPU DSCR default value */
+
+	(3) sysfs.c:
+		dscr_default	/* System DSCR default value */
+
+(B) Scheduler Changes:
+
+	Scheduler will write the per-CPU DSCR default which is stored in the
+	CPU's PACA value into the register if the thread has dscr_inherit value
+	cleared which means that it has not changed the default DSCR till now.
+	If the dscr_inherit value is set which means that it has changed the
+	default DSCR value, scheduler will write the changed value which will
+	now be contained in thread struct's dscr into the register instead of
+	the per-CPU default PACA based DSCR value.
+
+	NOTE: Please note here that the system wide global DSCR value never
+	gets used directly in the scheduler process context switch at all.
+
+(C) SYSFS Interface:
+
+	Global DSCR default:		/sys/devices/system/cpu/dscr_default
+	CPU specific DSCR default:	/sys/devices/system/cpu/cpuN/dscr
+
+	Changing the global DSCR default in the sysfs will change all the CPU
+	specific DSCR defaults immediately in their PACA structures. Again if
+	the current process has the dscr_inherit clear, it also writes the new
+	value into every CPU's DSCR register right away and updates the current
+	thread's DSCR value as well.
+
+	Changing the CPU specif DSCR default value in the sysfs does exactly
+	the same thing as above but unlike the global one above, it just changes
+	stuff for that particular CPU instead for all the CPUs on the system.
+
+(D) User Space Instructions:
+
+	The DSCR register can be accessed in the user space using any of these
+	two SPR numbers available for that purpose.
+
+	(1) Problem state SPR:		0x03	(Un-privileged, POWER8 only)
+	(2) Privileged state SPR:	0x11	(Privileged)
+
+	Accessing DSCR through privileged SPR number (0x11) from user space
+	works, as it is emulated following an illegal instruction exception
+	inside the kernel. Both mfspr and mtspr instructions are emulated.
+
+	Accessing DSCR through user level SPR (0x03) from user space will first
+	create a facility unavailable exception. Inside this exception handler
+	all mfspr isntruction based read attempts will get emulated and returned
+	where as the first mtspr instruction based write attempts will enable
+	the DSCR facility for the next time around (both for read and write) by
+	setting DSCR facility in the FSCR register.
+
+(E) Specifics about 'dscr_inherit':
+
+	The thread struct element 'dscr_inherit' represents whether the thread
+	in question has attempted and changed the DSCR itself using any of the
+	following methods. This element signifies whether the thread wants to
+	use the CPU default DSCR value or its own changed DSCR value in the
+	kernel.
+
+		(1) mtspr instruction	(SPR number 0x03)
+		(2) mtspr instruction	(SPR number 0x11)
+		(3) ptrace interface	(Explicitly set user DSCR value)
+
+	Any child of the process created after this event in the process inherits
+	this same behaviour as well.
-- 
1.9.3

  parent reply	other threads:[~2015-01-13 10:23 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13 10:22 [PATCH V2 00/12] POWER DSCR fixes, improvements, docs and tests Anshuman Khandual
2015-01-13 10:22 ` [PATCH V2 01/12] powerpc: Fix handling of DSCR related facility unavailable exception Anshuman Khandual
2015-01-13 10:22 ` [PATCH V2 02/12] powerpc, process: Remove the unused extern dscr_default Anshuman Khandual
2015-01-13 10:22 ` [PATCH V2 03/12] powerpc, offset: Change PACA_DSCR to PACA_DSCR_DEFAULT Anshuman Khandual
2015-01-13 10:22 ` [PATCH V2 04/12] powerpc, dscr: Added some in-code documentation Anshuman Khandual
2015-01-13 10:22 ` Anshuman Khandual [this message]
2015-01-13 10:22 ` [PATCH V2 06/12] selftests, powerpc: Add test for system wide DSCR default Anshuman Khandual
2015-01-13 15:22   ` Shuah Khan
2015-01-13 23:44     ` Michael Ellerman
2015-01-20 21:40       ` Dave Jones
2015-01-21  6:51         ` Michael Ellerman
2015-03-27 12:01   ` [V2, " Michael Ellerman
2015-04-09 10:31     ` Anshuman Khandual
2015-04-09 12:38       ` Anshuman Khandual
2015-01-13 10:22 ` [PATCH V2 07/12] selftests, powerpc: Add test for explicitly changing DSCR value Anshuman Khandual
2015-01-13 15:23   ` Shuah Khan
2015-01-13 10:22 ` [PATCH V2 08/12] selftests, powerpc: Add test for DSCR SPR numbers Anshuman Khandual
2015-01-13 15:23   ` Shuah Khan
2015-01-13 10:22 ` [PATCH V2 09/12] selftests, powerpc: Add test for DSCR value inheritence across fork Anshuman Khandual
2015-01-13 15:24   ` Shuah Khan
2015-01-13 10:22 ` [PATCH V2 10/12] selftests, powerpc: Add test for DSCR inheritence across fork & exec Anshuman Khandual
2015-01-13 15:24   ` Shuah Khan
2015-01-13 10:22 ` [PATCH V2 11/12] selftests, powerpc: Add test for all DSCR sysfs interfaces Anshuman Khandual
2015-01-13 15:24   ` Shuah Khan
2015-01-13 10:22 ` [PATCH V2 12/12] selftests, powerpc: Add thread based stress test for " Anshuman Khandual
2015-01-13 15:24   ` Shuah Khan
2015-02-04  8:21 ` [PATCH V2 00/12] POWER DSCR fixes, improvements, docs and tests Anshuman Khandual
2015-02-04  8:36   ` Anshuman Khandual

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=1421144560-15901-6-git-send-email-khandual@linux.vnet.ibm.com \
    --to=khandual@linux.vnet.ibm.com \
    --cc=anton@samba.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=shuahkh@osg.samsung.com \
    /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).