Thread (12 messages) 12 messages, 4 authors, 2018-08-16

Re: [PATCH 3/3] powerpc/pseries/mm: call H_BLOCK_REMOVE

From: Aneesh Kumar K.V <hidden>
Date: 2018-07-30 14:23:01
Also in: lkml

Michael Ellerman [off-list ref] writes:
Hi Laurent,

Just one comment below.

Laurent Dufour [off-list ref] writes:
quoted
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platfo=
rms/pseries/lpar.c
quoted
index 96b8cd8a802d..41ed03245eb4 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -418,6 +418,73 @@ static void pSeries_lpar_hpte_invalidate(unsigned l=
ong slot, unsigned long vpn,
quoted
 	BUG_ON(lpar_rc !=3D H_SUCCESS);
 }
=20=20
+
+/*
+ * As defined in the PAPR's section 14.5.4.1.8
+ * The control mask doesn't include the returned reference and change b=
it from
quoted
+ * the processed PTE.
+ */
+#define HBLKR_AVPN		0x0100000000000000UL
+#define HBLKR_CTRL_MASK		0xf800000000000000UL
+#define HBLKR_CTRL_SUCCESS	0x8000000000000000UL
+#define HBLKR_CTRL_ERRNOTFOUND	0x8800000000000000UL
+#define HBLKR_CTRL_ERRBUSY	0xa000000000000000UL
+
+/**
+ * H_BLOCK_REMOVE caller.
+ * @idx should point to the latest @param entry set with a PTEX.
+ * If PTE cannot be processed because another CPUs has already locked t=
hat
quoted
+ * group, those entries are put back in @param starting at index 1.
+ * If entries has to be retried and @retry_busy is set to true, these e=
ntries
quoted
+ * are retried until success. If @retry_busy is set to false, the retur=
ned
quoted
+ * is the number of entries yet to process.
+ */
+static unsigned long call_block_remove(unsigned long idx, unsigned long=
 *param,
quoted
+				       bool retry_busy)
+{
+	unsigned long i, rc, new_idx;
+	unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
+
+again:
+	new_idx =3D 0;
+	BUG_ON((idx < 2) || (idx > PLPAR_HCALL9_BUFSIZE));
I count 1 ..
quoted
+	if (idx < PLPAR_HCALL9_BUFSIZE)
+		param[idx] =3D HBR_END;
+
+	rc =3D plpar_hcall9(H_BLOCK_REMOVE, retbuf,
+			  param[0], /* AVA */
+			  param[1],  param[2],  param[3],  param[4], /* TS0-7 */
+			  param[5],  param[6],  param[7],  param[8]);
+	if (rc =3D=3D H_SUCCESS)
+		return 0;
+
+	BUG_ON(rc !=3D H_PARTIAL);
2 ...
quoted
+	/* Check that the unprocessed entries were 'not found' or 'busy' */
+	for (i =3D 0; i < idx-1; i++) {
+		unsigned long ctrl =3D retbuf[i] & HBLKR_CTRL_MASK;
+
+		if (ctrl =3D=3D HBLKR_CTRL_ERRBUSY) {
+			param[++new_idx] =3D param[i+1];
+			continue;
+		}
+
+		BUG_ON(ctrl !=3D HBLKR_CTRL_SUCCESS
+		       && ctrl !=3D HBLKR_CTRL_ERRNOTFOUND);
3 ...

BUG_ON()s.

I know the code in this file is already pretty liberal with the use of
BUG_ON() but I'd prefer if we don't make it any worse.

Given this is an optimisation it seems like we should be able to fall
back to the existing implementation in the case of error (which will
probably then BUG_ON() =F0=9F=98=82)

If there's some reason we can't then I guess I can live with it.
It would be nice to log the error in case we are not expecting the
error return. We recently did
https://marc.info/?i=3D20180629083904.29250-1-aneesh.kumar@linux.ibm.com

-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