Skip to contentSkip to conversation

drivers/dax: Avoiding potential deadlock

PATCH In review Pushkar Jambhlekar 3 participants 6 messages Apr 11, 2017 – Apr 12, 2017 Device direct access (DAX)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drivers/dax: Avoiding potential deadlock

dax_dev_huge_fault returning without releasing lock. Making code change to avoid this situation

---
 drivers/dax/dax.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/dax.c +1 -1
index 0d1ca24..fd9c4db 100644
@@ -590,7 +590,7 @@ static int dax_dev_huge_fault(struct vm_fault *vmf,
 		rc = __dax_dev_pud_fault(dax_dev, vmf);
 		break;
 	default:
-		return VM_FAULT_FALLBACK;
+		rc = VM_FAULT_FALLBACK;
 	}
 	rcu_read_unlock();
 
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 drivers/dax: Changing RC value

Changing rc value from VM_FAULT_FALLBACK to VM_FAULT_SIGBUS for an unknown / unsupported fault size.

---
 drivers/dax/dax.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/dax.c +1 -1
index fd9c4db..6156fdc 100644
@@ -590,7 +590,7 @@ static int dax_dev_huge_fault(struct vm_fault *vmf,
 		rc = __dax_dev_pud_fault(dax_dev, vmf);
 		break;
 	default:
-		rc = VM_FAULT_FALLBACK;
+		rc = VM_FAULT_SIGBUS;
 	}
 	rcu_read_unlock();
 
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 2/2] drivers/dax: Changing RC value

Quoted 7 lines · On Tue, 11 Apr 2017 10:56:45 +0530 Pushkar Jambhlekar <[email protected]>…

Changing rc value from VM_FAULT_FALLBACK to VM_FAULT_SIGBUS for an unknown / unsupported fault size.

...

drivers/dax/dax.c static int dax_dev_huge_fault(struct vm_fault *vmf, · line 595

Quoted 7 lines
drivers/dax/dax.c +1 -1
@@ -590,7 +590,7 @@ static int dax_dev_huge_fault(struct vm_fault *vmf,
 		rc = __dax_dev_pud_fault(dax_dev, vmf);
 		break;
 	default:
-		rc =  VM_FAULT_FALLBACK;
+		rc = VM_FAULT_SIGBUS;
 	}
 	rcu_read_unlock();

The change seems to make sense but more info would be helpful. What is wrong with the current code? ie, what goes wrong if we return VM_FAULT_FALLBACK here?

#3 lore raw

Re: [PATCH 2/2] drivers/dax: Changing RC value

Quoted 6 lines · Andrew Morton
Quoted 4 lines · On Tue, 11 Apr 2017 10:56:45 +0530 Pushkar Jambhlekar <[email protected]>…

Changing rc value from VM_FAULT_FALLBACK to VM_FAULT_SIGBUS for an unknown / unsupported fault size.

...

Quoted 14 lines

drivers/dax/dax.c static int dax_dev_huge_fault(struct vm_fault *vmf, · line 595

Quoted 10 lines
drivers/dax/dax.c +1 -1
@@ -590,7 +590,7 @@ static int dax_dev_huge_fault(struct vm_fault *vmf,
              rc = __dax_dev_pud_fault(dax_dev, vmf);
              break;
      default:
-             rc =  VM_FAULT_FALLBACK;
+             rc = VM_FAULT_SIGBUS;
      }
      rcu_read_unlock();

The change seems to make sense but more info would be helpful. What is wrong with the current code? ie, what goes wrong if we return VM_FAULT_FALLBACK here?

Hi Andrew, I took these two patches into my for-4.12/dax branch with the following fixed up changelog:

commit 17756a4c681c320712798b783eb40006de9b4cc3

Author: Pushkar Jambhlekar <[email protected]>
Date:   Tue Apr 11 09:12:25 2017 -0700

device-dax: fix dax_dev_huge_fault() unknown fault size handling

The default case for dax_dev_huge_fault() fault size handling mistakenly returns when it should unlock. This is not a problem in practice since the only three possible fault sizes are handled. Going forward, if the core mm adds a new fault size beyond pte, pmd, or pud device-dax should abort VM_FAULT_SIGBUS requests not VM_FAULT_FALLBACK since device-dax guarantees a configured fault granularity for all faults.

drivers/dax/dax.c +1 -1
index 19795eb35579..94036d92ed16 100644
@@ -591,7 +591,7 @@ static int dax_dev_huge_fault(struct vm_fault *vmf,
                rc = __dax_dev_pud_fault(dax_dev, vmf);
                break;
        default:
-               return VM_FAULT_FALLBACK;
+               rc = VM_FAULT_SIGBUS;
        }
        srcu_read_unlock(&dax_srcu, id);
#4 lore raw
In reply to Pushkar Jambhlekar
Quoted 12 lines · Pushkar Jambhlekar

dax_dev_huge_fault returning without releasing lock. Making code change to avoid this situation

---
 drivers/dax/dax.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/dax.c +0 -0
index 0d1ca24..fd9c4db 100644

drivers/dax/dax.c static int dax_dev_huge_fault(struct vm_fault *vmf, · line 595

Quoted 7 lines
drivers/dax/dax.c +1 -1
@@ -590,7 +590,7 @@ static int dax_dev_huge_fault(struct vm_fault *vmf,
                rc = __dax_dev_pud_fault(dax_dev, vmf);
                break;
        default:
-               return VM_FAULT_FALLBACK;
+               rc = VM_FAULT_FALLBACK;
        }
        rcu_read_unlock();

Thanks Pushkar, I'll apply this and combine with patch 2 as well.

#5 lore raw

Thanks Dan!

Quoted 23 lines · Dan Williams
Quoted 12 lines · Pushkar Jambhlekar

dax_dev_huge_fault returning without releasing lock. Making code change to avoid this situation

---
 drivers/dax/dax.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/dax.c +0 -0
index 0d1ca24..fd9c4db 100644

drivers/dax/dax.c static int dax_dev_huge_fault(struct vm_fault *vmf, · line 595

Quoted 7 lines
drivers/dax/dax.c +1 -1
@@ -590,7 +590,7 @@ static int dax_dev_huge_fault(struct vm_fault *vmf,
                rc = __dax_dev_pud_fault(dax_dev, vmf);
                break;
        default:
-               return VM_FAULT_FALLBACK;
+               rc = VM_FAULT_FALLBACK;
        }
        rcu_read_unlock();

Thanks Pushkar, I'll apply this and combine with patch 2 as well.

Signature · 1 line
Jambhlekar Pushkar Arun