linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/xmon: symbol lookup length fixed
@ 2024-10-23 21:22 Mukesh Kumar Chaurasiya
  2024-10-24  1:00 ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2024-10-23 21:22 UTC (permalink / raw)
  To: mpe
  Cc: npiggin, christophe.leroy, naveen, maddy, peterx, groug, sshegde,
	mchauras, linuxppc-dev, linux-kernel

Currently xmon cannot lookup symbol beyond 64 characters in some cases.

Fix this by using KSYM_NAME_LEN instead of fixed 64 characters.

Signed-off-by: Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com>
---
 arch/powerpc/xmon/xmon.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index e6cddbb2305f..22b8b5cc4df0 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -3662,7 +3662,7 @@ symbol_lookup(void)
 	int type = inchar();
 	unsigned long addr, cpu;
 	void __percpu *ptr = NULL;
-	static char tmp[64];
+	static char tmp[KSYM_NAME_LEN];
 
 	switch (type) {
 	case 'a':
@@ -3671,7 +3671,7 @@ symbol_lookup(void)
 		termch = 0;
 		break;
 	case 's':
-		getstring(tmp, 64);
+		getstring(tmp, KSYM_NAME_LEN);
 		if (setjmp(bus_error_jmp) == 0) {
 			catch_memory_errors = 1;
 			sync();
@@ -3686,7 +3686,7 @@ symbol_lookup(void)
 		termch = 0;
 		break;
 	case 'p':
-		getstring(tmp, 64);
+		getstring(tmp, KSYM_NAME_LEN);
 		if (setjmp(bus_error_jmp) == 0) {
 			catch_memory_errors = 1;
 			sync();
-- 
2.47.0


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

* Re: [PATCH] powerpc/xmon: symbol lookup length fixed
  2024-10-23 21:22 [PATCH] powerpc/xmon: symbol lookup length fixed Mukesh Kumar Chaurasiya
@ 2024-10-24  1:00 ` Michael Ellerman
  2024-10-24  5:12   ` Mukesh Kumar Chaurasiya
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Ellerman @ 2024-10-24  1:00 UTC (permalink / raw)
  To: Mukesh Kumar Chaurasiya
  Cc: npiggin, christophe.leroy, naveen, maddy, peterx, groug, sshegde,
	mchauras, linuxppc-dev, linux-kernel

Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com> writes:
> Currently xmon cannot lookup symbol beyond 64 characters in some cases.

Can you mention which commands? It looks like it's "ls" and "lp".

> Fix this by using KSYM_NAME_LEN instead of fixed 64 characters.
>
> Signed-off-by: Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com>
> ---
>  arch/powerpc/xmon/xmon.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index e6cddbb2305f..22b8b5cc4df0 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -3662,7 +3662,7 @@ symbol_lookup(void)
>  	int type = inchar();
>  	unsigned long addr, cpu;
>  	void __percpu *ptr = NULL;
> -	static char tmp[64];
> +	static char tmp[KSYM_NAME_LEN];
  
I think you could use the existing tmpstr buffer.

It is global so it's a little hard to track down all the users, but I
think it's only used briefly in get_function_bounds(),
xmon_print_symbol() and scanhex(). ie. none of the uses persist across
function calls.

We don't want to have two 512 byte static arrays lying around if we can
get by with one.

cheers

>  	switch (type) {
>  	case 'a':
> @@ -3671,7 +3671,7 @@ symbol_lookup(void)
>  		termch = 0;
>  		break;
>  	case 's':
> -		getstring(tmp, 64);
> +		getstring(tmp, KSYM_NAME_LEN);
>  		if (setjmp(bus_error_jmp) == 0) {
>  			catch_memory_errors = 1;
>  			sync();
> @@ -3686,7 +3686,7 @@ symbol_lookup(void)
>  		termch = 0;
>  		break;
>  	case 'p':
> -		getstring(tmp, 64);
> +		getstring(tmp, KSYM_NAME_LEN);
>  		if (setjmp(bus_error_jmp) == 0) {
>  			catch_memory_errors = 1;
>  			sync();
> -- 
> 2.47.0

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

* Re: [PATCH] powerpc/xmon: symbol lookup length fixed
  2024-10-24  1:00 ` Michael Ellerman
@ 2024-10-24  5:12   ` Mukesh Kumar Chaurasiya
  2024-10-24 19:03     ` Mukesh Kumar Chaurasiya
  0 siblings, 1 reply; 5+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2024-10-24  5:12 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: npiggin, christophe.leroy, naveen, maddy, peterx, groug, sshegde,
	linuxppc-dev, linux-kernel

On Thu, Oct 24, 2024 at 12:00:53PM +1100, Michael Ellerman wrote:
> Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com> writes:
> > Currently xmon cannot lookup symbol beyond 64 characters in some cases.
> 
> Can you mention which commands? It looks like it's "ls" and "lp".
Sure.
> 
> > Fix this by using KSYM_NAME_LEN instead of fixed 64 characters.
> >
> > Signed-off-by: Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com>
> > ---
> >  arch/powerpc/xmon/xmon.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> > index e6cddbb2305f..22b8b5cc4df0 100644
> > --- a/arch/powerpc/xmon/xmon.c
> > +++ b/arch/powerpc/xmon/xmon.c
> > @@ -3662,7 +3662,7 @@ symbol_lookup(void)
> >  	int type = inchar();
> >  	unsigned long addr, cpu;
> >  	void __percpu *ptr = NULL;
> > -	static char tmp[64];
> > +	static char tmp[KSYM_NAME_LEN];
>   
> I think you could use the existing tmpstr buffer.
> 
> It is global so it's a little hard to track down all the users, but I
> think it's only used briefly in get_function_bounds(),
> xmon_print_symbol() and scanhex(). ie. none of the uses persist across
> function calls.
> 
> We don't want to have two 512 byte static arrays lying around if we can
> get by with one.
> 
> cheers
Sure.

Will send out V2.
> >  	switch (type) {
> >  	case 'a':
> > @@ -3671,7 +3671,7 @@ symbol_lookup(void)
> >  		termch = 0;
> >  		break;
> >  	case 's':
> > -		getstring(tmp, 64);
> > +		getstring(tmp, KSYM_NAME_LEN);
> >  		if (setjmp(bus_error_jmp) == 0) {
> >  			catch_memory_errors = 1;
> >  			sync();
> > @@ -3686,7 +3686,7 @@ symbol_lookup(void)
> >  		termch = 0;
> >  		break;
> >  	case 'p':
> > -		getstring(tmp, 64);
> > +		getstring(tmp, KSYM_NAME_LEN);
> >  		if (setjmp(bus_error_jmp) == 0) {
> >  			catch_memory_errors = 1;
> >  			sync();
> > -- 
> > 2.47.0

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

* Re: [PATCH] powerpc/xmon: symbol lookup length fixed
  2024-10-24  5:12   ` Mukesh Kumar Chaurasiya
@ 2024-10-24 19:03     ` Mukesh Kumar Chaurasiya
  2024-10-25  2:32       ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2024-10-24 19:03 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: npiggin, christophe.leroy, naveen, maddy, peterx, groug, sshegde,
	linuxppc-dev, linux-kernel

On Thu, Oct 24, 2024 at 10:42:12AM +0530, Mukesh Kumar Chaurasiya wrote:
> On Thu, Oct 24, 2024 at 12:00:53PM +1100, Michael Ellerman wrote:
> > Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com> writes:
> > > Currently xmon cannot lookup symbol beyond 64 characters in some cases.
> > 
> > Can you mention which commands? It looks like it's "ls" and "lp".
> Sure.
> > 
> > > Fix this by using KSYM_NAME_LEN instead of fixed 64 characters.
> > >
> > > Signed-off-by: Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com>
> > > ---
> > >  arch/powerpc/xmon/xmon.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> > > index e6cddbb2305f..22b8b5cc4df0 100644
> > > --- a/arch/powerpc/xmon/xmon.c
> > > +++ b/arch/powerpc/xmon/xmon.c
> > > @@ -3662,7 +3662,7 @@ symbol_lookup(void)
> > >  	int type = inchar();
> > >  	unsigned long addr, cpu;
> > >  	void __percpu *ptr = NULL;
> > > -	static char tmp[64];
> > > +	static char tmp[KSYM_NAME_LEN];
> >   
> > I think you could use the existing tmpstr buffer.
> > 
> > It is global so it's a little hard to track down all the users, but I
> > think it's only used briefly in get_function_bounds(),
> > xmon_print_symbol() and scanhex(). ie. none of the uses persist across
> > function calls.
> > 
> > We don't want to have two 512 byte static arrays lying around if we can
> > get by with one.
> > 
> > cheers
> Sure.
For now i don't think so we can get by with only one. There is a lookup being
done when the scanhex is using the tmpstr for another lookup.

I'll send a V2 with commit message change.
> 
> Will send out V2.
> > >  	switch (type) {
> > >  	case 'a':
> > > @@ -3671,7 +3671,7 @@ symbol_lookup(void)
> > >  		termch = 0;
> > >  		break;
> > >  	case 's':
> > > -		getstring(tmp, 64);
> > > +		getstring(tmp, KSYM_NAME_LEN);
> > >  		if (setjmp(bus_error_jmp) == 0) {
> > >  			catch_memory_errors = 1;
> > >  			sync();
> > > @@ -3686,7 +3686,7 @@ symbol_lookup(void)
> > >  		termch = 0;
> > >  		break;
> > >  	case 'p':
> > > -		getstring(tmp, 64);
> > > +		getstring(tmp, KSYM_NAME_LEN);
> > >  		if (setjmp(bus_error_jmp) == 0) {
> > >  			catch_memory_errors = 1;
> > >  			sync();
> > > -- 
> > > 2.47.0
> 

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

* Re: [PATCH] powerpc/xmon: symbol lookup length fixed
  2024-10-24 19:03     ` Mukesh Kumar Chaurasiya
@ 2024-10-25  2:32       ` Michael Ellerman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2024-10-25  2:32 UTC (permalink / raw)
  To: Mukesh Kumar Chaurasiya
  Cc: npiggin, christophe.leroy, naveen, maddy, peterx, groug, sshegde,
	linuxppc-dev, linux-kernel

Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com> writes:
> On Thu, Oct 24, 2024 at 10:42:12AM +0530, Mukesh Kumar Chaurasiya wrote:
>> On Thu, Oct 24, 2024 at 12:00:53PM +1100, Michael Ellerman wrote:
>> > Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com> writes:
>> > > Currently xmon cannot lookup symbol beyond 64 characters in some cases.
>> > 
>> > Can you mention which commands? It looks like it's "ls" and "lp".
>> Sure.
>> > 
>> > > Fix this by using KSYM_NAME_LEN instead of fixed 64 characters.
>> > >
>> > > Signed-off-by: Mukesh Kumar Chaurasiya <mchauras@linux.ibm.com>
>> > > ---
>> > >  arch/powerpc/xmon/xmon.c | 6 +++---
>> > >  1 file changed, 3 insertions(+), 3 deletions(-)
>> > >
>> > > diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
>> > > index e6cddbb2305f..22b8b5cc4df0 100644
>> > > --- a/arch/powerpc/xmon/xmon.c
>> > > +++ b/arch/powerpc/xmon/xmon.c
>> > > @@ -3662,7 +3662,7 @@ symbol_lookup(void)
>> > >  	int type = inchar();
>> > >  	unsigned long addr, cpu;
>> > >  	void __percpu *ptr = NULL;
>> > > -	static char tmp[64];
>> > > +	static char tmp[KSYM_NAME_LEN];
>> >   
>> > I think you could use the existing tmpstr buffer.
>> > 
>> > It is global so it's a little hard to track down all the users, but I
>> > think it's only used briefly in get_function_bounds(),
>> > xmon_print_symbol() and scanhex(). ie. none of the uses persist across
>> > function calls.
>> > 
>> > We don't want to have two 512 byte static arrays lying around if we can
>> > get by with one.
>> > 
>> > cheers
>> Sure.

> For now i don't think so we can get by with only one. There is a lookup being
> done when the scanhex is using the tmpstr for another lookup.

Yeah I see it, when handling `lp <symbol> <cpu>`.

That's a bit annoying because for that command the CPU number is only
meant to be a number, it never makes sense to do a $symbol lookup there.

But I agree with the way the code is structured it's best not to reuse
tmpstr there.

cheers

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

end of thread, other threads:[~2024-10-25  2:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23 21:22 [PATCH] powerpc/xmon: symbol lookup length fixed Mukesh Kumar Chaurasiya
2024-10-24  1:00 ` Michael Ellerman
2024-10-24  5:12   ` Mukesh Kumar Chaurasiya
2024-10-24 19:03     ` Mukesh Kumar Chaurasiya
2024-10-25  2:32       ` Michael Ellerman

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).