All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
@ 2022-01-10 12:29 ` Christophe Leroy
  0 siblings, 0 replies; 10+ messages in thread
From: Christophe Leroy @ 2022-01-10 12:29 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: Christophe Leroy, linux-kernel, linuxppc-dev, Naveen N . Rao

BPF_REG_5, BPF_REG_AX and TMP_REG are mapped on non volatile registers
because there are not enough volatile registers, but they don't need
to be preserved on function calls.

So when some volatile registers become available, those registers can
always be reallocated regardless of whether SEEN_FUNC is set or not.

Suggested-by: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/net/bpf_jit.h        |  3 ---
 arch/powerpc/net/bpf_jit_comp32.c | 14 +++++++++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
index b20a2a83a6e7..b75507fc8f6b 100644
--- a/arch/powerpc/net/bpf_jit.h
+++ b/arch/powerpc/net/bpf_jit.h
@@ -127,9 +127,6 @@
 #define SEEN_FUNC	0x20000000 /* might call external helpers */
 #define SEEN_TAILCALL	0x40000000 /* uses tail calls */
 
-#define SEEN_VREG_MASK	0x1ff80000 /* Volatile registers r3-r12 */
-#define SEEN_NVREG_MASK	0x0003ffff /* Non volatile registers r14-r31 */
-
 #ifdef CONFIG_PPC64
 extern const int b2p[MAX_BPF_JIT_REG + 2];
 #else
diff --git a/arch/powerpc/net/bpf_jit_comp32.c b/arch/powerpc/net/bpf_jit_comp32.c
index d3a52cd42f53..cfec42c8a511 100644
--- a/arch/powerpc/net/bpf_jit_comp32.c
+++ b/arch/powerpc/net/bpf_jit_comp32.c
@@ -77,14 +77,22 @@ static int bpf_jit_stack_offsetof(struct codegen_context *ctx, int reg)
 	return BPF_PPC_STACKFRAME(ctx) - 4;
 }
 
+#define SEEN_VREG_MASK		0x1ff80000 /* Volatile registers r3-r12 */
+#define SEEN_NVREG_FULL_MASK	0x0003ffff /* Non volatile registers r14-r31 */
+#define SEEN_NVREG_TEMP_MASK	0x00001e01 /* BPF_REG_5, BPF_REG_AX, TMP_REG */
+
 void bpf_jit_realloc_regs(struct codegen_context *ctx)
 {
+	unsigned int nvreg_mask;
+
 	if (ctx->seen & SEEN_FUNC)
-		return;
+		nvreg_mask = SEEN_NVREG_TEMP_MASK;
+	else
+		nvreg_mask = SEEN_NVREG_FULL_MASK;
 
-	while (ctx->seen & SEEN_NVREG_MASK &&
+	while (ctx->seen & nvreg_mask &&
 	      (ctx->seen & SEEN_VREG_MASK) != SEEN_VREG_MASK) {
-		int old = 32 - fls(ctx->seen & (SEEN_NVREG_MASK & 0xaaaaaaab));
+		int old = 32 - fls(ctx->seen & (nvreg_mask & 0xaaaaaaab));
 		int new = 32 - fls(~ctx->seen & (SEEN_VREG_MASK & 0xaaaaaaaa));
 		int i;
 
-- 
2.33.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
@ 2022-01-10 12:29 ` Christophe Leroy
  0 siblings, 0 replies; 10+ messages in thread
From: Christophe Leroy @ 2022-01-10 12:29 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: Naveen N . Rao, linuxppc-dev, linux-kernel

BPF_REG_5, BPF_REG_AX and TMP_REG are mapped on non volatile registers
because there are not enough volatile registers, but they don't need
to be preserved on function calls.

So when some volatile registers become available, those registers can
always be reallocated regardless of whether SEEN_FUNC is set or not.

Suggested-by: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/net/bpf_jit.h        |  3 ---
 arch/powerpc/net/bpf_jit_comp32.c | 14 +++++++++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
index b20a2a83a6e7..b75507fc8f6b 100644
--- a/arch/powerpc/net/bpf_jit.h
+++ b/arch/powerpc/net/bpf_jit.h
@@ -127,9 +127,6 @@
 #define SEEN_FUNC	0x20000000 /* might call external helpers */
 #define SEEN_TAILCALL	0x40000000 /* uses tail calls */
 
-#define SEEN_VREG_MASK	0x1ff80000 /* Volatile registers r3-r12 */
-#define SEEN_NVREG_MASK	0x0003ffff /* Non volatile registers r14-r31 */
-
 #ifdef CONFIG_PPC64
 extern const int b2p[MAX_BPF_JIT_REG + 2];
 #else
diff --git a/arch/powerpc/net/bpf_jit_comp32.c b/arch/powerpc/net/bpf_jit_comp32.c
index d3a52cd42f53..cfec42c8a511 100644
--- a/arch/powerpc/net/bpf_jit_comp32.c
+++ b/arch/powerpc/net/bpf_jit_comp32.c
@@ -77,14 +77,22 @@ static int bpf_jit_stack_offsetof(struct codegen_context *ctx, int reg)
 	return BPF_PPC_STACKFRAME(ctx) - 4;
 }
 
+#define SEEN_VREG_MASK		0x1ff80000 /* Volatile registers r3-r12 */
+#define SEEN_NVREG_FULL_MASK	0x0003ffff /* Non volatile registers r14-r31 */
+#define SEEN_NVREG_TEMP_MASK	0x00001e01 /* BPF_REG_5, BPF_REG_AX, TMP_REG */
+
 void bpf_jit_realloc_regs(struct codegen_context *ctx)
 {
+	unsigned int nvreg_mask;
+
 	if (ctx->seen & SEEN_FUNC)
-		return;
+		nvreg_mask = SEEN_NVREG_TEMP_MASK;
+	else
+		nvreg_mask = SEEN_NVREG_FULL_MASK;
 
-	while (ctx->seen & SEEN_NVREG_MASK &&
+	while (ctx->seen & nvreg_mask &&
 	      (ctx->seen & SEEN_VREG_MASK) != SEEN_VREG_MASK) {
-		int old = 32 - fls(ctx->seen & (SEEN_NVREG_MASK & 0xaaaaaaab));
+		int old = 32 - fls(ctx->seen & (nvreg_mask & 0xaaaaaaab));
 		int new = 32 - fls(~ctx->seen & (SEEN_VREG_MASK & 0xaaaaaaaa));
 		int i;
 
-- 
2.33.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
  2022-01-10 12:29 ` Christophe Leroy
@ 2022-01-14  7:58   ` Naveen N. Rao
  -1 siblings, 0 replies; 10+ messages in thread
From: Naveen N. Rao @ 2022-01-14  7:58 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Christophe Leroy, Michael Ellerman,
	Paul Mackerras
  Cc: linux-kernel, linuxppc-dev

Christophe Leroy wrote:
> BPF_REG_5, BPF_REG_AX and TMP_REG are mapped on non volatile registers
> because there are not enough volatile registers, but they don't need
> to be preserved on function calls.
> 
> So when some volatile registers become available, those registers can
> always be reallocated regardless of whether SEEN_FUNC is set or not.
> 
> Suggested-by: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  arch/powerpc/net/bpf_jit.h        |  3 ---
>  arch/powerpc/net/bpf_jit_comp32.c | 14 +++++++++++---
>  2 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
> index b20a2a83a6e7..b75507fc8f6b 100644
> --- a/arch/powerpc/net/bpf_jit.h
> +++ b/arch/powerpc/net/bpf_jit.h
> @@ -127,9 +127,6 @@
>  #define SEEN_FUNC	0x20000000 /* might call external helpers */
>  #define SEEN_TAILCALL	0x40000000 /* uses tail calls */
>  
> -#define SEEN_VREG_MASK	0x1ff80000 /* Volatile registers r3-r12 */
> -#define SEEN_NVREG_MASK	0x0003ffff /* Non volatile registers r14-r31 */
> -
>  #ifdef CONFIG_PPC64
>  extern const int b2p[MAX_BPF_JIT_REG + 2];
>  #else
> diff --git a/arch/powerpc/net/bpf_jit_comp32.c b/arch/powerpc/net/bpf_jit_comp32.c
> index d3a52cd42f53..cfec42c8a511 100644
> --- a/arch/powerpc/net/bpf_jit_comp32.c
> +++ b/arch/powerpc/net/bpf_jit_comp32.c
> @@ -77,14 +77,22 @@ static int bpf_jit_stack_offsetof(struct codegen_context *ctx, int reg)
>  	return BPF_PPC_STACKFRAME(ctx) - 4;
>  }
>  
> +#define SEEN_VREG_MASK		0x1ff80000 /* Volatile registers r3-r12 */
> +#define SEEN_NVREG_FULL_MASK	0x0003ffff /* Non volatile registers r14-r31 */
> +#define SEEN_NVREG_TEMP_MASK	0x00001e01 /* BPF_REG_5, BPF_REG_AX, TMP_REG */

Could have been named better: SEEN_NVREG_BPF_VGER_MASK, or such.
Apart from that:
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
@ 2022-01-14  7:58   ` Naveen N. Rao
  0 siblings, 0 replies; 10+ messages in thread
From: Naveen N. Rao @ 2022-01-14  7:58 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Christophe Leroy, Michael Ellerman,
	Paul Mackerras
  Cc: linuxppc-dev, linux-kernel

Christophe Leroy wrote:
> BPF_REG_5, BPF_REG_AX and TMP_REG are mapped on non volatile registers
> because there are not enough volatile registers, but they don't need
> to be preserved on function calls.
> 
> So when some volatile registers become available, those registers can
> always be reallocated regardless of whether SEEN_FUNC is set or not.
> 
> Suggested-by: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  arch/powerpc/net/bpf_jit.h        |  3 ---
>  arch/powerpc/net/bpf_jit_comp32.c | 14 +++++++++++---
>  2 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
> index b20a2a83a6e7..b75507fc8f6b 100644
> --- a/arch/powerpc/net/bpf_jit.h
> +++ b/arch/powerpc/net/bpf_jit.h
> @@ -127,9 +127,6 @@
>  #define SEEN_FUNC	0x20000000 /* might call external helpers */
>  #define SEEN_TAILCALL	0x40000000 /* uses tail calls */
>  
> -#define SEEN_VREG_MASK	0x1ff80000 /* Volatile registers r3-r12 */
> -#define SEEN_NVREG_MASK	0x0003ffff /* Non volatile registers r14-r31 */
> -
>  #ifdef CONFIG_PPC64
>  extern const int b2p[MAX_BPF_JIT_REG + 2];
>  #else
> diff --git a/arch/powerpc/net/bpf_jit_comp32.c b/arch/powerpc/net/bpf_jit_comp32.c
> index d3a52cd42f53..cfec42c8a511 100644
> --- a/arch/powerpc/net/bpf_jit_comp32.c
> +++ b/arch/powerpc/net/bpf_jit_comp32.c
> @@ -77,14 +77,22 @@ static int bpf_jit_stack_offsetof(struct codegen_context *ctx, int reg)
>  	return BPF_PPC_STACKFRAME(ctx) - 4;
>  }
>  
> +#define SEEN_VREG_MASK		0x1ff80000 /* Volatile registers r3-r12 */
> +#define SEEN_NVREG_FULL_MASK	0x0003ffff /* Non volatile registers r14-r31 */
> +#define SEEN_NVREG_TEMP_MASK	0x00001e01 /* BPF_REG_5, BPF_REG_AX, TMP_REG */

Could have been named better: SEEN_NVREG_BPF_VGER_MASK, or such.
Apart from that:
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
  2022-01-14  7:58   ` Naveen N. Rao
@ 2022-01-14  8:03     ` Christophe Leroy
  -1 siblings, 0 replies; 10+ messages in thread
From: Christophe Leroy @ 2022-01-14  8:03 UTC (permalink / raw)
  To: Naveen N. Rao, Benjamin Herrenschmidt, Michael Ellerman, Paul Mackerras
  Cc: linux-kernel, linuxppc-dev



Le 14/01/2022 à 08:58, Naveen N. Rao a écrit :
> Christophe Leroy wrote:
>> BPF_REG_5, BPF_REG_AX and TMP_REG are mapped on non volatile registers
>> because there are not enough volatile registers, but they don't need
>> to be preserved on function calls.
>>
>> So when some volatile registers become available, those registers can
>> always be reallocated regardless of whether SEEN_FUNC is set or not.
>>
>> Suggested-by: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>>  arch/powerpc/net/bpf_jit.h        |  3 ---
>>  arch/powerpc/net/bpf_jit_comp32.c | 14 +++++++++++---
>>  2 files changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
>> index b20a2a83a6e7..b75507fc8f6b 100644
>> --- a/arch/powerpc/net/bpf_jit.h
>> +++ b/arch/powerpc/net/bpf_jit.h
>> @@ -127,9 +127,6 @@
>>  #define SEEN_FUNC    0x20000000 /* might call external helpers */
>>  #define SEEN_TAILCALL    0x40000000 /* uses tail calls */
>>
>> -#define SEEN_VREG_MASK    0x1ff80000 /* Volatile registers r3-r12 */
>> -#define SEEN_NVREG_MASK    0x0003ffff /* Non volatile registers 
>> r14-r31 */
>> -
>>  #ifdef CONFIG_PPC64
>>  extern const int b2p[MAX_BPF_JIT_REG + 2];
>>  #else
>> diff --git a/arch/powerpc/net/bpf_jit_comp32.c 
>> b/arch/powerpc/net/bpf_jit_comp32.c
>> index d3a52cd42f53..cfec42c8a511 100644
>> --- a/arch/powerpc/net/bpf_jit_comp32.c
>> +++ b/arch/powerpc/net/bpf_jit_comp32.c
>> @@ -77,14 +77,22 @@ static int bpf_jit_stack_offsetof(struct 
>> codegen_context *ctx, int reg)
>>      return BPF_PPC_STACKFRAME(ctx) - 4;
>>  }
>>
>> +#define SEEN_VREG_MASK        0x1ff80000 /* Volatile registers r3-r12 */
>> +#define SEEN_NVREG_FULL_MASK    0x0003ffff /* Non volatile registers 
>> r14-r31 */
>> +#define SEEN_NVREG_TEMP_MASK    0x00001e01 /* BPF_REG_5, BPF_REG_AX, 
>> TMP_REG */
> 
> Could have been named better: SEEN_NVREG_BPF_VGER_MASK, or such.

Yes, I was suffering from a lack of inspiration.

What does BPF_VGER mean ?


> Apart from that:
> Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> 

Thanks

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
@ 2022-01-14  8:03     ` Christophe Leroy
  0 siblings, 0 replies; 10+ messages in thread
From: Christophe Leroy @ 2022-01-14  8:03 UTC (permalink / raw)
  To: Naveen N. Rao, Benjamin Herrenschmidt, Michael Ellerman, Paul Mackerras
  Cc: linuxppc-dev, linux-kernel



Le 14/01/2022 à 08:58, Naveen N. Rao a écrit :
> Christophe Leroy wrote:
>> BPF_REG_5, BPF_REG_AX and TMP_REG are mapped on non volatile registers
>> because there are not enough volatile registers, but they don't need
>> to be preserved on function calls.
>>
>> So when some volatile registers become available, those registers can
>> always be reallocated regardless of whether SEEN_FUNC is set or not.
>>
>> Suggested-by: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>>  arch/powerpc/net/bpf_jit.h        |  3 ---
>>  arch/powerpc/net/bpf_jit_comp32.c | 14 +++++++++++---
>>  2 files changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
>> index b20a2a83a6e7..b75507fc8f6b 100644
>> --- a/arch/powerpc/net/bpf_jit.h
>> +++ b/arch/powerpc/net/bpf_jit.h
>> @@ -127,9 +127,6 @@
>>  #define SEEN_FUNC    0x20000000 /* might call external helpers */
>>  #define SEEN_TAILCALL    0x40000000 /* uses tail calls */
>>
>> -#define SEEN_VREG_MASK    0x1ff80000 /* Volatile registers r3-r12 */
>> -#define SEEN_NVREG_MASK    0x0003ffff /* Non volatile registers 
>> r14-r31 */
>> -
>>  #ifdef CONFIG_PPC64
>>  extern const int b2p[MAX_BPF_JIT_REG + 2];
>>  #else
>> diff --git a/arch/powerpc/net/bpf_jit_comp32.c 
>> b/arch/powerpc/net/bpf_jit_comp32.c
>> index d3a52cd42f53..cfec42c8a511 100644
>> --- a/arch/powerpc/net/bpf_jit_comp32.c
>> +++ b/arch/powerpc/net/bpf_jit_comp32.c
>> @@ -77,14 +77,22 @@ static int bpf_jit_stack_offsetof(struct 
>> codegen_context *ctx, int reg)
>>      return BPF_PPC_STACKFRAME(ctx) - 4;
>>  }
>>
>> +#define SEEN_VREG_MASK        0x1ff80000 /* Volatile registers r3-r12 */
>> +#define SEEN_NVREG_FULL_MASK    0x0003ffff /* Non volatile registers 
>> r14-r31 */
>> +#define SEEN_NVREG_TEMP_MASK    0x00001e01 /* BPF_REG_5, BPF_REG_AX, 
>> TMP_REG */
> 
> Could have been named better: SEEN_NVREG_BPF_VGER_MASK, or such.

Yes, I was suffering from a lack of inspiration.

What does BPF_VGER mean ?


> Apart from that:
> Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> 

Thanks

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
  2022-01-14  8:03     ` Christophe Leroy
@ 2022-01-14 10:37       ` Naveen N. Rao
  -1 siblings, 0 replies; 10+ messages in thread
From: Naveen N. Rao @ 2022-01-14 10:37 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Christophe Leroy, Michael Ellerman,
	Paul
	 Mackerras
  Cc: linux-kernel, linuxppc-dev

Christophe Leroy wrote:
> 
> 
> Le 14/01/2022 à 08:58, Naveen N. Rao a écrit :
>> Christophe Leroy wrote:
>>> BPF_REG_5, BPF_REG_AX and TMP_REG are mapped on non volatile registers
>>> because there are not enough volatile registers, but they don't need
>>> to be preserved on function calls.
>>>
>>> So when some volatile registers become available, those registers can
>>> always be reallocated regardless of whether SEEN_FUNC is set or not.
>>>
>>> Suggested-by: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
>>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>>> ---
>>>  arch/powerpc/net/bpf_jit.h        |  3 ---
>>>  arch/powerpc/net/bpf_jit_comp32.c | 14 +++++++++++---
>>>  2 files changed, 11 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
>>> index b20a2a83a6e7..b75507fc8f6b 100644
>>> --- a/arch/powerpc/net/bpf_jit.h
>>> +++ b/arch/powerpc/net/bpf_jit.h
>>> @@ -127,9 +127,6 @@
>>>  #define SEEN_FUNC    0x20000000 /* might call external helpers */
>>>  #define SEEN_TAILCALL    0x40000000 /* uses tail calls */
>>>
>>> -#define SEEN_VREG_MASK    0x1ff80000 /* Volatile registers r3-r12 */
>>> -#define SEEN_NVREG_MASK    0x0003ffff /* Non volatile registers 
>>> r14-r31 */
>>> -
>>>  #ifdef CONFIG_PPC64
>>>  extern const int b2p[MAX_BPF_JIT_REG + 2];
>>>  #else
>>> diff --git a/arch/powerpc/net/bpf_jit_comp32.c 
>>> b/arch/powerpc/net/bpf_jit_comp32.c
>>> index d3a52cd42f53..cfec42c8a511 100644
>>> --- a/arch/powerpc/net/bpf_jit_comp32.c
>>> +++ b/arch/powerpc/net/bpf_jit_comp32.c
>>> @@ -77,14 +77,22 @@ static int bpf_jit_stack_offsetof(struct 
>>> codegen_context *ctx, int reg)
>>>      return BPF_PPC_STACKFRAME(ctx) - 4;
>>>  }
>>>
>>> +#define SEEN_VREG_MASK        0x1ff80000 /* Volatile registers r3-r12 */
>>> +#define SEEN_NVREG_FULL_MASK    0x0003ffff /* Non volatile registers 
>>> r14-r31 */
>>> +#define SEEN_NVREG_TEMP_MASK    0x00001e01 /* BPF_REG_5, BPF_REG_AX, 
>>> TMP_REG */
>> 
>> Could have been named better: SEEN_NVREG_BPF_VGER_MASK, or such.
> 
> Yes, I was suffering from a lack of inspiration.
> 
> What does BPF_VGER mean ?

That I was suffering from a lack of caffeine.

I meant to suggest BPF_VREG, to indicate those are BPF volatile 
registers.


- Naveen


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
@ 2022-01-14 10:37       ` Naveen N. Rao
  0 siblings, 0 replies; 10+ messages in thread
From: Naveen N. Rao @ 2022-01-14 10:37 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Christophe Leroy, Michael Ellerman,
	Paul
	 Mackerras
  Cc: linuxppc-dev, linux-kernel

Christophe Leroy wrote:
> 
> 
> Le 14/01/2022 à 08:58, Naveen N. Rao a écrit :
>> Christophe Leroy wrote:
>>> BPF_REG_5, BPF_REG_AX and TMP_REG are mapped on non volatile registers
>>> because there are not enough volatile registers, but they don't need
>>> to be preserved on function calls.
>>>
>>> So when some volatile registers become available, those registers can
>>> always be reallocated regardless of whether SEEN_FUNC is set or not.
>>>
>>> Suggested-by: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
>>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>>> ---
>>>  arch/powerpc/net/bpf_jit.h        |  3 ---
>>>  arch/powerpc/net/bpf_jit_comp32.c | 14 +++++++++++---
>>>  2 files changed, 11 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
>>> index b20a2a83a6e7..b75507fc8f6b 100644
>>> --- a/arch/powerpc/net/bpf_jit.h
>>> +++ b/arch/powerpc/net/bpf_jit.h
>>> @@ -127,9 +127,6 @@
>>>  #define SEEN_FUNC    0x20000000 /* might call external helpers */
>>>  #define SEEN_TAILCALL    0x40000000 /* uses tail calls */
>>>
>>> -#define SEEN_VREG_MASK    0x1ff80000 /* Volatile registers r3-r12 */
>>> -#define SEEN_NVREG_MASK    0x0003ffff /* Non volatile registers 
>>> r14-r31 */
>>> -
>>>  #ifdef CONFIG_PPC64
>>>  extern const int b2p[MAX_BPF_JIT_REG + 2];
>>>  #else
>>> diff --git a/arch/powerpc/net/bpf_jit_comp32.c 
>>> b/arch/powerpc/net/bpf_jit_comp32.c
>>> index d3a52cd42f53..cfec42c8a511 100644
>>> --- a/arch/powerpc/net/bpf_jit_comp32.c
>>> +++ b/arch/powerpc/net/bpf_jit_comp32.c
>>> @@ -77,14 +77,22 @@ static int bpf_jit_stack_offsetof(struct 
>>> codegen_context *ctx, int reg)
>>>      return BPF_PPC_STACKFRAME(ctx) - 4;
>>>  }
>>>
>>> +#define SEEN_VREG_MASK        0x1ff80000 /* Volatile registers r3-r12 */
>>> +#define SEEN_NVREG_FULL_MASK    0x0003ffff /* Non volatile registers 
>>> r14-r31 */
>>> +#define SEEN_NVREG_TEMP_MASK    0x00001e01 /* BPF_REG_5, BPF_REG_AX, 
>>> TMP_REG */
>> 
>> Could have been named better: SEEN_NVREG_BPF_VGER_MASK, or such.
> 
> Yes, I was suffering from a lack of inspiration.
> 
> What does BPF_VGER mean ?

That I was suffering from a lack of caffeine.

I meant to suggest BPF_VREG, to indicate those are BPF volatile 
registers.


- Naveen


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
  2022-01-10 12:29 ` Christophe Leroy
@ 2022-02-16 12:25   ` Michael Ellerman
  -1 siblings, 0 replies; 10+ messages in thread
From: Michael Ellerman @ 2022-02-16 12:25 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Christophe Leroy, Michael Ellerman,
	Paul Mackerras
  Cc: linuxppc-dev, Naveen N . Rao, linux-kernel

On Mon, 10 Jan 2022 12:29:42 +0000, Christophe Leroy wrote:
> BPF_REG_5, BPF_REG_AX and TMP_REG are mapped on non volatile registers
> because there are not enough volatile registers, but they don't need
> to be preserved on function calls.
> 
> So when some volatile registers become available, those registers can
> always be reallocated regardless of whether SEEN_FUNC is set or not.
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
      https://git.kernel.org/powerpc/c/a8936569a07bf27cc9cfc2a39a1e5ea91273b2d4

cheers

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
@ 2022-02-16 12:25   ` Michael Ellerman
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Ellerman @ 2022-02-16 12:25 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Christophe Leroy, Michael Ellerman,
	Paul Mackerras
  Cc: Naveen N . Rao, linuxppc-dev, linux-kernel

On Mon, 10 Jan 2022 12:29:42 +0000, Christophe Leroy wrote:
> BPF_REG_5, BPF_REG_AX and TMP_REG are mapped on non volatile registers
> because there are not enough volatile registers, but they don't need
> to be preserved on function calls.
> 
> So when some volatile registers become available, those registers can
> always be reallocated regardless of whether SEEN_FUNC is set or not.
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible
      https://git.kernel.org/powerpc/c/a8936569a07bf27cc9cfc2a39a1e5ea91273b2d4

cheers

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-02-16 12:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 12:29 [PATCH] powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX and TMP_REG when possible Christophe Leroy
2022-01-10 12:29 ` Christophe Leroy
2022-01-14  7:58 ` Naveen N. Rao
2022-01-14  7:58   ` Naveen N. Rao
2022-01-14  8:03   ` Christophe Leroy
2022-01-14  8:03     ` Christophe Leroy
2022-01-14 10:37     ` Naveen N. Rao
2022-01-14 10:37       ` Naveen N. Rao
2022-02-16 12:25 ` Michael Ellerman
2022-02-16 12:25   ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.