* pin_user_pages supports NULL pages arguments?
@ 2022-02-10 19:17 Minchan Kim
2022-02-10 19:20 ` John Hubbard
0 siblings, 1 reply; 5+ messages in thread
From: Minchan Kim @ 2022-02-10 19:17 UTC (permalink / raw)
To: John Hubbard; +Cc: linux-mm, LKML
* pin_user_pages() - pin user pages in memory for use by other devices
< snip >
* @pages: array that receives pointers to the pages pinned.
* Should be at least nr_pages long. Or NULL, if caller
* only intends to ensure the pages are faulted in.
pin_user_pages(,, pages = NULL, );
gup_flags |= FOLL_PIN
__get_user_pages_locked
__get_user_pages
..
VM_BUG_ON(!!pages != !!(gup_flags & (FOLL_GET | FOLL_PIN)));
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: pin_user_pages supports NULL pages arguments? 2022-02-10 19:17 pin_user_pages supports NULL pages arguments? Minchan Kim @ 2022-02-10 19:20 ` John Hubbard 2022-02-10 19:29 ` Minchan Kim 0 siblings, 1 reply; 5+ messages in thread From: John Hubbard @ 2022-02-10 19:20 UTC (permalink / raw) To: Minchan Kim; +Cc: linux-mm, LKML On 2/10/22 11:17, Minchan Kim wrote: > * pin_user_pages() - pin user pages in memory for use by other devices > < snip > > * @pages: array that receives pointers to the pages pinned. > * Should be at least nr_pages long. Or NULL, if caller > * only intends to ensure the pages are faulted in. > > pin_user_pages(,, pages = NULL, ); > gup_flags |= FOLL_PIN > __get_user_pages_locked > __get_user_pages > .. > VM_BUG_ON(!!pages != !!(gup_flags & (FOLL_GET | FOLL_PIN))); Only FOLL_GET or FOLL_PIN are supposed to fill in the **pages array. So if a caller passes a null **pages arg, then that caller must not also set FOLL_GET or FOLL_PIN. That's what the VM_BUG_ON() is expressing. Perhaps that should be part of the documentation. It sort of is already, for get_user_pages*(). thanks, -- John Hubbard NVIDIA ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pin_user_pages supports NULL pages arguments? 2022-02-10 19:20 ` John Hubbard @ 2022-02-10 19:29 ` Minchan Kim 2022-02-10 20:20 ` John Hubbard 0 siblings, 1 reply; 5+ messages in thread From: Minchan Kim @ 2022-02-10 19:29 UTC (permalink / raw) To: John Hubbard; +Cc: linux-mm, LKML On Thu, Feb 10, 2022 at 11:20:31AM -0800, John Hubbard wrote: > On 2/10/22 11:17, Minchan Kim wrote: > > * pin_user_pages() - pin user pages in memory for use by other devices > > < snip > > > * @pages: array that receives pointers to the pages pinned. > > * Should be at least nr_pages long. Or NULL, if caller > > * only intends to ensure the pages are faulted in. > > > > pin_user_pages(,, pages = NULL, ); > > gup_flags |= FOLL_PIN > > __get_user_pages_locked > > __get_user_pages > > .. > > VM_BUG_ON(!!pages != !!(gup_flags & (FOLL_GET | FOLL_PIN))); > > Only FOLL_GET or FOLL_PIN are supposed to fill in the **pages array. So > if a caller passes a null **pages arg, then that caller must not also > set FOLL_GET or FOLL_PIN. That's what the VM_BUG_ON() is expressing. Yub, but pin_user_pages adds FOLL_PIN unconditinally and the comments says it supports NUU pages argument. Isn't it conflict? > > Perhaps that should be part of the documentation. It sort of is already, > for get_user_pages*(). I expected it was just copied from get_user_pages. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pin_user_pages supports NULL pages arguments? 2022-02-10 19:29 ` Minchan Kim @ 2022-02-10 20:20 ` John Hubbard 2022-02-10 21:17 ` Minchan Kim 0 siblings, 1 reply; 5+ messages in thread From: John Hubbard @ 2022-02-10 20:20 UTC (permalink / raw) To: Minchan Kim; +Cc: linux-mm, LKML On 2/10/22 11:29, Minchan Kim wrote: > On Thu, Feb 10, 2022 at 11:20:31AM -0800, John Hubbard wrote: >> On 2/10/22 11:17, Minchan Kim wrote: >>> * pin_user_pages() - pin user pages in memory for use by other devices >>> < snip > >>> * @pages: array that receives pointers to the pages pinned. >>> * Should be at least nr_pages long. Or NULL, if caller >>> * only intends to ensure the pages are faulted in. >>> >>> pin_user_pages(,, pages = NULL, ); >>> gup_flags |= FOLL_PIN >>> __get_user_pages_locked >>> __get_user_pages >>> .. >>> VM_BUG_ON(!!pages != !!(gup_flags & (FOLL_GET | FOLL_PIN))); >> >> Only FOLL_GET or FOLL_PIN are supposed to fill in the **pages array. So >> if a caller passes a null **pages arg, then that caller must not also >> set FOLL_GET or FOLL_PIN. That's what the VM_BUG_ON() is expressing. > > Yub, but pin_user_pages adds FOLL_PIN unconditinally and the comments > says it supports NUU pages argument. Isn't it conflict? > Oh right, that is a conflict. The documentation should *not* say that a NULL **pages arg is supported. Because the whole point of the FOLL_PIN APIs is to actually pin struct pages. The NULL cases are only useful for get_user_pages*(). So removing that last sentence is appropriate, plus also looking around for similar documentation claims, including in pin_user_pages.rst. I don't see anything from a very quick scan, though. Sending out a fix will also trigger the observation that both the kerneldoc headers mm/gup.c, and the writings in pin_user_pages.rst, could use some updating. However, it is also true that this can be reasonably treated as a documentation bug fix, and therefore allowed to be limited to just this change. Were you going to send out a formal patch? If not, I can include it in an upcoming gup series, with your Reported-by tag. Up to you. >> >> Perhaps that should be part of the documentation. It sort of is already, >> for get_user_pages*(). > > I expected it was just copied from get_user_pages. Yes it was. thanks, -- John Hubbard NVIDIA ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pin_user_pages supports NULL pages arguments? 2022-02-10 20:20 ` John Hubbard @ 2022-02-10 21:17 ` Minchan Kim 0 siblings, 0 replies; 5+ messages in thread From: Minchan Kim @ 2022-02-10 21:17 UTC (permalink / raw) To: John Hubbard; +Cc: linux-mm, LKML On Thu, Feb 10, 2022 at 12:20:47PM -0800, John Hubbard wrote: > On 2/10/22 11:29, Minchan Kim wrote: > > On Thu, Feb 10, 2022 at 11:20:31AM -0800, John Hubbard wrote: > > > On 2/10/22 11:17, Minchan Kim wrote: > > > > * pin_user_pages() - pin user pages in memory for use by other devices > > > > < snip > > > > > * @pages: array that receives pointers to the pages pinned. > > > > * Should be at least nr_pages long. Or NULL, if caller > > > > * only intends to ensure the pages are faulted in. > > > > > > > > pin_user_pages(,, pages = NULL, ); > > > > gup_flags |= FOLL_PIN > > > > __get_user_pages_locked > > > > __get_user_pages > > > > .. > > > > VM_BUG_ON(!!pages != !!(gup_flags & (FOLL_GET | FOLL_PIN))); > > > > > > Only FOLL_GET or FOLL_PIN are supposed to fill in the **pages array. So > > > if a caller passes a null **pages arg, then that caller must not also > > > set FOLL_GET or FOLL_PIN. That's what the VM_BUG_ON() is expressing. > > > > Yub, but pin_user_pages adds FOLL_PIN unconditinally and the comments > > says it supports NUU pages argument. Isn't it conflict? > > > > Oh right, that is a conflict. The documentation should *not* say that a > NULL **pages arg is supported. Because the whole point of the FOLL_PIN > APIs is to actually pin struct pages. The NULL cases are only useful for > get_user_pages*(). > > So removing that last sentence is appropriate, plus also looking around > for similar documentation claims, including in pin_user_pages.rst. I > don't see anything from a very quick scan, though. > > Sending out a fix will also trigger the observation that both the > kerneldoc headers mm/gup.c, and the writings in pin_user_pages.rst, > could use some updating. However, it is also true that this can be > reasonably treated as a documentation bug fix, and therefore allowed to > be limited to just this change. > > Were you going to send out a formal patch? If not, I can include it in > an upcoming gup series, with your Reported-by tag. Up to you. Yes, please. Thank you, John. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-10 21:17 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-02-10 19:17 pin_user_pages supports NULL pages arguments? Minchan Kim 2022-02-10 19:20 ` John Hubbard 2022-02-10 19:29 ` Minchan Kim 2022-02-10 20:20 ` John Hubbard 2022-02-10 21:17 ` Minchan Kim
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).