From: Lorenzo Stoakes <hidden> Date: 2025-01-13 23:16:37
Right now the only means by which we can write-protect a range using the
reverse mapping is via folio_mkclean().
However this is not always the appropriate means of doing so, specifically
in the case of the framebuffer deferred I/O logic (fb_defio enabled by
CONFIG_FB_DEFERRED_IO). There, kernel pages are mapped read-only and
write-protect faults used to batch up I/O operations.
Each time the deferred work is done, folio_mkclean() is used to mark the
framebuffer page as having had I/O performed on it. However doing so
requires the kernel page (perhaps allocated via vmalloc()) to have its
page->mapping, index fields set so the rmap can find everything that maps
it in order to write-protect.
This is problematic as firstly, these fields should not be set for
kernel-allocated memory, and secondly these are not folios (it's not user
memory) and page->index, mapping fields are now deprecated and soon to be
removed.
The implementers cannot be blamed for having used this however, as there is
simply no other way of performing this operation correctly.
This series fixes this - we provide the mapping_wrprotect_page() function
to allow the reverse mapping to be used to look up mappings from the page
cache object (i.e. its address_space pointer) at a specific offset.
The fb_defio logic already stores this offset, and can simply be expanded
to keep track of the page cache object, so the change then becomes
straight-forward.
This series should have no functional change.
*** REVIEWERS NOTES: ***
I do not have any hardware that uses fb_defio, so I'm asking for help with
testing this series from those who do :) I have tested the mm side of this,
and done a quick compile smoke test of the fb_defio side but this _very
much_ requires testing on actual hardware to ensure everything behaves as
expected.
This is based on Andrew's tree [0] in the mm-unstable branch - I was
thinking it'd be best to go through the mm tree (with fb_defio maintainer
approval, of course!) as it relies upon the mm changes to work correctly.
[0]: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/
RFC v2:
* Updated Jaya Kumar's email on cc - the MAINTAINERS section is apparently incorrect.
* Corrected rmap_walk_file() comment to refer to folios as per Matthew.
* Reference folio->mapping rather than folio_mapping(folio) in rmap_walk_file()
as per Matthew.
* Reference folio->index rather than folio_pgoff(folio) in rmap_walk_file() as
per Matthew.
* Renamed rmap_wrprotect_file_page() to mapping_wrprotect_page() as per Matthew.
* Fixed kerneldoc and moved to implementation as per Matthew.
* Updated mapping_wrprotect_page() to take a struct page pointer as per David.
* Removed folio lock when invoking mapping_wrprotect_page() in
fb_deferred_io_work() as per Matthew.
* Removed compound_nr() in fb_deferred_io_work() as per Matthew.
RFC v1:
https://lore.kernel.org/all/1e452b5b65f15a9a5d0c2ed3f5f812fdd1367603.1736352361.git.lorenzo.stoakes@oracle.com/
Lorenzo Stoakes (3):
mm: refactor rmap_walk_file() to separate out traversal logic
mm: provide mapping_wrprotect_page() function
fb_defio: do not use deprecated page->mapping, index fields
drivers/video/fbdev/core/fb_defio.c | 38 ++-----
include/linux/fb.h | 1 +
include/linux/rmap.h | 3 +
mm/rmap.c | 152 +++++++++++++++++++++++-----
4 files changed, 141 insertions(+), 53 deletions(-)
--
2.48.0
From: Lorenzo Stoakes <hidden> Date: 2025-01-13 23:16:43
In order to permit the traversal of the reverse mapping at a specified
mapping and offset rather than those specified by an input folio, we need
to separate out the portion of the rmap file logic which deals with this
traversal from those parts of the logic which interact with the folio.
This patch achieves this by adding a new static __rmap_walk_file() function
which rmap_walk_file() invokes.
This function permits the ability to pass NULL folio, on the assumption
that the caller has provided for this correctly in the callbacks specified
in the rmap_walk_control object.
Though it provides for this, and adds debug asserts to ensure that, should
a folio be specified, these are equal to the mapping and offset specified
in the folio, there should be no functional change as a result of this
patch.
The reason for adding this is to enable for future changes to permit users
to be able to traverse mappings of userland-mapped kernel memory,
write-protecting those mappings to enable page_mkwrite() or pfn_mkwrite()
fault handlers to be retriggered on subsequent dirty.
Signed-off-by: Lorenzo Stoakes <redacted>
---
mm/rmap.c | 79 +++++++++++++++++++++++++++++++++++++------------------
1 file changed, 53 insertions(+), 26 deletions(-)
From: Lorenzo Stoakes <hidden> Date: 2025-01-13 23:16:44
in the fb_defio video driver, page dirty state is used to determine when
frame buffer pages have been changed, allowing for batched, deferred I/O to
be performed for efficiency.
This implementation had only one means of doing so effectively - the use of
the folio_mkclean() function.
However, this use of the function is inappropriate, as the fb_defio
implementation allocates kernel memory to back the framebuffer, and then is
forced to specified page->index, mapping fields in order to permit the
folio_mkclean() rmap traversal to proceed correctly.
It is not correct to specify these fields on kernel-allocated memory, and
moreover since these are not folios, page->index, mapping are deprecated
fields, soon to be removed.
We therefore need to provide a means by which we can correctly traverse the
reverse mapping and write-protect mappings for a page backing an
address_space page cache object at a given offset.
This patch provides this - mapping_wrprotect_page() allows for this
operation to be performed for a specified address_space, offset and page,
without requiring a folio nor, of course, an inappropriate use of
page->index, mapping.
With this provided, we can subequently adjust the fb_defio implementation
to make use of this function and avoid incorrect invocation of
folio_mkclean() and more importantly, incorrect manipulation of
page->index, mapping fields.
Signed-off-by: Lorenzo Stoakes <redacted>
---
include/linux/rmap.h | 3 ++
mm/rmap.c | 73 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+)
From: Lorenzo Stoakes <hidden> Date: 2025-01-13 23:16:48
With the introduction of mapping_wrprotect_page() there is no need to use
folio_mkclean() in order to write-protect mappings of frame buffer pages,
and therefore no need to inappropriately set kernel-allocated page->index,
mapping fields to permit this operation.
Instead, store the pointer to the page cache object for the mapped driver
in the fb_deferred_io object, and use the already stored page offset from
the pageref object to look up mappings in order to write-protect them.
This is justified, as for the page objects to store a mapping pointer at
the point of assignment of pages, they must all reference the same
underlying address_space object. Since the life time of the pagerefs is
also the lifetime of the fb_deferred_io object, storing the pointer here
makes snese.
This eliminates the need for all of the logic around setting and
maintaining page->index,mapping which we remove.
This eliminates the use of folio_mkclean() entirely but otherwise should
have no functional change.
Signed-off-by: Lorenzo Stoakes <redacted>
---
drivers/video/fbdev/core/fb_defio.c | 38 +++++++++--------------------
include/linux/fb.h | 1 +
2 files changed, 12 insertions(+), 27 deletions(-)
@@ -274,14 +263,13 @@ static void fb_deferred_io_work(struct work_struct *work)structfb_deferred_io_pageref*pageref,*next;structfb_deferred_io*fbdefio=info->fbdefio;-/* here we mkclean the pages, then do all deferred IO */+/* here we wrprotect the page's mappings, then do all deferred IO. */mutex_lock(&fbdefio->lock);list_for_each_entry(pageref,&fbdefio->pagereflist,list){-structfolio*folio=page_folio(pageref->page);+structpage*page=pageref->page;+pgoff_tpgoff=pageref->offset>>PAGE_SHIFT;-folio_lock(folio);-folio_mkclean(folio);-folio_unlock(folio);+mapping_wrprotect_page(fbdefio->mapping,pgoff,1,page);}/* driver's callback with pagereflist */
@@ -344,13 +333,7 @@ EXPORT_SYMBOL_GPL(fb_deferred_io_open);staticvoidfb_deferred_io_lastclose(structfb_info*info){-unsignedlongi;-flush_delayed_work(&info->deferred_work);--/* clear out the mapping that we setup */-for(i=0;i<info->npagerefs;++i)-fb_deferred_io_pageref_clear(&info->pagerefs[i]);}voidfb_deferred_io_release(structfb_info*info)
@@ -225,6 +225,7 @@ struct fb_deferred_io {intopen_count;/* number of opened files; protected by fb_info lock */structmutexlock;/* mutex that protects the pageref list */structlist_headpagereflist;/* list of pagerefs for touched pages */+structaddress_space*mapping;/* page cache object for fb device *//* callback */structpage*(*get_page)(structfb_info*info,unsignedlongoffset);void(*deferred_io)(structfb_info*info,structlist_head*pagelist);
From: Lorenzo Stoakes <hidden> Date: 2025-01-27 18:45:48
Hi guys,
It'd be good if somebody from the drm side could look at this as you are
using fields that are deprecated and will be made unavailable (in a
non-optional fashion), and relatively soon :)
It'd be good to confirm this works on real hardware (none of mine supports
this sadly, I tried 3 separate machines...).
In effect I provide a whole new mechanism just so defio can do the right
thing and retain the exact same behaviour, so just need to confirm it does
what you need from our side.
Thanks, Lorenzo
On Mon, Jan 13, 2025 at 11:15:45PM +0000, Lorenzo Stoakes wrote:
Right now the only means by which we can write-protect a range using the
reverse mapping is via folio_mkclean().
However this is not always the appropriate means of doing so, specifically
in the case of the framebuffer deferred I/O logic (fb_defio enabled by
CONFIG_FB_DEFERRED_IO). There, kernel pages are mapped read-only and
write-protect faults used to batch up I/O operations.
Each time the deferred work is done, folio_mkclean() is used to mark the
framebuffer page as having had I/O performed on it. However doing so
requires the kernel page (perhaps allocated via vmalloc()) to have its
page->mapping, index fields set so the rmap can find everything that maps
it in order to write-protect.
This is problematic as firstly, these fields should not be set for
kernel-allocated memory, and secondly these are not folios (it's not user
memory) and page->index, mapping fields are now deprecated and soon to be
removed.
The implementers cannot be blamed for having used this however, as there is
simply no other way of performing this operation correctly.
This series fixes this - we provide the mapping_wrprotect_page() function
to allow the reverse mapping to be used to look up mappings from the page
cache object (i.e. its address_space pointer) at a specific offset.
The fb_defio logic already stores this offset, and can simply be expanded
to keep track of the page cache object, so the change then becomes
straight-forward.
This series should have no functional change.
*** REVIEWERS NOTES: ***
I do not have any hardware that uses fb_defio, so I'm asking for help with
testing this series from those who do :) I have tested the mm side of this,
and done a quick compile smoke test of the fb_defio side but this _very
much_ requires testing on actual hardware to ensure everything behaves as
expected.
This is based on Andrew's tree [0] in the mm-unstable branch - I was
thinking it'd be best to go through the mm tree (with fb_defio maintainer
approval, of course!) as it relies upon the mm changes to work correctly.
[0]: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/
RFC v2:
* Updated Jaya Kumar's email on cc - the MAINTAINERS section is apparently incorrect.
* Corrected rmap_walk_file() comment to refer to folios as per Matthew.
* Reference folio->mapping rather than folio_mapping(folio) in rmap_walk_file()
as per Matthew.
* Reference folio->index rather than folio_pgoff(folio) in rmap_walk_file() as
per Matthew.
* Renamed rmap_wrprotect_file_page() to mapping_wrprotect_page() as per Matthew.
* Fixed kerneldoc and moved to implementation as per Matthew.
* Updated mapping_wrprotect_page() to take a struct page pointer as per David.
* Removed folio lock when invoking mapping_wrprotect_page() in
fb_deferred_io_work() as per Matthew.
* Removed compound_nr() in fb_deferred_io_work() as per Matthew.
RFC v1:
https://lore.kernel.org/all/1e452b5b65f15a9a5d0c2ed3f5f812fdd1367603.1736352361.git.lorenzo.stoakes@oracle.com/
Lorenzo Stoakes (3):
mm: refactor rmap_walk_file() to separate out traversal logic
mm: provide mapping_wrprotect_page() function
fb_defio: do not use deprecated page->mapping, index fields
drivers/video/fbdev/core/fb_defio.c | 38 ++-----
include/linux/fb.h | 1 +
include/linux/rmap.h | 3 +
mm/rmap.c | 152 +++++++++++++++++++++++-----
4 files changed, 141 insertions(+), 53 deletions(-)
--
2.48.0
Hello Lorenzo!
I tried the patches below yesterday with the latest mm tree from git at the
time. I have some work in progress code which uses defio, and hardware which
needs that for shuffling bytes around to get the right picture.
There was no obvious difference in operation, it looked the same with and
without the patches. I've skipped the card's memory initialization so it
contained garbage while the system memory behind was clean. That garbage
remained and was only cleaned or overwritten where the system memory was
updated by the application. Fbcon wasn't assigned and the app mapped the
memory of course. Left it running at configured to HZ/50 for a while with
1/3 of the screen updated at ~50 FPS by the test app, nothing interesting
happened. Same tearing both ways.
I can't comment on performance as the CPU is moving the bytes in the defio
callback and that code is too heavy at the moment to notice a difference.
Test was performed on a dual core x86-64 (E3400).
So defio seems to still work after these changes for me.
Tested-by: Zsolt Kajtar <soci@c64.rulez.org>
On Mon, Jan 13, 2025 at 11:15:45PM +0000, Lorenzo Stoakes wrote:
quoted
Right now the only means by which we can write-protect a range using the
reverse mapping is via folio_mkclean().
However this is not always the appropriate means of doing so, specifically
in the case of the framebuffer deferred I/O logic (fb_defio enabled by
CONFIG_FB_DEFERRED_IO). There, kernel pages are mapped read-only and
write-protect faults used to batch up I/O operations.
Each time the deferred work is done, folio_mkclean() is used to mark the
framebuffer page as having had I/O performed on it. However doing so
requires the kernel page (perhaps allocated via vmalloc()) to have its
page->mapping, index fields set so the rmap can find everything that maps
it in order to write-protect.
This is problematic as firstly, these fields should not be set for
kernel-allocated memory, and secondly these are not folios (it's not user
memory) and page->index, mapping fields are now deprecated and soon to be
removed.
The implementers cannot be blamed for having used this however, as there is
simply no other way of performing this operation correctly.
This series fixes this - we provide the mapping_wrprotect_page() function
to allow the reverse mapping to be used to look up mappings from the page
cache object (i.e. its address_space pointer) at a specific offset.
The fb_defio logic already stores this offset, and can simply be expanded
to keep track of the page cache object, so the change then becomes
straight-forward.
This series should have no functional change.
*** REVIEWERS NOTES: ***
I do not have any hardware that uses fb_defio, so I'm asking for help with
testing this series from those who do :) I have tested the mm side of this,
and done a quick compile smoke test of the fb_defio side but this _very
much_ requires testing on actual hardware to ensure everything behaves as
expected.
This is based on Andrew's tree [0] in the mm-unstable branch - I was
thinking it'd be best to go through the mm tree (with fb_defio maintainer
approval, of course!) as it relies upon the mm changes to work correctly.
[0]: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/
RFC v2:
* Updated Jaya Kumar's email on cc - the MAINTAINERS section is apparently incorrect.
* Corrected rmap_walk_file() comment to refer to folios as per Matthew.
* Reference folio->mapping rather than folio_mapping(folio) in rmap_walk_file()
as per Matthew.
* Reference folio->index rather than folio_pgoff(folio) in rmap_walk_file() as
per Matthew.
* Renamed rmap_wrprotect_file_page() to mapping_wrprotect_page() as per Matthew.
* Fixed kerneldoc and moved to implementation as per Matthew.
* Updated mapping_wrprotect_page() to take a struct page pointer as per David.
* Removed folio lock when invoking mapping_wrprotect_page() in
fb_deferred_io_work() as per Matthew.
* Removed compound_nr() in fb_deferred_io_work() as per Matthew.
RFC v1:
https://lore.kernel.org/all/1e452b5b65f15a9a5d0c2ed3f5f812fdd1367603.1736352361.git.lorenzo.stoakes@oracle.com/
Lorenzo Stoakes (3):
mm: refactor rmap_walk_file() to separate out traversal logic
mm: provide mapping_wrprotect_page() function
fb_defio: do not use deprecated page->mapping, index fields
drivers/video/fbdev/core/fb_defio.c | 38 ++-----
include/linux/fb.h | 1 +
include/linux/rmap.h | 3 +
mm/rmap.c | 152 +++++++++++++++++++++++-----
4 files changed, 141 insertions(+), 53 deletions(-)
--
2.48.0
From: Lorenzo Stoakes <hidden> Date: 2025-01-31 17:04:22
+cc Kajtar, who has kindly smoke tested this series on real hardware and
confirmed things are working ostensibly the same as before.
On this basis I will be un-RFC'ing this and, if Kajtar can reply to
confirm, will add a Tested-by tag to patch 3/3.
Again to emphasise - there is some urgency here - as struct page fields
that defio relies upon prior to this series are being removed
non-optionally.
Thanks, Lorenzo
On Mon, Jan 13, 2025 at 11:15:45PM +0000, Lorenzo Stoakes wrote:
Right now the only means by which we can write-protect a range using the
reverse mapping is via folio_mkclean().
However this is not always the appropriate means of doing so, specifically
in the case of the framebuffer deferred I/O logic (fb_defio enabled by
CONFIG_FB_DEFERRED_IO). There, kernel pages are mapped read-only and
write-protect faults used to batch up I/O operations.
Each time the deferred work is done, folio_mkclean() is used to mark the
framebuffer page as having had I/O performed on it. However doing so
requires the kernel page (perhaps allocated via vmalloc()) to have its
page->mapping, index fields set so the rmap can find everything that maps
it in order to write-protect.
This is problematic as firstly, these fields should not be set for
kernel-allocated memory, and secondly these are not folios (it's not user
memory) and page->index, mapping fields are now deprecated and soon to be
removed.
The implementers cannot be blamed for having used this however, as there is
simply no other way of performing this operation correctly.
This series fixes this - we provide the mapping_wrprotect_page() function
to allow the reverse mapping to be used to look up mappings from the page
cache object (i.e. its address_space pointer) at a specific offset.
The fb_defio logic already stores this offset, and can simply be expanded
to keep track of the page cache object, so the change then becomes
straight-forward.
This series should have no functional change.
*** REVIEWERS NOTES: ***
I do not have any hardware that uses fb_defio, so I'm asking for help with
testing this series from those who do :) I have tested the mm side of this,
and done a quick compile smoke test of the fb_defio side but this _very
much_ requires testing on actual hardware to ensure everything behaves as
expected.
This is based on Andrew's tree [0] in the mm-unstable branch - I was
thinking it'd be best to go through the mm tree (with fb_defio maintainer
approval, of course!) as it relies upon the mm changes to work correctly.
[0]: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/
RFC v2:
* Updated Jaya Kumar's email on cc - the MAINTAINERS section is apparently incorrect.
* Corrected rmap_walk_file() comment to refer to folios as per Matthew.
* Reference folio->mapping rather than folio_mapping(folio) in rmap_walk_file()
as per Matthew.
* Reference folio->index rather than folio_pgoff(folio) in rmap_walk_file() as
per Matthew.
* Renamed rmap_wrprotect_file_page() to mapping_wrprotect_page() as per Matthew.
* Fixed kerneldoc and moved to implementation as per Matthew.
* Updated mapping_wrprotect_page() to take a struct page pointer as per David.
* Removed folio lock when invoking mapping_wrprotect_page() in
fb_deferred_io_work() as per Matthew.
* Removed compound_nr() in fb_deferred_io_work() as per Matthew.
RFC v1:
https://lore.kernel.org/all/1e452b5b65f15a9a5d0c2ed3f5f812fdd1367603.1736352361.git.lorenzo.stoakes@oracle.com/
Lorenzo Stoakes (3):
mm: refactor rmap_walk_file() to separate out traversal logic
mm: provide mapping_wrprotect_page() function
fb_defio: do not use deprecated page->mapping, index fields
drivers/video/fbdev/core/fb_defio.c | 38 ++-----
include/linux/fb.h | 1 +
include/linux/rmap.h | 3 +
mm/rmap.c | 152 +++++++++++++++++++++++-----
4 files changed, 141 insertions(+), 53 deletions(-)
--
2.48.0
+cc Kajtar, who has kindly smoke tested this series on real hardware and
confirmed things are working ostensibly the same as before.
On this basis I will be un-RFC'ing this and, if Kajtar can reply to
confirm, will add a Tested-by tag to patch 3/3.
No problem, I'm glad I could help. Using defio is required for higher
resolution modes anyway so I just had to code that part a bit earlier
than planned.
From: Lorenzo Stoakes <hidden> Date: 2025-02-01 17:03:34
Andrew - Ugh sorry - please disregard the below, I sent it to the wrong
thread. It's Saturday and I'm tired and brain not working :>)
Let me resend this against the correct non-RFC thread!
On Sat, Feb 01, 2025 at 05:01:15PM +0000, Lorenzo Stoakes wrote:
quoted hunk
On Mon, Jan 13, 2025 at 11:15:48PM +0000, Lorenzo Stoakes wrote:
quoted
With the introduction of mapping_wrprotect_page() there is no need to use
folio_mkclean() in order to write-protect mappings of frame buffer pages,
and therefore no need to inappropriately set kernel-allocated page->index,
mapping fields to permit this operation.
Instead, store the pointer to the page cache object for the mapped driver
in the fb_deferred_io object, and use the already stored page offset from
the pageref object to look up mappings in order to write-protect them.
This is justified, as for the page objects to store a mapping pointer at
the point of assignment of pages, they must all reference the same
underlying address_space object. Since the life time of the pagerefs is
also the lifetime of the fb_deferred_io object, storing the pointer here
makes snese.
This eliminates the need for all of the logic around setting and
maintaining page->index,mapping which we remove.
This eliminates the use of folio_mkclean() entirely but otherwise should
have no functional change.
Signed-off-by: Lorenzo Stoakes <redacted>
Andrew -
Sorry to be a pain but could you please apply the attached fix-patch to
avoid build bot failures when randconfig generates invalid
configurations. The defio mechanism entirely relies upon the page faulting
mechanism, and thus an MMU to function.
This was previously masked, because folio_mkclean() happens to have a
!CONFIG_MMU stub. It really doesn't make sense to apply such a stub for
mapping_wrprotect_page() for architectures without an MMU.
Instead, correctly express the actual dependency in Kconfig, which should
prevent randconfig from doing the wrong thing and also helps document this
fact about defio.
Thanks!
----8<----
From 32abcfbb8dea92d9a8a99e6a86f45a1823a75c59 Mon Sep 17 00:00:00 2001
From: Lorenzo Stoakes <redacted>
Date: Sat, 1 Feb 2025 16:56:02 +0000
Subject: [PATCH] fbdev: have CONFIG_FB_DEFERRED_IO depend on CONFIG_MMU
Frame buffer deferred I/O is entirely reliant on the page faulting
mechanism (and thus, an MMU) to function.
Express this dependency in the Kconfig, as otherwise randconfig could
generate invalid configurations resulting in build errors.
Signed-off-by: Lorenzo Stoakes <redacted>
Reported-by: kernel test robot <redacted>
Closes: https://lore.kernel.org/oe-kbuild-all/202502020030.MnEJ847Z-lkp@intel.com/
---
drivers/video/fbdev/core/Kconfig | 1 +
1 file changed, 1 insertion(+)
From: Lorenzo Stoakes <hidden> Date: 2025-02-01 17:54:08
On Mon, Jan 13, 2025 at 11:15:48PM +0000, Lorenzo Stoakes wrote:
With the introduction of mapping_wrprotect_page() there is no need to use
folio_mkclean() in order to write-protect mappings of frame buffer pages,
and therefore no need to inappropriately set kernel-allocated page->index,
mapping fields to permit this operation.
Instead, store the pointer to the page cache object for the mapped driver
in the fb_deferred_io object, and use the already stored page offset from
the pageref object to look up mappings in order to write-protect them.
This is justified, as for the page objects to store a mapping pointer at
the point of assignment of pages, they must all reference the same
underlying address_space object. Since the life time of the pagerefs is
also the lifetime of the fb_deferred_io object, storing the pointer here
makes snese.
This eliminates the need for all of the logic around setting and
maintaining page->index,mapping which we remove.
This eliminates the use of folio_mkclean() entirely but otherwise should
have no functional change.
Signed-off-by: Lorenzo Stoakes <redacted>
Andrew -
Sorry to be a pain but could you please apply the attached fix-patch to
avoid build bot failures when randconfig generates invalid
configurations. The defio mechanism entirely relies upon the page faulting
mechanism, and thus an MMU to function.
This was previously masked, because folio_mkclean() happens to have a
!CONFIG_MMU stub. It really doesn't make sense to apply such a stub for
mapping_wrprotect_page() for architectures without an MMU.
Instead, correctly express the actual dependency in Kconfig, which should
prevent randconfig from doing the wrong thing and also helps document this
fact about defio.
Thanks!
----8<----
From 32abcfbb8dea92d9a8a99e6a86f45a1823a75c59 Mon Sep 17 00:00:00 2001
From: Lorenzo Stoakes <redacted>
Date: Sat, 1 Feb 2025 16:56:02 +0000
Subject: [PATCH] fbdev: have CONFIG_FB_DEFERRED_IO depend on CONFIG_MMU
Frame buffer deferred I/O is entirely reliant on the page faulting
mechanism (and thus, an MMU) to function.
Express this dependency in the Kconfig, as otherwise randconfig could
generate invalid configurations resulting in build errors.
Signed-off-by: Lorenzo Stoakes <redacted>
Reported-by: kernel test robot <redacted>
Closes: https://lore.kernel.org/oe-kbuild-all/202502020030.MnEJ847Z-lkp@intel.com/
---
drivers/video/fbdev/core/Kconfig | 1 +
1 file changed, 1 insertion(+)
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-02-03 10:25:01
Hi
Am 14.01.25 um 00:15 schrieb Lorenzo Stoakes:
[...]
*** REVIEWERS NOTES: ***
I do not have any hardware that uses fb_defio, so I'm asking for help with
testing this series from those who do :) I have tested the mm side of this,
and done a quick compile smoke test of the fb_defio side but this _very
much_ requires testing on actual hardware to ensure everything behaves as
expected.
With a recent Linux distro, you likely boot up graphics with simpledrm, which uses fb_defio as part of its console emulation. To test, boot the kernel with the 'nomodeset' parameter and write to /dev/fb0.
Best regards
Thomas
This is based on Andrew's tree [0] in the mm-unstable branch - I was
thinking it'd be best to go through the mm tree (with fb_defio maintainer
approval, of course!) as it relies upon the mm changes to work correctly.
[0]: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/
RFC v2:
* Updated Jaya Kumar's email on cc - the MAINTAINERS section is apparently incorrect.
* Corrected rmap_walk_file() comment to refer to folios as per Matthew.
* Reference folio->mapping rather than folio_mapping(folio) in rmap_walk_file()
as per Matthew.
* Reference folio->index rather than folio_pgoff(folio) in rmap_walk_file() as
per Matthew.
* Renamed rmap_wrprotect_file_page() to mapping_wrprotect_page() as per Matthew.
* Fixed kerneldoc and moved to implementation as per Matthew.
* Updated mapping_wrprotect_page() to take a struct page pointer as per David.
* Removed folio lock when invoking mapping_wrprotect_page() in
fb_deferred_io_work() as per Matthew.
* Removed compound_nr() in fb_deferred_io_work() as per Matthew.
RFC v1:
https://lore.kernel.org/all/1e452b5b65f15a9a5d0c2ed3f5f812fdd1367603.1736352361.git.lorenzo.stoakes@oracle.com/
Lorenzo Stoakes (3):
mm: refactor rmap_walk_file() to separate out traversal logic
mm: provide mapping_wrprotect_page() function
fb_defio: do not use deprecated page->mapping, index fields
drivers/video/fbdev/core/fb_defio.c | 38 ++-----
include/linux/fb.h | 1 +
include/linux/rmap.h | 3 +
mm/rmap.c | 152 +++++++++++++++++++++++-----
4 files changed, 141 insertions(+), 53 deletions(-)
--
2.48.0
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
From: Lorenzo Stoakes <hidden> Date: 2025-02-03 10:55:00
On Mon, Feb 03, 2025 at 11:24:50AM +0100, Thomas Zimmermann wrote:
Hi
Am 14.01.25 um 00:15 schrieb Lorenzo Stoakes:
[...]
quoted
*** REVIEWERS NOTES: ***
I do not have any hardware that uses fb_defio, so I'm asking for help with
testing this series from those who do :) I have tested the mm side of this,
and done a quick compile smoke test of the fb_defio side but this _very
much_ requires testing on actual hardware to ensure everything behaves as
expected.
With a recent Linux distro, you likely boot up graphics with simpledrm,
which uses fb_defio as part of its console emulation. To test, boot the
kernel with the 'nomodeset' parameter and write to /dev/fb0.
Best regards
Thomas
This is based on Andrew's tree [0] in the mm-unstable branch - I was
thinking it'd be best to go through the mm tree (with fb_defio maintainer
approval, of course!) as it relies upon the mm changes to work correctly.
[0]: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/
RFC v2:
* Updated Jaya Kumar's email on cc - the MAINTAINERS section is apparently incorrect.
* Corrected rmap_walk_file() comment to refer to folios as per Matthew.
* Reference folio->mapping rather than folio_mapping(folio) in rmap_walk_file()
as per Matthew.
* Reference folio->index rather than folio_pgoff(folio) in rmap_walk_file() as
per Matthew.
* Renamed rmap_wrprotect_file_page() to mapping_wrprotect_page() as per Matthew.
* Fixed kerneldoc and moved to implementation as per Matthew.
* Updated mapping_wrprotect_page() to take a struct page pointer as per David.
* Removed folio lock when invoking mapping_wrprotect_page() in
fb_deferred_io_work() as per Matthew.
* Removed compound_nr() in fb_deferred_io_work() as per Matthew.
RFC v1:
https://lore.kernel.org/all/1e452b5b65f15a9a5d0c2ed3f5f812fdd1367603.1736352361.git.lorenzo.stoakes@oracle.com/
Lorenzo Stoakes (3):
mm: refactor rmap_walk_file() to separate out traversal logic
mm: provide mapping_wrprotect_page() function
fb_defio: do not use deprecated page->mapping, index fields
drivers/video/fbdev/core/fb_defio.c | 38 ++-----
include/linux/fb.h | 1 +
include/linux/rmap.h | 3 +
mm/rmap.c | 152 +++++++++++++++++++++++-----
4 files changed, 141 insertions(+), 53 deletions(-)
--
2.48.0
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)