@@ -61,6 +61,9 @@ extern unsigned long empty_zero_page;
61
61
* So we'll put up with a bit of inefficiency for now...
62
62
*/
63
63
64
+ /* We borrow bit 6 to store the exclusive marker in swap PTEs. */
65
+ #define _PAGE_SWP_EXCLUSIVE (1<<6)
66
+
64
67
/*
65
68
* Top "FOURTH" level (pgd), which for the Hexagon VM is really
66
69
* only the second from the bottom, pgd and pud both being collapsed.
@@ -359,9 +362,12 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
359
362
#define ZERO_PAGE (vaddr ) (virt_to_page(&empty_zero_page))
360
363
361
364
/*
365
+ * Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that
366
+ * are !pte_none() && !pte_present().
367
+ *
362
368
* Swap/file PTE definitions. If _PAGE_PRESENT is zero, the rest of the PTE is
363
369
* interpreted as swap information. The remaining free bits are interpreted as
364
- * swap type/offset tuple . Rather than have the TLB fill handler test
370
+ * listed below . Rather than have the TLB fill handler test
365
371
* _PAGE_PRESENT, we're going to reserve the permissions bits and set them to
366
372
* all zeros for swap entries, which speeds up the miss handler at the cost of
367
373
* 3 bits of offset. That trade-off can be revisited if necessary, but Hexagon
@@ -371,9 +377,10 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
371
377
* Format of swap PTE:
372
378
* bit 0: Present (zero)
373
379
* bits 1-5: swap type (arch independent layer uses 5 bits max)
374
- * bits 6-9: bits 3:0 of offset
380
+ * bit 6: exclusive marker
381
+ * bits 7-9: bits 2:0 of offset
375
382
* bits 10-12: effectively _PAGE_PROTNONE (all zero)
376
- * bits 13-31: bits 22:4 of swap offset
383
+ * bits 13-31: bits 21:3 of swap offset
377
384
*
378
385
* The split offset makes some of the following macros a little gnarly,
379
386
* but there's plenty of precedent for this sort of thing.
@@ -383,11 +390,29 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
383
390
#define __swp_type (swp_pte ) (((swp_pte).val >> 1) & 0x1f)
384
391
385
392
#define __swp_offset (swp_pte ) \
386
- ((((swp_pte).val >> 6 ) & 0xf ) | (((swp_pte).val >> 9 ) & 0x7ffff0 ))
393
+ ((((swp_pte).val >> 7 ) & 0x7 ) | (((swp_pte).val >> 10 ) & 0x3ffff8 ))
387
394
388
395
#define __swp_entry (type , offset ) \
389
396
((swp_entry_t) { \
390
- ((type << 1) | \
391
- ((offset & 0x7ffff0) << 9) | ((offset & 0xf) << 6)) })
397
+ (((type & 0x1f) << 1) | \
398
+ ((offset & 0x3ffff8) << 10) | ((offset & 0x7) << 7)) })
399
+
400
+ #define __HAVE_ARCH_PTE_SWP_EXCLUSIVE
401
+ static inline int pte_swp_exclusive (pte_t pte )
402
+ {
403
+ return pte_val (pte ) & _PAGE_SWP_EXCLUSIVE ;
404
+ }
405
+
406
+ static inline pte_t pte_swp_mkexclusive (pte_t pte )
407
+ {
408
+ pte_val (pte ) |= _PAGE_SWP_EXCLUSIVE ;
409
+ return pte ;
410
+ }
411
+
412
+ static inline pte_t pte_swp_clear_exclusive (pte_t pte )
413
+ {
414
+ pte_val (pte ) &= ~_PAGE_SWP_EXCLUSIVE ;
415
+ return pte ;
416
+ }
392
417
393
418
#endif
0 commit comments