mm/highmem: VM_BUG_ON() if offset + len > PAGE_SIZE
RFC PATCH 1/1 mm/highmem: VM_BUG_ON() if offset + len > PAGE_SIZE
Call VM_BUG_ON() if offset + len > PAGE_SIZE.
This is an RFC patch because I'm not sure if we actually need to BUG_ON(), so I'd like to know what Maintainers and other developers think about this proposal.
Please note that memset_page() uses VM_BUG_ON() to prevent the same issue.
Furthermore, I also cannot understand why memset_page() does not call flush_dcache_page() after memset() but I suppose that the different implementations of these two functions should be addressed in another RFC.
--- include/linux/highmem.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/highmem.h +2 -0
@@ -349,6 +349,8 @@ static inline void memcpy_to_page(struct page *page, size_t offset,static inline void memzero_page (struct page *page,size_t offset,size_t len) {char *addr =kmap_local_page (page); + +VM_BUG_ON (offset + len >PAGE_SIZE );memset (addr + offset,0 , len);flush_dcache_page (page);kunmap_local (addr);
Signature · 1 line
2.34.1
Quoted 3 lines · On domenica 24 aprile 2022 12:48:06 CEST Fabio M. De Francesco wrote:
Call
VM_BUG_ON()if offset + len >PAGE_SIZE.This is an RFC patch because I'm not sure if we actually need to
BUG_ON(),
Actually I considered VM_BUG_ON() for consistency with the other functions in highmem.h
What about VM_WARN_ON_ONCE() here and also in memset_page?
Thanks,
Fabio
Quoted 1 line
so I'd like to know what Maintainers and other developers think about
this
Quoted 3 lines
proposal.
Please note that
memset_page()usesVM_BUG_ON()to prevent the same
issue.
Quoted 4 lines
Furthermore, I also cannot understand why
memset_page()does not callflush_dcache_page()aftermemset()but I suppose that the different implementations of these two functions should be addressed in another
RFC.
include/linux/highmem.h static inline void memcpy_to_page(struct page *page,
Quoted 11 lines
Signed-off-by Fabio M. De Francesco <[email protected]>--- include/linux/highmem.h | 2 ++ 1 file changed, 2 insertions(+)include/linux/highmem.h +0
-0@@ -349,6 +349,8 @@ static inline void memcpy_to_page(struct page *page,
size_t offset,
include/linux/highmem.h static inline void memcpy_to_page(struct page *page, · line 349
Quoted 1 line
include/linux/highmem.h +0
-0static inline void memzero_page(struct page *page, size_t offset, size_t
len)
Quoted 11 lines
include/linux/highmem.h +2
-0{char *addr =kmap_local_page (page); + +VM_BUG_ON (offset + len >PAGE_SIZE );memset (addr + offset,0 , len);flush_dcache_page (page);kunmap_local (addr);Signature · 1 line
2.34.1
Quoted 10 lines · Fabio M. De Francesco
Quoted 3 lines · On domenica 24 aprile 2022 12:48:06 CEST Fabio M. De Francesco wrote:
Call
VM_BUG_ON()if offset + len >PAGE_SIZE.This is an RFC patch because I'm not sure if we actually need to
BUG_ON(),Actually I considered
VM_BUG_ON()for consistency with the other functions inhighmem.hWhat about
VM_WARN_ON_ONCE()here and also inmemset_page?
For consistency leave this as a VM_BUG_ON[1]
I've been down a similar path[2] and there was a long discussion about it.[3]
In the end we settled on VM_BUG_ON.[4]
As to the addition of flush_dcache_page(). There was a discussion here.
https://lore.kernel.org/lkml/CAHk-=wiKac4t-fOP_3fAf7nETfFLhT3ShmRmBq2J96y6jAr56Q@mail.gmail.com/
Ira
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/
[4] https://lore.kernel.org/lkml/[email protected]/
Quoted 45 lines
Thanks,
Fabio
Quoted 1 line
so I'd like to know what Maintainers and other developers think about
this
Quoted 3 lines
proposal.
Please note that
memset_page()usesVM_BUG_ON()to prevent the sameissue.
Quoted 4 lines
Furthermore, I also cannot understand why
memset_page()does not callflush_dcache_page()aftermemset()but I suppose that the different implementations of these two functions should be addressed in anotherRFC.
include/linux/highmem.h static inline void memcpy_to_page(struct page *page,
Quoted 11 lines
Signed-off-by Fabio M. De Francesco <[email protected]>--- include/linux/highmem.h | 2 ++ 1 file changed, 2 insertions(+)include/linux/highmem.h +0
-0@@ -349,6 +349,8 @@ static inline void memcpy_to_page(struct page *page,
size_toffset,include/linux/highmem.h static inline void memcpy_to_page(struct page *page, · line 349
Quoted 1 line
include/linux/highmem.h +0
-0static inline void memzero_page(struct page *page, size_t offset, size_tlen)
Quoted 11 lines
include/linux/highmem.h +2
-0{char *addr =kmap_local_page (page); + +VM_BUG_ON (offset + len >PAGE_SIZE );memset (addr + offset,0 , len);flush_dcache_page (page);kunmap_local (addr);Signature · 1 line
2.34.1
Quoted 8 lines · On lunedì 25 aprile 2022 18:47:18 CEST Ira Weiny wrote:
Quoted 7 lines · Fabio M. De Francesco
Quoted 3 lines · On domenica 24 aprile 2022 12:48:06 CEST Fabio M. De Francesco wrote:
Call
VM_BUG_ON()if offset + len >PAGE_SIZE.This is an RFC patch because I'm not sure if we actually need to
BUG_ON(),Actually I considered
VM_BUG_ON()for consistency with the other
functions
Quoted 7 lines
Quoted 3 lines
in
highmem.hWhat about
VM_WARN_ON_ONCE()here and also inmemset_page?For consistency leave this as a VM_BUG_ON[1]
I've been down a similar path[2] and there was a long discussion about
it.[3]
Quoted 2 lines
In the end we settled on VM_BUG_ON.[4]
Thanks for your reply and for providing so many helpful links :)
I just read the ones related to VM_BUG_ON() (I don't have time for flush_dcache_page() today). Since the consensus for these kinds of issues is in favor of using VM_BUG_ON(), that's OK for me.
I will send a "real" patch by tomorrow.
Again, thanks,
Fabio
Quoted 13 lines
As to the addition of
flush_dcache_page(). There was a discussion here.https://lore.kernel.org/lkml/CAHk-=wiKac4t-fOP_3fAf7nETfFLhT3ShmRmBq2J96y6jAr56Q@mail.gmail.com/
Ira
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/