Thread (47 messages) flat view 47 messages, 4 authors, 2012-07-24

Re: [PATCH -V3 03/11] arch/powerpc: Convert virtual address to vpn

From: Aneesh Kumar K.V <hidden>
Date: 2012-07-23 05:54:45

Paul Mackerras [off-list ref] writes:
On Mon, Jul 09, 2012 at 06:43:33PM +0530, Aneesh Kumar K.V wrote:
quoted
From: "Aneesh Kumar K.V" <redacted>

This patch convert different functions to take virtual page number
instead of virtual address. Virtual page number is virtual address
shifted right by VPN_SHIFT (12) bits. This enable us to have an
address range of upto 76 bits.
Some comments inline below...
quoted
+/*
+ * encode page number shift.
+ * Inorder to fit the 78 bit va in a 64 bit variable we shift the va by
      ^ "in order"
quoted
+ * 12 bits. This enable us to address upto 76 bit va.
                                         ^ "up to"
quoted
+ * For hpt hash from a va we can ignore the page size bits of va and for
+ * hpte encoding we ignore upto 23 bits of va. So ignoring lower 12 bits ensure
+ * we work in all cases including 4k page size.
+ */
+#define VPN_SHIFT	12
This can't be more than 12 bits because we sometimes use 4k pages even
in a kernel configured for 64k pages (e.g. with the subpage_protection
system call).
Yes, I wanted to make that explicit, ie this is not a virtual page
number and hence all these BUG_ON. I actually updated few of them
to BUILD_BUG_ON() based of earlier review.
quoted
+static inline unsigned long hpte_encode_avpn(unsigned long vpn, int psize,
+					     int ssize)
+{
+	unsigned long v;
+	/*
+	 * The AVA field omits the low-order 23 bits of the 78 bits VA.
+	 * These bits are not needed in the PTE, because the
+	 * low-order b of these bits are part of the byte offset
+	 * into the virtual page and, if b < 23, the high-order
+	 * 23-b of these bits are always used in selecting the
+	 * PTEGs to be searched
+	 */
+	BUG_ON(VPN_SHIFT > 23);
I don't think we need this.  If VPN_SHIFT was computed by some complex
expression whose value is not obvious, then BUG_ON (or BUILD_BUG_ON)
would be appropriate, but since it's just a #define, a comment at the
site of the definition will suffice.
quoted
 static inline unsigned long hpt_hash(unsigned long va, unsigned int shift,
 				     int ssize)
 {
+	int mask;
 	unsigned long hash, vsid;
 
+	BUG_ON(shift < VPN_SHIFT);
So VPN_SHIFT can be at most 12, since 12 is the smallest shift value
possible here.
quoted
-static inline void __tlbiel(unsigned long va, int psize, int ssize)
+static inline void __tlbiel(unsigned long vpn, int psize, int ssize)
 {
+	unsigned long va;
 	unsigned int penc;
 
+	BUG_ON((77 - 65) > VPN_SHIFT);
+	va = vpn << VPN_SHIFT;
So VPN_SHIFT has to be at least 12.  What is the significance of 77
and 65 here?
It is the other way around . I updated that in 77guccfav.fsf@skywalker.in.ibm.com

       BUILD_BUG_ON(VPN_SHIFT > (77 - 65));

tlbiel says we can only ignore bits above 65 of va. hence the math of 77- 65. 

-aneesh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help