History

mm/gup: fix a misnamed "write" argument, and a related bug

In several routines, the "flags" argument is incorrectly named "write". Change it to "flags". Also, in one place, the misnaming led to an actual bug: "flags & FOLL_WRITE" is required, rather than just "flags". (That problem was flagged by krobot, in v1 of this patch.) Also, change the flags argument from int, to unsigned int. You can see that this was a simple oversight, because the calling code passes "flags" to the fifth argument: gup_pgd_range(): ... if (!gup_huge_pd(__hugepd(pgd_val(pgd)), addr, PGDIR_SHIFT, next, flags, pages, nr)) ...which, until this patch, the callees referred to as "write". Also, change two lines to avoid checkpatch line length complaints, and another line to fix another oversight that checkpatch called out: missing "int" on pdshift.

John Hubbard committed 7 years ago

Commit 0cd22af1 parent 6f24c8d1 file · +8 −6Browse files

Unified · Split

mm/gup.c+8−6
@@ -1973,7 +1973,8 @@ static unsigned long hugepte_addr_end(unsigned long addr, unsigned long end, · 1972 unmodified lines
1973}1973}
1974 1974
1975static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr,1975static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr,
1976 unsigned long end, int write, struct page **pages, int *nr)1976 unsigned long end, unsigned int flags,
1977 struct page **pages, int *nr)
1977{1978{
1978 unsigned long pte_end;1979 unsigned long pte_end;
1979 struct page *head, *page;1980 struct page *head, *page;
@@ -1986,7 +1987,7 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, · 6 unmodified lines
1986 1987
1987 pte = READ_ONCE(*ptep);1988 pte = READ_ONCE(*ptep);
1988 1989
1989 if (!pte_access_permitted(pte, write))1990 if (!pte_access_permitted(pte, flags & FOLL_WRITE))
1990 return 0;1991 return 0;
1991 1992
1992 /* hugepages are never "special" */1993 /* hugepages are never "special" */
@@ -2023,7 +2024,7 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, · 30 unmodified lines
2023}2024}
2024 2025
2025static int gup_huge_pd(hugepd_t hugepd, unsigned long addr,2026static int gup_huge_pd(hugepd_t hugepd, unsigned long addr,
2026 unsigned int pdshift, unsigned long end, int write,2027 unsigned int pdshift, unsigned long end, unsigned int flags,
2027 struct page **pages, int *nr)2028 struct page **pages, int *nr)
2028{2029{
2029 pte_t *ptep;2030 pte_t *ptep;
@@ -2033,7 +2034,7 @@ static int gup_huge_pd(hugepd_t hugepd, unsigned long addr, · 3 unmodified lines
2033 ptep = hugepte_offset(hugepd, addr, pdshift);2034 ptep = hugepte_offset(hugepd, addr, pdshift);
2034 do {2035 do {
2035 next = hugepte_addr_end(addr, end, sz);2036 next = hugepte_addr_end(addr, end, sz);
2036 if (!gup_hugepte(ptep, sz, addr, end, write, pages, nr))2037 if (!gup_hugepte(ptep, sz, addr, end, flags, pages, nr))
2037 return 0;2038 return 0;
2038 } while (ptep++, addr = next, addr != end);2039 } while (ptep++, addr = next, addr != end);
2039 2040
@@ -2041,7 +2042,7 @@ static int gup_huge_pd(hugepd_t hugepd, unsigned long addr, · 1 unmodified line
2041}2042}
2042#else2043#else
2043static inline int gup_huge_pd(hugepd_t hugepd, unsigned long addr,2044static inline int gup_huge_pd(hugepd_t hugepd, unsigned long addr,
2044 unsigned pdshift, unsigned long end, int write,2045 unsigned int pdshift, unsigned long end, unsigned int flags,
2045 struct page **pages, int *nr)2046 struct page **pages, int *nr)
2046{2047{
2047 return 0;2048 return 0;
@@ -2049,7 +2050,8 @@ static inline int gup_huge_pd(hugepd_t hugepd, unsigned long addr, · 1 unmodified line
2049#endif /* CONFIG_ARCH_HAS_HUGEPD */2050#endif /* CONFIG_ARCH_HAS_HUGEPD */
2050 2051
2051static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr,2052static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr,
2052 unsigned long end, unsigned int flags, struct page **pages, int *nr)2053 unsigned long end, unsigned int flags,
2054 struct page **pages, int *nr)
2053{2055{
2054 struct page *head, *page;2056 struct page *head, *page;
2055 int refs;2057 int refs;