History

mm/hmm: a few more C style and comment clean ups

A few more comments and minor programming style clean ups. There should be no functional changes.

Ralph Campbell committed 7 years ago

Commit d2e8d551 parent 1f961801 file · +17 −22Browse files

Unified · Split

mm/hmm.c+17−22
@@ -32,7 +32,7 @@ static const struct mmu_notifier_ops hmm_mmu_notifier_ops; · 31 unmodified lines
32 * hmm_get_or_create - register HMM against an mm (HMM internal)32 * hmm_get_or_create - register HMM against an mm (HMM internal)
33 *33 *
34 * @mm: mm struct to attach to34 * @mm: mm struct to attach to
35 * Returns: returns an HMM object, either by referencing the existing35 * Return: an HMM object, either by referencing the existing
36 * (per-process) object, or by creating a new one.36 * (per-process) object, or by creating a new one.
37 *37 *
38 * This is not intended to be used directly by device drivers. If mm already38 * This is not intended to be used directly by device drivers. If mm already
@@ -325,8 +325,8 @@ static int hmm_pfns_bad(unsigned long addr, · 286 unmodified lines
325}325}
326 326
327/*327/*
328 * hmm_vma_walk_hole() - handle a range lacking valid pmd or pte(s)328 * hmm_vma_walk_hole_() - handle a range lacking valid pmd or pte(s)
329 * @start: range virtual start address (inclusive)329 * @addr: range virtual start address (inclusive)
330 * @end: range virtual end address (exclusive)330 * @end: range virtual end address (exclusive)
331 * @fault: should we fault or not ?331 * @fault: should we fault or not ?
332 * @write_fault: write fault ?332 * @write_fault: write fault ?
@@ -376,9 +376,9 @@ static inline void hmm_pte_need_fault(const struct hmm_vma_walk *hmm_vma_walk, · 43 unmodified lines
376 /*376 /*
377 * So we not only consider the individual per page request we also377 * So we not only consider the individual per page request we also
378 * consider the default flags requested for the range. The API can378 * consider the default flags requested for the range. The API can
379 * be use in 2 fashions. The first one where the HMM user coalesce379 * be used 2 ways. The first one where the HMM user coalesces
380 * multiple page fault into one request and set flags per pfns for380 * multiple page faults into one request and sets flags per pfn for
381 * of those faults. The second one where the HMM user want to pre-381 * those faults. The second one where the HMM user wants to pre-
382 * fault a range with specific flags. For the latter one it is a382 * fault a range with specific flags. For the latter one it is a
383 * waste to have the user pre-fill the pfn arrays with a default383 * waste to have the user pre-fill the pfn arrays with a default
384 * flags value.384 * flags value.
@@ -388,7 +388,7 @@ static inline void hmm_pte_need_fault(const struct hmm_vma_walk *hmm_vma_walk, · 3 unmodified lines
388 /* We aren't ask to do anything ... */388 /* We aren't ask to do anything ... */
389 if (!(pfns & range->flags[HMM_PFN_VALID]))389 if (!(pfns & range->flags[HMM_PFN_VALID]))
390 return;390 return;
391 /* If this is device memory than only fault if explicitly requested */391 /* If this is device memory then only fault if explicitly requested */
392 if ((cpu_flags & range->flags[HMM_PFN_DEVICE_PRIVATE])) {392 if ((cpu_flags & range->flags[HMM_PFN_DEVICE_PRIVATE])) {
393 /* Do we fault on device memory ? */393 /* Do we fault on device memory ? */
394 if (pfns & range->flags[HMM_PFN_DEVICE_PRIVATE]) {394 if (pfns & range->flags[HMM_PFN_DEVICE_PRIVATE]) {
@@ -502,7 +502,7 @@ static int hmm_vma_handle_pmd(struct mm_walk *walk, · 107 unmodified lines
502 hmm_vma_walk->last = end;502 hmm_vma_walk->last = end;
503 return 0;503 return 0;
504#else504#else
505 /* If THP is not enabled then we should never reach that code ! */505 /* If THP is not enabled then we should never reach this code ! */
506 return -EINVAL;506 return -EINVAL;
507#endif507#endif
508}508}
@@ -522,7 +522,6 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr, · 13 unmodified lines
522{522{
523 struct hmm_vma_walk *hmm_vma_walk = walk->private;523 struct hmm_vma_walk *hmm_vma_walk = walk->private;
524 struct hmm_range *range = hmm_vma_walk->range;524 struct hmm_range *range = hmm_vma_walk->range;
525 struct vm_area_struct *vma = walk->vma;
526 bool fault, write_fault;525 bool fault, write_fault;
527 uint64_t cpu_flags;526 uint64_t cpu_flags;
528 pte_t pte = *ptep;527 pte_t pte = *ptep;
@@ -571,8 +570,7 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr, · 42 unmodified lines
571 if (fault || write_fault) {570 if (fault || write_fault) {
572 pte_unmap(ptep);571 pte_unmap(ptep);
573 hmm_vma_walk->last = addr;572 hmm_vma_walk->last = addr;
574 migration_entry_wait(vma->vm_mm,573 migration_entry_wait(walk->mm, pmdp, addr);
575 pmdp, addr);
576 return -EBUSY;574 return -EBUSY;
577 }575 }
578 return 0;576 return 0;
@@ -620,13 +618,11 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp, · 41 unmodified lines
620{618{
621 struct hmm_vma_walk *hmm_vma_walk = walk->private;619 struct hmm_vma_walk *hmm_vma_walk = walk->private;
622 struct hmm_range *range = hmm_vma_walk->range;620 struct hmm_range *range = hmm_vma_walk->range;
623 struct vm_area_struct *vma = walk->vma;
624 uint64_t *pfns = range->pfns;621 uint64_t *pfns = range->pfns;
625 unsigned long addr = start, i;622 unsigned long addr = start, i;
626 pte_t *ptep;623 pte_t *ptep;
627 pmd_t pmd;624 pmd_t pmd;
628 625
629
630again:626again:
631 pmd = READ_ONCE(*pmdp);627 pmd = READ_ONCE(*pmdp);
632 if (pmd_none(pmd))628 if (pmd_none(pmd))
@@ -648,7 +644,7 @@ again: · 15 unmodified lines
648 0, &fault, &write_fault);644 0, &fault, &write_fault);
649 if (fault || write_fault) {645 if (fault || write_fault) {
650 hmm_vma_walk->last = addr;646 hmm_vma_walk->last = addr;
651 pmd_migration_entry_wait(vma->vm_mm, pmdp);647 pmd_migration_entry_wait(walk->mm, pmdp);
652 return -EBUSY;648 return -EBUSY;
653 }649 }
654 return 0;650 return 0;
@@ -657,11 +653,11 @@ again: · 2 unmodified lines
657 653
658 if (pmd_devmap(pmd) || pmd_trans_huge(pmd)) {654 if (pmd_devmap(pmd) || pmd_trans_huge(pmd)) {
659 /*655 /*
660 * No need to take pmd_lock here, even if some other threads656 * No need to take pmd_lock here, even if some other thread
661 * is splitting the huge pmd we will get that event through657 * is splitting the huge pmd we will get that event through
662 * mmu_notifier callback.658 * mmu_notifier callback.
663 *659 *
664 * So just read pmd value and check again its a transparent660 * So just read pmd value and check again it's a transparent
665 * huge or device mapping one and compute corresponding pfn661 * huge or device mapping one and compute corresponding pfn
666 * values.662 * values.
667 */663 */
@@ -675,7 +671,7 @@ again: · 7 unmodified lines
675 }671 }
676 672
677 /*673 /*
678 * We have handled all the valid case above ie either none, migration,674 * We have handled all the valid cases above ie either none, migration,
679 * huge or transparent huge. At this point either it is a valid pmd675 * huge or transparent huge. At this point either it is a valid pmd
680 * entry pointing to pte directory or it is a bad pmd that will not676 * entry pointing to pte directory or it is a bad pmd that will not
681 * recover.677 * recover.
@@ -795,10 +791,10 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask, · 113 unmodified lines
795 pte_t entry;791 pte_t entry;
796 int ret = 0;792 int ret = 0;
797 793
798 size = 1UL << huge_page_shift(h);794 size = huge_page_size(h);
799 mask = size - 1;795 mask = size - 1;
800 if (range->page_shift != PAGE_SHIFT) {796 if (range->page_shift != PAGE_SHIFT) {
801 /* Make sure we are looking at full page. */797 /* Make sure we are looking at a full page. */
802 if (start & mask)798 if (start & mask)
803 return -EINVAL;799 return -EINVAL;
804 if (end < (start + size))800 if (end < (start + size))
@@ -809,8 +805,7 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask, · 4 unmodified lines
809 size = PAGE_SIZE;805 size = PAGE_SIZE;
810 }806 }
811 807
812 808 ptl = huge_pte_lock(hstate_vma(vma), walk->mm, pte);
813 ptl = huge_pte_lock(hstate_vma(walk->vma), walk->mm, pte);
814 entry = huge_ptep_get(pte);809 entry = huge_ptep_get(pte);
815 810
816 i = (start - range->start) >> range->page_shift;811 i = (start - range->start) >> range->page_shift;
@@ -859,7 +854,7 @@ static void hmm_pfns_clear(struct hmm_range *range, · 42 unmodified lines
859 * @start: start virtual address (inclusive)854 * @start: start virtual address (inclusive)
860 * @end: end virtual address (exclusive)855 * @end: end virtual address (exclusive)
861 * @page_shift: expect page shift for the range856 * @page_shift: expect page shift for the range
862 * Returns 0 on success, -EFAULT if the address space is no longer valid857 * Return: 0 on success, -EFAULT if the address space is no longer valid
863 *858 *
864 * Track updates to the CPU page table see include/linux/hmm.h859 * Track updates to the CPU page table see include/linux/hmm.h
865 */860 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t