Sergei,

If you are running with this patch you sent, this is why are you having
problems with the swapper task getting killed on the x86_64.
kgdb_unset_may_fault() is responsible for restoring the preempt count.
And if it is not in the return path from a set_longjmp, then there is no
way to restore the preempt count.

It may seem counter intuitive to have the mayfault setup before
settingup up the stack for a possible return from a long jump, but that
is the way it works right now.

Another possibility would be to split the functions to explicitly save
the preempt count separately if you realy want to move the may_fault
sets and unsets around.

Jason.

> -----Original Message-----
> From: Sergei Shtylyov [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, June 17, 2007 12:21 PM
> To: [email protected]; Wessel, Jason
> Subject: [PATCH] Set kgdb_may_fault after jump buffer is 
> setup (take 2)
> 
> It doesn't make sense to set kgdb_may_fault before setting up 
> the jump buffer, so move kgdb_set_may_fault() calls to where 
> the buffer is known to be set up and get rid of 
> kgdb_unset_may_fault() calls in the error return paths.
> Clean up grammar and style in some comments, while at it...
> 
> Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>
> 
> ---
> Comments needed some more fixing than had been initially noticed.
> This cleanup is against the linux_2_6_21_uprev branch as usual...
> 
>  kernel/kgdb.c |   46 +++++++++++++++++++++-------------------------
>  1 files changed, 21 insertions(+), 25 deletions(-)
> 
> Index: linux-2.6/kernel/kgdb.c
> ===================================================================
> --- linux-2.6.orig/kernel/kgdb.c
> +++ linux-2.6/kernel/kgdb.c
> @@ -303,17 +303,17 @@ static void put_packet(char *buffer)  }
>  
>  /*
> - * convert the memory pointed to by mem into hex, placing 
> result in buf
> - * return a pointer to the last char put in buf (null). May 
> return an error.
> + * Convert the memory pointed to by mem into hex, placing 
> result in buf.
> + * Return a pointer to the last char put in buf (null). May 
> return an error.
>   */
>  char *kgdb_mem2hex(char *mem, char *buf, int count)  {
> -     kgdb_set_may_fault();
> -     if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
> -             kgdb_unset_may_fault();
> +     if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0)
>               return ERR_PTR(-EINVAL);
> -     }
> -     /* Accessing some registers in a single load instruction is
> +
> +     kgdb_set_may_fault();
> +     /*
> +      * Accessing some registers in a single load instruction is
>        * required to avoid bad side effects for some I/O registers.
>        */
>       if ((count == 2) && (((long)mem & 1) == 0)) { @@ 
> -411,11 +411,10 @@ char *kgdb_mem2hex(char *mem, char *buf,
>   */
>  static char *kgdb_ebin2mem(char *buf, char *mem, int count)  {
> -     kgdb_set_may_fault();
> -     if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
> -             kgdb_unset_may_fault();
> +     if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0)
>               return ERR_PTR(-EINVAL);
> -     }
> +
> +     kgdb_set_may_fault();
>       for (; count > 0; count--, buf++) {
>               if (*buf == 0x7d)
>                       *mem++ = *(++buf) ^ 0x20;
> @@ -427,17 +426,16 @@ static char *kgdb_ebin2mem(char *buf, ch  }
>  
>  /*
> - * convert the hex array pointed to by buf into binary to be 
> placed in mem
> - * return a pointer to the character AFTER the last byte written
> + * Convert the hex array pointed to by buf into binary to be 
> placed in mem.
> + * Return a pointer to the character AFTER the last byte written.
>   * May return an error.
>   */
>  char *kgdb_hex2mem(char *buf, char *mem, int count)  {
> -     kgdb_set_may_fault();
> -     if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
> -             kgdb_unset_may_fault();
> +     if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0)
>               return ERR_PTR(-EINVAL);
> -     }
> +
> +     kgdb_set_may_fault();
>       if ((count == 2) && (((long)mem & 1) == 0)) {
>               unsigned short tmp_s = 0;
>  #ifdef __BIG_ENDIAN
> @@ -639,11 +637,10 @@ static void kgdb_wait(struct pt_regs *re
>  
>  int kgdb_get_mem(char *addr, unsigned char *buf, int count)  {
> -     kgdb_set_may_fault();
> -     if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
> -             kgdb_unset_may_fault();
> +     if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0)
>               return -EINVAL;
> -     }
> +
> +     kgdb_set_may_fault();
>       while (count) {
>               if ((unsigned long)addr < TASK_SIZE) {
>                       kgdb_unset_may_fault();
> @@ -658,11 +655,10 @@ int kgdb_get_mem(char *addr, unsigned ch
>  
>  int kgdb_set_mem(char *addr, unsigned char *buf, int count)  {
> -     kgdb_set_may_fault();
> -     if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
> -             kgdb_unset_may_fault();
> +     if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0)
>               return -EINVAL;
> -     }
> +
> +     kgdb_set_may_fault();
>       while (count) {
>               if ((unsigned long)addr < TASK_SIZE) {
>                       kgdb_unset_may_fault();
> 
> 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Kgdb-bugreport mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to