Skip to contentSkip to conversation

rmap and nvidia?

DISCUSSION O.Sezer 3 participants 5 messages Dec 16, 2002 – Dec 17, 2002

lore
Share & tools
lore

O.Sezer

author
#0 lore raw

Is this patch correct in any way?
(Ripped out of the 2.5 patch and modified some).

Thanks.

nv.c +2 -9
diff -urN NVIDIA_kernel-1.0-4191/nv.c NVIDIA_kernel.rmap15b/nv.c
@@ -2217,7 +2217,7 @@
 {
     pgd_t *pg_dir;
     pmd_t *pg_mid_dir;
-    pte_t *pte__, pte;
+    pte_t pte;
 
 #if defined(NVCPU_IA64)
     if (address > __IA64_UNCACHED_OFFSET)
@@ -2241,14 +2241,7 @@
     if (pmd_none(*pg_mid_dir))
         goto failed;
 
-#if defined (pte_offset_atomic)
-    pte__ = pte_offset_atomic(pg_mid_dir, address);
-    pte = *pte__;
-    pte_kunmap(pte__);
-#else
-    pte__ = NULL;
-    pte = *pte_offset(pg_mid_dir, address);
-#endif
+    PTE_OFFSET(pg_mid_dir, address, pte);
 
     if (!pte_present(pte))
         goto failed;
nv-linux.h +22 -0
diff -urN NVIDIA_kernel-1.0-4191/nv-linux.h NVIDIA_kernel.rmap15b/nv-linux.h
@@ -146,6 +146,28 @@
 #  define VMA_PRIVATE(vma)              ((void*)((vma)->vm_pte))
 #endif
 
+#ifdef pte_offset_map		/* rmap-vm or 2.5  */
+#define PTE_OFFSET(pmd, address, pte)               \
+ {                                                  \
+     pte_t *pPTE;                                   \
+     pPTE = pte_offset_map(pmd, address);           \
+     pte = *pPTE;                                   \
+     pte_unmap(pPTE);                               \
+ }
+#else
+#ifdef pte_offset_atomic		/* aa-vm   */
+#define PTE_OFFSET(pmd, address, pte)               \
+  {                                                 \
+     pte_t *pPTE;                                   \
+     pPTE = pte_offset_atomic(pmd, address);        \
+     pte = *pPTE;                                   \
+     pte_kunmap(pPTE);                              \
+  }
+#else	/* !pte_offset_atomic */
+#define PTE_OFFSET(pmd, address, pte)   (pte = *pte_offset(pmd, address))
+#endif	/* pte_offset_atomic  */
+#endif	/* pte_offset_map     */
+
 #define NV_PAGE_ALIGN(addr)             ( ((addr) + PAGE_SIZE - 1) / PAGE_SIZE)
 #define NV_MASK_OFFSET(addr)            ( (addr) & (PAGE_SIZE - 1) )
 
#1 lore raw
Quoted 3 lines · O.Sezer

Is this patch correct in any way?
(Ripped out of the 2.5 patch and modified some).

The equivalent minimal patch for nv.c in 2.4 will then be:

nvidia/NVIDIA_kernel/nv.c Tue Dec 17 10:07:37 2002 renamed from nvidia/NVIDIA_kernel/nv.c.orig Tue Dec 10 07:27:15 2002 +6 -1
@@ -2247,7 +2247,13 @@
     pte_kunmap(pte__);
 #else
     pte__ = NULL;
+#ifdef pte_offset
     pte = *pte_offset(pg_mid_dir, address);
+#else	/* rmap-vm */
+    pte__ = pte_offset_map(pg_mid_dir, address);
+    pte = *pte__;
+    pte_unmap(pte__);
+#endif
 #endif
 
--

Eyal Lebedinsky ([email protected]) <http://samba.org/eyal/>

#2 lore raw
In reply to O.Sezer

The bit calling pte_unmap in nv-linux.h is the only difference from the current minion.de patch, but it works, doesn't oops any more, nor does it leak memory any more :-)

Great! X on 2.5 on my laptop!

Andrew

Quoted 5 lines · --On Tuesday, December 17, 2002 00:22:34 +0200 "O.Sezer"…

Is this patch correct in any way?
(Ripped out of the 2.5 patch and modified some).

Thanks.

#3 lore raw
In reply to O.Sezer

So, first apply the patch for 4191 from www.minion.de, then the attached one based on yours. Been running overnight and beaten on by XScreesaver, no memory leak anymore.

Andrew

Quoted 5 lines · --On Tuesday, December 17, 2002 00:22:34 +0200 "O.Sezer"…

Is this patch correct in any way?
(Ripped out of the 2.5 patch and modified some).

Thanks.

nv-linux.h +13 -7
@@ -151,21 +151,27 @@
 #  define SMP_NUM_CPUS                  smp_num_cpus
 #endif
 
-#ifdef KERNEL_2_5
-#define PTE_OFFSET(pmd, address, pte)   (pte = *pte_offset_map(pmd, address))
+#ifdef pte_offset_map		/* rmap-vm or 2.5  */
+#define PTE_OFFSET(pmd, address, pte)               \
+ {                                                  \
+     pte_t *pPTE;                                   \
+     pPTE = pte_offset_map(pmd, address);           \
+     pte = *pPTE;                                   \
+     pte_unmap(pPTE);                               \
+ }
 #else
-#ifdef pte_offset_atomic
+#ifdef pte_offset_atomic		/* aa-vm   */
 #define PTE_OFFSET(pmd, address, pte)               \
-  {                                                  \
+  {                                                 \
      pte_t *pPTE;                                   \
      pPTE = pte_offset_atomic(pmd, address);        \
      pte = *pPTE;                                   \
      pte_kunmap(pPTE);                              \
   }
-#else /* !pte_offset_atomic */
+#else	/* !pte_offset_atomic */
 #define PTE_OFFSET(pmd, address, pte)   (pte = *pte_offset(pmd, address))
-#endif /* pte_offset_atomic */
-#endif /* KERNEL_2_5 */
+#endif	/* pte_offset_atomic  */
+#endif	/* pte_offset_map     */
 
 #define NV_PAGE_ALIGN(addr)             ( ((addr) + PAGE_SIZE - 1) / PAGE_SIZE)
 #define NV_MASK_OFFSET(addr)            ( (addr) & (PAGE_SIZE - 1) )
author
#4 lore raw

So, we should thank to wli for the information.

Quoted 13 lines · Andrew McGregor

So, first apply the patch for 4191 from www.minion.de, then the attached one based on yours. Been running overnight and beaten on by XScreesaver, no memory leak anymore.

Andrew

--On Tuesday, December 17, 2002 00:22:34 +0200 "O.Sezer"

Quoted 5 lines · <[email protected]> wrote:

Is this patch correct in any way?
(Ripped out of the 2.5 patch and modified some).

Thanks.