Skip to content

Commit b505417

Browse files
dhowellsakpm00
authored andcommitted
mm: move FOLL_* defs to mm_types.h
Move FOLL_* definitions to linux/mm_types.h to make them more accessible without having to drag in all of linux/mm.h and everything that drags in too[1]. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: David Howells <[email protected]> Suggested-by: Matthew Wilcox <[email protected]> Reviewed-by: John Hubbard <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0b7b870 commit b505417

File tree

2 files changed

+75
-75
lines changed

2 files changed

+75
-75
lines changed

include/linux/mm.h

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3057,81 +3057,6 @@ static inline vm_fault_t vmf_error(int err)
30573057
struct page *follow_page(struct vm_area_struct *vma, unsigned long address,
30583058
unsigned int foll_flags);
30593059

3060-
#define FOLL_WRITE 0x01 /* check pte is writable */
3061-
#define FOLL_TOUCH 0x02 /* mark page accessed */
3062-
#define FOLL_GET 0x04 /* do get_page on page */
3063-
#define FOLL_DUMP 0x08 /* give error on hole if it would be zero */
3064-
#define FOLL_FORCE 0x10 /* get_user_pages read/write w/o permission */
3065-
#define FOLL_NOWAIT 0x20 /* if a disk transfer is needed, start the IO
3066-
* and return without waiting upon it */
3067-
#define FOLL_NOFAULT 0x80 /* do not fault in pages */
3068-
#define FOLL_HWPOISON 0x100 /* check page is hwpoisoned */
3069-
#define FOLL_TRIED 0x800 /* a retry, previous pass started an IO */
3070-
#define FOLL_REMOTE 0x2000 /* we are working on non-current tsk/mm */
3071-
#define FOLL_ANON 0x8000 /* don't do file mappings */
3072-
#define FOLL_LONGTERM 0x10000 /* mapping lifetime is indefinite: see below */
3073-
#define FOLL_SPLIT_PMD 0x20000 /* split huge pmd before returning */
3074-
#define FOLL_PIN 0x40000 /* pages must be released via unpin_user_page */
3075-
#define FOLL_FAST_ONLY 0x80000 /* gup_fast: prevent fall-back to slow gup */
3076-
#define FOLL_PCI_P2PDMA 0x100000 /* allow returning PCI P2PDMA pages */
3077-
#define FOLL_INTERRUPTIBLE 0x200000 /* allow interrupts from generic signals */
3078-
3079-
/*
3080-
* FOLL_PIN and FOLL_LONGTERM may be used in various combinations with each
3081-
* other. Here is what they mean, and how to use them:
3082-
*
3083-
* FOLL_LONGTERM indicates that the page will be held for an indefinite time
3084-
* period _often_ under userspace control. This is in contrast to
3085-
* iov_iter_get_pages(), whose usages are transient.
3086-
*
3087-
* FIXME: For pages which are part of a filesystem, mappings are subject to the
3088-
* lifetime enforced by the filesystem and we need guarantees that longterm
3089-
* users like RDMA and V4L2 only establish mappings which coordinate usage with
3090-
* the filesystem. Ideas for this coordination include revoking the longterm
3091-
* pin, delaying writeback, bounce buffer page writeback, etc. As FS DAX was
3092-
* added after the problem with filesystems was found FS DAX VMAs are
3093-
* specifically failed. Filesystem pages are still subject to bugs and use of
3094-
* FOLL_LONGTERM should be avoided on those pages.
3095-
*
3096-
* FIXME: Also NOTE that FOLL_LONGTERM is not supported in every GUP call.
3097-
* Currently only get_user_pages() and get_user_pages_fast() support this flag
3098-
* and calls to get_user_pages_[un]locked are specifically not allowed. This
3099-
* is due to an incompatibility with the FS DAX check and
3100-
* FAULT_FLAG_ALLOW_RETRY.
3101-
*
3102-
* In the CMA case: long term pins in a CMA region would unnecessarily fragment
3103-
* that region. And so, CMA attempts to migrate the page before pinning, when
3104-
* FOLL_LONGTERM is specified.
3105-
*
3106-
* FOLL_PIN indicates that a special kind of tracking (not just page->_refcount,
3107-
* but an additional pin counting system) will be invoked. This is intended for
3108-
* anything that gets a page reference and then touches page data (for example,
3109-
* Direct IO). This lets the filesystem know that some non-file-system entity is
3110-
* potentially changing the pages' data. In contrast to FOLL_GET (whose pages
3111-
* are released via put_page()), FOLL_PIN pages must be released, ultimately, by
3112-
* a call to unpin_user_page().
3113-
*
3114-
* FOLL_PIN is similar to FOLL_GET: both of these pin pages. They use different
3115-
* and separate refcounting mechanisms, however, and that means that each has
3116-
* its own acquire and release mechanisms:
3117-
*
3118-
* FOLL_GET: get_user_pages*() to acquire, and put_page() to release.
3119-
*
3120-
* FOLL_PIN: pin_user_pages*() to acquire, and unpin_user_pages to release.
3121-
*
3122-
* FOLL_PIN and FOLL_GET are mutually exclusive for a given function call.
3123-
* (The underlying pages may experience both FOLL_GET-based and FOLL_PIN-based
3124-
* calls applied to them, and that's perfectly OK. This is a constraint on the
3125-
* callers, not on the pages.)
3126-
*
3127-
* FOLL_PIN should be set internally by the pin_user_pages*() APIs, never
3128-
* directly by the caller. That's in order to help avoid mismatches when
3129-
* releasing pages: get_user_pages*() pages must be released via put_page(),
3130-
* while pin_user_pages*() pages must be released via unpin_user_page().
3131-
*
3132-
* Please see Documentation/core-api/pin_user_pages.rst for more information.
3133-
*/
3134-
31353060
static inline int vm_fault_to_errno(vm_fault_t vm_fault, int foll_flags)
31363061
{
31373062
if (vm_fault & VM_FAULT_OOM)

include/linux/mm_types.h

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,4 +1085,79 @@ enum fault_flag {
10851085

10861086
typedef unsigned int __bitwise zap_flags_t;
10871087

1088+
/*
1089+
* FOLL_PIN and FOLL_LONGTERM may be used in various combinations with each
1090+
* other. Here is what they mean, and how to use them:
1091+
*
1092+
* FOLL_LONGTERM indicates that the page will be held for an indefinite time
1093+
* period _often_ under userspace control. This is in contrast to
1094+
* iov_iter_get_pages(), whose usages are transient.
1095+
*
1096+
* FIXME: For pages which are part of a filesystem, mappings are subject to the
1097+
* lifetime enforced by the filesystem and we need guarantees that longterm
1098+
* users like RDMA and V4L2 only establish mappings which coordinate usage with
1099+
* the filesystem. Ideas for this coordination include revoking the longterm
1100+
* pin, delaying writeback, bounce buffer page writeback, etc. As FS DAX was
1101+
* added after the problem with filesystems was found FS DAX VMAs are
1102+
* specifically failed. Filesystem pages are still subject to bugs and use of
1103+
* FOLL_LONGTERM should be avoided on those pages.
1104+
*
1105+
* FIXME: Also NOTE that FOLL_LONGTERM is not supported in every GUP call.
1106+
* Currently only get_user_pages() and get_user_pages_fast() support this flag
1107+
* and calls to get_user_pages_[un]locked are specifically not allowed. This
1108+
* is due to an incompatibility with the FS DAX check and
1109+
* FAULT_FLAG_ALLOW_RETRY.
1110+
*
1111+
* In the CMA case: long term pins in a CMA region would unnecessarily fragment
1112+
* that region. And so, CMA attempts to migrate the page before pinning, when
1113+
* FOLL_LONGTERM is specified.
1114+
*
1115+
* FOLL_PIN indicates that a special kind of tracking (not just page->_refcount,
1116+
* but an additional pin counting system) will be invoked. This is intended for
1117+
* anything that gets a page reference and then touches page data (for example,
1118+
* Direct IO). This lets the filesystem know that some non-file-system entity is
1119+
* potentially changing the pages' data. In contrast to FOLL_GET (whose pages
1120+
* are released via put_page()), FOLL_PIN pages must be released, ultimately, by
1121+
* a call to unpin_user_page().
1122+
*
1123+
* FOLL_PIN is similar to FOLL_GET: both of these pin pages. They use different
1124+
* and separate refcounting mechanisms, however, and that means that each has
1125+
* its own acquire and release mechanisms:
1126+
*
1127+
* FOLL_GET: get_user_pages*() to acquire, and put_page() to release.
1128+
*
1129+
* FOLL_PIN: pin_user_pages*() to acquire, and unpin_user_pages to release.
1130+
*
1131+
* FOLL_PIN and FOLL_GET are mutually exclusive for a given function call.
1132+
* (The underlying pages may experience both FOLL_GET-based and FOLL_PIN-based
1133+
* calls applied to them, and that's perfectly OK. This is a constraint on the
1134+
* callers, not on the pages.)
1135+
*
1136+
* FOLL_PIN should be set internally by the pin_user_pages*() APIs, never
1137+
* directly by the caller. That's in order to help avoid mismatches when
1138+
* releasing pages: get_user_pages*() pages must be released via put_page(),
1139+
* while pin_user_pages*() pages must be released via unpin_user_page().
1140+
*
1141+
* Please see Documentation/core-api/pin_user_pages.rst for more information.
1142+
*/
1143+
1144+
#define FOLL_WRITE 0x01 /* check pte is writable */
1145+
#define FOLL_TOUCH 0x02 /* mark page accessed */
1146+
#define FOLL_GET 0x04 /* do get_page on page */
1147+
#define FOLL_DUMP 0x08 /* give error on hole if it would be zero */
1148+
#define FOLL_FORCE 0x10 /* get_user_pages read/write w/o permission */
1149+
#define FOLL_NOWAIT 0x20 /* if a disk transfer is needed, start the IO
1150+
* and return without waiting upon it */
1151+
#define FOLL_NOFAULT 0x80 /* do not fault in pages */
1152+
#define FOLL_HWPOISON 0x100 /* check page is hwpoisoned */
1153+
#define FOLL_TRIED 0x800 /* a retry, previous pass started an IO */
1154+
#define FOLL_REMOTE 0x2000 /* we are working on non-current tsk/mm */
1155+
#define FOLL_ANON 0x8000 /* don't do file mappings */
1156+
#define FOLL_LONGTERM 0x10000 /* mapping lifetime is indefinite: see below */
1157+
#define FOLL_SPLIT_PMD 0x20000 /* split huge pmd before returning */
1158+
#define FOLL_PIN 0x40000 /* pages must be released via unpin_user_page */
1159+
#define FOLL_FAST_ONLY 0x80000 /* gup_fast: prevent fall-back to slow gup */
1160+
#define FOLL_PCI_P2PDMA 0x100000 /* allow returning PCI P2PDMA pages */
1161+
#define FOLL_INTERRUPTIBLE 0x200000 /* allow interrupts from generic signals */
1162+
10881163
#endif /* _LINUX_MM_TYPES_H */

0 commit comments

Comments
 (0)